Text archives Help
- From: sparker@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r752 - in trunk: . Core Core/Color Core/Geometry Core/Math Core/Shm Core/Util Engine Engine/Control Engine/Display Engine/IdleModes Engine/ImageTraversers Engine/ImageTraversers/AFR Engine/LoadBalancers Engine/PixelSamplers Engine/Renderers Engine/Shadows Image Interface Model Model/AmbientLights Model/Backgrounds Model/Cameras Model/Groups Model/Instances Model/Intersections Model/Lights Model/Materials Model/MiscObjects Model/Primitives Model/Readers Model/Readers/glm Model/TexCoordMappers Model/Textures Readers Readers/BART SCIRun/Core StandAlone UserInterface fox histx scenes tests/perftest
- Date: Tue, 6 Dec 2005 16:58:13 -0700 (MST)
Author: sparker
Date: Tue Dec 6 16:58:03 2005
New Revision: 752
Added:
trunk/Core/Math/CatmullRomInterpolator.h
- copied unchanged from r751,
branches/itanium2/Core/Math/CatmullRomInterpolator.h
trunk/Core/Shm/
- copied from r751, branches/itanium2/Core/Shm/
trunk/Core/Shm/MFStreamData.cc
- copied unchanged from r751, branches/itanium2/Core/Shm/MFStreamData.cc
trunk/Core/Shm/MFStreamData.h
- copied unchanged from r751, branches/itanium2/Core/Shm/MFStreamData.h
trunk/Core/Shm/ShmSemaphore.cc
- copied unchanged from r751, branches/itanium2/Core/Shm/ShmSemaphore.cc
trunk/Core/Shm/ShmSemaphore.h
- copied unchanged from r751, branches/itanium2/Core/Shm/ShmSemaphore.h
trunk/Core/Util/ThreadStorageAllocator.cc
- copied, changed from r751,
branches/itanium2/Core/Util/ThreadStorageAllocator.cc
trunk/Core/Util/ThreadStorageAllocator.h
- copied unchanged from r751,
branches/itanium2/Core/Util/ThreadStorageAllocator.h
trunk/Engine/Display/GLXImageDisplay.cc
- copied, changed from r751,
branches/itanium2/Engine/Display/GLXImageDisplay.cc
trunk/Engine/Display/GLXImageDisplay.h
- copied unchanged from r751,
branches/itanium2/Engine/Display/GLXImageDisplay.h
trunk/Engine/Display/SHMImageDisplay.cc
- copied unchanged from r751,
branches/itanium2/Engine/Display/SHMImageDisplay.cc
trunk/Engine/Display/SHMImageDisplay.h
- copied unchanged from r751,
branches/itanium2/Engine/Display/SHMImageDisplay.h
trunk/Model/Backgrounds/TextureBackground.cc
- copied unchanged from r751,
branches/itanium2/Model/Backgrounds/TextureBackground.cc
trunk/Model/Backgrounds/TextureBackground.h
- copied unchanged from r751,
branches/itanium2/Model/Backgrounds/TextureBackground.h
trunk/Model/Cameras/StereoPinholeCamera.cc
- copied, changed from r751,
branches/itanium2/Model/Cameras/StereoPinholeCamera.cc
trunk/Model/Cameras/StereoPinholeCamera.h
- copied unchanged from r751,
branches/itanium2/Model/Cameras/StereoPinholeCamera.h
trunk/Model/Groups/FrustumKDTree.cc
- copied, changed from r751,
branches/itanium2/Model/Groups/FrustumKDTree.cc
trunk/Model/Groups/FrustumKDTree.h
- copied unchanged from r751,
branches/itanium2/Model/Groups/FrustumKDTree.h
trunk/Model/Groups/KDTree.cc
- copied, changed from r751, branches/itanium2/Model/Groups/KDTree.cc
trunk/Model/Groups/KDTree.h
- copied, changed from r751, branches/itanium2/Model/Groups/KDTree.h
trunk/Model/Groups/KDTreeLoader.cc
- copied unchanged from r751,
branches/itanium2/Model/Groups/KDTreeLoader.cc
trunk/Model/Groups/KDTreeLoader.h
- copied unchanged from r751,
branches/itanium2/Model/Groups/KDTreeLoader.h
trunk/Model/Groups/PsiGammaTable.cc
- copied unchanged from r751,
branches/itanium2/Model/Groups/PsiGammaTable.cc
trunk/Model/Groups/PsiGammaTable.h
- copied unchanged from r751,
branches/itanium2/Model/Groups/PsiGammaTable.h
trunk/Model/Groups/RayTriangleMailbox.h
- copied unchanged from r751,
branches/itanium2/Model/Groups/RayTriangleMailbox.h
trunk/Model/Groups/RealisticBvh.cc
- copied, changed from r751,
branches/itanium2/Model/Groups/RealisticBvh.cc
trunk/Model/Groups/RealisticBvh.h
- copied unchanged from r751,
branches/itanium2/Model/Groups/RealisticBvh.h
trunk/Model/Groups/TransparentKDTree.cc
- copied, changed from r751,
branches/itanium2/Model/Groups/TransparentKDTree.cc
trunk/Model/Groups/TransparentKDTree.h
- copied, changed from r751,
branches/itanium2/Model/Groups/TransparentKDTree.h
trunk/Model/Groups/VolumeDesc.h
- copied unchanged from r751,
branches/itanium2/Model/Groups/VolumeDesc.h
trunk/Model/Groups/VolumeGrid.h
- copied unchanged from r751,
branches/itanium2/Model/Groups/VolumeGrid.h
trunk/Model/Groups/varray.h (props changed)
- copied unchanged from r751, branches/itanium2/Model/Groups/varray.h
trunk/Model/Intersections/
- copied from r751, branches/itanium2/Model/Intersections/
trunk/Model/Intersections/AxisAlignedBox.cc
- copied unchanged from r751,
branches/itanium2/Model/Intersections/AxisAlignedBox.cc
trunk/Model/Intersections/AxisAlignedBox.h
- copied unchanged from r751,
branches/itanium2/Model/Intersections/AxisAlignedBox.h
trunk/Model/Intersections/CMakeLists.txt
- copied unchanged from r751,
branches/itanium2/Model/Intersections/CMakeLists.txt
trunk/Model/Intersections/Plane.h
- copied unchanged from r751,
branches/itanium2/Model/Intersections/Plane.h
trunk/Model/Intersections/TriangleEdge.h
- copied unchanged from r751,
branches/itanium2/Model/Intersections/TriangleEdge.h
trunk/Model/Lights/HeadLight.cc
- copied unchanged from r751,
branches/itanium2/Model/Lights/HeadLight.cc
trunk/Model/Lights/HeadLight.h
- copied unchanged from r751, branches/itanium2/Model/Lights/HeadLight.h
trunk/Model/Materials/NormalMaterial.cc
- copied unchanged from r751,
branches/itanium2/Model/Materials/NormalMaterial.cc
trunk/Model/Materials/NormalMaterial.h
- copied unchanged from r751,
branches/itanium2/Model/Materials/NormalMaterial.h
trunk/Model/MiscObjects/CuttingPlane.cc
- copied, changed from r751,
branches/itanium2/Model/MiscObjects/CuttingPlane.cc
trunk/Model/MiscObjects/CuttingPlane.h
- copied unchanged from r751,
branches/itanium2/Model/MiscObjects/CuttingPlane.h
trunk/Model/Primitives/BvhTriangleMesh.cc
- copied, changed from r751,
branches/itanium2/Model/Primitives/BvhTriangleMesh.cc
trunk/Model/Primitives/BvhTriangleMesh.h
- copied unchanged from r751,
branches/itanium2/Model/Primitives/BvhTriangleMesh.h
trunk/Model/Readers/glm/
- copied from r751, branches/itanium2/Model/Readers/glm/
trunk/Model/Readers/glm/glm.cc
- copied unchanged from r751, branches/itanium2/Model/Readers/glm/glm.cc
trunk/Model/Readers/glm/glm.h
- copied unchanged from r751, branches/itanium2/Model/Readers/glm/glm.h
trunk/Model/Textures/CMakeLists.txt
- copied unchanged from r751,
branches/itanium2/Model/Textures/CMakeLists.txt
trunk/StandAlone/barrier_test.cc
- copied unchanged from r751,
branches/itanium2/StandAlone/barrier_test.cc
trunk/StandAlone/frust-test.cc
- copied unchanged from r751, branches/itanium2/StandAlone/frust-test.cc
trunk/StandAlone/manta_path_plot.pl
- copied unchanged from r751,
branches/itanium2/StandAlone/manta_path_plot.pl
trunk/StandAlone/manta_scaling_plot.pl
- copied unchanged from r751,
branches/itanium2/StandAlone/manta_scaling_plot.pl
trunk/StandAlone/manta_tile_size.pl
- copied unchanged from r751,
branches/itanium2/StandAlone/manta_tile_size.pl
trunk/StandAlone/mf_stream_test.cc
- copied unchanged from r751,
branches/itanium2/StandAlone/mf_stream_test.cc
trunk/StandAlone/v3c1_tools.cc
- copied unchanged from r751, branches/itanium2/StandAlone/v3c1_tools.cc
trunk/UserInterface/AutomatorUI.cc
- copied unchanged from r751,
branches/itanium2/UserInterface/AutomatorUI.cc
trunk/UserInterface/AutomatorUI.h
- copied unchanged from r751,
branches/itanium2/UserInterface/AutomatorUI.h
trunk/UserInterface/CameraPathAutomator.cc
- copied unchanged from r751,
branches/itanium2/UserInterface/CameraPathAutomator.cc
trunk/UserInterface/CameraPathAutomator.h
- copied unchanged from r751,
branches/itanium2/UserInterface/CameraPathAutomator.h
trunk/UserInterface/NullUI.h
- copied unchanged from r751, branches/itanium2/UserInterface/NullUI.h
trunk/fox/
- copied from r751, branches/itanium2/fox/
trunk/fox/CMakeLists.txt
- copied unchanged from r751, branches/itanium2/fox/CMakeLists.txt
trunk/fox/FMantaImageFrame.cc
- copied unchanged from r751, branches/itanium2/fox/FMantaImageFrame.cc
trunk/fox/FMantaImageFrame.h
- copied unchanged from r751, branches/itanium2/fox/FMantaImageFrame.h
trunk/fox/FMantaKdExplorer.cc
- copied unchanged from r751, branches/itanium2/fox/FMantaKdExplorer.cc
trunk/fox/FMantaKdExplorer.h
- copied unchanged from r751, branches/itanium2/fox/FMantaKdExplorer.h
trunk/fox/FMantaNavigator.cc
- copied unchanged from r751, branches/itanium2/fox/FMantaNavigator.cc
trunk/fox/FMantaNavigator.h
- copied unchanged from r751, branches/itanium2/fox/FMantaNavigator.h
trunk/fox/FMantaQuakeNav.cc
- copied unchanged from r751, branches/itanium2/fox/FMantaQuakeNav.cc
trunk/fox/FMantaQuakeNav.h
- copied unchanged from r751, branches/itanium2/fox/FMantaQuakeNav.h
trunk/fox/FMantaRecorder.cc
- copied unchanged from r751, branches/itanium2/fox/FMantaRecorder.cc
trunk/fox/FMantaRecorder.h
- copied unchanged from r751, branches/itanium2/fox/FMantaRecorder.h
trunk/fox/FMantaStereo.cc
- copied unchanged from r751, branches/itanium2/fox/FMantaStereo.cc
trunk/fox/FMantaStereo.h
- copied unchanged from r751, branches/itanium2/fox/FMantaStereo.h
trunk/fox/FMantaTrackballNav.cc
- copied unchanged from r751,
branches/itanium2/fox/FMantaTrackballNav.cc
trunk/fox/FMantaTrackballNav.h
- copied unchanged from r751, branches/itanium2/fox/FMantaTrackballNav.h
trunk/fox/FMantaTransparent.cc
- copied unchanged from r751, branches/itanium2/fox/FMantaTransparent.cc
trunk/fox/FMantaTransparent.h
- copied unchanged from r751, branches/itanium2/fox/FMantaTransparent.h
trunk/fox/FMantaUniformNav.cc
- copied unchanged from r751, branches/itanium2/fox/FMantaUniformNav.cc
trunk/fox/FMantaUniformNav.h
- copied unchanged from r751, branches/itanium2/fox/FMantaUniformNav.h
trunk/fox/FMantaWidgets.cc
- copied unchanged from r751, branches/itanium2/fox/FMantaWidgets.cc
trunk/fox/FMantaWidgets.h
- copied unchanged from r751, branches/itanium2/fox/FMantaWidgets.h
trunk/fox/FMantaWindow.cc
- copied unchanged from r751, branches/itanium2/fox/FMantaWindow.cc
trunk/fox/FMantaWindow.h
- copied unchanged from r751, branches/itanium2/fox/FMantaWindow.h
trunk/fox/MediaFusionApp.cc
- copied unchanged from r751, branches/itanium2/fox/MediaFusionApp.cc
trunk/fox/MediaFusionApp.h
- copied unchanged from r751, branches/itanium2/fox/MediaFusionApp.h
trunk/fox/MediaFusionBridge.cc
- copied unchanged from r751, branches/itanium2/fox/MediaFusionBridge.cc
trunk/fox/MediaFusionBridge.h
- copied unchanged from r751, branches/itanium2/fox/MediaFusionBridge.h
trunk/fox/dm_demo.cc
- copied unchanged from r751, branches/itanium2/fox/dm_demo.cc
trunk/fox/sc_demo.cc
- copied unchanged from r751, branches/itanium2/fox/sc_demo.cc
trunk/histx/
- copied from r751, branches/itanium2/histx/
trunk/histx/CMakeLists.txt
- copied unchanged from r751, branches/itanium2/histx/CMakeLists.txt
trunk/histx/Counter.h
- copied unchanged from r751, branches/itanium2/histx/Counter.h
trunk/histx/DerivedMonitor.cc
- copied unchanged from r751, branches/itanium2/histx/DerivedMonitor.cc
trunk/histx/DerivedMonitor.h
- copied unchanged from r751, branches/itanium2/histx/DerivedMonitor.h
trunk/histx/IA64Monitors.cc
- copied unchanged from r751, branches/itanium2/histx/IA64Monitors.cc
trunk/histx/IA64Monitors.h
- copied unchanged from r751, branches/itanium2/histx/IA64Monitors.h
trunk/histx/MmTimer.h
- copied unchanged from r751, branches/itanium2/histx/MmTimer.h
trunk/histx/SingleSamplerCounter.cc
- copied unchanged from r751,
branches/itanium2/histx/SingleSamplerCounter.cc
trunk/histx/SingleSamplerCounter.h
- copied unchanged from r751,
branches/itanium2/histx/SingleSamplerCounter.h
trunk/manta-commands.txt
- copied unchanged from r751, branches/itanium2/manta-commands.txt
trunk/scenes/boeing777.cc
- copied unchanged from r751, branches/itanium2/scenes/boeing777.cc
trunk/scenes/cube.cc
- copied unchanged from r751, branches/itanium2/scenes/cube.cc
trunk/scenes/objviewer.cc
- copied unchanged from r751, branches/itanium2/scenes/objviewer.cc
trunk/scenes/volume.cc
- copied unchanged from r751, branches/itanium2/scenes/volume.cc
Removed:
trunk/Engine/ImageTraversers/AFImageTraverser.cc
trunk/Engine/ImageTraversers/AFImageTraverser.h
trunk/Engine/ImageTraversers/AFR/
trunk/Engine/ImageTraversers/FramelessImageTraverser.cc
trunk/Engine/ImageTraversers/FramelessImageTraverser.h
trunk/Engine/PixelSamplers/HammersleySampler.cc
trunk/Engine/PixelSamplers/HammersleySampler.h
trunk/Engine/PixelSamplers/InterLeaveSampler.cc
trunk/Engine/PixelSamplers/InterLeaveSampler.h
trunk/Engine/PixelSamplers/MultiJitterSampler.cc
trunk/Engine/PixelSamplers/MultiJitterSampler.h
trunk/Engine/PixelSamplers/NRooksSampler.cc
trunk/Engine/PixelSamplers/NRooksSampler.h
trunk/Engine/PixelSamplers/RampSampler.cc
trunk/Engine/PixelSamplers/RampSampler.h
trunk/Engine/PixelSamplers/Sample.cc
trunk/Engine/PixelSamplers/Sample.h
Modified:
trunk/CMakeLists.txt
trunk/Core/CMakeLists.txt
trunk/Core/Color/ColorDB.cc
trunk/Core/Color/ColorDB.h
trunk/Core/Color/ColorSpace.h
trunk/Core/Geometry/AffineTransform.cc
trunk/Core/Geometry/BBox.h
trunk/Core/Geometry/PointVector.cc
trunk/Core/Geometry/PointVector.h
trunk/Core/Geometry/Ray.h
trunk/Core/Math/Noise.cc
trunk/Core/Math/Noise.h
trunk/Core/Math/ipow.h
trunk/Core/Util/Args.cc
trunk/Core/Util/Args.h
trunk/Engine/CMakeLists.txt
trunk/Engine/Control/CMakeLists.txt
trunk/Engine/Control/RTRT.cc
trunk/Engine/Control/RTRT.h
trunk/Engine/Control/RTRT_register.cc
trunk/Engine/Display/CMakeLists.txt
trunk/Engine/Display/FileDisplay.cc
trunk/Engine/Display/OpenGLDisplay.cc
trunk/Engine/Display/OpenGLDisplay.h
trunk/Engine/IdleModes/CMakeLists.txt
trunk/Engine/IdleModes/ZoomIdleMode.cc
trunk/Engine/IdleModes/ZoomIdleMode.h
trunk/Engine/ImageTraversers/CMakeLists.txt
trunk/Engine/ImageTraversers/DissolveImageTraverser.cc
trunk/Engine/ImageTraversers/DissolveTiledImageTraverser.cc
trunk/Engine/ImageTraversers/TiledImageTraverser.cc
trunk/Engine/ImageTraversers/TiledImageTraverser.h
trunk/Engine/LoadBalancers/CMakeLists.txt
trunk/Engine/PixelSamplers/CMakeLists.txt
trunk/Engine/PixelSamplers/JitterSampler.cc
trunk/Engine/PixelSamplers/SingleSampler.cc
trunk/Engine/PixelSamplers/SingleSampler.h
trunk/Engine/Renderers/CMakeLists.txt
trunk/Engine/Renderers/Moire.cc
trunk/Engine/Renderers/NullRenderer.cc
trunk/Engine/Renderers/Raytracer.cc
trunk/Engine/Shadows/BeamShadows.cc
trunk/Engine/Shadows/CMakeLists.txt
trunk/Engine/Shadows/HardShadows.cc
trunk/Engine/Shadows/NoShadows.cc
trunk/Image/CMakeLists.txt
trunk/Image/NullImage.cc
trunk/Image/NullImage.h
trunk/Image/Pixel.h
trunk/Image/SimpleImage.h
trunk/Image/SimpleImage_templates.cc
trunk/Image/TGAFile.cc
trunk/Interface/CMakeLists.txt
trunk/Interface/Callback.h
trunk/Interface/CallbackHelpers.h
trunk/Interface/Camera.h
trunk/Interface/Context.h
trunk/Interface/Fragment.cc
trunk/Interface/Fragment.h
trunk/Interface/HitInfo.cc
trunk/Interface/HitInfo.h
trunk/Interface/Image.h
trunk/Interface/Light.h
trunk/Interface/LightSet.cc
trunk/Interface/LightSet.h
trunk/Interface/Material.h
trunk/Interface/Object.h
trunk/Interface/Parameters.h
trunk/Interface/Primitive.h
trunk/Interface/RTRTInterface.h
trunk/Interface/RayPacket.h
trunk/Interface/RenderParameters.h
trunk/MantaTypes.h
trunk/Model/AmbientLights/ArcAmbient.cc
trunk/Model/Backgrounds/CMakeLists.txt
trunk/Model/Backgrounds/LinearBackground.cc
trunk/Model/CMakeLists.txt
trunk/Model/Cameras/CMakeLists.txt
trunk/Model/Cameras/EnvironmentCamera.cc
trunk/Model/Cameras/EnvironmentCamera.h
trunk/Model/Cameras/FisheyeCamera.cc
trunk/Model/Cameras/FisheyeCamera.h
trunk/Model/Cameras/OrthogonalCamera.cc
trunk/Model/Cameras/OrthogonalCamera.h
trunk/Model/Cameras/PinholeCamera.cc
trunk/Model/Cameras/PinholeCamera.h
trunk/Model/Groups/BVH.cc
trunk/Model/Groups/CMakeLists.txt
trunk/Model/Instances/Instance.cc
trunk/Model/Instances/InstanceRST.cc
trunk/Model/Instances/InstanceRST.h
trunk/Model/Instances/InstanceRT.cc
trunk/Model/Instances/InstanceST.cc
trunk/Model/Instances/InstanceT.cc
trunk/Model/Lights/CMakeLists.txt
trunk/Model/Lights/PointLight.cc
trunk/Model/Lights/PointLight.h
trunk/Model/Materials/CMakeLists.txt
trunk/Model/Materials/Checker.cc
trunk/Model/Materials/Dielectric.cc
trunk/Model/Materials/Dielectric.h
trunk/Model/Materials/Lambertian.cc
trunk/Model/Materials/Lambertian.h
trunk/Model/Materials/MetalMaterial.cc
trunk/Model/Materials/Phong.cc
trunk/Model/Materials/Phong.h
trunk/Model/MiscObjects/CMakeLists.txt
trunk/Model/MiscObjects/Difference.cc
trunk/Model/MiscObjects/Intersection.cc
trunk/Model/Primitives/CMakeLists.txt
trunk/Model/Primitives/Cone.cc
trunk/Model/Primitives/Cone.h
trunk/Model/Primitives/Cube.cc
trunk/Model/Primitives/Cube.h
trunk/Model/Primitives/Disk.cc
trunk/Model/Primitives/Disk.h
trunk/Model/Primitives/HeavyTriangle.cc
trunk/Model/Primitives/Heightfield.cc
trunk/Model/Primitives/Heightfield.h
trunk/Model/Primitives/Hemisphere.cc
trunk/Model/Primitives/Hemisphere.h
trunk/Model/Primitives/Parallelogram.cc
trunk/Model/Primitives/Parallelogram.h
trunk/Model/Primitives/PrimitiveCommon.cc
trunk/Model/Primitives/PrimitiveCommon.h
trunk/Model/Primitives/Sphere.cc
trunk/Model/Primitives/Sphere.h
trunk/Model/Primitives/SuperEllipsoid.cc
trunk/Model/Primitives/SuperEllipsoid.h
trunk/Model/Primitives/TexTriangle.cc
trunk/Model/Primitives/Triangle.cc
trunk/Model/Primitives/Triangle.h
trunk/Model/Readers/CMakeLists.txt
trunk/Model/TexCoordMappers/CMakeLists.txt
trunk/Model/TexCoordMappers/SphericalMapper.cc
trunk/Model/TexCoordMappers/SphericalMapper.h
trunk/Model/Textures/CheckerTexture.cc
trunk/Model/Textures/CheckerTexture.h
trunk/Model/Textures/Constant.h
trunk/Model/Textures/ImageTexture.cc
trunk/Model/Textures/ImageTexture.h
trunk/Model/Textures/MarbleTexture.cc
trunk/Model/Textures/MarbleTexture.h
trunk/Readers/BART/parse.cc
trunk/Readers/CMakeLists.txt
trunk/SCIRun/Core/CMakeLists.txt
trunk/StandAlone/CMakeLists.txt
trunk/StandAlone/manta.cc
trunk/UserInterface/CMakeLists.txt
trunk/UserInterface/PromptUI.cc
trunk/UserInterface/PromptUI.h
trunk/UserInterface/XWindowUI.cc
trunk/UserInterface/XWindowUI.h
trunk/scenes/CMakeLists.txt
trunk/scenes/primtest.cc
trunk/tests/perftest/perftest1.cc
Log:
Initial phase of itanium2 branch merge. Everything compiles, but
many things not tested: fox, boeing, any scene besides the default, etc.
Modified: trunk/CMakeLists.txt
==============================================================================
--- trunk/CMakeLists.txt (original)
+++ trunk/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,5 +1,5 @@
# Hello, and welcome the Manta CMake build system. Here you can find
-# many system dependent action. We will try and keep all that in this
+# many system dependent actions. We will try and keep all that in this
# file rather than in subdirectories.
# # You need at least CMake version 2.0
@@ -39,25 +39,25 @@
INCLUDE (${CMAKE_ROOT}/Modules/FindThreads.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/FindX11.cmake)
-# #################################################################
-# ### ADD_CXX_FLAGS(flags) ###
-# ### flags will be added to CMAKE_CXX_FLAGS, but only once ###
-# ### This only works for CMake 2.0 and above. ###
-# #################################################################
-# MACRO(FORCE_ADD_CXX_FLAGS)
-# FOREACH(arg ${ARGN})
-# SET(TMP ${arg}) #elsewise the Seperate command doesn't work)
-# SEPARATE_ARGUMENTS(TMP)
-# FOREACH(option ${TMP})
-# STRING(REGEX REPLACE " ${option}" "" CMAKE_CXX_FLAGS
-# "${CMAKE_CXX_FLAGS}")
-# STRING(REGEX REPLACE "${option}" "" CMAKE_CXX_FLAGS
-# "${CMAKE_CXX_FLAGS}")
-# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${option}" CACHE STRING
-# "common C++ build flags" FORCE)
-# ENDFOREACH(option ${TMP})
-# ENDFOREACH(arg ${ARGN})
-# ENDMACRO(FORCE_ADD_CXX_FLAGS)
+#################################################################
+### ADD_CXX_FLAGS(flags) ###
+### flags will be added to CMAKE_CXX_FLAGS, but only once ###
+### This only works for CMake 2.0 and above. ###
+#################################################################
+MACRO(FORCE_ADD_CXX_FLAGS)
+ FOREACH(arg ${ARGN})
+ SET(TMP ${arg}) #elsewise the Seperate command doesn't work)
+ SEPARATE_ARGUMENTS(TMP)
+ FOREACH(option ${TMP})
+ STRING(REGEX REPLACE " ${option}" "" CMAKE_CXX_FLAGS
+ "${CMAKE_CXX_FLAGS}")
+ STRING(REGEX REPLACE "${option}" "" CMAKE_CXX_FLAGS
+ "${CMAKE_CXX_FLAGS}")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${option}" CACHE STRING
+ "common C++ build flags" FORCE)
+ ENDFOREACH(option ${TMP})
+ ENDFOREACH(arg ${ARGN})
+ENDMACRO(FORCE_ADD_CXX_FLAGS)
# This MACRO is designed to set variables to default values only on
# the first configure. Subsequent configures will produce no ops.
@@ -68,29 +68,79 @@
ENDMACRO(FIRST_TIME_SET)
-###################################################
+######################################################################
+# Check for SGI Linux.
+# Assume that if we are running on an Itanium (ia64), then it is an
+# SGI linux system
+
+IF (CMAKE_SYSTEM_PROCESSOR MATCHES "ia64")
+
+ SET(SGI_LINUX TRUE)
+
+ # Warn if the compiler is not icc
+ IF (CMAKE_C_COMPILER MATCHES "icc$")
+ FIRST_TIME_SET(CMAKE_C_FLAGS_RELEASE "-O3 -IPO -g" CACHE STRING "Release
Flags" FORCE)
+ FIRST_TIME_SET(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug Flags"
FORCE)
+
+ ELSE (CMAKE_C_COMPILER MATCHES "icc$")
+ MESSAGE("Intel Compilers recommended on ia64. setenv CC icc before
running cmake.")
+ FIRST_TIME_SET(CMAKE_C_FLAGS_RELEASE "-O3 -ffast-math
-funroll-loops -g" CACHE STRING "Release Flags" FORCE)
+ FIRST_TIME_SET(CMAKE_C_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug
Flags" FORCE)
+ ENDIF(CMAKE_C_COMPILER MATCHES "icc$")
+
+ IF (CMAKE_CXX_COMPILER MATCHES "icpc$")
+ FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -IPO -g" CACHE STRING
"Release Flags" FORCE)
+ FIRST_TIME_SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug
Flags" FORCE)
+ ELSE (CMAKE_CXX_COMPILER MATCHES "icpc$")
+ MESSAGE("Intel Compilers recommended on ia64. setenv CXX icpc
before running cmake.")
+ FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -ffast-math
-funroll-loops -g" CACHE STRING "Release Flags" FORCE)
+ FIRST_TIME_SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g" CACHE STRING "Debug
Flags" FORCE)
+ ENDIF(CMAKE_CXX_COMPILER MATCHES "icpc$")
+
+ENDIF (CMAKE_SYSTEM_PROCESSOR MATCHES "ia64")
+
+
+######################################################################
+# Check for SGI Irix
IF(CMAKE_SYSTEM MATCHES IRIX)
+
# For now force sproc on IRIX systems.
# MESSAGE("Forcing Irix Threads")
- SET(CMAKE_USE_SPROC_INIT 1)
- SET(CMAKE_USE_PTHREADS_INIT 0)
- SET(CMAKE_THREAD_LIBS_INIT -lfetchop)
+ SET(CMAKE_USE_SPROC_INIT 0)
+ SET(CMAKE_USE_PTHREADS_INIT 1)
+ SET(CMAKE_THREAD_LIBS_INIT -lpthread -lfetchop)
+
# Check for CC compiler and add -LANG:std to it
IF(CMAKE_CXX_COMPILER MATCHES "CC")
- FIRST_TIME_SET(CMAKE_CXX_FLAGS "-LANG:std" STRING "Standard CXX flags")
- FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -OPT:IEEE_arithmetic=3"
- STRING "Optimized Flags")
+ FIRST_TIME_SET(CMAKE_CXX_FLAGS "-64 -LANG:std" STRING "Standard CXX
flags")
+ FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -OPT:IEEE_arithmetic=3"
STRING "Optimized Flags")
ENDIF(CMAKE_CXX_COMPILER MATCHES "CC")
+
+ IF(CMAKE_C_COMPILER MATCHES "cc")
+ FIRST_TIME_SET(CMAKE_C_FLAGS "-64" STRING "Standard CC flags")
+ FIRST_TIME_SET(CMAKE_SHARED_LINKER_FLAGS "-64" STRING "Standard Linker
flags")
+ ENDIF(CMAKE_C_COMPILER MATCHES "cc")
+
ELSE(CMAKE_SYSTEM MATCHES IRIX)
# MESSAGE("IRIX not found")
ENDIF(CMAKE_SYSTEM MATCHES IRIX)
-
+######################################################################
+# Check for Mac OS
IF (APPLE)
FIRST_TIME_SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -g -fgcse-sm -funroll-loops
-fstrict-aliasing -fsched-interblock -falign-loops=16 -falign-jumps=16
-falign-functions=16 -falign-jumps-max-skip=15 -falign-loops-max-skip=15
-ffast-math -freorder-blocks -mpowerpc-gpopt -force_cpusubtype_ALL -mtune=G5
-mcpu=G5 -mpowerpc64 -faltivec -mabi=altivec -mpowerpc-gfxopt" STRING
"Optimized Flags")
ENDIF (APPLE)
+
+##################################################################
+## No more setting CXX_FLAGS beyond this point. Only appending.
+
+## We need SCI_NOPERSISTENT to be defined
+FORCE_ADD_CXX_FLAGS("-DSCI_NOPERSISTENT")
+
+
+
IF (OPENGL_INCLUDE_PATH)
INCLUDE_DIRECTORIES (${OPENGL_INCLUDE_PATH})
ENDIF (OPENGL_INCLUDE_PATH)
@@ -127,10 +177,26 @@
SUBDIRS( ${MAIN_SUBDIRS} )
+# Check to see whether the optional glfw/ directory should be included.
+SET(BUILD_GLFW 0 CACHE BOOL "Build glfw frontend.")
+IF(BUILD_GLFW)
+ SUBDIRS(glfw)
+ENDIF(BUILD_GLFW)
+
+# Check to see whether the histx performance monitoring tools should
+# be built on IA64.
+SET(BUILD_HISTX_MANTA 0 CACHE BOOL "Build Histx-Manta tools")
+IF(BUILD_HISTX_MANTA)
+ SUBDIRS(histx)
+ENDIF(BUILD_HISTX_MANTA)
+
+# Check to see whether the optional fox/ directory should be included.
+SET(BUILD_FOX 0 CACHE BOOL "Build fox frontend.")
+IF(BUILD_FOX)
+ SUBDIRS(fox)
+ENDIF(BUILD_FOX)
# Now that everything is done indicate that we have finished
# configuring at least once.
SET(PASSED_FIRST_CONFIGURE ON CACHE INTERNAL "Already Configured once?")
-
-
Modified: trunk/Core/CMakeLists.txt
==============================================================================
--- trunk/Core/CMakeLists.txt (original)
+++ trunk/Core/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,25 +1,53 @@
SET (CORE_SOURCES)
SET (CORE_SOURCES ${CORE_SOURCES}
+ Color/ColorDB.h
Color/ColorDB.cc
+ Color/ColorSpace.h
+ Color/RGBColor.h
Color/RGBColor.cc
Color/GrayColor.cc)
SET (CORE_SOURCES ${CORE_SOURCES}
+ Geometry/Ray.h
+ Geometry/PointVector.h
Geometry/PointVector.cc
+ Geometry/BBox.h
)
SET (CORE_SOURCES ${CORE_SOURCES}
+ Exceptions/BadPrimitive.h
Exceptions/BadPrimitive.cc
+ Exceptions/IllegalArgument.h
Exceptions/IllegalArgument.cc
+ Exceptions/UnknownColor.h
Exceptions/UnknownColor.cc
)
SET (CORE_SOURCES ${CORE_SOURCES}
+ Math/MT_RNG.h
Math/MT_RNG.cc
- Math/Noise.cc)
+ Math/Noise.h
+ Math/Noise.cc
+ Math/ipow.h
+ Math/CatmullRomInterpolator.h
+ )
SET (CORE_SOURCES ${CORE_SOURCES}
- Util/Args.cc)
+ Util/Args.h
+ Util/Args.cc
+ Util/ThreadStorageAllocator.h
+ Util/ThreadStorageAllocator.cc)
SET (CORE_SOURCES ${CORE_SOURCES}
- Geometry/AffineTransform.cc
+ Geometry/AffineTransform.h
+ Geometry/AffineTransform.cc
)
+
+
+IF(SGI_LINUX)
+ SET (CORE_SOURCES ${CORE_SOURCES}
+ Shm/ShmSemaphore.h
+ Shm/ShmSemaphore.cc
+ Shm/MFStreamData.h
+ Shm/MFStreamData.cc
+ )
+ENDIF(SGI_LINUX)
ADD_LIBRARY (Manta_Core ${CORE_SOURCES})
Modified: trunk/Core/Color/ColorDB.cc
==============================================================================
--- trunk/Core/Color/ColorDB.cc (original)
+++ trunk/Core/Color/ColorDB.cc Tue Dec 6 16:58:03 2005
@@ -796,6 +796,31 @@
return Color(RGBColor(nc.r*scale, nc.g*scale, nc.b*scale));
}
+bool ColorDB::getNamedColor( unsigned char result[3], const std::string
&name ) {
+
+ int l = 0;
+ int h = sizeof(namedColors)/sizeof(RGBData)-1;
+
+ while(h > l+1){
+ int m = (h+l)/2;
+ if(name < namedColors[m].name)
+ h = m;
+ else
+ l = m;
+ }
+
+ if(name != namedColors[l].name)
+ return false;
+
+ RGBData& nc = namedColors[l];
+
+ result[0] = nc.r;
+ result[1] = nc.g;
+ result[2] = nc.b;
+
+ return true;
+}
+
bool ColorDB::test() {
bool passed_all = true;
size_t num_entries = sizeof(namedColors)/sizeof(RGBData);
@@ -821,3 +846,4 @@
}
return passed_all;
}
+
Modified: trunk/Core/Color/ColorDB.h
==============================================================================
--- trunk/Core/Color/ColorDB.h (original)
+++ trunk/Core/Color/ColorDB.h Tue Dec 6 16:58:03 2005
@@ -11,6 +11,7 @@
class ColorDB {
public:
static Color getNamedColor(const std::string& name);
+ static bool getNamedColor(unsigned char result[3], const std::string
&name);
// Tests to make sure the namedColors array is sorted properly and
// that you can find all the entries. Return true if everything
Modified: trunk/Core/Color/ColorSpace.h
==============================================================================
--- trunk/Core/Color/ColorSpace.h (original)
+++ trunk/Core/Color/ColorSpace.h Tue Dec 6 16:58:03 2005
@@ -15,16 +15,15 @@
class ColorSpace {
public:
typedef typename Traits::ComponentType ComponentType;
+ typedef typename Traits::ComponentType ScalarType;
enum { NumComponents = Traits::NumComponents};
- ColorSpace()
- {
- }
+ ColorSpace() { }
ColorSpace(const ColorSpace<Traits>& copy)
{
for(int i=0;i<3;i++)
- data[i]=copy.data[i];
+ data[i]=copy.data[i];
}
#ifndef SWIG
ColorSpace& operator=(const ColorSpace<Traits> ©) {
@@ -50,12 +49,12 @@
// Conversions to concrete color classes
- //
+ //
// This is what I originally did, but I thought that the error
// messages were confusing when you tried to pass the wrong thing
// into the ctor
//
- //template<class C>
+ //template<class C>
// explicit ColorSpace(const C& color) {
// Traits::convertFrom(data, color);
//}
@@ -154,6 +153,14 @@
return *this;
}
+ ComponentType Mean() const
+ {
+ ComponentType sum = 0;
+ for (int i = 0; i < NumComponents; i++)
+ sum += data[i];
+ return sum*(1/ComponentType(NumComponents));
+ }
+
// Apply functor
ColorSpace<Traits> attenuate(ComponentType scale) const {
using SCIRun::Exp;
@@ -171,6 +178,32 @@
// that header file and it will get instantiated properly.
std::string toString() const;
+
+ template<typename Scalar>
+ ColorSpace<Traits> Pow(Scalar exponent) const
+ {
+ using SCIRun::Pow;
+ ColorSpace<Traits> returnValue;
+ for (int i=0; i < NumComponents; i++)
+ returnValue.data[i] = SCIRun::Pow(data[i], exponent);
+ return returnValue;
+ }
+
+ ColorSpace<Traits> Log() const
+ {
+ ColorSpace<Traits> returnValue;
+ for (int i=0; i < NumComponents; i++)
+ returnValue.data[i] = log(data[i]);
+ return returnValue;
+ }
+
+ ColorSpace<Traits> attenuate(const ColorSpace<Traits> &scale) const {
+ using SCIRun::Exp;
+ ColorSpace<Traits> returnValue;
+ for(int i=0;i<NumComponents;i++)
+ returnValue.data[i] = Exp(scale.data[i]*data[i]);
+ return returnValue;
+ }
protected:
// DO NOT MAKE THIS PUBLIC!
ComponentType data[NumComponents];
@@ -179,6 +212,7 @@
data[i] = fillValue;
}
};
+
}
#endif
Modified: trunk/Core/Geometry/AffineTransform.cc
==============================================================================
--- trunk/Core/Geometry/AffineTransform.cc (original)
+++ trunk/Core/Geometry/AffineTransform.cc Tue Dec 6 16:58:03 2005
@@ -92,10 +92,10 @@
VectorT<T, 3> v = Cross(from, to);
T e = Dot(from, to);
- if(e > 1.0-1.e-9){
+ if(e > 1-(T)(1.e-9)){
// No rotation
return;
- } else if (e < -1.0+1.e-9){
+ } else if (e < -1+(T)(1.e-9)){
// 180 degree rotation
VectorT<T, 3> x = v.absoluteValue();
int largest = x.indexOfMaxComponent();
@@ -112,11 +112,11 @@
for(int j = 0; j < 3; j++){
mtx[i][j] = -c1 * u[i] * u[j] + c2 * v[i] * v[j] + c3 * v[i] *
u[j];
}
- mtx[i][i] += 1.0;
+ mtx[i][i] += 1;
}
pre_multiply(mtx);
} else {
- T h = 1.0/(1.0 + e); /* optimization by Gottfried Chen */
+ T h = (T)1/(1 + e); /* optimization by Gottfried Chen */
T mtx[3][3];
mtx[0][0] = e + h * v[0] * v[0];
mtx[0][1] = h * v[0] * v[1] - v[2];
@@ -225,7 +225,7 @@
T denom = c*d*h-c*e*g-b*d*i+b*f*g+a*e*i-a*f*h;
- T inv_denom = 1./denom;
+ T inv_denom = (T)(1)/denom;
mat[0][0] = (e*i-f*h)*inv_denom;
mat[0][1] = (c*h-b*i)*inv_denom;
mat[0][2] = (b*f-c*e)*inv_denom;
@@ -235,9 +235,11 @@
mat[2][0] = (d*h-e*g)*inv_denom;
mat[2][1] = (b*g-a*h)*inv_denom;
mat[2][2] = (a*e-b*d)*inv_denom;
- double x = mat[0][3];
- double y = mat[1][3];
- double z = mat[2][3];
+ // These were double, but I changed them to type T. Do they need
+ // to be double for some reason?
+ T x = mat[0][3];
+ T y = mat[1][3];
+ T z = mat[2][3];
mat[0][3] = -(mat[0][0]*x + mat[0][1]*y + mat[0][2]*z);
mat[1][3] = -(mat[1][0]*x + mat[1][1]*y + mat[1][2]*z);
mat[2][3] = -(mat[2][0]*x + mat[2][1]*y + mat[2][2]*z);
Modified: trunk/Core/Geometry/BBox.h
==============================================================================
--- trunk/Core/Geometry/BBox.h (original)
+++ trunk/Core/Geometry/BBox.h Tue Dec 6 16:58:03 2005
@@ -2,6 +2,9 @@
#ifndef Manta_Core_BBox_h
#define Manta_Core_BBox_h
+#include <Core/Geometry/PointVector.h>
+#include <SCIRun/Core/Math/MiscMath.h>
+
#include <sgi_stl_warnings_off.h>
#include <limits>
#include <sgi_stl_warnings_on.h>
@@ -9,8 +12,11 @@
namespace Manta {
class BBox {
public:
- BBox(const Point& min, const Point& max)
- : min(min), max(max) {
+
+ template< typename T >
+ BBox(const PointT<T,3>& min_, const PointT<T,3>& max_ ) {
+ bounds[0] = min_;
+ bounds[1] = max_;
}
BBox() {
// Need to initialize min and max.
@@ -18,92 +24,89 @@
}
~BBox() {
}
-
+
// This resets min and max to an uninitialized state that will
// accept new bounds [MAX, -MAX].
void reset() {
Real max_val = std::numeric_limits<Real>::max();
- min = Point( max_val, max_val, max_val);
- max = Point(-max_val, -max_val, -max_val);
+ bounds[0] = Point( max_val, max_val, max_val);
+ bounds[1] = Point(-max_val, -max_val, -max_val);
}
-
+
// Test whether the box is in the "uninitialized state"
- bool isDefault() {
+ bool isDefault() const {
Real max_val = std::numeric_limits<Real>::max();
- return ( min.x() == max_val && max.x() == -max_val &&
- min.y() == max_val && max.y() == -max_val &&
- min.z() == max_val && max.z() == -max_val );
+ return ( bounds[0] == Point(max_val, max_val, max_val) &&
+ bounds[1] == Point(-max_val, -max_val, -max_val) );
}
Vector diagonal() const {
- return max-min;
+ return bounds[1] - bounds[0];
}
Point center() const {
- return Interpolate(min, max, 0.5);
+ return Interpolate(bounds[0], bounds[1], 0.5);
}
- void extendByPoint(const Point& p) {
- min = Min(min, p);
- max = Max(max, p);
+ template< typename T >
+ void extendByPoint(const PointT<T,3>& p) {
+ bounds[0] = Min(bounds[0],
Point((Point::ScalarType)p[0],(Point::ScalarType)p[1],(Point::ScalarType)p[2]));
+ bounds[1] = Max(bounds[1],
Point((Point::ScalarType)p[0],(Point::ScalarType)p[1],(Point::ScalarType)p[2]));
}
+
void extendBySphere(const Point& p, Real radius) {
- min = Min(min, p-Vector(radius, radius, radius));
- max = Max(max, p+Vector(radius, radius, radius));
+ bounds[0] = Min(bounds[0], p-Vector(radius, radius, radius));
+ bounds[1] = Max(bounds[1], p+Vector(radius, radius, radius));
}
void extendByDisc(const Point& p, const Vector& n, Real radius) {
Vector v(sqrt(1-p.x()*p.x()), sqrt(1-p.y()*p.y()),
sqrt(1-p.z()*p.z()));
- min = Min(min, p-v*radius);
- max = Max(max, p+v*radius);
+ bounds[0] = Min(bounds[0], p-v*radius);
+ bounds[1] = Max(bounds[1], p+v*radius);
}
void extendByBox(const BBox& b) {
- min = Min(min, b.min);
- max = Max(max, b.max);
+ bounds[0] = Min(bounds[0], b.bounds[0]);
+ bounds[1] = Max(bounds[1], b.bounds[1]);
}
const Point& getMin() const {
- return min;
+ return bounds[0];
}
const Point& getMax() const {
- return max;
+ return bounds[1];
}
Point getCorner(int i) const {
- return Point(i&4?min.x():max.x(),
- i&2?min.y():max.y(),
- i&1?min.z():max.z());
+ return Point(bounds[i&4].x(), bounds[i&2].y(), bounds[i&1].z());
}
double computeVolume() const
{
- return ( ( max.x() - min.x() ) *
- ( max.y() - min.y() ) *
- ( max.z() - min.z() ) );
+ Vector d = bounds[1] - bounds[0];
+ return ( d.x() * d.y() * d.z() );
}
double computeArea() const
{
- double lenx = max.x() - min.x();
- double leny = max.y() - min.y();
- double lenz = max.z() - min.z();
- return (2.0*((lenx*leny) + (leny*lenz) + (lenx*lenz)));
+ Vector d = bounds[1] - bounds[0];
+ return (2.0*(d.x()*d.y() + d.y()*d.z()) + d.x()*d.z() );
}
int longestAxis() const
{
- double lenx = max.x() - min.x();
- double leny = max.y() - min.y();
- double lenz = max.z() - min.z();
- if ( lenx > leny )
- return lenx > lenz ? 0 : 2;
+ Vector d = bounds[1] - bounds[0];
+ if ( d.x() > d.y() )
+ return d.x() > d.z() ? 0 : 2;
else
- return leny > lenz ? 1 : 2;
+ return d.y() > d.z() ? 1 : 2;
}
+ inline Point &operator[] (int i) { return bounds[i]; }
+ inline const Point &operator[] (int i) const { return bounds[i]; }
+
private:
- BBox(const BBox&);
- BBox& operator=(const BBox&);
+ // BBox(const BBox&);
+ // BBox& operator=(const BBox&);
- Point min, max;
+ Point bounds[2];
};
}
Modified: trunk/Core/Geometry/PointVector.cc
==============================================================================
--- trunk/Core/Geometry/PointVector.cc (original)
+++ trunk/Core/Geometry/PointVector.cc Tue Dec 6 16:58:03 2005
@@ -20,12 +20,62 @@
return os;
}
+ template<typename T, int Dim>
+ std::istream &operator>> (std::istream &is, VectorT<T,Dim> &v) {
+ for (int i=0;i<Dim;++i)
+ is >> v[i];
+ return is;
+ }
+
+ template<typename T, int Dim>
+ std::istream &operator>> (std::istream &is, PointT<T,Dim> &v) {
+ for (int i=0;i<Dim;++i)
+ is >> v[i];
+ return is;
+ }
+
// Explicit instantiations for ostream operators
+
+ // 3D Vectors
template std::ostream& operator<<(std::ostream& os, const VectorT<double,
3>&);
template std::ostream& operator<<(std::ostream& os, const VectorT<float,
3>&);
template std::ostream& operator<<(std::ostream& os, const VectorT<int,
3>&);
+ // 3D Points
template std::ostream& operator<<(std::ostream& os, const PointT<double,
3>&);
template std::ostream& operator<<(std::ostream& os, const PointT<float,
3>&);
template std::ostream& operator<<(std::ostream& os, const PointT<int, 3>&);
+
+ // 2D Vectors
+ template std::ostream& operator<<(std::ostream& os, const VectorT<double,
2>&);
+ template std::ostream& operator<<(std::ostream& os, const VectorT<float,
2>&);
+ template std::ostream& operator<<(std::ostream& os, const VectorT<int,
2>&);
+
+ // 2D Points
+ template std::ostream& operator<<(std::ostream& os, const PointT<double,
2>&);
+ template std::ostream& operator<<(std::ostream& os, const PointT<float,
2>&);
+ template std::ostream& operator<<(std::ostream& os, const PointT<int, 2>&);
+
+ // Explicit instantiations for istream operators
+
+ // 3D Vectors
+ template std::istream& operator>>(std::istream& is, VectorT<double, 3>&);
+ template std::istream& operator>>(std::istream& is, VectorT<float, 3>&);
+ template std::istream& operator>>(std::istream& is, VectorT<int, 3>&);
+
+ // 3D Points
+ template std::istream& operator>>(std::istream& is, PointT<double, 3>&);
+ template std::istream& operator>>(std::istream& is, PointT<float, 3>&);
+ template std::istream& operator>>(std::istream& is, PointT<int, 3>&);
+
+ // 2D Vectors
+ template std::istream& operator>>(std::istream& is, VectorT<double, 2>&);
+ template std::istream& operator>>(std::istream& is, VectorT<float, 2>&);
+ template std::istream& operator>>(std::istream& is, VectorT<int, 2>&);
+
+ // 2D Points
+ template std::istream& operator>>(std::istream& is, PointT<double, 2>&);
+ template std::istream& operator>>(std::istream& is, PointT<float, 2>&);
+ template std::istream& operator>>(std::istream& is, PointT<int, 2>&);
+
}
Modified: trunk/Core/Geometry/PointVector.h
==============================================================================
--- trunk/Core/Geometry/PointVector.h (original)
+++ trunk/Core/Geometry/PointVector.h Tue Dec 6 16:58:03 2005
@@ -1,3 +1,10 @@
+/*
+
+ PointT and VectorT are made to be templated with floating point
+ types. If you use an integral type, you could get into trouble with
+ certain functions that compute division. Be warned!
+
+*/
#ifndef Manta_Core_PointVector_h
#define Manta_Core_PointVector_h
@@ -6,13 +13,19 @@
#include <Core/Math/Expon.h>
#include <Core/Math/MinMax.h>
#include <Core/Math/MiscMath.h>
+
+#include <sgi_stl_warnings_off.h>
#include <iosfwd>
+#include <sgi_stl_warnings_on.h>
+
#include <math.h>
namespace Manta {
template<typename T, int Dim>
class VectorT {
public:
+ typedef T ScalarType;
+
VectorT() {
}
#ifndef SWIG
@@ -31,15 +44,17 @@
data[i] = copy[i];
}
- VectorT(const VectorT<T, Dim>& copy) {
+ // Copy from another vector of the same size.
+ template< typename S >
+ VectorT(const VectorT<S, Dim> ©) {
for(int i=0;i<Dim;i++)
- data[i] = copy[i];
+ data[i] = (T)copy[i];
}
#ifndef SWIG
VectorT<T, Dim>& operator=(const VectorT<T, Dim>& copy) {
for(int i=0;i<Dim;i++)
- data[i] = copy.data[i];
+ data[i] = (T)copy[i];
return *this;
}
#endif
@@ -64,7 +79,9 @@
}
T &operator[] ( int i ) {
return data[i];
- }
+ }
+ const T *operator &() const { return data; }
+
#else
%extend {
T& __getitem__( int i ) {
@@ -72,6 +89,7 @@
}
}
#endif
+
VectorT<T, Dim> operator+(const VectorT<T, Dim>& v) const {
VectorT<T, Dim> result;
for(int i=0;i<Dim;i++)
@@ -124,14 +142,14 @@
return *this;
}
VectorT<T, Dim> operator/(T s) const {
- T inv_s = 1./s;
+ T inv_s = 1/s;
VectorT<T, Dim> result;
for(int i=0;i<Dim;i++)
result.data[i] = data[i] * inv_s;
return result;
}
VectorT<T, Dim>& operator/=(T s) {
- T inv_s = 1./s;
+ T inv_s = 1/s;
for(int i=0;i<Dim;i++)
data[i] *= inv_s;
return *this;
@@ -143,6 +161,13 @@
return result;
}
+ bool operator==(const VectorT<T, Dim>& right) const {
+ for (int i = 0; i < Dim; ++i)
+ if(data[i] != right.data[i])
+ return false;
+ return true;
+ }
+
T length() const {
T sum = 0;
for(int i=0;i<Dim;i++)
@@ -158,13 +183,13 @@
T normalize() {
T l = length();
- T scale = 1./l;
+ T scale = 1/l;
*this *= scale;
return l;
}
VectorT<T, Dim> normal() const {
T l = length();
- T scale = 1./l;
+ T scale = 1/l;
return *this * scale;
}
T minComponent() const {
@@ -199,7 +224,7 @@
VectorT<T, Dim> inverse() const {
VectorT<T, Dim> result;
for(int i=0;i<Dim;i++)
- result.data[i] = 1./data[i];
+ result.data[i] = 1/data[i];
return result;
}
VectorT<T, Dim> absoluteValue() const {
@@ -230,6 +255,8 @@
template<typename T, int Dim>
class PointT {
public:
+ typedef T ScalarType;
+
PointT() {
}
@@ -244,9 +271,10 @@
data[0] = x; data[1] = y; data[2] = z;
}
- PointT(const PointT<T, Dim>& copy) {
+ template< typename S >
+ PointT(const PointT<S, Dim>& copy) {
for(int i=0;i<Dim;i++)
- data[i] = copy.data[i];
+ data[i] = (T)copy[i];
}
explicit PointT( const VectorT<T,Dim> © ) {
@@ -254,10 +282,17 @@
data[i] = copy[i];
}
+ bool operator==(const PointT<T, Dim>& right) const {
+ for (int i = 0; i < Dim; ++i)
+ if(data[i] != right.data[i])
+ return false;
+ return true;
+ }
#ifndef SWIG
- PointT<T, Dim>& operator=(const PointT<T, Dim>& copy) {
+ template< typename S >
+ PointT<T, Dim>& operator=(const PointT<S, Dim>& copy) {
for(int i=0;i<Dim;i++)
- data[i] = copy.data[i];
+ data[i] = (T)copy[i];
return *this;
}
#endif
@@ -282,6 +317,7 @@
T &operator[](int i) {
return data[i];
}
+
#else
%extend {
T& __getitem__( int i ) {
@@ -359,15 +395,22 @@
T data[Dim];
};
- template<typename T, int Dim>
- inline VectorT<T, Dim> operator*(T s, const VectorT<T, Dim>& v)
+ // Two multiplication by a scalar operators.
+ template<typename T, int Dim, typename S >
+ inline VectorT<T, Dim> operator*(S s, const VectorT<T, Dim>& v)
{
VectorT<T, Dim> result;
for(int i=0;i<Dim;i++)
- result[i] = s * v[i];
+ result[i] = s * (S)v[i];
return result;
}
+ template<typename T, int Dim, typename S >
+ inline VectorT<T, Dim> operator*(const VectorT<T, Dim>& v, S s)
+ {
+ return operator*((T)s,v);
+ }
+
template<typename T, int Dim>
inline T Dot(const VectorT<T, Dim>& v1, const VectorT<T, Dim>& v2)
{
@@ -461,6 +504,11 @@
template<typename T, int Dim>
std::ostream &operator<< (std::ostream &os, const PointT<T,Dim> &v);
+ template<typename T, int Dim>
+ std::istream &operator>> (std::istream &is, VectorT<T,Dim> &v);
+
+ template<typename T, int Dim>
+ std::istream &operator>> (std::istream &is, PointT<T,Dim> &v);
}
#endif
Modified: trunk/Core/Geometry/Ray.h
==============================================================================
--- trunk/Core/Geometry/Ray.h (original)
+++ trunk/Core/Geometry/Ray.h Tue Dec 6 16:58:03 2005
@@ -44,7 +44,7 @@
const Vector& direction() const {
return dir;
}
- double normalizeDirection() {
+ Real normalizeDirection() {
return dir.normalize();
}
private:
Modified: trunk/Core/Math/Noise.cc
==============================================================================
--- trunk/Core/Math/Noise.cc (original)
+++ trunk/Core/Math/Noise.cc Tue Dec 6 16:58:03 2005
@@ -1,5 +1,7 @@
+
#include <Core/Geometry/PointVector.h>
#include <Core/Math/MiscMath.h>
+#include <Core/Math/Noise.h>
using namespace SCIRun;
using namespace std;
@@ -10,7 +12,7 @@
* This is the table of permutations required by the noise functions to
* hash their input to generate the X coordinates.
*/
- int NoiseXPermutationTable[] = {
+ static int NoiseXPermutationTable[] = {
76, 97, 84, 215, 37, 4, 251, 48, 100, 174, 161, 125, 136, 99, 139, 19,
101, 158, 202, 165, 138, 129, 144, 180, 232, 196, 155, 252, 182, 173,
55, 201, 189, 14, 225, 31, 171, 46, 79, 146, 217, 127, 41, 92, 191, 82,
@@ -34,7 +36,7 @@
* This is the table of permutations required by the noise functions to
* hash their input to generate the Y coordinates.
*/
- int NoiseYPermutationTable[] = {
+ static int NoiseYPermutationTable[] = {
105, 76, 135, 3, 66, 169, 252, 41, 40, 69, 26, 141, 91, 88, 75, 191,
118, 184, 126, 110, 172, 64, 185, 142, 157, 85, 39, 113, 56, 192, 70,
111, 170, 87, 177, 100, 186, 216, 127, 94, 136, 182, 200, 37, 241, 251,
@@ -58,7 +60,7 @@
* This is the table of permutations required by the noise functions to
* hash their input to generate the Z coordinates.
*/
- int NoiseZPermutationTable[] = {
+ static int NoiseZPermutationTable[] = {
228, 169, 108, 236, 15, 208, 250, 147, 72, 76, 155, 10, 186, 3, 187,
87, 1, 37, 19, 239, 123, 235, 70, 181, 122, 30, 125, 175, 221, 165,
167, 231, 58, 211, 154, 38, 191, 130, 64, 206, 197, 114, 54, 40, 220,
@@ -83,7 +85,7 @@
* The values in the noise permutation tables can be used to index into
* this table to get the gradients for the noise.
*/
- double Noise1DValueTable[] = {
+ static double Noise1DValueTable[] = {
0.47451, 0.482353, 0.670588, 0.545098, 0.803922, -0.443137, -0.678431,
0.32549, 0.45098, 0.396078, 0.905882, -0.0666667, -0.466667, 0.733333,
0.87451, 0.568627, 0.921569, -0.584314, 0.262745, -0.670588, 0.254902,
@@ -133,7 +135,7 @@
* permutation tables can be used to index into this table to get the
* gradients for the noise.
*/
- double Noise3DValueTable[][ 3 ] = {
+ static double Noise3DValueTable[][ 3 ] = {
{ -0.439336, 0.540416, 0.71759 }, { 0.183348, 0.923971, 0.33565 },
{ -0.15203, -0.392751, -0.906991 }, { 0.707649, 0.112768, 0.697507 },
{ 0.136611, -0.456018, 0.879423 }, { -0.414372, -0.868792, -0.271103 },
@@ -560,3 +562,4 @@
}
}
+
Modified: trunk/Core/Math/Noise.h
==============================================================================
--- trunk/Core/Math/Noise.h (original)
+++ trunk/Core/Math/Noise.h Tue Dec 6 16:58:03 2005
@@ -3,10 +3,6 @@
#include <Core/Geometry/PointVector.h>
-namespace SCIRun {
- class Point;
-}
-
namespace Manta {
/**
Modified: trunk/Core/Math/ipow.h
==============================================================================
--- trunk/Core/Math/ipow.h (original)
+++ trunk/Core/Math/ipow.h Tue Dec 6 16:58:03 2005
@@ -8,9 +8,21 @@
double result=1;
while(p){
if(p&1)
- result*=x;
+ result*=x;
x*=x;
- p>>=1;
+ p>>=1;
+ }
+ return result;
+ }
+
+ inline float ipow(float x, int p)
+ {
+ float result=1;
+ while(p){
+ if(p&1)
+ result*=x;
+ x*=x;
+ p>>=1;
}
return result;
}
Modified: trunk/Core/Util/Args.cc
==============================================================================
--- trunk/Core/Util/Args.cc (original)
+++ trunk/Core/Util/Args.cc Tue Dec 6 16:58:03 2005
@@ -80,20 +80,37 @@
char* ptr = const_cast<char*>(args[i].c_str());
int tmpxres = (int)strtol(ptr, &ptr, 10);
if(ptr == args[i].c_str() || *ptr != 'x'){
- i--;
- return false;
+ i--;
+ return false;
}
char* oldptr = ++ptr; // Skip the x
int tmpyres = (int)strtol(ptr, &ptr, 10);
if(ptr == oldptr || *ptr != 0){
- i--;
- return false;
+ i--;
+ return false;
}
xres = tmpxres;
yres = tmpyres;
return true;
}
}
+
+ bool getResolutionArg(const string& arg, int& xres, int& yres)
+ {
+ char* ptr = const_cast<char*>(arg.c_str());
+ int tmpxres = (int)strtol(ptr, &ptr, 10);
+ if(ptr == arg.c_str() || *ptr != 'x'){
+ return false;
+ }
+ char* oldptr = ++ptr; // Skip the x
+ int tmpyres = (int)strtol(ptr, &ptr, 10);
+ if(ptr == oldptr || *ptr != 0){
+ return false;
+ }
+ xres = tmpxres;
+ yres = tmpyres;
+ return true;
+ }
bool getPointArg(int& i, const vector<string>& args, Point& p)
{
Modified: trunk/Core/Util/Args.h
==============================================================================
--- trunk/Core/Util/Args.h (original)
+++ trunk/Core/Util/Args.h Tue Dec 6 16:58:03 2005
@@ -20,6 +20,9 @@
bool getVectorArg(int& i, const vector<string>&, Vector& p);
void parseSpec(const string& spec, string& name, vector<string>& args);
+ // Parse a resolution value from a string.
+ bool getResolutionArg(const string& arg, int& xres, int& yres);
+
// Generic version that grabs an argument of type T.
template<typename T>
bool getArg(int& i, const vector<string>& args, T& result) {
@@ -42,8 +45,6 @@
}
}
-
-
// This will separate input into whitespace separated arguments. If
// you want a single argument to contain whitespace you must
// encapsulate the argument with single quotes.
Copied: trunk/Core/Util/ThreadStorageAllocator.cc (from r751,
branches/itanium2/Core/Util/ThreadStorageAllocator.cc)
==============================================================================
--- branches/itanium2/Core/Util/ThreadStorageAllocator.cc (original)
+++ trunk/Core/Util/ThreadStorageAllocator.cc Tue Dec 6 16:58:03 2005
@@ -28,8 +28,6 @@
#include <Core/Util/ThreadStorageAllocator.h>
-#include <malloc.h>
-
using namespace Manta;
ThreadStorageAllocator::ThreadStorageAllocator( int num_procs_ ) :
@@ -41,7 +39,7 @@
bytes = (bytes % 128) ? ((bytes/128)+1)*128 : bytes;
// Allocate array of pointers.
- storage = (char **)memalign( 128, bytes );
+ storage = (char **)malloc(bytes);
// Initialize all of the pointers to zero.
for (int i=0;i<num_procs;++i) {
@@ -67,7 +65,7 @@
free( storage[proc] );
// Allocate aligned storage.
- storage[proc] = (char *)memalign( 128, requested );
+ storage[proc] = (char *)malloc(requested);
if (storage[proc] == 0)
throw InternalError( "Could not allocate thread local memory", __FILE__,
__LINE__ );
Modified: trunk/Engine/CMakeLists.txt
==============================================================================
--- trunk/Engine/CMakeLists.txt (original)
+++ trunk/Engine/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -7,6 +7,7 @@
INCLUDE (PixelSamplers/CMakeLists.txt)
INCLUDE (Renderers/CMakeLists.txt)
INCLUDE (Shadows/CMakeLists.txt)
+# INCLUDE (Animators/CMakeLists.txt)
ADD_LIBRARY (Manta_Engine
${Manta_Control_SRCS}
@@ -17,6 +18,7 @@
${Manta_PixelSamplers_SRCS}
${Manta_Renderers_SRCS}
${Manta_Shadows_SRCS}
+# ${Manta_Animators_SRCS}
)
Modified: trunk/Engine/Control/CMakeLists.txt
==============================================================================
--- trunk/Engine/Control/CMakeLists.txt (original)
+++ trunk/Engine/Control/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,6 +1,8 @@
SET (Manta_Control_SRCS
+ Control/RTRT.h
Control/RTRT.cc
Control/RTRT_register.cc
+ Control/Worker.h
Control/Worker.cc
)
Modified: trunk/Engine/Control/RTRT.cc
==============================================================================
--- trunk/Engine/Control/RTRT.cc (original)
+++ trunk/Engine/Control/RTRT.cc Tue Dec 6 16:58:03 2005
@@ -40,6 +40,7 @@
#include <dlfcn.h>
#include <stdio.h>
+#include <Interface/Material.h>
using namespace Manta;
using namespace std;
@@ -50,7 +51,7 @@
using SCIRun::Time;
using SCIRun::split_string;
-#define RENDER_THREAD_STACKSIZE 1024*1024
+#define RENDER_THREAD_STACKSIZE 8*1024*1024
namespace Manta {
RTRTInterface* createRTRT()
@@ -58,10 +59,7 @@
return new RTRT();
}
- bool bool_or(const bool& b1, const bool& b2) {
- return b1 || b2;
- }
- void registerKnownComponents(RTRTInterface* rtrt);
+ extern void registerKnownComponents(RTRTInterface* rtrt);
}
RTRT::RTRT()
@@ -71,7 +69,8 @@
barrier2("RTRT frame barrier #2"),
barrier3("RTRT frame barrier #3"),
transaction_lock("RTRT transaction lock"),
- ids("RTRT id counter", 1)
+ ids("RTRT id counter", 1),
+ thread_storage( 0 )
{
workersWanted=0;
workersRendering=0;
@@ -97,7 +96,7 @@
Channel* channel = *iter;
delete channel->display;
for(vector<Image*>::iterator iter = channel->images.begin();
- iter != channel->images.end(); iter++)
+ iter != channel->images.end(); iter++)
delete *iter;
}
delete currentImageTraverser;
@@ -108,7 +107,7 @@
void RTRT::changeNumWorkers(int newNumWorkers)
{
- if(newNumWorkers <= 0)
+ if(newNumWorkers < 0)
throw IllegalValue<int>("RTRT::changeNumWorkers, number of workers
should be > 0", newNumWorkers);
workersWanted=newNumWorkers;
@@ -119,21 +118,38 @@
return workersWanted;
}
-void RTRT::addOneShotCallback(Whence /*whence*/, long frame,
- CallbackBase_2Data<int, int>* callback)
+void RTRT::addOneShotCallback(Whence whence, long frame,
+ CallbackBase_2Data<int, int>* callback)
{
#if NOTFINISHED
// What about adding callbacks during anim cycle?
#endif
callbackLock.writeLock();
-#if NOTFINISHED
- if(whence == RTRTInterface::Relative)
- frame += current Fame;
-#endif
+ // #if NOTFINISHED
+
+ if(whence == RTRTInterface::Relative) {
+ frame += animFrameState.frameNumber;
+ }
+ // #endif
+
oneShots.insert(OneShotMapType::value_type(frame, callback));
callbackLock.writeUnlock();
}
+void RTRT::addParallelOneShotCallback(Whence whence, long frame,
+ CallbackBase_2Data<int, int>* callback)
+{
+ callbackLock.writeLock();
+
+ if(whence == RTRTInterface::Relative) {
+ frame += animFrameState.frameNumber;
+ }
+
+ parallelOneShots.insert(OneShotMapType::value_type(frame, callback));
+ callbackLock.writeUnlock();
+}
+
+
void RTRT::registerSetupCallback(SetupCallback* callback)
{
setupCallbacks.push_back(callback);
@@ -153,6 +169,13 @@
callbackLock.writeUnlock();
}
+void RTRT::registerTerminationCallback( CallbackBase_1Data< RTRTInterface *>
*cb ) {
+ callbackLock.writeLock();
+ terminationCallbacks.push_back(cb);
+ callbackLock.writeUnlock();
+}
+
+
void RTRT::setTimeMode(TimeMode /*tm*/, double /*rate*/)
{
NOT_FINISHED("RTRT::setTimeMode");
@@ -175,7 +198,7 @@
scene->getObject()->preprocess(context);
if(!currentImageCreator)
- throw InvalidState("Image type was not selected", __FILE__, __LINE__);
+ throw InvalidState("Image type was not selected", __FILE__, __LINE__ );
#if NOTFINISHED
check for existence of other components;
@@ -201,14 +224,17 @@
ostringstream name;
name << "RTRT Worker " << i;
Thread* t = new Thread(new Worker(this, i, false), name.str().c_str(),
- 0, Thread::NotActivated);
+ 0, Thread::NotActivated);
t->setStackSize(RENDER_THREAD_STACKSIZE);
t->activate(false);
workers[i] = t;
}
}
+
+ // Block until finished is set while running in bin/manta
if(blockUntilFinished)
internalRenderLoop(0, false);
+
}
void RTRT::blockUntilFinished()
@@ -232,15 +258,15 @@
animFrameState.frameNumber++;
switch(timeMode){
case RealTime:
- animFrameState.frameTime = Time::currentSeconds() * timeScale;
- break;
+ animFrameState.frameTime = Time::currentSeconds() * timeScale;
+ break;
case FixedRate:
- animFrameState.frameTime =
static_cast<double>(animFrameState.frameNumber) / frameRate;
- break;
+ animFrameState.frameTime =
static_cast<double>(animFrameState.frameNumber) / frameRate;
+ break;
case Static:
- break;
+ break;
}
-
+
// Update the number of workers to be used for the animation and
// image display portion
workersAnimAndImage = workersRendering;
@@ -254,7 +280,7 @@
// Copy over the frame state
if(proc == 0)
renderFrameState = animFrameState;
-
+
// Do callbacks
changed=false;
//callbackLock.readLock();
@@ -265,13 +291,13 @@
if(!firstFrame){
for(int index = 0;index < static_cast<int>(channels.size());index++){
- Channel* channel = channels[index];
- RenderContext myContext(this, index, proc, workersAnimAndImage,
- &animFrameState,
- currentLoadBalancer, currentPixelSampler,
- currentRenderer, currentShadowAlgorithm,
- channel->camera, scene);
- currentImageTraverser->setupFrame(myContext);
+ Channel* channel = channels[index];
+ RenderContext myContext(this, index, proc, workersAnimAndImage,
+ &animFrameState,
+ currentLoadBalancer, currentPixelSampler,
+ currentRenderer, currentShadowAlgorithm,
+ channel->camera, scene, thread_storage );
+ currentImageTraverser->setupFrame(myContext);
}
}
//callbackLock.readUnlock();
@@ -286,29 +312,29 @@
// in case it changes
int newWorkers = workersWanted;
if(newWorkers > workersRendering){
- // We must start new threads, if the number increased. Mark
- // these threads as "latecomers", which will skip to the rendering
- // section of this loop for the first frame
- workersChanged = true;
- workers.resize(newWorkers);
- int oldworkers = workersRendering;
- workersRendering = workersWanted;
- for(int i=oldworkers;i<newWorkers;i++){
- ostringstream name;
- name << "RTRT Worker " << i;
- workers[i] = new Thread(new Worker(this, i, true),
name.str().c_str(),
- 0, Thread::NotActivated);
- workers[i]->setStackSize(RENDER_THREAD_STACKSIZE);
- workers[i]->activate(false);
- }
+ // We must start new threads, if the number increased. Mark
+ // these threads as "latecomers", which will skip to the rendering
+ // section of this loop for the first frame
+ workersChanged = true;
+ workers.resize(newWorkers);
+ int oldworkers = workersRendering;
+ workersRendering = workersWanted;
+ for(int i=oldworkers;i<newWorkers;i++){
+ ostringstream name;
+ name << "RTRT Worker " << i;
+ workers[i] = new Thread(new Worker(this, i, true),
name.str().c_str(),
+ 0, Thread::NotActivated);
+ workers[i]->setStackSize(RENDER_THREAD_STACKSIZE);
+ workers[i]->activate(false);
+ }
} else if(newWorkers < workersRendering) {
- workersChanged = true;
- workersRendering = workersWanted;
+ workersChanged = true;
+ workersRendering = workersWanted;
} else {
- // Don't set it to false if it is already false - avoids
- // flushing the other caches
- if(workersChanged)
- workersChanged = false;
+ // Don't set it to false if it is already false - avoids
+ // flushing the other caches
+ if(workersChanged)
+ workersChanged = false;
}
}
@@ -322,71 +348,92 @@
barrier2.wait(numProcs);
changed=false;
for(int i=0;i<numProcs;i++){
- if(changedFlags[i].changed){
- changed=true;
- break;
- }
+ if(changedFlags[i].changed){
+ changed=true;
+ break;
+ }
}
-
+
if(changed != lastChanged || firstFrame){
if(proc == 0)
doIdleModeCallbacks(changed, firstFrame, pipelineNeedsSetup,
proc, numProcs);
- barrier2.wait(numProcs);
+ barrier2.wait(numProcs);
lastChanged = changed;
}
if(firstFrame)
firstFrame=false;
-
+
// P0 process deletions
if(proc == 0){
- //callbackLock.readLock();
- processDeletions();
- //callbackLock.readUnlock();
+ //callbackLock.readLock();
+ processDeletions();
+ //callbackLock.readUnlock();
}
if(pipelineNeedsSetup){
- // Negotiate the image pipeline for each channel
- if(proc == 0){
- setupPipelines(numProcs);
- resizeImages(renderFrameState.frameNumber);
- }
- for(int index = 0;index < static_cast<int>(channels.size());index++){
- Channel* channel = channels[index];
- RenderContext myContext(this, index, proc, workersAnimAndImage,
- &animFrameState,
- currentLoadBalancer, currentPixelSampler,
- currentRenderer, currentShadowAlgorithm,
- channel->camera, scene);
- currentImageTraverser->setupFrame(myContext);
- }
- barrier3.wait(numProcs);
- pipelineNeedsSetup = false;
+
+ // Negotiate the image pipeline for each channel
+ if(proc == 0){
+ setupPipelines(numProcs);
+ resizeImages(renderFrameState.frameNumber);
+ }
+
+ // Wait for processor zero to setup the image pipeline
+ barrier3.wait(numProcs);
+
+ // Allocate thread local storage for each thread.
+ thread_storage->allocateStorage( proc );
+
+ for(int index = 0;index < static_cast<int>(channels.size());index++){
+ Channel* channel = channels[index];
+ RenderContext myContext(this, index, proc, workersAnimAndImage,
+ &animFrameState,
+ currentLoadBalancer,
+ currentPixelSampler,
+ currentRenderer,
+ currentShadowAlgorithm,
+ channel->camera,
+ scene,
+ thread_storage );
+
+ currentImageTraverser->setupFrame(myContext);
+ }
+ barrier3.wait(numProcs);
+ pipelineNeedsSetup = false;
}
// Image display, if image is valid
for(ChannelListType::iterator iter = channels.begin();
- iter != channels.end(); iter++){
- Channel* channel = *iter;
- long displayFrame =
(renderFrameState.frameNumber-1)%channel->pipelineDepth;
- Image* image = channel->images[displayFrame];
- if(image && image->isValid()){
- DisplayContext myContext(proc, workersAnimAndImage);
- channel->display->displayImage(myContext, image);
- }
+ iter != channels.end(); iter++){
+ Channel* channel = *iter;
+ long displayFrame =
(renderFrameState.frameNumber-1)%channel->pipelineDepth;
+ Image* image = channel->images[displayFrame];
+ if(image && image->isValid()){
+ DisplayContext myContext(proc, workersAnimAndImage);
+ channel->display->displayImage(myContext, image);
+ }
}
-
+
// Possibly change # of workers
if(proc == 0 && workersRendering < numProcs){
- for(int i = workersRendering; i<numProcs; i++){
- // Clean up after worker. Don't attempt to join with self
- if(i != 0)
- workers[i]->join();
- }
- workers.resize(workersRendering == 0?1:workersRendering);
+ for(int i = workersRendering; i<numProcs; i++){
+ // Clean up after worker. Don't attempt to join with self
+ if(i != 0)
+ workers[i]->join();
+ }
+ workers.resize(workersRendering == 0?1:workersRendering);
+ }
+
+ if(proc >= workersRendering) {
+
+ // If proc 0 is exiting invoke the termination callbacks.
+ if (proc == 0) {
+ doTerminationCallbacks();
+ }
+
+ break;
}
- if(proc >= workersRendering)
- break;
}
skipToRendering:
// Pre-render callbacks
@@ -398,37 +445,46 @@
if(workersChanged){
barrier3.wait(workersRendering);
if(proc == 0)
- changedFlags.resize(workersRendering);
+ changedFlags.resize(workersRendering);
}
-#if NOTFINISHED
+ // #if NOTFINISHED
//if(!idle){
-#endif
+ // #endif
{
for(int index = 0;index < static_cast<int>(channels.size());index++){
- Channel* channel = channels[index];
- long renderFrame =
renderFrameState.frameNumber%channel->pipelineDepth;
- Image* image = channel->images[renderFrame];
- RenderContext myContext(this, index, proc, workersRendering,
&renderFrameState,
- currentLoadBalancer, currentPixelSampler,
- currentRenderer, currentShadowAlgorithm,
- channel->camera, scene);
- currentImageTraverser->renderImage(myContext, image);
+ Channel* channel = channels[index];
+ long renderFrame =
renderFrameState.frameNumber%channel->pipelineDepth;
+ Image* image = channel->images[renderFrame];
+ RenderContext myContext(this, index, proc, workersRendering,
&renderFrameState,
+ currentLoadBalancer, currentPixelSampler,
+ currentRenderer, currentShadowAlgorithm,
+ channel->camera, scene, thread_storage );
+ currentImageTraverser->renderImage(myContext, image);
}
}
-#if NOTFINISHED
- how to set rendering complete flag?;
- } else {
- //callbackLock.readLock();
- idle callbacks;
- //callbackLock.readUnlock();
- }
-#endif
+ // #if NOTFINISHED
+ // how to set rendering complete flag?;
+ // } else {
+ //callbackLock.readLock();
+ // idle callbacks;
+ //callbackLock.readUnlock();
+ // }
+ //#endif
}
}
-void RTRT::doParallelAnimationCallbacks(bool& changed, int proc, int
numProcs)
-{
+void RTRT::doParallelAnimationCallbacks(bool& changed, int proc, int
numProcs) {
+
+ // Parallel one shot callbacks.
+ ParallelOneShotMapType::iterator iter = parallelOneShots.begin();
+ while(iter != parallelOneShots.end() && iter->first <
animFrameState.frameNumber){
+ iter->second->call(proc, numProcs);
+ delete iter->second;
+ parallelOneShots.erase(iter);
+ iter = parallelOneShots.begin();
+ }
+
// All threads do the parallel animation callbacks
for(ACallbackMapType::iterator iter = parallelAnimationCallbacks.begin();
iter != parallelAnimationCallbacks.end(); iter++){
@@ -458,25 +514,37 @@
(*iter)->call(proc, numProcs, changed);
}
+void RTRT::doTerminationCallbacks() {
+
+ // All threads have terminated.
+ TCallbackMapType::iterator iter = terminationCallbacks.begin();
+ while (iter != terminationCallbacks.end()) {
+
+ // Invoke the callback and pass in the RTRTInterface.
+ (*iter)->call( this );
+ ++iter;
+ }
+}
+
void RTRT::postTransactions(bool& changed)
{
if(transactions.size() > 0){
transaction_lock.lock();
changed = true;
for(TransactionListType::iterator iter = transactions.begin();
- iter != transactions.end(); iter++){
+ iter != transactions.end(); iter++){
TransactionBase* transaction = *iter;
if(verbose_transactions){
- cerr << "Apply transaction: " << transaction->getName() << " : ";
- transaction->printValue(cerr);
- cerr << " : ";
- transaction->printOp(cerr);
- cerr << " : ";
+ cerr << "Apply transaction: " << transaction->getName() << " : ";
+ transaction->printValue(cerr);
+ cerr << " : ";
+ transaction->printOp(cerr);
+ cerr << " : ";
}
transaction->apply();
if(verbose_transactions){
- transaction->printValue(cerr);
- cerr << '\n';
+ transaction->printValue(cerr);
+ cerr << '\n';
}
delete transaction;
}
@@ -539,24 +607,42 @@
{
string name;
vector<string> args;
+
+ // Parse the arg string.
parseSpec(spec, name, args);
+
+ // Search for an image display with the name.
ImageDisplayMapType::iterator iter = imageDisplays.find(name);
if(iter == imageDisplays.end())
return 0;
+
+ // Create the channel with the image display.
+ return createChannel( (*iter->second)(args), camera, stereo, xres, yres );
+}
+
+int RTRT::createChannel(ImageDisplay *image_display, Camera* camera, bool
stereo, int xres, int yres)
+{
+
+ // Create the channel.
Channel* channel = new Channel;
- channel->id = ids++;
- channel->display = (*iter->second)(args);
- channel->stereo = stereo;
- channel->xres = xres;
- channel->yres = yres;
- channel->active = true;
- channel->imageCreator = 0;
+ channel->id = ids++;
+ channel->display = image_display;
+ channel->stereo = stereo;
+ channel->xres = xres;
+ channel->yres = yres;
+ channel->active = true;
+ channel->imageCreator = 0;
channel->pipelineDepth = 2;
channel->images.resize(channel->pipelineDepth);
channel->camera = camera;
+
+ // Setup images for pipeline.
for(int i=0;i<channel->pipelineDepth;i++)
channel->images[i] = 0;
+
pipelineNeedsSetup = true;
+
+ // Add the channel to the renderer.
channels.push_back(channel);
return channel->id;
}
@@ -583,6 +669,11 @@
return channels[channel]->camera;
}
+void RTRT::setCamera(int channel, Camera *camera ) {
+
+ channels[channel]->camera = camera;
+}
+
void RTRT::getResolution(int channel, bool& stereo, int& xres, int& yres)
{
stereo = channels[channel]->stereo;
@@ -601,58 +692,91 @@
void RTRT::setupPipelines(int numProcs)
{
+ // Total number of channels.
int numChannels = static_cast<int>(channels.size());
+
+ // Create a setup context.
SetupContext globalcontext(this, numChannels, 0, numProcs,
currentLoadBalancer, currentPixelSampler,
currentRenderer);
+
+ // Setup the image traverser.
currentImageTraverser->setupBegin(globalcontext, numChannels);
- for(vector<SetupCallback*>::iterator iter = setupCallbacks.begin();
- iter != setupCallbacks.end(); iter++)
+
+ // Proceess setup callbacks.
+ for(vector<SetupCallback*>::iterator iter = setupCallbacks.begin(); iter
!= setupCallbacks.end(); iter++)
(*iter)->setupBegin(globalcontext, numChannels);
+
+ // Allocate/resize per thread local storage.
+ if (thread_storage != 0)
+ delete thread_storage;
+ thread_storage = new ThreadStorageAllocator( numProcs );
+
+ // Setup each channel.
for(int index = 0;index < static_cast<int>(channels.size());index++){
Channel* channel = channels[index];
SetupContext context(this, index, numChannels, 0, numProcs,
channel->stereo, channel->xres, channel->yres,
- currentLoadBalancer, currentPixelSampler,
- currentRenderer);
+ currentLoadBalancer,
+ currentPixelSampler,
+ currentRenderer,
+ thread_storage );
+
+ // Setup the channel iteratively, until context.isChanged() is false.
int iteration = 100;
+
do {
context.setChanged(false);
context.clearMasterWindow();
- for(vector<SetupCallback*>::iterator iter = setupCallbacks.begin();
- iter != setupCallbacks.end(); iter++)
- (*iter)->setupDisplayChannel(context);
+
+ // Call setup callbacks.
+ for(vector<SetupCallback*>::iterator iter = setupCallbacks.begin();
iter != setupCallbacks.end(); iter++)
+ (*iter)->setupDisplayChannel(context);
+
+ // Setup the image display.
currentImageTraverser->setupDisplayChannel(context);
channel->display->setupDisplayChannel(context);
+
} while(context.isChanged() && --iteration > 0);
+
+ // Check to for errors.
if(!iteration)
throw InternalError("Pipeline/resolution negotiation failed",
__FILE__, __LINE__);
context.getResolution(channel->stereo, channel->xres, channel->yres);
+
if(channel->xres <= 0)
throw IllegalValue<int>("Resolution should be positive",
channel->xres);
if(channel->yres <= 0)
throw IllegalValue<int>("Resolution should be positive",
channel->yres);
-
if(context.getMinDepth() > context.getMaxDepth())
- throw InternalError("Pipeline depth negotiation failed",
- __FILE__, __LINE__);
+ throw InternalError("Pipeline depth negotiation failed", __FILE__,
__LINE__ );
+
int depth = context.getMinDepth();
if(depth == 1 && context.getMaxDepth() > 1)
depth = 2; // Prefer double-buffering
- cerr << "RTRT::setupPipelines:: depth = "<< depth << "\n";
+
+ //cerr << "RTRT::setupPipelines:: depth = "<< depth << "\n";
+
+ // Set the pipeline depth.
channel->pipelineDepth = depth;
unsigned long osize = channel->images.size();
for(unsigned long i=depth;i<osize;i++)
delete channel->images[i];
+
+ // Zero pointers to images.
for(unsigned long i=osize;i<static_cast<unsigned long>(depth);i++)
channel->images[i]=0;
+
+ // Specify the number of frames needed for the entire pipeline.
channel->images.resize(depth);
}
}
-
+
void RTRT::resizeImages(long frame)
{
+
+
for(ChannelListType::iterator iter = channels.begin();
iter != channels.end(); iter++){
Channel* channel = *iter;
@@ -665,13 +789,13 @@
if(!channel->images[which] || channel->stereo != stereo
|| channel->xres != xres || channel->yres != yres){
if(channel->images[which])
- delete channel->images[which];
+ delete channel->images[which];
ImageCreator creator = channel->imageCreator;
if(!creator)
- creator = currentImageCreator;
+ creator = currentImageCreator;
channel->images[which] = (creator)(currentImageCreatorArgs,
- channel->stereo,
- channel->xres, channel->yres);
+ channel->stereo,
+ channel->xres, channel->yres);
} else {
if (channel->pipelineDepth > 1)
channel->images[which]->setValid(false);
@@ -717,6 +841,11 @@
if(iter == imageTraversers.end())
return false;
currentImageTraverser = (*iter->second)(args);
+
+ // Setup the pipeline again so that the traverser's
+ // setup display channel will be called.
+ pipelineNeedsSetup = true;
+
return true;
}
@@ -746,6 +875,7 @@
if(iter == loadBalancers.end())
return false;
currentLoadBalancer = (*iter->second)(args);
+ pipelineNeedsSetup = true;
return true;
}
@@ -766,6 +896,10 @@
return list;
}
+void RTRT::setPixelSampler( PixelSampler *sampler_ ) {
+ currentPixelSampler = sampler_;
+}
+
bool RTRT::selectPixelSampler(const string& spec)
{
string name;
@@ -934,6 +1068,11 @@
scene = newScene;
}
+Scene *RTRT::getScene() {
+
+ return scene;
+}
+
bool RTRT::readScene(const string& spec)
{
string name;
@@ -961,28 +1100,15 @@
system_suffix = "so";
#endif
- std::cout << "Scene suffix: " << suffix << std::endl;
-
if((suffix == "mo") || (suffix == "so") || (suffix == "dylib") ||
(suffix == "dll")) {
// Do this twice - once silently and once printing errors
- std::cout << "Reading "<<suffix<<" scene\n";
-
newScene = readMOScene(name, args, false);
if(!newScene)
readMOScene(name, args, true);
} else {
// Try reading it as an MO
- std::cout << "Appending "<<system_suffix<<" to scene" << std::endl;
-
newScene = readMOScene(name+"."+system_suffix, args, false);
-
-#if 0
- // This looks redundant, going to nix it.
- if(!newScene){
- readMOScene(name+".so", args, true);
- }
-#endif
}
if(!newScene){
return false;
@@ -1027,7 +1153,7 @@
}
Scene* RTRT::readMOScene(const string& name, const vector<string>& args,
- bool printErrors)
+ bool printErrors)
{
vector<string> dirs = split_string(scenePath, ':');
for(vector<string>::iterator dir = dirs.begin(); dir != dirs.end(); dir++){
@@ -1035,22 +1161,22 @@
struct stat statbuf;
if(stat(fullname.c_str(), &statbuf) != 0){
if(printErrors){
- cerr << "Error reading " << fullname << ": " << strerror(errno) <<
'\n';
+ cerr << "Error reading " << fullname << ": " << strerror(errno) <<
'\n';
}
continue;
}
void* handle=dlopen(fullname.c_str(), RTLD_NOW);
if(!handle){
if(printErrors){
- cerr << "Error opening scene: " << fullname << '\n';
- cerr << dlerror() << '\n';
+ cerr << "Error opening scene: " << fullname << '\n';
+ cerr << dlerror() << '\n';
}
continue;
}
void* scene_fn=dlsym(handle, "make_scene");
if(!scene_fn){
if(printErrors){
- cerr << "Scene file found, but make_scene() function not found\n";
+ cerr << "Scene file found, but make_scene() function not found\n";
}
// If we get here, we fail so that we don't keep searching the path
// for another scene
@@ -1063,7 +1189,7 @@
Scene* scene=(*make_scene)(context, args);
if(!scene){
if(printErrors)
- cerr << "scene " << name << " did not produce a scene\n";
+ cerr << "scene " << name << " did not produce a scene\n";
return 0;
}
return scene;
@@ -1126,3 +1252,49 @@
transactions.push_back(transaction);
transaction_lock.unlock();
}
+
+#include <Interface/RayPacket.h>
+
+///////////////////////////////////////////////////////////////////////////////
+
+// Experimental. Shoot one ray from the calling thread. Populates the result
ray
+// packet datastructure. Useful for debugging. Very un-thread-safe.
+
+void RTRT::shootOneRay( Color &result_color, RayPacket &result_rays, Real
image_x, Real image_y, int channel_index ) {
+
+ // Only shoot one ray.
+ result_rays.resize( 1 );
+
+ // Set the image space coordinates of the pixel.
+ result_rays.setPixel(0, 0, image_x, image_y, &result_color );
+ result_rays.setFlag ( RayPacket::HaveImageCoordinates );
+
+ // Get a pointer to the channel.
+ Channel *channel = channels[ channel_index ];
+
+ // Create a render context.
+ RenderContext render_context(this, channel_index, workersRendering, 0, 0,
+ currentLoadBalancer, currentPixelSampler,
+ currentRenderer, currentShadowAlgorithm,
+ channel->camera, scene, thread_storage );
+
+ // Send this to the renderer.
+ currentRenderer->traceEyeRays( render_context, result_rays );
+
+ // Check to see if the ray hit anything.
+ if (result_rays.hitInfo(0).wasHit()) {
+
+ // Compute hit positions.
+ result_rays.computeHitPositions();
+
+ // Compute the normal.
+ result_rays.computeNormals( render_context );
+
+ // Shade.
+ result_rays.hitInfo(0).hitMaterial()->shade( render_context, result_rays
);
+ }
+}
+
+
+
+
Modified: trunk/Engine/Control/RTRT.h
==============================================================================
--- trunk/Engine/Control/RTRT.h (original)
+++ trunk/Engine/Control/RTRT.h Tue Dec 6 16:58:03 2005
@@ -10,10 +10,16 @@
#include <Core/Thread/CrowdMonitor.h>
#include <Core/Thread/Mutex.h>
#include <Core/Thread/Semaphore.h>
+#include <Core/Util/ThreadStorageAllocator.h>
#include <map>
#include <set>
#include <vector>
+// The following are used by shootOneRay (experimental)
+#include <MantaTypes.h>
+#include <Interface/RayPacket.h>
+#include <Core/Color/Color.h>
+
namespace SCIRun {
class Thread;
}
@@ -35,9 +41,12 @@
// Image Modes (opengl, file, mpeg, etc.)
virtual int createChannel(const string& modespec, Camera* camera,
bool stereo, int xres, int yres);
+ virtual int createChannel(ImageDisplay *image_display,
Camera* camera,
+
bool stereo, int xres, int yres);
virtual void registerComponent(const string& name, ImageDisplayCreator
display);
virtual listType listImageDisplays() const;
virtual Camera* getCamera(int channel) const;
+ virtual void setCamera(int channel, Camera *camera );
virtual void getResolution(int channel, bool& stereo, int& xres, int&
yres);
virtual void changeResolution(int channel, int xres, int yres,
bool changePipeline);
@@ -58,6 +67,7 @@
virtual listType listLoadBalancers() const;
// PixelSamplers
+ virtual void setPixelSampler( PixelSampler *sampler_ );
virtual bool selectPixelSampler(const string& spec);
virtual void registerComponent(const string& name, PixelSamplerCreator
creator);
virtual listType listPixelSamplers() const;
@@ -85,6 +95,7 @@
// Scenes
virtual bool haveScene();
virtual void setScene(Scene* scene);
+ virtual Scene *getScene();
virtual bool readScene(const string& sceneSpec/*, const vector<string>
&args*/);
virtual void setScenePath(const string& path);
@@ -96,9 +107,12 @@
// Callbacks
virtual void addOneShotCallback(Whence whence, long frame,
CallbackBase_2Data<int, int>* callback);
+ virtual void addParallelOneShotCallback(Whence whence, long frame,
+ CallbackBase_2Data<int, int>* callback);
virtual void registerSetupCallback(SetupCallback*);
virtual void registerSerialAnimationCallback(CallbackBase_3Data<int,
int, bool&>*);
virtual void registerParallelAnimationCallback(CallbackBase_3Data<int,
int, bool&>*);
+ virtual void registerTerminationCallback( CallbackBase_1Data<
RTRTInterface *> *);
// Control of time/animation
virtual void setTimeMode(TimeMode tm, double rate);
@@ -121,7 +135,8 @@
// Query functions
-
+ virtual int getCurrentFrame() const { return animFrameState.frameNumber;
};
+
// what specifies what you want which is then placed in result.
// If the function cannot determine what you want, false is return.
virtual bool queryState(const string& what, vector<string>& results);
@@ -130,7 +145,12 @@
// Transactions
virtual void addTransaction(TransactionBase*);
- protected:
+
+ // Debug:
+ void shootOneRay( Color &result_color, RayPacket
&result_rays, Real image_x, Real image_y, int channel_index );
+
+
+ protected:
friend class Worker;
void internalRenderLoop(int workerIndex, bool lateComerFlag);
@@ -146,7 +166,8 @@
void doIdleModeCallbacks(bool changed, bool firstFrame,
bool& pipelineNeedsSetup,
int proc, int numProcs);
-
+ void doTerminationCallbacks();
+
void resizeImages(long frameNumber);
void setupPipelines(int numProcs);
TValue<int> workersWanted;
@@ -172,6 +193,10 @@
// Callbacks
typedef multimap<long, CallbackBase_2Data<int, int>*, less<long> >
OneShotMapType;
OneShotMapType oneShots;
+
+ typedef multimap<long, CallbackBase_2Data<int, int>*, less<long> >
ParallelOneShotMapType;
+ ParallelOneShotMapType parallelOneShots;
+
typedef vector<CallbackBase_2Data<int, int>*> PRCallbackMapType;
typedef vector<CallbackBase_3Data<int, int, bool&>*> ACallbackMapType;
PRCallbackMapType parallelPreRenderCallbacks;
@@ -180,6 +205,10 @@
ACallbackMapType serialAnimationCallbacks;
vector<SetupCallback*> setupCallbacks;
+ typedef vector<CallbackBase_1Data<RTRTInterface *>*> TCallbackMapType;
+ TCallbackMapType terminationCallbacks;
+
+
// Transactions
typedef vector<TransactionBase*> TransactionListType;
TransactionListType transactions;
@@ -190,33 +219,44 @@
// Component databases and current instances
typedef map<string, ImageDisplayCreator> ImageDisplayMapType;
ImageDisplayMapType imageDisplays;
+
typedef map<string, ImageCreator> ImageCreatorMapType;
ImageCreatorMapType imageCreators;
- vector<string> currentImageCreatorArgs;
+
+ vector<string> currentImageCreatorArgs;
ImageCreator currentImageCreator;
typedef map<string, ImageTraverserCreator> ImageTraverserMapType;
- ImageTraverserMapType imageTraversers;
+
+ ImageTraverserMapType imageTraversers;
ImageTraverser* currentImageTraverser;
- typedef map<string, LoadBalancerCreator> LoadBalancerMapType;
+
+ typedef map<string, LoadBalancerCreator> LoadBalancerMapType;
LoadBalancerMapType loadBalancers;
LoadBalancer* currentLoadBalancer;
- typedef map<string, PixelSamplerCreator> PixelSamplerMapType;
+
+ typedef map<string, PixelSamplerCreator> PixelSamplerMapType;
PixelSamplerMapType pixelSamplers;
PixelSampler* currentPixelSampler;
- typedef map<string, RendererCreator> RendererMapType;
+
+ typedef map<string, RendererCreator> RendererMapType;
RendererMapType renderers;
Renderer* currentRenderer;
- typedef map<string, ShadowAlgorithmCreator> ShadowAlgorithmMapType;
+
+ typedef map<string, ShadowAlgorithmCreator>
ShadowAlgorithmMapType;
ShadowAlgorithmMapType shadowAlgorithms;
ShadowAlgorithm* currentShadowAlgorithm;
- typedef map<string, IdleModeCreator> IdleModeMapType;
+
+ typedef map<string, IdleModeCreator> IdleModeMapType;
IdleModeMapType idleModes;
vector<IdleMode*> currentIdleModes;
- typedef map<string, CameraCreator> CameraMapType;
+
+ typedef map<string, CameraCreator> CameraMapType;
CameraMapType cameras;
- typedef map<string, UserInterfaceCreator> UserInterfaceMapType;
+
+ typedef map<string, UserInterfaceCreator>
UserInterfaceMapType;
UserInterfaceMapType userInterfaces;
- typedef map<string, GroupCreator> GroupMapType;
+
+ typedef map<string, GroupCreator> GroupMapType;
GroupMapType groups;
// The pipeline
@@ -247,6 +287,9 @@
typedef vector<Channel*> ChannelListType;
ChannelListType channels;
+ // Thread local storage allocator.
+ ThreadStorageAllocator *thread_storage;
+
Scene* scene;
string scenePath;
Modified: trunk/Engine/Control/RTRT_register.cc
==============================================================================
--- trunk/Engine/Control/RTRT_register.cc (original)
+++ trunk/Engine/Control/RTRT_register.cc Tue Dec 6 16:58:03 2005
@@ -2,11 +2,12 @@
#include <Engine/Display/NullDisplay.h>
#include <Engine/Display/OpenGLDisplay.h>
#include <Engine/Display/FileDisplay.h>
+#include <Engine/Display/SHMImageDisplay.h>
#include <Engine/IdleModes/ZoomIdleMode.h>
#include <Engine/ImageTraversers/NullImageTraverser.h>
#include <Engine/ImageTraversers/TiledImageTraverser.h>
-#include <Engine/ImageTraversers/FramelessImageTraverser.h>
-#include <Engine/ImageTraversers/AFImageTraverser.h>
+#include <Engine/ImageTraversers/DissolveImageTraverser.h>
+#include <Engine/ImageTraversers/DissolveTiledImageTraverser.h>
#include <Engine/ImageTraversers/DissolveImageTraverser.h>
#include <Engine/ImageTraversers/DissolveTiledImageTraverser.h>
#include <Engine/LoadBalancers/CyclicLoadBalancer.h>
@@ -14,13 +15,7 @@
#include <Engine/LoadBalancers/WQLoadBalancer.h>
#include <Engine/PixelSamplers/NullSampler.h>
#include <Engine/PixelSamplers/SingleSampler.h>
-#include <Engine/PixelSamplers/InterLeaveSampler.h>
#include <Engine/PixelSamplers/JitterSampler.h>
-#include <Engine/PixelSamplers/Sample.h>
-#include <Engine/PixelSamplers/NRooksSampler.h>
-#include <Engine/PixelSamplers/MultiJitterSampler.h>
-#include <Engine/PixelSamplers/HammersleySampler.h>
-#include <Engine/PixelSamplers/RampSampler.h>
#include <Engine/Renderers/Moire.h>
#include <Engine/Renderers/NullRenderer.h>
#include <Engine/Renderers/Raytracer.h>
@@ -32,6 +27,7 @@
#include <Image/SimpleImage.h>
#include <Model/Cameras/EnvironmentCamera.h>
#include <Model/Cameras/PinholeCamera.h>
+#include <Model/Cameras/StereoPinholeCamera.h>
#include <Model/Cameras/OrthogonalCamera.h>
#include <Model/Cameras/FisheyeCamera.h>
#include <Model/Groups/BVH.h>
@@ -39,6 +35,8 @@
#include <Model/Groups/Group.h>
#include <UserInterface/PromptUI.h>
#include <UserInterface/XWindowUI.h>
+#include <UserInterface/NullUI.h>
+#include <UserInterface/CameraPathAutomator.h>
@@ -49,12 +47,13 @@
rtrt->registerComponent("null", &NullDisplay::create);
rtrt->registerComponent("opengl", &OpenGLDisplay::create);
rtrt->registerComponent("file", &FileDisplay::create);
+#ifdef __ia64__
+ rtrt->registerComponent("mf", &SHMImageDisplay::create);
+#endif
// Register image traversers
rtrt->registerComponent("null", &NullImageTraverser::create);
rtrt->registerComponent("tiled", &TiledImageTraverser::create);
- rtrt->registerComponent("frameless", &FramelessImageTraverser::create);
- rtrt->registerComponent("afr", &AFImageTraverser::create);
rtrt->registerComponent("dissolve", &DissolveImageTraverser::create);
rtrt->registerComponent("dissolvetiled",
&DissolveTiledImageTraverser::create);
@@ -75,12 +74,7 @@
// Register pixel samplers
rtrt->registerComponent("null", &NullSampler::create);
rtrt->registerComponent("singlesample", &SingleSampler::create);
- rtrt->registerComponent("interleavesample", &InterLeaveSampler::create);
rtrt->registerComponent("jittersample", &JitterSampler::create);
- rtrt->registerComponent("nrooksSample", &NRooksSampler::create);
- rtrt->registerComponent("multijittersample",
&MultiJitterSampler::create);
- rtrt->registerComponent("hammersleysample", &HammersleySampler::create);
- rtrt->registerComponent("ramp", &RampSampler::create);
// Register renderers
rtrt->registerComponent("null", &NullRenderer::create);
@@ -90,6 +84,7 @@
// Register cameras
rtrt->registerComponent("environment", &EnvironmentCamera::create);
rtrt->registerComponent("pinhole", &PinholeCamera::create);
+ rtrt->registerComponent("stereo", &StereoPinholeCamera::create);
rtrt->registerComponent("orthogonal", &OrthogonalCamera::create);
rtrt->registerComponent("fisheye", &FisheyeCamera::create);
@@ -102,8 +97,10 @@
rtrt->registerComponent("zoom", &ZoomIdleMode::create);
// Register user interfaces
+ rtrt->registerComponent("null", &NullUI::create);
rtrt->registerComponent("prompt", &PromptUI::create);
rtrt->registerComponent("X", &XWindowUI::create);
+ rtrt->registerComponent("camerapath", &CameraPathAutomator::create);
// Register groups
rtrt->registerObject("group", &Group::create);
Modified: trunk/Engine/Display/CMakeLists.txt
==============================================================================
--- trunk/Engine/Display/CMakeLists.txt (original)
+++ trunk/Engine/Display/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,6 +1,18 @@
SET (Manta_Display_SRCS
+ Display/FileDisplay.cc
+ Display/FileDisplay.h
+ Display/GLXImageDisplay.cc
+ Display/GLXImageDisplay.h
Display/NullDisplay.cc
+ Display/NullDisplay.h
Display/OpenGLDisplay.cc
- Display/FileDisplay.cc
- )
+ Display/OpenGLDisplay.h
+)
+
+IF(SGI_LINUX)
+ SET(Manta_Display_SRCS ${Manta_Display_SRCS}
+ Display/SHMImageDisplay.h
+ Display/SHMImageDisplay.cc
+ )
+ENDIF(SGI_LINUX)
Modified: trunk/Engine/Display/FileDisplay.cc
==============================================================================
--- trunk/Engine/Display/FileDisplay.cc (original)
+++ trunk/Engine/Display/FileDisplay.cc Tue Dec 6 16:58:03 2005
@@ -10,12 +10,14 @@
#include <Image/Pixel.h>
#include <Image/SimpleImage.h>
#include <Image/TGAFile.h>
+#include <Interface/Context.h>
+#include <SCIRun/Core/Thread/Time.h>
using namespace Manta;
using namespace std;
using SCIRun::IllegalValue;
using SCIRun::InternalError;
-
+using SCIRun::Time;
ImageDisplay *FileDisplay::create(
const vector< string > &args )
{
@@ -44,6 +46,9 @@
const DisplayContext &context,
const Image *image )
{
+ if(context.proc != 0)
+ return;
+
bool stereo;
int xres, yres;
image->getResolution( stereo, xres, yres );
@@ -59,7 +64,14 @@
stringstream ss;
ss << baseName << "_" << setfill( '0' ) << setw( 5 ) << currentFrame <<
".tga";
string name = ss.str();
+
+ double start_time = Time::currentSeconds();
+
writeTGA( image, name, 0 );
+
+ double end_time = Time::currentSeconds();
+
+ std::cout << "Frame write time: " << (end_time -
start_time)/60.0 << " minutes." << std::endl;
}
++currentFrame;
}
Copied: trunk/Engine/Display/GLXImageDisplay.cc (from r751,
branches/itanium2/Engine/Display/GLXImageDisplay.cc)
==============================================================================
--- branches/itanium2/Engine/Display/GLXImageDisplay.cc (original)
+++ trunk/Engine/Display/GLXImageDisplay.cc Tue Dec 6 16:58:03 2005
@@ -9,7 +9,7 @@
#include <Image/Pixel.h>
#include <Interface/Image.h>
#include <Interface/Context.h>
-#include <Engine/Display/XHelper.h>
+#include <Core/XUtils/XHelper.h>
#include <iostream>
#include <vector>
Modified: trunk/Engine/Display/OpenGLDisplay.cc
==============================================================================
--- trunk/Engine/Display/OpenGLDisplay.cc (original)
+++ trunk/Engine/Display/OpenGLDisplay.cc Tue Dec 6 16:58:03 2005
@@ -16,7 +16,7 @@
#include <Core/Util/NotFinished.h>
#include <X11/Xutil.h>
-#include <GL/glu.h>
+
#include <sgi_stl_warnings_off.h>
#include <typeinfo>
@@ -42,14 +42,14 @@
if(args[i] == "-parentWindow"){
long window;
if(!getLongArg(i, args, window))
- throw IllegalArgument("OpenGLDisplay -parentWindow", i, args);
+ throw new IllegalArgument("OpenGLDisplay -parentWindow", i, args);
else
parentWindow = static_cast<Window>(window);
} else if(args[i] == "-displayProc"){
if(!getIntArg(i, args, displayProc))
- throw IllegalArgument("OpenGLDisplay -displayProc", i, args);
+ throw new IllegalArgument("OpenGLDisplay -displayProc", i, args);
if(displayProc < 0)
- throw IllegalValue<int>("Display processor should be >= 0",
displayProc);
+ throw new IllegalValue<int>("Display processor should be >= 0",
displayProc);
} else {
throw IllegalArgument("OpenGLDisplay", i, args);
}
@@ -61,7 +61,6 @@
win = 0;
// If this is zero then the value hasn't been used yet.
last_frame_time = 0;
- alwaysMakeContextCurrent = false;
}
OpenGLDisplay::~OpenGLDisplay()
@@ -78,7 +77,7 @@
int xres, yres;
context.getResolution(stereo, xres, yres);
if(!windowOpen){
- createWindow(xres, yres, context.masterWindow);
+ createWindow(stereo, xres, yres, context.masterWindow);
old_xres = xres;
old_yres = yres;
} else if(old_xres != xres || old_yres != yres){
@@ -86,13 +85,9 @@
old_xres = xres;
old_yres = yres;
}
- if(context.getMultipleGLWindows())
- {
- alwaysMakeContextCurrent = true;
- }
}
-void OpenGLDisplay::createWindow(int xres, int yres, XWindow* masterWindow)
+void OpenGLDisplay::createWindow(bool stereo, int xres, int yres, XWindow*
masterWindow)
{
XHelper::Xlock.lock();
// Open the display and make sure it has opengl
@@ -110,7 +105,7 @@
}
int screen=DefaultScreen(dpy);
- // Form the criteria for the
+ // Form the criteria for the visual
vector<int> attribList;
attribList.push_back(GLX_RGBA);
attribList.push_back(GLX_RED_SIZE); attribList.push_back(1);
@@ -118,6 +113,12 @@
attribList.push_back(GLX_BLUE_SIZE); attribList.push_back(1);
attribList.push_back(GLX_ALPHA_SIZE); attribList.push_back(0);
attribList.push_back(GLX_DEPTH_SIZE); attribList.push_back(0);
+
+ // Require stereo.
+ if (stereo) {
+ attribList.push_back(GLX_STEREO);
+ }
+
attribList.push_back(GLX_DOUBLEBUFFER); // This must be the last one
attribList.push_back(None);
@@ -231,7 +232,7 @@
// Compute the framerate
double currentTime = SCIRun::Time::currentSeconds();
- if(!madeCurrent || alwaysMakeContextCurrent){
+ if(!madeCurrent){
if(!glXMakeCurrent(dpy, win, cx))
throw InternalError("glXMakeCurrent failed!\n", __FILE__, __LINE__);
madeCurrent=true;
@@ -252,9 +253,10 @@
glDrawBuffer(GL_BACK_LEFT);
glRasterPos2i(0,0);
glDrawPixels(xres, yres, GL_RGBA, GL_UNSIGNED_BYTE, si->getRaw(0));
- glDrawBuffer(GL_BACK_RIGHT);
- glRasterPos2i(0,0);
+ glDrawBuffer(GL_BACK_RIGHT);
+ glRasterPos2i(0,0); gl_print_error(__FILE__,__LINE__);
glDrawPixels(xres, yres, GL_RGBA, GL_UNSIGNED_BYTE, si->getRaw(1));
+
} else {
glDrawBuffer(GL_BACK);
glRasterPos2i(0,0);
@@ -263,16 +265,21 @@
} else if(typeid(*image) == typeid(SimpleImage<RGB8Pixel>)){
const SimpleImage<RGB8Pixel>* si = dynamic_cast<const
SimpleImage<RGB8Pixel>*>(image);
if(stereo){
+
glDrawBuffer(GL_BACK_LEFT);
glRasterPos2i(0,0);
glDrawPixels(xres, yres, GL_RGB, GL_UNSIGNED_BYTE, si->getRaw(0));
glDrawBuffer(GL_BACK_RIGHT);
glRasterPos2i(0,0);
glDrawPixels(xres, yres, GL_RGB, GL_UNSIGNED_BYTE, si->getRaw(1));
+
+ gl_print_error(__FILE__,__LINE__);
} else {
glDrawBuffer(GL_BACK);
glRasterPos2i(0,0);
glDrawPixels(xres, yres, GL_RGB, GL_UNSIGNED_BYTE, si->getRaw(0));
+
+ gl_print_error(__FILE__,__LINE__);
}
} else if(typeid(*image) == typeid(SimpleImage<RGBAfloatPixel>)){
const SimpleImage<RGBAfloatPixel>* si = dynamic_cast<const
SimpleImage<RGBAfloatPixel>*>(image);
@@ -311,9 +318,7 @@
last_frame_time = currentTime;
glXSwapBuffers(dpy, win);
- GLenum errcode = glGetError();
- if(errcode != GL_NO_ERROR)
- cerr << "OpenGLDisplay: Error code from OpenGL: " <<
gluErrorString(errcode) << '\n';
+ gl_print_error(__FILE__,__LINE__);
// Suck up X events to keep opengl happy
while (XPending(dpy)) {
Modified: trunk/Engine/Display/OpenGLDisplay.h
==============================================================================
--- trunk/Engine/Display/OpenGLDisplay.h (original)
+++ trunk/Engine/Display/OpenGLDisplay.h Tue Dec 6 16:58:03 2005
@@ -5,8 +5,10 @@
#include <Interface/ImageDisplay.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
+#include <GL/glu.h>
#include <sgi_stl_warnings_off.h>
#include <string>
+#include <iostream>
#include <vector>
#include <sgi_stl_warnings_on.h>
@@ -24,7 +26,7 @@
OpenGLDisplay(const OpenGLDisplay&);
OpenGLDisplay& operator=(const OpenGLDisplay&);
- void createWindow(int xres, int yres, XWindow* masterWindow);
+ void createWindow(bool stereo, int xres, int yres, XWindow*
masterWindow);
Window parentWindow;
Window win;
Display* dpy;
@@ -45,7 +47,16 @@
// Used to display the frame rate on the screen
void display_frame_rate(double framerate);
- bool alwaysMakeContextCurrent;
+
+ inline void gl_print_error(const char *file, int line) {
+
+ GLenum errcode = glGetError();
+ if(errcode != GL_NO_ERROR)
+ std::cerr << "OpenGLDisplay: "
+ << file << ":"
+ << line << " error: "
+ << gluErrorString(errcode) << std::endl;
+ }
};
}
Modified: trunk/Engine/IdleModes/CMakeLists.txt
==============================================================================
--- trunk/Engine/IdleModes/CMakeLists.txt (original)
+++ trunk/Engine/IdleModes/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,4 +1,5 @@
SET (Manta_IdleModes_SRCS
+ IdleModes/ZoomIdleMode.h
IdleModes/ZoomIdleMode.cc
)
Modified: trunk/Engine/IdleModes/ZoomIdleMode.cc
==============================================================================
--- trunk/Engine/IdleModes/ZoomIdleMode.cc (original)
+++ trunk/Engine/IdleModes/ZoomIdleMode.cc Tue Dec 6 16:58:03 2005
@@ -40,13 +40,13 @@
// Save old resolution and shrink the image
channeldata[channel].xres = xres;
channeldata[channel].yres = yres;
- xres = Max((int)(xres/factor+0.5), 0);
- yres = Max((int)(yres/factor+0.5), 0);
+ xres = Max((int)(xres/factor+(Real)0.5), 0);
+ yres = Max((int)(yres/factor+(Real)0.5), 0);
} else {
if(channeldata[channel].xres == -1){
// Grow it - we don't know what the old res was
- xres = Max((int)(xres*factor+0.5), 0);
- yres = Max((int)(yres*factor+0.5), 0);
+ xres = Max((int)(xres*factor+(Real)0.5), 0);
+ yres = Max((int)(yres*factor+(Real)0.5), 0);
} else {
// Restore old resolution
xres = channeldata[channel].xres;
Modified: trunk/Engine/IdleModes/ZoomIdleMode.h
==============================================================================
--- trunk/Engine/IdleModes/ZoomIdleMode.h (original)
+++ trunk/Engine/IdleModes/ZoomIdleMode.h Tue Dec 6 16:58:03 2005
@@ -2,6 +2,7 @@
#ifndef Manta_Engine_ZoomIdleMode_h
#define Manta_Engine_ZoomIdleMode_h
+#include <MantaTypes.h>
#include <Interface/IdleMode.h>
#include <sgi_stl_warnings_off.h>
#include <string>
@@ -29,7 +30,7 @@
};
vector<ChannelData> channeldata;
- double factor;
+ Real factor;
};
}
Modified: trunk/Engine/ImageTraversers/CMakeLists.txt
==============================================================================
--- trunk/Engine/ImageTraversers/CMakeLists.txt (original)
+++ trunk/Engine/ImageTraversers/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,12 +1,11 @@
SET (Manta_ImageTraversers_SRCS
- ImageTraversers/NullImageTraverser.cc
- ImageTraversers/TiledImageTraverser.cc
- ImageTraversers/FramelessImageTraverser.cc
ImageTraversers/DissolveImageTraverser.cc
+ ImageTraversers/DissolveImageTraverser.h
ImageTraversers/DissolveTiledImageTraverser.cc
- ImageTraversers/AFImageTraverser.cc
- ImageTraversers/AFR/stats.cc
- ImageTraversers/AFR/tiles.cc
- ImageTraversers/AFR/kdtree.cc
+ ImageTraversers/DissolveTiledImageTraverser.h
+ ImageTraversers/NullImageTraverser.cc
+ ImageTraversers/NullImageTraverser.h
+ ImageTraversers/TiledImageTraverser.cc
+ ImageTraversers/TiledImageTraverser.h
)
Modified: trunk/Engine/ImageTraversers/DissolveImageTraverser.cc
==============================================================================
--- trunk/Engine/ImageTraversers/DissolveImageTraverser.cc (original)
+++ trunk/Engine/ImageTraversers/DissolveImageTraverser.cc Tue Dec 6
16:58:03 2005
@@ -151,7 +151,7 @@
ChannelContext& cdata = channel_data[context.channelIndex];
Fragment frag;
- frag.setFlags(Fragment::ConstantEye);
+ frag.setAllFlags(Fragment::ConstantEye);
unsigned int pixel = 0;
// We need to render the (0,0) pixel every once in a while, so see
// if we are the last processor and if we've gone through so many
Modified: trunk/Engine/ImageTraversers/DissolveTiledImageTraverser.cc
==============================================================================
--- trunk/Engine/ImageTraversers/DissolveTiledImageTraverser.cc (original)
+++ trunk/Engine/ImageTraversers/DissolveTiledImageTraverser.cc Tue Dec 6
16:58:03 2005
@@ -158,7 +158,7 @@
unsigned int next_tile = cdata.next_tile;
Fragment frag;
- frag.setFlags(Fragment::ConstantEye);
+ frag.setAllFlags(Fragment::ConstantEye);
// Loop over all the assignments. tc stands for tile count.
for(unsigned int tc = 0; tc < cdata.tiles_per_pass; ++tc) {
@@ -193,7 +193,7 @@
image->set(frag);
// Reset the Fragment, so we can start filling it up again.
frag.resetSize();
- frag.setFlags(Fragment::ConstantEye);
+ frag.setAllFlags(Fragment::ConstantEye);
}
}
} // end looping over the tile
Modified: trunk/Engine/ImageTraversers/TiledImageTraverser.cc
==============================================================================
--- trunk/Engine/ImageTraversers/TiledImageTraverser.cc (original)
+++ trunk/Engine/ImageTraversers/TiledImageTraverser.cc Tue Dec 6 16:58:03
2005
@@ -26,7 +26,7 @@
string arg = args[i];
if(arg == "-tilesize"){
if(!getResolutionArg(i, args, xtilesize, ytilesize))
- throw IllegalArgument("TiledImageTraverser -tilesize", i, args);
+ throw IllegalArgument("TiledImageTraverser -tilesize", i, args);
} else {
throw IllegalArgument("TiledImageTraverser", i, args);
}
@@ -45,13 +45,20 @@
void TiledImageTraverser::setupDisplayChannel(SetupContext& context)
{
+ // Determine the resolution.
bool stereo;
int xres, yres;
context.getResolution(stereo, xres, yres);
- int xtiles = (xres + xtilesize-1)/xtilesize;
- int ytiles = (yres + ytilesize-1)/ytilesize;
+
+ // Determine how many tiles are needed.
+ xtiles = (xres + xtilesize-1)/xtilesize;
+ ytiles = (yres + ytilesize-1)/ytilesize;
+
+ // Tell the load balancer how much work to assign.
int numAssignments = xtiles * ytiles;
context.loadBalancer->setupDisplayChannel(context, numAssignments);
+
+ // Continue setting up the rendering stack.
context.pixelSampler->setupDisplayChannel(context);
}
@@ -63,35 +70,47 @@
void TiledImageTraverser::renderImage(const RenderContext& context, Image*
image)
{
+
+ // Determine number of tiles.
bool stereo;
int xres, yres;
image->getResolution(stereo, xres, yres);
- int ytiles = (yres + ytilesize-1)/ytilesize;
+
int s,e;
while(context.loadBalancer->getNextAssignment(context, s, e)){
+
for(int assignment = s; assignment < e; assignment++){
+
int xtile = assignment/ytiles;
int ytile = assignment%ytiles;
int xstart = xtile * xtilesize;
int xend = (xtile+1) * xtilesize;
+
if(xend > xres)
- xend = xres;
+ xend = xres;
+
int ystart = ytile * ytilesize;
int yend = (ytile+1) * ytilesize;
+
if(yend > yres)
- yend = yres;
+ yend = yres;
+
for(int y = ystart; y<yend; y++){
- for(int x = xstart; x<xend; x+= Fragment::MaxFragmentSize){
- // Create a Fragment that is consecutive in X pixels
- Fragment frag(0, x, xend, y);
- context.pixelSampler->renderFragment(context, frag);
- image->set(frag);
- if(stereo){
- Fragment frag(1, x, xend, y);
- context.pixelSampler->renderFragment(context, frag);
- image->set(frag);
- }
- }
+ for(int x = xstart; x<xend; x+= Fragment::MaxFragmentSize){
+
+ // Create a Fragment that is consecutive in X pixels
+ Fragment frag(0, x, xend, y);
+ context.pixelSampler->renderFragment(context, frag);
+ image->set(frag);
+
+ // Check to see if we need to render another copy in setero.
+ if(stereo){
+ Fragment frag(1, x, xend, y);
+ context.pixelSampler->renderFragment(context, frag);
+ image->set(frag);
+ }
+
+ }
}
}
}
Modified: trunk/Engine/ImageTraversers/TiledImageTraverser.h
==============================================================================
--- trunk/Engine/ImageTraversers/TiledImageTraverser.h (original)
+++ trunk/Engine/ImageTraversers/TiledImageTraverser.h Tue Dec 6 16:58:03
2005
@@ -26,6 +26,9 @@
int xtilesize;
int ytilesize;
+
+ int xtiles;
+ int ytiles;
};
}
Modified: trunk/Engine/LoadBalancers/CMakeLists.txt
==============================================================================
--- trunk/Engine/LoadBalancers/CMakeLists.txt (original)
+++ trunk/Engine/LoadBalancers/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,6 +1,9 @@
SET (Manta_LoadBalancers_SRCS
+ LoadBalancers/CyclicLoadBalancer.h
LoadBalancers/CyclicLoadBalancer.cc
+ LoadBalancers/SimpleLoadBalancer.h
LoadBalancers/SimpleLoadBalancer.cc
+ LoadBalancers/WQLoadBalancer.h
LoadBalancers/WQLoadBalancer.cc
)
Modified: trunk/Engine/PixelSamplers/CMakeLists.txt
==============================================================================
--- trunk/Engine/PixelSamplers/CMakeLists.txt (original)
+++ trunk/Engine/PixelSamplers/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,12 +1,9 @@
SET (Manta_PixelSamplers_SRCS
- PixelSamplers/HammersleySampler.cc
- PixelSamplers/InterLeaveSampler.cc
+ PixelSamplers/JitterSampler.h
PixelSamplers/JitterSampler.cc
- PixelSamplers/MultiJitterSampler.cc
+ PixelSamplers/NullSampler.h
PixelSamplers/NullSampler.cc
- PixelSamplers/NRooksSampler.cc
- PixelSamplers/RampSampler.cc
- PixelSamplers/Sample.cc
+ PixelSamplers/SingleSampler.h
PixelSamplers/SingleSampler.cc
)
Modified: trunk/Engine/PixelSamplers/JitterSampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/JitterSampler.cc (original)
+++ trunk/Engine/PixelSamplers/JitterSampler.cc Tue Dec 6 16:58:03 2005
@@ -8,9 +8,7 @@
#include <Interface/Renderer.h>
#include <Core/Math/CheapRNG.h>
-
-#include <Engine/PixelSamplers/Sample.h>
-#include <stdio.h>
+#include <Core/Math/MiscMath.h>
using namespace Manta;
@@ -26,7 +24,7 @@
}
JitterSampler::JitterSampler(const vector<string>& args):
- num_samples(4), use_cheaprng(true)
+ num_samples(4), use_cheaprng(true), random(0)
{
int argc = static_cast<int>(args.size());
for(int i = 0; i<argc;i++){
@@ -47,7 +45,7 @@
}
// Compute nx and ny
- Sample::nearest_square_finder(num_samples, nx, ny);
+ SCIRun::findFactorsNearRoot(num_samples, nx, ny);
}
JitterSampler::~JitterSampler()
@@ -207,7 +205,7 @@
sample_count = 0;
// Make sure we start with a fresh slate
rays.resetHit();
- rays.setFlags(flags);
+ rays.setAllFlags(flags);
}
} // end sample filling loops
} // end fragment loop
Modified: trunk/Engine/PixelSamplers/SingleSampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/SingleSampler.cc (original)
+++ trunk/Engine/PixelSamplers/SingleSampler.cc Tue Dec 6 16:58:03 2005
@@ -34,10 +34,10 @@
context.getResolution(stereo, xres, yres);
// Set up the scale from -1 to 1
- ci.xscale = 2./xres;
+ ci.xscale = (Real)2/xres;
ci.yscale = ci.xscale;
- ci.xoffset = (-xres/2.+0.5)*ci.xscale; // Offset to pixel center
- ci.yoffset = (-yres/2.+0.5)*ci.yscale;
+ ci.xoffset = (-xres/(Real)2+(Real)0.5)*ci.xscale; // Offset to pixel center
+ ci.yoffset = (-yres/(Real)2+(Real)0.5)*ci.yscale;
context.renderer->setupDisplayChannel(context);
}
@@ -47,7 +47,7 @@
}
void SingleSampler::renderFragment(const RenderContext& context,
- Fragment& fragment)
+ Fragment& fragment)
{
ChannelInfo& ci = channelInfo[context.channelIndex];
int flags = RayPacket::HaveImageCoordinates;
@@ -67,24 +67,33 @@
RayPacketData raydata;
RayPacket rays(raydata, size, depth, flags);
+ // Check to see if the fragment is consecutive in x.
if(fragment.getFlags() & Fragment::ConsecutiveX){
+
+ // If so place each pixel in the ray packet relative to the first
+ // fragment.
Fragment::Element& fe0 = fragment.get(f);
- double px = fe0.x*ci.xscale+ci.xoffset;
- double py = fe0.y*ci.yscale+ci.yoffset;
+ Real px = fe0.x*ci.xscale+ci.xoffset;
+ Real py = fe0.y*ci.yscale+ci.yoffset;
+
for(int i=0;i<size;i++){
- Fragment::Element& fe = fragment.get(f+i);
- rays.setPixel(i, 0, px, py, &fe.color);
- px += ci.xscale;
+ Fragment::Element& fe = fragment.get(f+i);
+ rays.setPixel(i, fe.which_eye, px, py, &fe.color);
+ px += ci.xscale;
}
- } else {
+
+ }
+
+ // Otherwise, set each pixel individually.
+ else {
for(int i=0;i<size;i++){
- Fragment::Element& fe = fragment.get(f+i);
- double px = fe.x*ci.xscale+ci.xoffset;
- double py = fe.y*ci.yscale+ci.yoffset;
- rays.setPixel(i, 1, px, py, &fe.color);
+ Fragment::Element& fe = fragment.get(f+i);
+ Real px = fe.x*ci.xscale+ci.xoffset;
+ Real py = fe.y*ci.yscale+ci.yoffset;
+ rays.setPixel(i, fe.which_eye, px, py, &fe.color);
}
}
-
+
// Trace the rays. The results will automatically go into the fragment
context.renderer->traceEyeRays(context, rays);
}
Modified: trunk/Engine/PixelSamplers/SingleSampler.h
==============================================================================
--- trunk/Engine/PixelSamplers/SingleSampler.h (original)
+++ trunk/Engine/PixelSamplers/SingleSampler.h Tue Dec 6 16:58:03 2005
@@ -2,6 +2,7 @@
#ifndef Manta_Engine_SingleSampler_h
#define Manta_Engine_SingleSampler_h
+#include <MantaTypes.h>
#include <Interface/PixelSampler.h>
#include <sgi_stl_warnings_off.h>
#include <string>
@@ -26,10 +27,10 @@
SingleSampler& operator=(const SingleSampler&);
struct ChannelInfo {
- double xscale;
- double xoffset;
- double yscale;
- double yoffset;
+ Real xscale;
+ Real xoffset;
+ Real yscale;
+ Real yoffset;
};
vector<ChannelInfo> channelInfo;
};
Modified: trunk/Engine/Renderers/CMakeLists.txt
==============================================================================
--- trunk/Engine/Renderers/CMakeLists.txt (original)
+++ trunk/Engine/Renderers/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,6 +1,9 @@
SET (Manta_Renderers_SRCS
+ Renderers/Moire.h
Renderers/Moire.cc
+ Renderers/NullRenderer.h
Renderers/NullRenderer.cc
+ Renderers/Raytracer.h
Renderers/Raytracer.cc
)
Modified: trunk/Engine/Renderers/Moire.cc
==============================================================================
--- trunk/Engine/Renderers/Moire.cc (original)
+++ trunk/Engine/Renderers/Moire.cc Tue Dec 6 16:58:03 2005
@@ -52,7 +52,7 @@
void Moire::traceEyeRays(const RenderContext& context, RayPacket& rays)
{
- ASSERT(rays.getFlags() & RayPacket::HaveImageCoordinates);
+ ASSERT(rays.getFlag(RayPacket::HaveImageCoordinates));
double phase = context.frameState->frameTime * M_PI;
double cycles = 100;
for(int i=0;i<rays.getSize();i++){
Modified: trunk/Engine/Renderers/NullRenderer.cc
==============================================================================
--- trunk/Engine/Renderers/NullRenderer.cc (original)
+++ trunk/Engine/Renderers/NullRenderer.cc Tue Dec 6 16:58:03 2005
@@ -37,7 +37,7 @@
void NullRenderer::traceEyeRays(const RenderContext&, RayPacket& rays)
{
- ASSERT(rays.getFlags() & RayPacket::HaveImageCoordinates);
+ ASSERT(rays.getFlag(RayPacket::HaveImageCoordinates));
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& p = rays.get(i);
*p.color = Color(RGBColor(0.9, 0.6, 0.3));
Modified: trunk/Engine/Renderers/Raytracer.cc
==============================================================================
--- trunk/Engine/Renderers/Raytracer.cc (original)
+++ trunk/Engine/Renderers/Raytracer.cc Tue Dec 6 16:58:03 2005
@@ -38,7 +38,7 @@
void Raytracer::traceEyeRays(const RenderContext& context, RayPacket& rays)
{
- ASSERT(rays.getFlags() & RayPacket::HaveImageCoordinates);
+ ASSERT(rays.getFlag(RayPacket::HaveImageCoordinates));
context.camera->makeRays(rays);
traceRays(context, rays);
}
Modified: trunk/Engine/Shadows/BeamShadows.cc
==============================================================================
--- trunk/Engine/Shadows/BeamShadows.cc (original)
+++ trunk/Engine/Shadows/BeamShadows.cc Tue Dec 6 16:58:03 2005
@@ -61,6 +61,7 @@
const LightSet* lights, RayPacket& rays,
int start, RayPacket& shadowRays)
{
+#if 0
int nlights = lights->numLights();
rays.computeHitPositions();
int sidx = 0;
@@ -218,6 +219,8 @@
shadowRays.setFlag(RayPacket::ConstantOrigin);
context.scene->getObject()->intersect(context, shadowRays);
return end;
+#endif
+ return 0;
}
string BeamShadows::getName() const {
Modified: trunk/Engine/Shadows/CMakeLists.txt
==============================================================================
--- trunk/Engine/Shadows/CMakeLists.txt (original)
+++ trunk/Engine/Shadows/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,6 +1,9 @@
SET (Manta_Shadows_SRCS
+ Shadows/NoShadows.h
Shadows/NoShadows.cc
+ Shadows/HardShadows.h
Shadows/HardShadows.cc
+ Shadows/BeamShadows.h
Shadows/BeamShadows.cc
)
Modified: trunk/Engine/Shadows/HardShadows.cc
==============================================================================
--- trunk/Engine/Shadows/HardShadows.cc (original)
+++ trunk/Engine/Shadows/HardShadows.cc Tue Dec 6 16:58:03 2005
@@ -23,35 +23,108 @@
}
int HardShadows::computeShadows(const RenderContext& context,
- const LightSet* lights, RayPacket& rays,
- int start, RayPacket& shadowRays)
+
const LightSet* lights,
+
RayPacket& rays,
// Input rays.
+
int start,
// Offset to start from in input rays?
+
RayPacket& shadow_rays)
// Output shadow rays, already intersected.
{
int nlights = lights->numLights();
- rays.computeHitPositions();
+
+ // Compute the hit positions.
+ rays.computeHitPositions();
+ rays.computeNormals( context );
+
+#if 0
+ // Construct a shadow ray packet.
+ // NOTE: this code won't send more then RayPacket::MaxSize shadow
rays.
+ // Although the old code didn't either.
+
+ Real distance [RayPacket::MaxSize];
+ Color color [RayPacket::MaxSize];
+ Vector direction[RayPacket::MaxSize];
+
+ int shadow_i = 0; // Iterator over computed shadow rays.
+ int i = start; // Iterator over initial rays used to compute
shadow rays.
+
+ // NEED TO MAKE SURE ORDER MATCHES MATERIAL SHADER!!
+ // WANT ALL RAYS TOWARDS ONE LIGHT TO BE COMMON PACKET.
+ //
+
+ // Iterate over the lights and compute directions, colors, distances.
+ for (int light=0;
+ (light<lights->numLights()) &&
+ (shadow_i<RayPacket::MaxSize);
+ ++light) {
+
+ // Compute the info for this light.
+ lights->get(light)->getLight( distance, color, direction,
rays, context );
+
+ // Compute the shadow rays and append them to the shadow
packet.
+
+ // Set the shadow ray.
+ for (int i=0; ((shadow_i+i)<RayPacket::MaxSize) &&
(i<rays.getSize();++i) {
+ shadow_rays.get(shadow_i+i).ray.set(
rays[i].hitPosition, direction[i] );
+ }
+
+ // Copy the light contribution.
+ for (int i=0; ((shadow_i+i)<RayPacket::MaxSize) &&
(i<rays.getSize();++i) {
+ shadow_rays.get(shadow_i+i).light =
lights[light].color;
+ }
+
+ // Copy the distance.
+ for (int i=0; ((shadow_i+i)<RayPacket::MaxSize) &&
(i<rays.getSize();++i) {
+ shadow_rays.get(shadow_i+i).hitInfo.reset(
distance[i] );
+ }
+
+ // Move to the next part of the shadow ray packet.
+ shadow_i += rays.getSize();
+ }
+#endif
int sidx = 0;
int end = start;
while(end < rays.getSize() && sidx+nlights <= RayPacket::MaxSize){
+
RayPacket::Element& e = rays.get(end++);
+
+ // Specify the beginning index for this ray in the shadow
packet.
e.shadowBegin = sidx;
- for(int l = 0;l<nlights;l++){
- Vector dir(lights->centers[l]-e.hitPosition);
- if(Dot(dir, e.normal) > 0){
- RayPacket::Element& s = shadowRays.get(sidx++);
- double length = dir.normalize();
- s.ray.set(e.hitPosition, dir);
- s.light = lights->colors[l];
- s.hitInfo.reset(length);
+
+ // Iterate over the lights and create shadow rays.
+ for(int l=0;l<nlights;l++){
+
+ Vector dir;
+ Color color;
+
+ // Compute the contribution for this light.
+ lights->getLight(l)->computeLight( color, dir,
context, e );
+
+ // Check to see if the light is on the front face.
+ if(Dot(dir, e.normal) > 0) {
+
+ // If so normalize and compute length.
+ Real length = dir.normalize();
+
+ // Populate the shadow ray.
+ RayPacket::Element& s =
shadow_rays.get(sidx++);
+ s.ray.set( e.hitPosition, dir );
+ s.light = color;
+ s.hitInfo.reset( length );
}
}
e.shadowEnd = sidx;
}
-
-
shadowRays.setFlag(RayPacket::NormalizedDirections|RayPacket::HaveHitRecords);
- shadowRays.resize(sidx);
+
+ // Send the shadow rays.
+ shadow_rays.setFlag(
RayPacket::NormalizedDirections|RayPacket::HaveHitRecords );
+ shadow_rays.resize ( sidx );
+
+ // Check to see if all of the shadow rays start from the same input
ray.
if(end == start+1)
- shadowRays.setFlag(RayPacket::ConstantOrigin);
- context.scene->getObject()->intersect(context, shadowRays);
+ shadow_rays.setFlag( RayPacket::ConstantOrigin );
+
+ context.scene->getObject()->intersect(context, shadow_rays);
+
return end;
}
Modified: trunk/Engine/Shadows/NoShadows.cc
==============================================================================
--- trunk/Engine/Shadows/NoShadows.cc (original)
+++ trunk/Engine/Shadows/NoShadows.cc Tue Dec 6 16:58:03 2005
@@ -19,28 +19,39 @@
{
}
-int NoShadows::computeShadows(const RenderContext&,
- const LightSet* lights, RayPacket& rays,
- int start, RayPacket& shadowRays)
+int NoShadows::computeShadows(const RenderContext& context,
+
const LightSet* lights, RayPacket&
rays,
+
int start, RayPacket& shadowRays)
{
int nlights = lights->numLights();
rays.computeHitPositions();
-
+
int sidx = 0;
while(start < rays.getSize() && sidx+nlights < RayPacket::MaxSize){
RayPacket::Element& e = rays.get(start++);
e.shadowBegin = sidx;
for(int l = 0;l<nlights;l++){
+ Color color;
+ Vector dir;
+
+ // Compute the direction & color of this light.
+
lights->getLight(l)->computeLight(color,dir,context,e);
+
+ // Construct the shadow ray.
RayPacket::Element& s = shadowRays.get(sidx);
- Vector dir(lights->centers[l]-e.hitPosition);
+
if(Dot(dir, e.normal) > 0){
- sidx++;
- s.ray.setDirection(dir);
- s.light = lights->colors[l];
+ sidx++;
+ // Be sure to normalize the normals
+ s.ray.setDirection(dir.normal());
+ s.light = color;
}
}
e.shadowEnd = sidx;
}
+ // We already normalized the rays, so indicate that so we don't do
+ // redundant work.
+ shadowRays.setFlag( RayPacket::NormalizedDirections );
shadowRays.resize(sidx);
shadowRays.resetHit();
return start;
Modified: trunk/Image/CMakeLists.txt
==============================================================================
--- trunk/Image/CMakeLists.txt (original)
+++ trunk/Image/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,3 +1,12 @@
-ADD_LIBRARY (Manta_Image NullImage.cc TGAFile.cc)
+ADD_LIBRARY (Manta_Image
+ NullImage.cc
+ NullImage.h
+ Pixel.h
+ SimpleImage.h
+ SimpleImage_templates.cc
+ TGAFile.h
+ TGAFile.cc
+ )
+
TARGET_LINK_LIBRARIES(Manta_Image Manta_Interface SCIRun_Core)
Modified: trunk/Image/NullImage.cc
==============================================================================
--- trunk/Image/NullImage.cc (original)
+++ trunk/Image/NullImage.cc Tue Dec 6 16:58:03 2005
@@ -45,3 +45,8 @@
// Do nothing
}
+void NullImage::get(Fragment&) const
+{
+ // Do nothing
+}
+
Modified: trunk/Image/NullImage.h
==============================================================================
--- trunk/Image/NullImage.h (original)
+++ trunk/Image/NullImage.h Tue Dec 6 16:58:03 2005
@@ -15,6 +15,7 @@
NullImage(bool stereo, int xres, int yres);
virtual ~NullImage();
virtual void set(const Fragment&);
+ virtual void get(Fragment&) const;
virtual bool isValid() const;
virtual void setValid(bool to);
virtual void getResolution(bool& stereo, int& xres, int& yres) const;
Modified: trunk/Image/Pixel.h
==============================================================================
--- trunk/Image/Pixel.h (original)
+++ trunk/Image/Pixel.h Tue Dec 6 16:58:03 2005
@@ -42,6 +42,13 @@
p.a = 255;
}
+ inline void convertToRGBColor(RGBColor& c, const RGBA8Pixel& p) {
+ ColorComponent norm = (ColorComponent)1/255;
+ c.setR(p.r*norm);
+ c.setG(p.g*norm);
+ c.setB(p.b*norm);
+ }
+
class RGB8Pixel {
public:
unsigned char r;
@@ -77,6 +84,13 @@
#endif
}
+ inline void convertToRGBColor(RGBColor& c, const RGB8Pixel& p) {
+ ColorComponent norm = (ColorComponent)1/255;
+ c.setR(p.r*norm);
+ c.setG(p.g*norm);
+ c.setB(p.b*norm);
+ }
+
class RGBfloatPixel {
public:
float r;
@@ -90,6 +104,12 @@
p.b = c.b();
}
+ inline void convertToRGBColor(RGBColor& c, const RGBfloatPixel& p) {
+ c.setR(p.r);
+ c.setG(p.g);
+ c.setB(p.b);
+ }
+
class RGBAfloatPixel {
public:
float r;
@@ -103,6 +123,12 @@
p.g = c.g();
p.b = c.b();
p.a = 1;
+ }
+
+ inline void convertToRGBColor(RGBColor& c, const RGBAfloatPixel& p) {
+ c.setR(p.r);
+ c.setG(p.g);
+ c.setB(p.b);
}
}
Modified: trunk/Image/SimpleImage.h
==============================================================================
--- trunk/Image/SimpleImage.h (original)
+++ trunk/Image/SimpleImage.h Tue Dec 6 16:58:03 2005
@@ -18,13 +18,14 @@
SimpleImage(bool stereo, int xres, int yres);
virtual ~SimpleImage();
virtual void set(const Fragment&);
+ virtual void get(Fragment&) const;
virtual bool isValid() const;
virtual void setValid(bool to);
virtual void getResolution(bool& stereo, int& xres, int& yres) const;
static Image* create(const std::vector<std::string>& args, bool stereo,
int xres, int yres);
- const Pixel* getRaw(int which_eye) const;
+ Pixel* getRaw(int which_eye) const;
private:
SimpleImage(const Image&);
SimpleImage& operator=(const SimpleImage&);
@@ -122,7 +123,31 @@
}
template<class Pixel>
- const Pixel* SimpleImage<Pixel>::getRaw(int which_eye) const
+ void SimpleImage<Pixel>::get(Fragment& fragment) const
+ {
+ if(fragment.getFlags() & (Fragment::ConsecutiveX|Fragment::ConstantEye)
+ == (Fragment::ConsecutiveX|Fragment::ConstantEye)){
+ int nf = fragment.getSize();
+ Pixel* pix =
eyeStart[fragment.get(0).which_eye][fragment.get(0).y]+fragment.get(0).x;
+ for(int i=0;i<nf;i++) {
+ RGBColor color;
+ convertToRGBColor(color, *pix++);
+ // Convert from RGBColor to Color
+ fragment.setColor(i, Color(color));
+ }
+ } else {
+ for(int i=0;i<fragment.getSize();i++){
+ const Fragment::Element& f = fragment.get(i);
+ RGBColor color;
+ convertToRGBColor(color, eyeStart[f.which_eye][f.y][f.x]);
+ // Convert from RGBColor to Color
+ fragment.setColor(i, Color(color));
+ }
+ }
+ }
+
+ template<class Pixel>
+ Pixel* SimpleImage<Pixel>::getRaw(int which_eye) const
{
return eyeStart[which_eye][0];
}
Modified: trunk/Image/SimpleImage_templates.cc
==============================================================================
--- trunk/Image/SimpleImage_templates.cc (original)
+++ trunk/Image/SimpleImage_templates.cc Tue Dec 6 16:58:03 2005
@@ -1,5 +1,5 @@
-#include <Packages/manta/Image/SimpleImage.h>
-#include <Packages/manta/Image/Pixel.h>
+#include <Image/SimpleImage.h>
+#include <Image/Pixel.h>
using namespace Manta;
Modified: trunk/Image/TGAFile.cc
==============================================================================
--- trunk/Image/TGAFile.cc (original)
+++ trunk/Image/TGAFile.cc Tue Dec 6 16:58:03 2005
@@ -1,11 +1,15 @@
-#include <fstream>
#include <Core/Exceptions/IllegalArgument.h>
#include <Core/Exceptions/InternalError.h>
#include <Core/Util/NotFinished.h>
#include <Image/NullImage.h>
#include <Image/Pixel.h>
#include <Image/SimpleImage.h>
+#include <Image/TGAFile.h>
+
+#include <sgi_stl_warnings_off.h>
+#include <fstream>
+#include <sgi_stl_warnings_on.h>
using namespace std;
using SCIRun::IllegalValue;
@@ -14,7 +18,7 @@
namespace Manta
{
- static inline void writeShort(
+ static inline void write16bit(
ofstream &out,
int const value )
{
@@ -22,7 +26,8 @@
out.put( ( value >> 8 ) & 0xFF );
}
- static inline void writeLong(
+ // This function should be removed, because it isn't used.
+ static inline void write32bit(
ofstream &out,
int const value )
{
@@ -39,21 +44,20 @@
{
ofstream out( filename.c_str(), ios::out | ios::binary );
if ( !out )
- throw InternalError("Couldn't open TGA file for writing: " + filename,
- __FILE__, __LINE__);
+ throw InternalError( "Couldn't open TGA file for writing: " +
filename, __FILE__, __LINE__ );
out.put( 0 ); // ID length: 0
out.put( 0 ); // Color map type: None
out.put( 2 ); // Image type: uncompressed, true-color
image
- writeShort( out, 0 ); // Color map first entry index
- writeShort( out, 0 ); // Color map length
+ write16bit( out, 0 ); // Color map first entry index
+ write16bit( out, 0 ); // Color map length
out.put( 0 ); // Color map entry size
- writeShort( out, 0 ); // X-origin of image (left)
- writeShort( out, 0 ); // Y-origin of image (bottom)
+ write16bit( out, 0 ); // X-origin of image (left)
+ write16bit( out, 0 ); // Y-origin of image (bottom)
bool stereo;
int xres, yres;
image->getResolution( stereo, xres, yres );
- writeShort( out, xres ); // Image width
- writeShort( out, yres ); // Image height
+ write16bit( out, xres ); // Image width
+ write16bit( out, yres ); // Image height
if ( typeid( *image ) == typeid( SimpleImage< RGBA8Pixel > ) ) {
out.put( 32 ); // Pixel depth: 32bpp
out.put( 8 ); // Image descriptor: 8 bits of alpha,
bottom-left origin
@@ -126,12 +130,11 @@
++buffer;
}
} else {
- throw InternalError("Unknown image type in writeTGA()",
- __FILE__, __LINE__);
+ throw InternalError( "Unknown image type in writeTGA()", __FILE__,
__LINE__ );
}
}
- static inline int readShort(
+ static inline int read16bit(
ifstream &in )
{
int byte_1 = in.get();
@@ -139,14 +142,15 @@
return byte_1 | ( byte_2 << 8 );
}
- static inline int readLong(
+ // This function should be removed, because it isn't used.
+ static inline int read32bit(
ifstream &in )
{
int byte_1 = in.get();
int byte_2 = in.get();
int byte_3 = in.get();
int byte_4 = in.get();
- return byte_1 | ( byte_2 << 8 ) | ( byte_2 << 16 ) | ( byte_2 << 24 );
+ return byte_1 | ( byte_2 << 8 ) | ( byte_3 << 16 ) | ( byte_4 << 24 );
}
Image *readTGA(
@@ -154,23 +158,21 @@
{
ifstream in( filename.c_str(), ios::in | ios::binary );
if ( !in )
- throw InternalError("Couldn't open TGA file for reading: " + filename,
- __FILE__, __LINE__);
+ throw InternalError( "Couldn't open TGA file for reading: " +
filename, __FILE__, __LINE__ );
int id_length = in.get();
int color_map_type = in.get();
if ( color_map_type != 0 )
- throw InternalError("Color map TGA files currently unsupported",
- __FILE__, __LINE__);
+ throw InternalError( "Color map TGA files currently unsupported",
__FILE__, __LINE__ );
int image_type = in.get();
if ( image_type != 2 )
- throw InternalError("Only uncompressed true-color TGA files currently
supported", __FILE__, __LINE__);
- int color_map_first_entry_index = readShort( in );
- int color_map_length = readShort( in );
+ throw InternalError( "Only uncompressed true-color TGA files currently
supported", __FILE__, __LINE__ );
+ int color_map_first_entry_index = read16bit( in );
+ int color_map_length = read16bit( in );
int color_map_entry_size = in.get();
- int x_origin = readShort( in );
- int y_origin = readShort( in );
- int width = readShort( in );
- int height = readShort( in );
+ int x_origin = read16bit( in );
+ int y_origin = read16bit( in );
+ int width = read16bit( in );
+ int height = read16bit( in );
int pixel_depth = in.get();
int image_descriptor = in.get();
in.ignore( id_length );
@@ -180,11 +182,11 @@
for ( int y = 0; y < height; ++y )
for ( int x = 0; x < width; ++x ) {
RGB8Pixel *offset = ( buffer +
- ( image_descriptor & 32 ? height - y : y ) *
width +
- ( image_descriptor & 16 ? width - x : x ) );
- offset->b = in.get();
- offset->g = in.get();
- offset->r = in.get();
+ ( image_descriptor & 32 ? height-1 - y : y )
* width +
+ ( image_descriptor & 16 ? width-1 - x : x )
);
+ offset->b = static_cast<unsigned char>(in.get());
+ offset->g = static_cast<unsigned char>(in.get());
+ offset->r = static_cast<unsigned char>(in.get());
}
return si;
} else if ( pixel_depth == 32 && ( image_descriptor & 15 ) == 8 ) {
@@ -193,17 +195,16 @@
for ( int y = 0; y < height; ++y )
for ( int x = 0; x < width; ++x ) {
RGBA8Pixel *offset = ( buffer +
- ( image_descriptor & 32 ? height - y : y )
* width +
- ( image_descriptor & 16 ? width - x : x ) );
- offset->b = in.get();
- offset->g = in.get();
- offset->r = in.get();
- offset->a = in.get();
+ ( image_descriptor & 32 ? height-1 - y : y
) * width +
+ ( image_descriptor & 16 ? width-1 - x : x )
);
+ offset->b = static_cast<unsigned char>(in.get());
+ offset->g = static_cast<unsigned char>(in.get());
+ offset->r = static_cast<unsigned char>(in.get());
+ offset->a = static_cast<unsigned char>(in.get());
}
return si;
}
- throw InternalError("Unhandled pixel depth and alpha for TGA files",
- __FILE__, __LINE__);
+ throw InternalError( "Unhandled pixel depth and alpha for TGA files",
__FILE__, __LINE__ );
}
}
Modified: trunk/Interface/CMakeLists.txt
==============================================================================
--- trunk/Interface/CMakeLists.txt (original)
+++ trunk/Interface/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,26 +1,57 @@
ADD_LIBRARY(Manta_Interface
+ AmbientLight.h
AmbientLight.cc
+ Background.h
Background.cc
+ Camera.h
Camera.cc
+ Context.h
+ Fragment.h
+ HitInfo.h
+ IdleMode.h
IdleMode.cc
+ Image.h
Image.cc
+ ImageDisplay.h
ImageDisplay.cc
+ ImageTraverser.h
ImageTraverser.cc
+ Light.h
Light.cc
+ LightSet.h
LightSet.cc
+ LoadBalancer.h
LoadBalancer.cc
+ Material.h
Material.cc
+ Object.h
Object.cc
+ PixelSampler.h
PixelSampler.cc
+ Primitive.h
Primitive.cc
+ RayPacket.h
+ Renderer.h
Renderer.cc
+ RenderParameters.h
+ RTRTInterface.h
RTRTInterface.cc
+ SetupCallback.h
SetupCallback.cc
+ Scene.h
+ ShadowAlgorithm.h
ShadowAlgorithm.cc
+ TexCoordMapper.h
TexCoordMapper.cc
+ Texture.h
+ Transaction.h
Transaction.cc
+ UserInterface.h
UserInterface.cc
+ XWindow.h
+ Callback.h
+ CallbackHelpers.h
)
TARGET_LINK_LIBRARIES(Manta_Interface SCIRun_Core)
Modified: trunk/Interface/Callback.h
==============================================================================
--- trunk/Interface/Callback.h (original)
+++ trunk/Interface/Callback.h Tue Dec 6 16:58:03 2005
@@ -13,16 +13,46 @@
return new Callback_0Data_0Arg<T>(ptr, pmf);
}
+ template<class T> static
+ CallbackBase_0Data*
+ create(T* ptr, void (T::*pmf)() const) {
+ return new Callback_0Data_0Arg_const<T>(ptr, pmf);
+ }
+
template<class T, typename Arg1> static
CallbackBase_0Data*
create(T* ptr, void (T::*pmf)(Arg1), Arg1 arg1) {
return new Callback_0Data_1Arg<T, Arg1>(ptr, pmf, arg1);
}
+
+ template<class T, typename Arg1> static
+ CallbackBase_0Data*
+ create(T* ptr, void (T::*pmf)(Arg1) const, Arg1 arg1) {
+ return new Callback_0Data_1Arg_const<T, Arg1>(ptr, pmf, arg1);
+ }
template<class T, typename Arg1, typename Arg2> static
CallbackBase_0Data*
create(T* ptr, void (T::*pmf)(Arg1, Arg2), Arg1 arg1, Arg2 arg2) {
return new Callback_0Data_2Arg<T, Arg1, Arg2>(ptr, pmf, arg1, arg2);
+ }
+
+ template<class T, typename Arg1, typename Arg2> static
+ CallbackBase_0Data*
+ create(T* ptr, void (T::*pmf)(Arg1, Arg2) const, Arg1 arg1, Arg2 arg2) {
+ return new Callback_0Data_2Arg_const<T, Arg1, Arg2>(ptr, pmf, arg1,
arg2);
+ }
+
+ template<class T, typename Arg1, typename Arg2, typename Arg3> static
+ CallbackBase_0Data*
+ create(T* ptr, void (T::*pmf)(Arg1, Arg2, Arg3), Arg1 arg1, Arg2 arg2,
Arg3 arg3) {
+ return new Callback_0Data_3Arg<T, Arg1, Arg2, Arg3>(ptr, pmf, arg1,
arg2, arg3);
+ }
+
+ template<class T, typename Arg1, typename Arg2, typename
Arg3, typename Arg4> static
+ CallbackBase_0Data*
+ create(T* ptr, void (T::*pmf)(Arg1, Arg2, Arg3, Arg4), Arg1 arg1, Arg2
arg2, Arg3 arg3, Arg4 arg4) {
+ return new Callback_0Data_4Arg<T, Arg1, Arg2, Arg3, Arg4>(ptr, pmf,
arg1, arg2, arg3, arg4);
}
template<class T, typename Data1> static
Modified: trunk/Interface/CallbackHelpers.h
==============================================================================
--- trunk/Interface/CallbackHelpers.h (original)
+++ trunk/Interface/CallbackHelpers.h Tue Dec 6 16:58:03 2005
@@ -140,6 +140,26 @@
void (T::*pmf)();
};
+ template<class T>
+ class Callback_0Data_0Arg_const : public CallbackBase_0Data {
+ public:
+ Callback_0Data_0Arg_const(T* ptr, void (T::*pmf)()
const)
+ : ptr(ptr), pmf(pmf)
+ {
+ }
+ virtual ~Callback_0Data_0Arg_const()
+ {
+ }
+ virtual void call()
+ {
+ (ptr->*pmf)();
+ }
+ private:
+ T* ptr;
+ void (T::*pmf)() const;
+ };
+
+
template<class T, typename Arg1>
class Callback_0Data_1Arg : public CallbackBase_0Data {
public:
@@ -160,6 +180,26 @@
Arg1 arg1;
};
+ template<class T, typename Arg1>
+ class Callback_0Data_1Arg_const : public CallbackBase_0Data {
+ public:
+ Callback_0Data_1Arg_const(T* ptr, void (T::*pmf)(Arg1) const,
Arg1 arg1)
+ : ptr(ptr), pmf(pmf), arg1(arg1)
+ {
+ }
+ virtual ~Callback_0Data_1Arg_const()
+ {
+ }
+ virtual void call()
+ {
+ (ptr->*pmf)(arg1);
+ }
+ private:
+ T* ptr;
+ void (T::*pmf)(Arg1) const;
+ Arg1 arg1;
+ };
+
template<class T, typename Arg1, typename Arg2>
class Callback_0Data_2Arg : public CallbackBase_0Data {
public:
@@ -180,6 +220,73 @@
Arg1 arg1;
Arg2 arg2;
};
+
+ template<class T, typename Arg1, typename Arg2>
+ class Callback_0Data_2Arg_const : public CallbackBase_0Data {
+ public:
+ Callback_0Data_2Arg_const(T* ptr, void (T::*pmf)(Arg1, Arg2)
const, Arg1 arg1, Arg2 arg2)
+ : ptr(ptr), pmf(pmf), arg1(arg1), arg2(arg2)
+ {
+ }
+ virtual ~Callback_0Data_2Arg_const()
+ {
+ }
+ virtual void call()
+ {
+ (ptr->*pmf)(arg1, arg2);
+ }
+ private:
+ T* ptr;
+ void (T::*pmf)(Arg1, Arg2) const;
+ Arg1 arg1;
+ Arg2 arg2;
+ };
+
+ template<class T, typename Arg1, typename Arg2, typename Arg3>
+ class Callback_0Data_3Arg : public CallbackBase_0Data {
+ public:
+ Callback_0Data_3Arg(T* ptr, void (T::*pmf)(Arg1, Arg2, Arg3), Arg1
arg1, Arg2 arg2, Arg3 arg3)
+ : ptr(ptr), pmf(pmf), arg1(arg1), arg2(arg2), arg3(arg3)
+ {
+ }
+ virtual ~Callback_0Data_3Arg()
+ {
+ }
+ virtual void call()
+ {
+ (ptr->*pmf)(arg1, arg2, arg3);
+ }
+ private:
+ T* ptr;
+ void (T::*pmf)(Arg1, Arg2, Arg3);
+ Arg1 arg1;
+ Arg2 arg2;
+ Arg3 arg3;
+ };
+
+
+ template<class T, typename Arg1, typename Arg2, typename Arg3,
typename Arg4 >
+ class Callback_0Data_4Arg : public CallbackBase_0Data {
+ public:
+ Callback_0Data_4Arg(T* ptr, void (T::*pmf)(Arg1,
Arg2, Arg2, Arg4), Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4)
+ : ptr(ptr), pmf(pmf), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4)
+ {
+ }
+ virtual ~Callback_0Data_4Arg()
+ {
+ }
+ virtual void call()
+ {
+ (ptr->*pmf)(arg1, arg2, arg3, arg4);
+ }
+ private:
+ T* ptr;
+ void (T::*pmf)(Arg1, Arg2, Arg3, Arg4);
+ Arg1 arg1;
+ Arg2 arg2;
+ Arg3 arg3;
+ Arg4 arg4;
+ };
// 1 Data
template<class T, typename Data1>
Modified: trunk/Interface/Camera.h
==============================================================================
--- trunk/Interface/Camera.h (original)
+++ trunk/Interface/Camera.h Tue Dec 6 16:58:03 2005
@@ -3,6 +3,11 @@
#define Manta_Interface_Camera_h
#include <MantaTypes.h>
+#include <Core/Geometry/BBox.h>
+
+#include <sgi_stl_warnings_off.h>
+#include <ostream>
+#include <sgi_stl_warnings_on.h>
namespace Manta {
class RayPacket;
@@ -14,17 +19,28 @@
virtual void makeRays(RayPacket&) const = 0;
// Camera manipulation
- virtual void scaleFOV(double) = 0;
- virtual void translate(Vector v) = 0;
- virtual void dolly(double) = 0;
+ virtual void scaleFOV(Real) = 0;
+ virtual void translate(Vector v) = 0; // Translate in image plane
coordinates.
+ virtual void dolly(Real) = 0;
+
+ // Accessors
+ virtual Point getPosition() const = 0; // This method is called to get
the eye point by HeadLight etc.
+ virtual Vector getUp() const = 0; // This method returns the
"horizontal center of rotation" about the camera.
+ virtual Point getLookAt() const = 0; // This method returns the
"center of rotation point" about the look at point.
+
+ // Reset the camera.
+ virtual void reset( const Point &eye_, const Vector &up_, const Point
&lookat_ ) = 0;
+
virtual Point project(const Point &point) const = 0; // project the 3D
point on to the camera image plane
+
enum TransformCenter {
LookAt,
Eye,
Origin
};
virtual void transform(AffineTransform t, TransformCenter) = 0;
- virtual void autoview(double fov) = 0;
+ virtual void autoview(const BBox bbox) = 0;
+ virtual void output( std::ostream &os ) = 0; // Output a text
description of the camera's state.
private:
Camera(const Camera&);
Camera& operator=(const Camera&);
Modified: trunk/Interface/Context.h
==============================================================================
--- trunk/Interface/Context.h (original)
+++ trunk/Interface/Context.h Tue Dec 6 16:58:03 2005
@@ -14,45 +14,57 @@
class Scene;
class ShadowAlgorithm;
class XWindow;
-
+ class ThreadStorageAllocator;
+
class ReadContext {
public:
ReadContext(RTRTInterface* rtrt_int)
: rtrt_int(rtrt_int)
{
}
- RTRTInterface* rtrt_int;
+ mutable RTRTInterface* rtrt_int;
private:
ReadContext(const ReadContext&);
ReadContext& operator=(const ReadContext&);
};
+
+
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Setup context is used to configure rendering stack components.
+
+
+
class SetupContext {
public:
SetupContext(RTRTInterface* rtrt_int,
int channelIndex, int numChannels, int proc, int numProcs,
- bool stereo, int xres, int yres,
- LoadBalancer* loadBalancer, PixelSampler* pixelSampler,
- Renderer* renderer)
+ bool stereo, int xres, int yres,
+ LoadBalancer* loadBalancer, PixelSampler* pixelSampler,
+ Renderer* renderer,
+ ThreadStorageAllocator *storage_allocator_ )
+
: rtrt_int(rtrt_int),
channelIndex(channelIndex), numChannels(numChannels),
proc(proc), numProcs(numProcs),
- loadBalancer(loadBalancer), pixelSampler(pixelSampler),
- renderer(renderer),
- stereo(stereo), xres(xres), yres(yres)
+ loadBalancer(loadBalancer), pixelSampler(pixelSampler),
+ renderer(renderer),
+ stereo(stereo), xres(xres), yres(yres),
+ storage_allocator( storage_allocator_ )
{
init();
}
SetupContext(RTRTInterface* rtrt_int, int numChannels,
int proc, int numProcs,
- LoadBalancer* loadBalancer, PixelSampler* pixelSampler,
- Renderer* renderer)
+ LoadBalancer* loadBalancer, PixelSampler* pixelSampler,
+ Renderer* renderer)
: rtrt_int(rtrt_int), channelIndex(-1), numChannels(numChannels),
proc(proc), numProcs(numProcs),
- loadBalancer(loadBalancer), pixelSampler(pixelSampler),
- renderer(renderer),
- stereo(false), xres(-1), yres(-1)
+ loadBalancer(loadBalancer), pixelSampler(pixelSampler),
+ renderer(renderer),
+ stereo(false), xres(-1), yres(-1)
{
init();
}
@@ -60,7 +72,6 @@
minPipelineDepth =1;
maxPipelineDepth = 1000;
masterWindow = 0;
- multipleGLWindows = false;
}
RTRTInterface* rtrt_int;
int channelIndex;
@@ -71,14 +82,16 @@
LoadBalancer* loadBalancer;
PixelSampler* pixelSampler;
Renderer* renderer;
+
+ ThreadStorageAllocator *storage_allocator;
mutable XWindow* masterWindow;
void changeResolution(bool new_stereo, int new_xres, int new_yres) {
if(new_stereo != stereo || new_xres != xres || new_yres != yres){
- stereo = new_stereo;
- xres = new_xres;
- yres = new_yres;
- changed=true;
+ stereo = new_stereo;
+ xres = new_xres;
+ yres = new_yres;
+ changed=true;
}
}
void getResolution(bool& out_stereo, int& out_xres, int& out_yres) const
{
@@ -89,9 +102,9 @@
void constrainPipelineDepth(int newmin, int newmax) {
if(newmin > minPipelineDepth)
- minPipelineDepth = newmin;
+ minPipelineDepth = newmin;
if(newmax < maxPipelineDepth)
- maxPipelineDepth = newmax;
+ maxPipelineDepth = newmax;
}
int getMinDepth() const {
return minPipelineDepth;
@@ -109,21 +122,11 @@
void clearMasterWindow() {
masterWindow = 0;
}
- void setMultipleGLWindows() {
- multipleGLWindows = true;
- }
- void unsetMultipleGLWindows() {
- multipleGLWindows = false;
- }
- bool getMultipleGLWindows() {
- return multipleGLWindows;
- }
private:
SetupContext(const SetupContext&);
SetupContext& operator=(const SetupContext&);
bool stereo;
- bool multipleGLWindows;
int xres, yres;
int minPipelineDepth, maxPipelineDepth;
bool changed;
@@ -145,16 +148,18 @@
public:
RenderContext(RTRTInterface* rtrt_int,
int channelIndex, int proc, int numProcs,
- const FrameState* frameState,
- LoadBalancer* loadBalancer, PixelSampler* pixelSampler,
- Renderer* renderer, ShadowAlgorithm* shadowAlgorithm,
- const Camera* camera, const Scene* scene)
+ const FrameState* frameState,
+ LoadBalancer* loadBalancer, PixelSampler* pixelSampler,
+ Renderer* renderer, ShadowAlgorithm* shadowAlgorithm,
+ const Camera* camera, const Scene* scene,
+ ThreadStorageAllocator *storage_allocator_ )
: rtrt_int(rtrt_int), channelIndex(channelIndex),
proc(proc), numProcs(numProcs),
frameState(frameState),
loadBalancer(loadBalancer), pixelSampler(pixelSampler),
renderer(renderer), shadowAlgorithm(shadowAlgorithm),
- camera(camera), scene(scene)
+ camera(camera), scene(scene),
+ storage_allocator( storage_allocator_ )
{
}
RTRTInterface* rtrt_int;
@@ -168,12 +173,16 @@
ShadowAlgorithm* shadowAlgorithm;
const Camera* camera;
const Scene* scene;
+
+ mutable ThreadStorageAllocator *storage_allocator;
+
private:
RenderContext(const RenderContext&);
RenderContext& operator=(const RenderContext&);
};
class PreprocessContext {
public:
+ PreprocessContext() { }; // Lights are dynamic now. This
context isn't needed.
PreprocessContext(RTRTInterface* /*rtrt_int*/, LightSet* globalLights)
: globalLights(globalLights)
{
Modified: trunk/Interface/Fragment.cc
==============================================================================
--- trunk/Interface/Fragment.cc (original)
+++ trunk/Interface/Fragment.cc Tue Dec 6 16:58:03 2005
@@ -1,5 +1,5 @@
-#include <Packages/manta/Interface/Fragment.h>
+#include <Interface/Fragment.h>
#include <Core/Util/FancyAssert.h>
using namespace Manta;
Modified: trunk/Interface/Fragment.h
==============================================================================
--- trunk/Interface/Fragment.h (original)
+++ trunk/Interface/Fragment.h Tue Dec 6 16:58:03 2005
@@ -19,7 +19,6 @@
#include <Core/Color/Color.h>
#include <Core/Util/FancyAssert.h>
#include <Core/Util/Assert.h>
-#include <Core/Math/MT_RNG.h>
// TODO:
//
@@ -36,7 +35,12 @@
static const int ConsecutiveX = 0x01; // Implies a constant Y:
static const int ConstantEye = 0x02;
- Fragment(): flags(0), size(0) {} // empty constructor
+
///////////////////////////////////////////////////////////////////////////
+ // Empty Constructor
+ Fragment()
+ : flags(0), size(0)
+ {}
+
// Creates a "Scan-line" fragment.
Fragment(int which_eye, int xstart, int xend, int y) {
ASSERTRANGE(xend-xstart, 0, MaxFragmentSize+1);
@@ -59,27 +63,20 @@
data[size].which_eye = which_eye;
size++;
}
- // input: a rectangular tile and number of sample locations to generate
- // output: creates randomly oriented sample locations in given range
- void createRandom(const int numElements,
- const int xstart, const int ystart,
- const int xend, const int yend, const int which_eye,
- MT_RNG &myRandomNumber)
- {
- size = numElements;
- flags = ConstantEye;
- for(int i=0;i<size;i++)
- {
- data[i].x = (int)(xstart+myRandomNumber.genfrand()*(xend - xstart));
- data[i].y = (int)(ystart+myRandomNumber.genfrand()*(yend - ystart));
- data[i].which_eye = which_eye;
- }
- }
+ void setElement( int i, int x, int y, int which_eye ) {
+ ASSERTRANGE(i, 0, MaxFragmentSize);
+ data[i].x = x;
+ data[i].y = y;
+ data[i].which_eye = which_eye;
+ }
+
+
///////////////////////////////////////////////////////////////////////////
+ // Accessors.
int getFlags() const {
return flags;
}
- void setFlags(const int newflags) {
+ void setAllFlags(const int newflags) {
flags = newflags;
}
@@ -89,7 +86,6 @@
void setSize(const int newSize) {
size = newSize;
}
-
void resetSize() {
size = 0;
}
@@ -129,6 +125,9 @@
data[which].color = color;
}
+
///////////////////////////////////////////////////////////////////////////
+ // Fragment Element Structure.
+
// Constant number of Elements so that we do not have to
// dynamically allocate them.
static const int MaxFragmentSize = 32;
@@ -155,6 +154,10 @@
// Number of Elements that are currently being used.
int size;
};
+
+
+ // Fragment with a dynamic size.
+
}
#endif
Modified: trunk/Interface/HitInfo.cc
==============================================================================
--- trunk/Interface/HitInfo.cc (original)
+++ trunk/Interface/HitInfo.cc Tue Dec 6 16:58:03 2005
@@ -1,4 +1,4 @@
-#include <Packages/manta/Interface/HitInfo.h>
+#include <Interface/HitInfo.h>
using namespace Manta;
Modified: trunk/Interface/HitInfo.h
==============================================================================
--- trunk/Interface/HitInfo.h (original)
+++ trunk/Interface/HitInfo.h Tue Dec 6 16:58:03 2005
@@ -2,6 +2,7 @@
#ifndef Manta_Interface_HitInfo_h
#define Manta_Interface_HitInfo_h
+#include <MantaTypes.h>
#include <Interface/Parameters.h>
#include <Core/Util/Assert.h>
#include <stdlib.h>
@@ -17,50 +18,50 @@
class Material;
class Primitive;
class TexCoordMapper;
-
+
// Convenience struct to hold a material, primitive and texcoordmapper
struct MPT {
const Material* material;
const Primitive* primitive;
const TexCoordMapper* tex;
MPT(const Material* material, const Primitive* primitive,
- const TexCoordMapper* tex)
+ const TexCoordMapper* tex)
: material(material), primitive(primitive), tex(tex)
{
}
};
-
+
// Convenience struct to hold a material, primitive and texcoordmapper
// and a scale/inverse scale
struct MPTscale {
const Material* material;
const Primitive* primitive;
const TexCoordMapper* tex;
- double scale;
- double inv_scale;
+ Real scale;
+ Real inv_scale;
MPTscale(const Material* material, const Primitive* primitive,
- const TexCoordMapper* tex, double scale, double inv_scale)
+ const TexCoordMapper* tex,
Real scale, Real inv_scale)
: material(material), primitive(primitive), tex(tex),
- scale(scale), inv_scale(inv_scale)
+ scale(scale), inv_scale(inv_scale)
{
}
};
-
+
class HitInfo {
- public:
+public:
HitInfo()
- {
- }
-
+ {
+ }
+
~HitInfo()
- {
- }
+ {
+ }
inline void reset() {
hitMatl = 0;
min_t = MAXT;
}
- inline void reset(double min) {
+ inline void reset(Real min) {
hitMatl = 0;
min_t = min;
}
@@ -76,33 +77,45 @@
const TexCoordMapper* hitTexCoordMapper() const {
return hitTex;
}
- double minT() const {
+ Real minT() const {
return min_t;
}
- void scaleT(double scale) {
+ void scaleT(Real scale) {
if(hitMatl != 0)
- min_t *= scale;
+ min_t *= scale;
}
- void overrideT(double new_mint) {
+ void overrideT(Real new_mint) {
min_t = new_mint;
}
-
- bool hit(double t, const Material* matl, const Primitive* prim,
- const TexCoordMapper* tex) {
- if(t<T_EPSILON)
- return false;
+
+ bool hit(Real t, const Material* matl, const Primitive* prim,
+ const TexCoordMapper* tex) {
+ if(t < (Real)T_EPSILON)
+ return false;
if(t < min_t){
- min_t=t;
- hitMatl = matl;
- hitPrim = prim;
- hitTex = tex;
- return true;
+ min_t = t;
+ hitMatl = matl;
+ hitPrim = prim;
+ hitTex = tex;
+ return true;
} else {
- return false;
+ return false;
}
}
+ void set_hit(Real t, const Material* matl, const Primitive* prim,
+ const TexCoordMapper* tex) {
+ min_t=t;
+ hitMatl = matl;
+ hitPrim = prim;
+ hitTex = tex;
+ }
static const size_t MaxScratchpadSize = 128;
-
+
+ void copyScratchpad( const HitInfo &info ) {
+ for (size_t i=0;i<MaxScratchpadSize;++i)
+ scratchpad_data[i] = info.scratchpad_data[i];
+ }
+
template<class T> T& scratchpad() {
// This pragma relates to the following expression being
@@ -131,14 +144,14 @@
std::swap( scratchpad_data[ i ], that.scratchpad_data[ i ] );
}
- private:
+private:
HitInfo(const HitInfo&);
HitInfo& operator=(const HitInfo&);
-
+
const Primitive* hitPrim;
const Material* hitMatl;
const TexCoordMapper* hitTex;
- double min_t;
+ Real min_t;
char scratchpad_data[MaxScratchpadSize];
};
}
Modified: trunk/Interface/Image.h
==============================================================================
--- trunk/Interface/Image.h (original)
+++ trunk/Interface/Image.h Tue Dec 6 16:58:03 2005
@@ -13,6 +13,7 @@
virtual bool isValid() const = 0;
virtual void setValid(bool to) = 0;
virtual void set(const Fragment&) = 0;
+ virtual void get(Fragment&) const = 0;
private:
Image(const Image&);
Image& operator=(const Image&);
Modified: trunk/Interface/Light.h
==============================================================================
--- trunk/Interface/Light.h (original)
+++ trunk/Interface/Light.h Tue Dec 6 16:58:03 2005
@@ -3,21 +3,45 @@
#define Manta_Interface_Light_h
#include <Core/Color/Color.h>
+#include <Core/Geometry/PointVector.h>
+#include <Interface/RayPacket.h>
namespace Manta {
class PreprocessContext;
+ class RenderContext;
+
class Light {
public:
Light();
virtual ~Light();
+
+ virtual void preprocess( const PreprocessContext& context ) = 0;
+ // virtual const Point& getCenter() const = 0;
+ // virtual const Color& getColor() const = 0;
- virtual void preprocess(const PreprocessContext& context) = 0;
- virtual const Point& getCenter() const = 0;
- virtual const Color& getColor() const = 0;
+#if 0
+ // This method is called on the light by the shadow
algorithm. The color and direction
+ // produced by the light may change for each ray in the
packet, and may change based
+ // on the render context.
+ virtual void computeLight( Real
lightDistance[RayPacket::MaxSize],
+ Color
resultColor[RayPacket::MaxSize],
+
Vector lightDirection[RayPacket::MaxSize],
+
+
RenderContext &context, RayPacket &rays ) = 0;
+#endif
+
+ // This method is called on the light by the shadow algorithm
to compute
+ // the direction and contribution for one ray packet element.
+ // The direction is not normalized and the distance to the
light from
+ // the intersection must be computed.
+ virtual void computeLight( Color &resultColor, Vector
&lightDirection,
+ const RenderContext &context,
RayPacket::Element &e ) const = 0;
+
private:
- Light(const Light&);
- Light& operator=(const Light&);
+ // Lights may not be copied.
+ Light( const Light & );
+ Light& operator = ( const Light & );
};
}
Modified: trunk/Interface/LightSet.cc
==============================================================================
--- trunk/Interface/LightSet.cc (original)
+++ trunk/Interface/LightSet.cc Tue Dec 6 16:58:03 2005
@@ -30,18 +30,12 @@
void LightSet::preprocess(const PreprocessContext& context)
{
// This won't work in many of the shadow algorithms
- ASSERT(static_cast<int>(lights.size()) <= RayPacket::MaxSize);
- if(ambientLight){
- AmbientLight* test = dynamic_cast<AmbientLight*>(ambientLight);
- if (test)
- ambientLight->preprocess(context);
- else
- cerr << "ambientLight is not an AmbientLight\n";
- }
- for(int i=0;i<static_cast<int>(lights.size());i++){
+ // Call preprocess on ambient light.
+ ambientLight->preprocess(context);
+
+ // Call preprocess on each light.
+ for(unsigned int i=0;i<lights.size();++i){
lights[i]->preprocess(context);
- centers[i] = lights[i]->getCenter();
- colors[i] = lights[i]->getColor();
}
}
@@ -53,7 +47,6 @@
out << "Num lights = "<<lights.size()<<"\n";
for(int i = 0; i < static_cast<int>(lights.size()); i++) {
out << "lights["<<i<<"] = "<<lights[i]<<"\n";
- // if (lights[i]) lights[i]->printme();
}
return out.str();
}
Modified: trunk/Interface/LightSet.h
==============================================================================
--- trunk/Interface/LightSet.h (original)
+++ trunk/Interface/LightSet.h Tue Dec 6 16:58:03 2005
@@ -17,48 +17,32 @@
class LightSet {
public:
- LightSet()
- : ambientLight(0)
- {
- }
- ~LightSet()
- {
- }
-
- const AmbientLight* getAmbientLight() const
- {
- return ambientLight;
- }
- void setAmbientLight(AmbientLight* newamb)
- {
- ambientLight = newamb;
- }
-
- int numLights() const
- {
- return static_cast<int>(lights.size());
- }
- void add(Light* light)
- {
- lights.push_back(light);
- }
-
- const Light* getLight(int which) const
- {
- return lights[which];
- }
- Light* getLight(int which)
- {
- return lights[which];
- }
+ LightSet() : ambientLight(0) { }
+ LightSet( int size_ ) : lights( size_ ), ambientLight(0) { }
+ ~LightSet() { }
+
+ // Get and set the ambient light for the scene.
+ const AmbientLight* getAmbientLight() const { return ambientLight; }
+ void setAmbientLight(AmbientLight* newamb) { ambientLight = newamb; }
+
+ // Determine the size of the light set.
+ int numLights() const { return static_cast<int>(lights.size()); }
+
+ // Append a light to the light set.
+ void add(Light* light) { lights.push_back(light); }
+
+ // Accessors.
+ const Light* getLight(int which) const { return lights[which]; }
+ Light* getLight(int which) { return lights[which]; }
+
+ // Combine two light sets.
static LightSet* merge(LightSet* l1, LightSet* l2);
+ // Calls preprocess on each light.
void preprocess(const PreprocessContext&);
string toString();
- Point centers[RayPacket::MaxSize];
- Color colors[RayPacket::MaxSize];
private:
LightSet(const LightSet&);
LightSet& operator=(const LightSet&);
Modified: trunk/Interface/Material.h
==============================================================================
--- trunk/Interface/Material.h (original)
+++ trunk/Interface/Material.h Tue Dec 6 16:58:03 2005
@@ -18,8 +18,8 @@
virtual void preprocess(const PreprocessContext&) = 0;
virtual void shade(const RenderContext& context, RayPacket& rays) const
= 0;
private:
- Material(const Material&);
- Material& operator=(const Material&);
+ // Material(const Material&);
+ // Material& operator=(const Material&);
};
}
Modified: trunk/Interface/Object.h
==============================================================================
--- trunk/Interface/Object.h (original)
+++ trunk/Interface/Object.h Tue Dec 6 16:58:03 2005
@@ -3,6 +3,7 @@
#define Manta_Interface_Object_h
namespace Manta {
+
class BBox;
class PreprocessContext;
class RayPacket;
@@ -14,12 +15,11 @@
virtual ~Object();
virtual void preprocess(const PreprocessContext& context) = 0;
- virtual void computeBounds(const PreprocessContext& context,
- BBox& bbox) const = 0;
+ virtual void computeBounds(const PreprocessContext& context, BBox& bbox)
const = 0;
virtual void intersect(const RenderContext& context, RayPacket& rays)
const = 0;
private:
- Object(const Object&);
- Object& operator=(const Object&);
+ // Object(const Object&);
+ // Object& operator=(const Object&);
};
}
Modified: trunk/Interface/Parameters.h
==============================================================================
--- trunk/Interface/Parameters.h (original)
+++ trunk/Interface/Parameters.h Tue Dec 6 16:58:03 2005
@@ -3,6 +3,6 @@
#define Manta_Interface_Parameters_h
#define MAXCACHELINESIZE 128
-#define T_EPSILON 1.e-8
+#define T_EPSILON 1.e-3
#endif
Modified: trunk/Interface/Primitive.h
==============================================================================
--- trunk/Interface/Primitive.h (original)
+++ trunk/Interface/Primitive.h Tue Dec 6 16:58:03 2005
@@ -19,8 +19,9 @@
RayPacket& rays) const = 0;
virtual void setTexCoordMapper(const TexCoordMapper* new_tex) = 0;
private:
- Primitive(const Primitive&);
- Primitive& operator=(const Primitive&);
+ // These undefined private methods make it so that primitives
cannot be copied.
+ // Primitive(const Primitive&);
+ // Primitive& operator=(const Primitive&);
};
}
Modified: trunk/Interface/RTRTInterface.h
==============================================================================
--- trunk/Interface/RTRTInterface.h (original)
+++ trunk/Interface/RTRTInterface.h Tue Dec 6 16:58:03 2005
@@ -38,9 +38,15 @@
typedef ImageDisplay* (*ImageDisplayCreator)(const vector<string>& args);
virtual int createChannel(const string& modespec, Camera* camera,
bool stereo, int xres, int yres) = 0;
+
+ // Create a channel given a pointer to the ImageDisplay for
the channel.
+ virtual int createChannel( ImageDisplay *image_display,
Camera *camera,
+ bool stereo, int xres, int
yres) = 0;
+
virtual void registerComponent(const string& name, ImageDisplayCreator
display) = 0;
virtual listType listImageDisplays() const = 0;
virtual Camera* getCamera(int channel) const = 0;
+ virtual void setCamera(int channel, Camera *camera ) = 0;
virtual void getResolution(int channel, bool& stereo, int& xres, int&
yres) = 0;
// You can change the resolution of the rendered image without
// having to change the pipeline. If you want the pipeline
@@ -68,6 +74,7 @@
virtual listType listLoadBalancers() const = 0;
// PixelSamplers
+ virtual void setPixelSampler( PixelSampler *sampler_ ) = 0;
typedef PixelSampler* (*PixelSamplerCreator)(const vector<string>& args);
virtual bool selectPixelSampler(const string& spec) = 0;
virtual void registerComponent(const string& name, PixelSamplerCreator
creator) = 0;
@@ -100,6 +107,7 @@
// Scenes
virtual bool haveScene() = 0;
virtual void setScene(Scene* scene) = 0;
+ virtual Scene *getScene() = 0;
virtual bool readScene(const string& sceneSpec) = 0;
virtual void setScenePath(const string& path) = 0;
@@ -117,6 +125,7 @@
virtual void registerSetupCallback(SetupCallback*) = 0;
virtual void registerSerialAnimationCallback(CallbackBase_3Data<int,
int, bool&>*) = 0;
virtual void registerParallelAnimationCallback(CallbackBase_3Data<int,
int, bool&>*) = 0;
+ virtual void registerTerminationCallback( CallbackBase_1Data<
RTRTInterface *> *) = 0;
// Settings
enum TimeMode {
@@ -144,9 +153,11 @@
// Query functions
virtual bool queryState(const string& what, vector<string>& results) = 0;
+ virtual int getCurrentFrame() const = 0;
// Transactions
virtual void addTransaction(TransactionBase*) = 0;
+
template<class T, class Op>
void addTransaction(const char* name, TValue<T>& value, Op op)
{
Modified: trunk/Interface/RayPacket.h
==============================================================================
--- trunk/Interface/RayPacket.h (original)
+++ trunk/Interface/RayPacket.h Tue Dec 6 16:58:03 2005
@@ -14,44 +14,58 @@
class RenderContext;
class RayPacket {
public:
- static const int MaxSize = 32;
+ enum {
+ MaxSize = 32,
+
+ // Flags.
+ ConstantOrigin = 0x0001,
+ ConstantEye = 0x0002,
+ HaveImageCoordinates = 0x0004,
+ NormalizedDirections = 0x0008,
+ HaveHitPositions = 0x0010,
+ HaveHitRecords = 0x0020,
+ HaveTexture3 = 0x0040,
+ HaveTexture2 = 0x0080,
+ // HaveFrame = 0x0100,
+ HaveNormals = 0x0200,
+ HaveUnitNormals = 0x0300,
+
+ HaveInverseDirections = 0x0400,
+ HaveSigns = 0x0800,
+ ConstantSigns = 0x1000
+ };
+
- static const int ConstantOrigin = 0x01;
- static const int ConstantEye = 0x02;
- static const int HaveImageCoordinates = 0x04;
- static const int NormalizedDirections = 0x08;
- static const int HaveHitPositions = 0x10;
- static const int HaveHitRecords = 0x20;
- static const int HaveTexture3 = 0x40;
- static const int HaveTexture2 = 0x80;
- //static const int HaveFrame = 0x100;
- static const int HaveNormals = 0x200;
- static const int HaveUnitNormals = 0x300;
- static const int HaveInverseDirections = 0x800;
- static const int HaveSigns = 0x1000;
- static const int ConstantSigns = 0x2000;
inline RayPacket(RayPacketData& data, int size, int depth, int flags);
// Create a subset of another raypacket
RayPacket(RayPacket& parent, int start, int end)
: data(parent.data+start), size(end-start), depth(parent.depth),
flags(parent.flags)
- {
- }
+ {
+ }
~RayPacket()
{
}
- int getFlags() const {
+ int getAllFlags() const
+ {
return flags;
}
- void setFlag(int flag) {
- flags |= flag;
+
+ bool getFlag( int flag ) const
+ {
+ return (flags & flag) == flag;
}
- void setFlags(int new_flags) {
+
+ void setAllFlags(int new_flags)
+ {
flags = new_flags;
}
+ void setFlag(int flag) {
+ flags |= flag;
+ }
void resetFlag(int flag) {
flags &= ~flag;
}
@@ -71,21 +85,22 @@
#ifndef SWIG // SWIG doesn't support nested structs/classes.
struct Element {
- Color localColor;
- Color* color;
- double imageX;
- double imageY;
- int whichEye;
- Ray ray;
+ Color localColor;
+ Color* color;
+ Real imageX;
+ Real imageY;
+ Ray ray;
HitInfo hitInfo;
- Vector normal;
- Point hitPosition;
- Point texCoords;
- Vector inverseDirection;
- int sign[3];
- Color ambientLight;
+ Vector normal;
+ Point hitPosition;
+ Point texCoords;
+ Vector inverseDirection;
+ int sign[3]; // Mask describing ray direction, 1==negative
0==positive,zero
+ Color ambientLight;
+ Color light;
+
int shadowBegin, shadowEnd;
- Color light;
+ int whichEye;
};
const Element& get(int which) const {
@@ -95,8 +110,7 @@
return data[which];
}
#endif // SWIG
-
- void setPixel(int which, int whichEye, double imageX, double imageY,
+ void setPixel(int which, int whichEye, Real imageX, Real imageY,
Color* color) {
data[which].color = color;
data[which].imageX = imageX;
@@ -120,9 +134,10 @@
{
if(flags & NormalizedDirections)
return;
+
if(flags & HaveHitRecords){
for(int i=0;i<size;i++){
- double length = data[i].ray.normalizeDirection();
+ Real length = data[i].ray.normalizeDirection();
data[i].hitInfo.scaleT(length);
}
} else {
@@ -136,8 +151,10 @@
{
if(flags & HaveHitPositions)
return;
- for(int i=0;i<size;i++)
- data[i].hitPosition = data[i].ray.origin() + data[i].ray.direction()
* data[i].hitInfo.minT();
+ for(int i=0;i<size;i++) {
+ data[i].hitPosition = data[i].ray.origin() +
+ data[i].ray.direction() * data[i].hitInfo.minT();
+ }
flags |= HaveHitPositions;
}
void computeInverseDirections()
@@ -150,6 +167,7 @@
1./data[i].ray.direction().z());
flags |= HaveInverseDirections;
}
+
void computeSigns()
{
if(flags & HaveSigns)
@@ -169,6 +187,7 @@
return;
flags |= ConstantSigns;
}
+
void computeTextureCoordinates2(const RenderContext& context)
{
if(flags & (HaveTexture2|HaveTexture3))
@@ -203,6 +222,7 @@
{
if(flags & HaveNormals)
return;
+
// Compute normals
for(int i=0;i<size;){
RayPacket::Element& e = data[i];
@@ -214,6 +234,7 @@
prim->computeNormal(context, subPacket);
i=end;
}
+
flags |= HaveNormals;
}
@@ -245,11 +266,13 @@
friend class RayPacket;
};
- inline RayPacket::RayPacket(RayPacketData& data, int size,
- int depth, int flags)
+ // This is dependent on the RayPacketData struct, so it cannot be defined
in the
+ // RayPacket class
+ inline RayPacket::RayPacket(RayPacketData& data, int size, int depth, int
flags)
: data(&data.data[0]), size(size), depth(depth), flags(flags)
- {
- }
-}
+ {
+ }
+} // end namespace Manta
+
#endif
Modified: trunk/Interface/RenderParameters.h
==============================================================================
--- trunk/Interface/RenderParameters.h (original)
+++ trunk/Interface/RenderParameters.h Tue Dec 6 16:58:03 2005
@@ -6,7 +6,7 @@
class RenderParameters {
public:
RenderParameters() {
- maxDepth = 5;
+ maxDepth = 15;
}
int maxDepth;
private:
Modified: trunk/MantaTypes.h
==============================================================================
--- trunk/MantaTypes.h (original)
+++ trunk/MantaTypes.h Tue Dec 6 16:58:03 2005
@@ -5,8 +5,14 @@
namespace Manta {
// Scalars
typedef double Real;
+ // typedef float Real;
// Colors - forward declarations only
+
+ // Note about this component type. It should be a floating point
+ // type and not an integral type. If you wish to make it an
+ // integral type, you should go through the code and make sure
+ // function like ColorSpace::Mean do the right thing.
typedef float ColorComponent;
class RGBTraits;
template<typename T> class ColorSpace;
Modified: trunk/Model/AmbientLights/ArcAmbient.cc
==============================================================================
--- trunk/Model/AmbientLights/ArcAmbient.cc (original)
+++ trunk/Model/AmbientLights/ArcAmbient.cc Tue Dec 6 16:58:03 2005
@@ -6,8 +6,11 @@
#include <sstream>
#include <sgi_stl_warnings_on.h>
+#include <Core/Math/Trig.h>
+
using namespace Manta;
using namespace std;
+using namespace SCIRun;
ArcAmbient::ArcAmbient(const Color& cup, const Color& cdown,
const Vector& up)
@@ -29,15 +32,19 @@
rays.computeNormals(context);
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
- double cosine = Dot(e.normal, up);
- double sine = sqrt(1-cosine*cosine);
- double w0, w1;
+ Real cosine = Dot(e.normal, up);
+ Real sine = SCIRun::Sqrt(1-cosine*cosine);
+ // So we want to do the computation for w0 and w1 as type Real,
+ // because that is what all the other computation will be done,
+ // but we would like to cast that to type ColorComponent, because
+ // we will do operations on the color with this value.
+ ColorComponent w0, w1;
if(cosine > 0){
- w0= sine/2.;
- w1= (1. - w0);
+ w0= sine/2;
+ w1= (1 - w0);
} else {
- w1= sine/2.;
- w0= (1. - w1);
+ w1= sine/2;
+ w0= (1 - w1);
}
rays.get(i).ambientLight = cup*w1 + cdown*w0;
}
Modified: trunk/Model/Backgrounds/CMakeLists.txt
==============================================================================
--- trunk/Model/Backgrounds/CMakeLists.txt (original)
+++ trunk/Model/Backgrounds/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -2,5 +2,5 @@
SET (Manta_Backgrounds_SRCS
Backgrounds/ConstantBackground.cc
Backgrounds/LinearBackground.cc
-
+ Backgrounds/TextureBackground.cc
)
Modified: trunk/Model/Backgrounds/LinearBackground.cc
==============================================================================
--- trunk/Model/Backgrounds/LinearBackground.cc (original)
+++ trunk/Model/Backgrounds/LinearBackground.cc Tue Dec 6 16:58:03 2005
@@ -1,6 +1,7 @@
#include <Model/Backgrounds/LinearBackground.h>
#include <Interface/RayPacket.h>
+#include <MantaTypes.h>
using namespace Manta;
@@ -24,7 +25,11 @@
rays.normalizeDirections();
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
- double t = 0.5 * (1 + Dot(e.ray.direction(), up));
+ // So we want to do the computation for t as type Real, because
+ // that is what all the other computation will be done, but we
+ // would like to cast that to type ColorComponent, because we will
+ // do operations on the color with this value.
+ ColorComponent t = (Real)0.5 * (1 + Dot(e.ray.direction(), up));
rays.setResult(i, cup*t+cdown*(1-t));
}
}
Modified: trunk/Model/CMakeLists.txt
==============================================================================
--- trunk/Model/CMakeLists.txt (original)
+++ trunk/Model/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -10,6 +10,8 @@
INCLUDE (Instances/CMakeLists.txt)
INCLUDE (MiscObjects/CMakeLists.txt)
INCLUDE (Readers/CMakeLists.txt)
+INCLUDE (Intersections/CMakeLists.txt)
+INCLUDE (Textures/CMakeLists.txt)
SET(BUILD_SCALAR_VOLUME CACHE BOOL false)
IF(BUILD_SCALAR_VOLUME)
@@ -29,6 +31,8 @@
${Manta_Instances_SRCS}
${Manta_MiscObjects_SRCS}
${Manta_Readers_SRCS}
+ ${Manta_Intersections_SRCS}
+ ${Manta_Textures_SRCS}
)
TARGET_LINK_LIBRARIES(Manta_Model Manta_Interface Manta_Core)
Modified: trunk/Model/Cameras/CMakeLists.txt
==============================================================================
--- trunk/Model/Cameras/CMakeLists.txt (original)
+++ trunk/Model/Cameras/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,6 +1,13 @@
SET (Manta_Cameras_SRCS
+ Cameras/EnvironmentCamera.h
Cameras/EnvironmentCamera.cc
+ Cameras/PinholeCamera.h
Cameras/PinholeCamera.cc
+ Cameras/OrthogonalCamera.h
Cameras/OrthogonalCamera.cc
- Cameras/FisheyeCamera.cc)
+ Cameras/FisheyeCamera.h
+ Cameras/FisheyeCamera.cc
+ Cameras/StereoPinholeCamera.h
+ Cameras/StereoPinholeCamera.cc
+ )
Modified: trunk/Model/Cameras/EnvironmentCamera.cc
==============================================================================
--- trunk/Model/Cameras/EnvironmentCamera.cc (original)
+++ trunk/Model/Cameras/EnvironmentCamera.cc Tue Dec 6 16:58:03 2005
@@ -27,15 +27,15 @@
string arg=args[i];
if (arg=="-eye") {
if (!getPointArg(i, args, eye))
- throw IllegalArgument("EnvironmentCamera -eye", i, args);
+ throw IllegalArgument("EnvironmentCamera -eye", i, args);
gotEye=true;
} else if (arg=="-lookat") {
if (!getPointArg(i, args, lookat))
- throw IllegalArgument("EnvironmentCamera -lookat", i, args);
+ throw IllegalArgument("EnvironmentCamera -lookat", i, args);
gotLookat=true;
} else if (arg=="-up") {
if (!getVectorArg(i, args, up))
- throw IllegalArgument("EnvironmentCamera -up", i, args);
+ throw IllegalArgument("EnvironmentCamera -up", i, args);
gotUp=true;
} else if (arg=="-normalizeRays") {
normalizeRays=true;
@@ -57,6 +57,15 @@
return new EnvironmentCamera(args);
}
+void EnvironmentCamera::reset( const Point &eye_, const Vector &up_,
+ const Point &lookat_ )
+{
+ eye = eye_;
+ up = up_;
+ lookat = lookat_;
+ setup();
+}
+
void EnvironmentCamera::setup()
{
direction=lookat - eye;
@@ -77,15 +86,15 @@
void EnvironmentCamera::makeRays(RayPacket& rays) const
{
- ASSERT(rays.getFlags() & RayPacket::HaveImageCoordinates);
+ ASSERT(rays.getAllFlags() & RayPacket::HaveImageCoordinates);
rays.setFlag(RayPacket::ConstantOrigin);
if (normalizeRays) {
for (int i=0; i<rays.getSize(); i++) {
RayPacket::Element& e=rays.get(i);
- double theta=0.5*(M_PI - M_PI*e.imageY);
- double phi=M_PI*e.imageX + M_PI;
- Vector xyz(sin(theta)*cos(phi), sin(theta)*sin(phi),
- cos(theta));
+ Real theta = (Real)0.5 * ((Real)M_PI - (Real)M_PI * e.imageY);
+ Real phi = (Real)M_PI * e.imageX + (Real)M_PI;
+ Vector xyz(Sin(theta)*Cos(phi), Sin(theta)*Sin(phi),
+ Cos(theta));
Vector raydir(Dot(xyz, v),
Dot(xyz, n),
Dot(xyz, u));
@@ -96,10 +105,10 @@
} else {
for (int i=0; i<rays.getSize(); i++) {
RayPacket::Element& e=rays.get(i);
- double theta=0.5*(M_PI - M_PI*e.imageY);
- double phi=M_PI*e.imageX + M_PI;
- Vector xyz(sin(theta)*cos(phi), sin(theta)*sin(phi),
- cos(theta));
+ Real theta = (Real)0.5 * ((Real)M_PI - (Real)M_PI * e.imageY);
+ Real phi = (Real)M_PI * e.imageX + (Real)M_PI;
+ Vector xyz(Sin(theta)*Cos(phi), Sin(theta)*Sin(phi),
+ Cos(theta));
Vector raydir(Dot(xyz, v),
Dot(xyz, n),
Dot(xyz, u));
@@ -108,7 +117,7 @@
}
}
-void EnvironmentCamera::scaleFOV(double scale)
+void EnvironmentCamera::scaleFOV(Real /*scale*/)
{
// This functionality doesn't make much sense with the environment camera
}
@@ -122,7 +131,7 @@
setup();
}
-void EnvironmentCamera::dolly(double scale)
+void EnvironmentCamera::dolly(Real scale)
{
Vector dir=lookat - eye;
eye += dir*scale;
@@ -145,7 +154,6 @@
}
Vector lookdir(eye - lookat);
- double length=lookdir.length();
AffineTransform frame;
frame.initWithBasis(v.normal(), u.normal(), lookdir.normal(), cen);
@@ -160,13 +168,23 @@
setup();
}
-void EnvironmentCamera::autoview(double new_fov)
+void EnvironmentCamera::autoview(const BBox /*bbox*/)
{
// This functionality doesn't make much sense with the environment camera
}
-Point EnvironmentCamera::project(const Point &point) const
+Point EnvironmentCamera::project(const Point& /*point*/) const
{
// NOT FINISHED
- return Point(0., 0., 0.);
+ return Point(0, 0, 0);
}
+
+void EnvironmentCamera::output( std::ostream &os ) {
+
+ os << "environment( -eye " << eye
+ << " -lookat " << lookat
+ << " -up " << up
+ << " )"
+ << std::endl;
+}
+
Modified: trunk/Model/Cameras/EnvironmentCamera.h
==============================================================================
--- trunk/Model/Cameras/EnvironmentCamera.h (original)
+++ trunk/Model/Cameras/EnvironmentCamera.h Tue Dec 6 16:58:03 2005
@@ -15,17 +15,30 @@
class EnvironmentCamera : public Camera {
public:
EnvironmentCamera(const vector<string>& args);
+ EnvironmentCamera(const Point &eye_, const Point &lookat_,
+ const Vector &up_ ) :
+ eye( eye_ ), lookat( lookat_ ), up( up_ ) { setup(); }
virtual ~EnvironmentCamera();
virtual void makeRays(RayPacket&) const;
// Camera manipulation
- virtual void scaleFOV(double);
+ virtual void scaleFOV(Real);
virtual void translate(Vector);
- virtual void dolly(double);
+ virtual void dolly(Real);
virtual void transform(AffineTransform t, TransformCenter);
- virtual void autoview(double fov);
+ virtual void autoview(const BBox bbox);
virtual Point project(const Point &point) const; // project a 3D point
to the camera image plane
+
static Camera* create(const vector<string>& args);
+
+ virtual Point getPosition() const { return eye; }
+ virtual Point getLookAt() const { return lookat; };
+ virtual Vector getUp() const { return up; };
+
+ virtual void reset( const Point &eye_, const Vector &up_,
+ const Point &lookat_ );
+
+ virtual void output( std::ostream &os );
private:
void setup();
Point eye;
Modified: trunk/Model/Cameras/FisheyeCamera.cc
==============================================================================
--- trunk/Model/Cameras/FisheyeCamera.cc (original)
+++ trunk/Model/Cameras/FisheyeCamera.cc Tue Dec 6 16:58:03 2005
@@ -15,8 +15,6 @@
using namespace std;
using SCIRun::Clamp;
-static const double sqrt_two = 1.4142135623730951;
-
FisheyeCamera::FisheyeCamera(const vector<string>& args)
{
bool gotEye = false;
@@ -28,19 +26,19 @@
string arg = args[i];
if(arg == "-eye"){
if(!getPointArg(i, args, eye))
- throw IllegalArgument("FisheyeCamera -eye", i, args);
+ throw IllegalArgument("FisheyeCamera -eye", i, args);
gotEye = true;
} else if(arg == "-lookat"){
if(!getPointArg(i, args, lookat))
- throw IllegalArgument("FisheyeCamera -lookat", i, args);
+ throw IllegalArgument("FisheyeCamera -lookat", i, args);
gotLookat = true;
} else if(arg == "-up"){
if(!getVectorArg(i, args, up))
- throw IllegalArgument("FisheyeCamera -up", i, args);
+ throw IllegalArgument("FisheyeCamera -up", i, args);
gotUp = true;
} else if(arg == "-fov"){
- if(!getDoubleArg(i, args, hfov))
- throw IllegalArgument("FisheyeCamera -fov", i, args);
+ if(!getArg<Real>(i, args, hfov))
+ throw IllegalArgument("FisheyeCamera -fov", i, args);
gotFov = true;
} else {
throw IllegalArgument("FisheyeCamera", i, args);
@@ -49,7 +47,7 @@
if(!gotEye || !gotLookat || !gotUp || !gotFov)
throw IllegalArgument("FisheyeCamera needs -eye -lookat -up and -fov",
0, args);
setup();
- hfov = hfov / 90.0;
+ hfov /= 90;
}
FisheyeCamera::~FisheyeCamera()
@@ -71,45 +69,36 @@
n = direction;
n.normalize();
- for(i=0; i<3; i++)
- uvn[2][i] = n[i];
-
v=Cross(direction, up);
if(v.length2() == 0.0){
std::cerr << __FILE__ << " line: " << __LINE__ << " Ambiguous up
direciton...\n";
}
v.normalize();
- for(i=0; i<3; i++)
- uvn[1][i] = v[i];
-
u=Cross(v, direction);
u.normalize();
-
- for(i=0; i<3; i++)
- uvn[0][i] = u[i];
}
void FisheyeCamera::makeRays(RayPacket& rays) const
{
- ASSERT(rays.getFlags() & RayPacket::HaveImageCoordinates);
+ ASSERT(rays.getFlag(RayPacket::HaveImageCoordinates) );
rays.setFlag(RayPacket::ConstantOrigin|RayPacket::NormalizedDirections);
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
- double z = sqrt( 2.0 - e.imageX * e.imageX - e.imageY * e.imageY );
- double theta = atan2( e.imageY, e.imageX );
- double phi = acos( z / sqrt_two ) * hfov;
- double x = cos( theta ) * sin( phi );
- double y = sin( theta ) * sin( phi );
- z = cos( phi );
+ Real z = Sqrt( 2 - e.imageX * e.imageX - e.imageY * e.imageY );
+ Real theta = Atan2( e.imageY, e.imageX );
+ Real phi = Acos( z * (Real)M_SQRT1_2 ) * hfov;
+ Real x = Cos( theta ) * Sin( phi );
+ Real y = Sin( theta ) * Sin( phi );
+ z = Cos( phi );
e.ray.set(eye, v*x+u*y+n*z);
}
}
-void FisheyeCamera::scaleFOV(double scale)
+void FisheyeCamera::scaleFOV(Real scale)
{
- double fov_min = 0;
- double fov_max = 4.0;
+ Real fov_min = 0;
+ Real fov_max = 4;
hfov = scale*hfov;
hfov = Clamp(hfov, fov_min, fov_max);
vfov = scale*vfov;
@@ -125,7 +114,7 @@
setup();
}
-void FisheyeCamera::dolly(double scale)
+void FisheyeCamera::dolly(Real scale)
{
Vector dir = lookat - eye;
eye += dir*scale;
@@ -148,7 +137,6 @@
}
Vector lookdir(eye-lookat);
- double length = lookdir.length();
AffineTransform frame;
frame.initWithBasis(v.normal(), u.normal(), lookdir.normal(), cen);
@@ -163,25 +151,31 @@
setup();
}
-void FisheyeCamera::autoview(double new_fov)
+void FisheyeCamera::autoview(const BBox bbox)
{
- BBox bbox(Point(-1,-1,0.2), Point(1,1,2.2));
- // double ratio = tan(DtoR(vfov/2))/tan(DtoR(hfov/2));
- hfov = new_fov;
- vfov = new_fov;
+ output(cerr);
Vector diag(bbox.diagonal());
- double w=diag.length();
+ Real w=diag.length();
Vector lookdir(eye-lookat);
lookdir.normalize();
- double scale = 1.0/(2*tan(DtoR(hfov/2.0)));
- double length = w*scale;
+ Real scale = 1/(2*tan(DtoR(hfov*45)));
+ Real length = w*scale;
lookat = bbox.center();
eye = lookat+lookdir*length;
setup();
}
-Point FisheyeCamera::project(const Point &point) const
+void FisheyeCamera::output( std::ostream &os ) {
+ os << "fisheye( -eye " << eye
+ << " -lookat " << lookat
+ << " -up " << up
+ << " -fov " << hfov*90 << " )"
+ << std::endl;
+}
+
+Point FisheyeCamera::project(const Point& /*point*/) const
{
// NOT FINISHED
return Point(0,0,0); // just a placeholder
}
+
Modified: trunk/Model/Cameras/FisheyeCamera.h
==============================================================================
--- trunk/Model/Cameras/FisheyeCamera.h (original)
+++ trunk/Model/Cameras/FisheyeCamera.h Tue Dec 6 16:58:03 2005
@@ -13,33 +13,49 @@
using namespace std;
class FisheyeCamera : public Camera {
+ private:
+ void setup();
public:
FisheyeCamera(const vector<string>& args);
+ FisheyeCamera( const Point &eye_, const Point &lookat_, const Vector
&up_,
+ Real hfov_ = 60 ) :
+ eye( eye_ ), up( up_ ), lookat( lookat_ ), hfov( hfov_ )
+ {
+ setup();
+ hfov = hfov / 90;
+ };
+
virtual ~FisheyeCamera();
virtual void makeRays(RayPacket&) const;
// Camera manipulation
- virtual void scaleFOV(double);
+ virtual void scaleFOV(Real);
virtual void translate(Vector);
- virtual void dolly(double);
+ virtual void dolly(Real);
virtual void transform(AffineTransform t, TransformCenter);
- virtual void autoview(double fov);
+ virtual void autoview(const BBox bbox);
+ virtual void output( std::ostream &os );
virtual Point project(const Point &point) const; // project a 3D point
to the camera image plane
static Camera* create(const vector<string>& args);
+
+ virtual Point getPosition() const { return eye; }
+ virtual Point getLookAt() const { return lookat; };
+ virtual Vector getUp() const { return up; };
+
+ virtual void reset( const Point &eye_, const Vector &up_, const Point
&lookat_ ) {
+ eye = eye_; up = up_; lookat = lookat_; setup(); };
+
private:
- void setup();
Point eye;
Point lookat;
Vector up;
- double hfov, vfov, width, height, nearZ; // x and y field of view,
- // width and height of image
plane
- // distance from eye to image
plane
+ Real hfov, vfov, width, height, nearZ; // x and y field of view,
+ // width and height of
+ // image plane distance
+ // from eye to image plane
Vector direction;
Vector u,v,n;
-
- // for projection we maintain a uvn rotation matrix
- double uvn[3][3];
};
}
Modified: trunk/Model/Cameras/OrthogonalCamera.cc
==============================================================================
--- trunk/Model/Cameras/OrthogonalCamera.cc (original)
+++ trunk/Model/Cameras/OrthogonalCamera.cc Tue Dec 6 16:58:03 2005
@@ -24,19 +24,19 @@
string arg = args[i];
if(arg == "-eye"){
if(!getPointArg(i, args, eye))
- throw IllegalArgument("OrthogonalCamera -eye", i, args);
+ throw IllegalArgument("OrthogonalCamera -eye", i, args);
gotEye = true;
} else if(arg == "-lookat"){
if(!getPointArg(i, args, lookat))
- throw IllegalArgument("OrthogonalCamera -lookat", i, args);
+ throw IllegalArgument("OrthogonalCamera -lookat", i, args);
gotLookat = true;
} else if(arg == "-up"){
if(!getVectorArg(i, args, up))
- throw IllegalArgument("OrthogonalCamera -up", i, args);
+ throw IllegalArgument("OrthogonalCamera -up", i, args);
gotUp = true;
} else if(arg == "-scale"){
- if(!getDoubleArg(i, args, hscale))
- throw IllegalArgument("OrthogonalCamera -scale", i, args);
+ if(!getArg<Real>(i, args, hscale))
+ throw IllegalArgument("OrthogonalCamera -scale", i, args);
gotScale = true;
} else {
throw IllegalArgument("OrthogonalCamera", i, args);
@@ -62,7 +62,7 @@
direction=lookat-eye;
direction.normalize();
v=Cross(direction, up);
- if(v.length2() == 0.0){
+ if(v.length2() == 0){
cerr << "Ambiguous up direction...\n";
}
v.normalize();
@@ -76,7 +76,7 @@
void OrthogonalCamera::makeRays(RayPacket& rays) const
{
- ASSERT(rays.getFlags() & RayPacket::HaveImageCoordinates);
+ ASSERT(rays.getFlag(RayPacket::HaveImageCoordinates));
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
@@ -89,7 +89,7 @@
// FOV doesn't quite make sense here - orthogonal cameras don't have FOV's.
// But in the context of the camera interface, adjusting the scale makes
// the most sense, so we'll do that.
-void OrthogonalCamera::scaleFOV(double scale)
+void OrthogonalCamera::scaleFOV(Real scale)
{
hscale *= scale;
vscale *= scale;
@@ -105,7 +105,7 @@
setup();
}
-void OrthogonalCamera::dolly(double scale)
+void OrthogonalCamera::dolly(Real scale)
{
Vector dir = lookat - eye;
eye += dir*scale;
@@ -128,7 +128,8 @@
}
Vector lookdir(eye-lookat);
- double length = lookdir.length();
+ Real length = lookdir.length();
+
AffineTransform frame;
frame.initWithBasis(v.normal()*length, u.normal()*length, lookdir, cen);
@@ -143,14 +144,11 @@
setup();
}
-void OrthogonalCamera::autoview(double new_fov)
+void OrthogonalCamera::autoview(const BBox bbox)
{
- BBox bbox(Point(-1,-1,0.2), Point(1,1,2.2));
- // double ratio = tan(DtoR(vscale/2))/tan(DtoR(hscale/2));
- hscale = new_fov;
- vscale = new_fov;
+ output(cerr);
Vector diag(bbox.diagonal());
- double w=diag.length();
+ Real w=diag.length();
Vector lookdir(eye-lookat);
lookdir.normalize();
lookat = bbox.center();
@@ -158,8 +156,16 @@
setup();
}
-Point OrthogonalCamera::project(const Point &point) const
+void OrthogonalCamera::output( std::ostream &os ) {
+ os << "orthogonal( -eye " << eye
+ << " -lookat " << lookat
+ << " -up " << up
+ << " -scale " << hscale << " )"
+ << std::endl;
+}
+
+Point OrthogonalCamera::project(const Point& /*point*/) const
{
- // NOT FINISHED
- return Point(0,0,0); // just a placeholder
+ // NOT FINISHED
+ return Point(0,0,0); // just a placeholder
}
Modified: trunk/Model/Cameras/OrthogonalCamera.h
==============================================================================
--- trunk/Model/Cameras/OrthogonalCamera.h (original)
+++ trunk/Model/Cameras/OrthogonalCamera.h Tue Dec 6 16:58:03 2005
@@ -14,23 +14,34 @@
class OrthogonalCamera : public Camera {
public:
OrthogonalCamera(const vector<string>& args);
+ OrthogonalCamera( const Point &eye_, const Point &lookat_,
const Vector &up_, Real hscale_ ) :
+ eye( eye_ ), lookat( lookat_ ), up( up_ ), hscale(
hscale_ ) { setup(); }
virtual ~OrthogonalCamera();
virtual void makeRays(RayPacket&) const;
// Camera manipulation
- virtual void scaleFOV(double);
+ virtual void scaleFOV(Real);
virtual void translate(Vector);
- virtual void dolly(double);
+ virtual void dolly(Real);
virtual void transform(AffineTransform t, TransformCenter);
- virtual void autoview(double fov);
+ virtual void autoview(const BBox bbox);
+ virtual void output( std::ostream &os );
virtual Point project(const Point &point) const;
static Camera* create(const vector<string>& args);
+
+ virtual Point getPosition() const { return eye; }
+ virtual Point getLookAt() const { return lookat; }
+ virtual Vector getUp() const { return up; }
+
+ virtual void reset( const Point &eye_, const Vector &up_, const Point
&lookat_ ) {
+ eye = eye_; up = up_; lookat = lookat_; setup(); }
+
private:
void setup();
Point eye;
Point lookat;
Vector up;
- double hscale, vscale;
+ Real hscale, vscale;
Vector direction;
Vector u,v;
Modified: trunk/Model/Cameras/PinholeCamera.cc
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.cc (original)
+++ trunk/Model/Cameras/PinholeCamera.cc Tue Dec 6 16:58:03 2005
@@ -14,6 +14,7 @@
using namespace Manta;
using namespace std;
using SCIRun::Clamp;
+using SCIRun::Abs;
PinholeCamera::PinholeCamera(const vector<string>& args)
{
@@ -21,25 +22,39 @@
bool gotLookat = false;
bool gotFov = false;
bool gotUp = false;
+ bool gotStereo = false;
normalizeRays = false;
+
+ stereo_offset = 0;
+
+ // pinhole(-eye 3 3 2 -lookat 0 0 0.3 -up 0 0 1 -fov 60
+ eye = Point ( 3, 3, 2 );
+ lookat = Point ( 0, 0, (Real)0.3 );
+ up = Vector( 0, 0, 1 );
+ hfov = 60;
+
int argc = static_cast<int>(args.size());
for(int i=0; i< argc; i++){
string arg = args[i];
- if(arg == "-eye"){
+ if (arg == "-offset") {
+ if(!getArg(i, args, stereo_offset))
+ throw IllegalArgument("PinholeCamera -offset", i, args);
+ gotStereo = true;
+ } else if(arg == "-eye"){
if(!getPointArg(i, args, eye))
- throw IllegalArgument("PinholeCamera -eye", i, args);
+ throw IllegalArgument("PinholeCamera -eye", i, args);
gotEye = true;
} else if(arg == "-lookat"){
if(!getPointArg(i, args, lookat))
- throw IllegalArgument("PinholeCamera -lookat", i, args);
+ throw IllegalArgument("PinholeCamera -lookat", i, args);
gotLookat = true;
} else if(arg == "-up"){
if(!getVectorArg(i, args, up))
- throw IllegalArgument("PinholeCamera -up", i, args);
+ throw IllegalArgument("PinholeCamera -up", i, args);
gotUp = true;
} else if(arg == "-fov"){
- if(!getDoubleArg(i, args, hfov))
- throw IllegalArgument("PinholeCamera -fov", i, args);
+ if(!getArg<Real>(i, args, hfov))
+ throw IllegalArgument("PinholeCamera -fov", i, args);
gotFov = true;
} else if(arg == "-normalizeRays"){
normalizeRays = true;
@@ -47,8 +62,7 @@
throw IllegalArgument("PinholeCamera", i, args);
}
}
- if(!gotEye || !gotLookat || !gotUp || !gotFov)
- throw IllegalArgument("PinholeCamera needs -eye -lookat -up and -fov",
0, args);
+
setup();
}
@@ -56,6 +70,15 @@
{
}
+void PinholeCamera::output( std::ostream &os ) {
+
+ os << "pinhole( -eye " << eye
+ << " -lookat " << lookat
+ << " -up " << up
+ << " -fov " << hfov << " )"
+ << std::endl;
+}
+
Camera* PinholeCamera::create(const vector<string>& args)
{
return new PinholeCamera(args);
@@ -67,20 +90,20 @@
vfov = hfov; // set field of view
direction=lookat-eye; // the normal vector
nearZ=direction.length(); // lenghth to near plane
-
+
Vector n = direction;
n.normalize();
-
up.normalize();
+
v=Cross(direction, up);
- if(v.length2() == 0.0){
+ if(v.length2() == 0){
std::cerr << __FILE__ << " line: " << __LINE__ << " Ambiguous up
direciton...\n";
}
v.normalize();
-
+
u=Cross(v, direction);
u.normalize();
-
+
for(i=0; i<4; i++)
for(j=0; j<4; j++)
proj[i][j] = mv[i][j] = 0.0;
@@ -93,10 +116,10 @@
mv[2][0] = -1.0*n.x(); mv[2][1] = -1.0*n.y(); mv[2][2] = -1.0*n.z();
mv[2][3] = (eye.x()*n.x()) + (eye.y()*n.y()) + (eye.z()*n.z());
mv[3][3]= 1.0;
-
- height=nearZ*tan(vfov*0.5*M_PI/180.0);
+
+ height=nearZ*tan(vfov*(Real)(0.5*M_PI/180.0));
u*=height;
- width=nearZ*tan(hfov*0.5*M_PI/180.0);
+ width=nearZ*tan(hfov*(Real)(0.5*M_PI/180.0));
v*=width;
// form projection matrix
double f = 1.0/tan((vfov*M_PI/180.0)/2.0);
@@ -126,32 +149,43 @@
void PinholeCamera::makeRays(RayPacket& rays) const
{
- ASSERT(rays.getFlags() & RayPacket::HaveImageCoordinates);
+ ASSERT(rays.getFlag(RayPacket::HaveImageCoordinates));
rays.setFlag(RayPacket::ConstantOrigin);
- if(normalizeRays){
+
+ Point stereo_eye[2];
+ stereo_eye[0] = (eye - (v*stereo_offset));
+ stereo_eye[1] = (eye + (v*stereo_offset));
+
+ if(normalizeRays){
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
Vector raydir(v*e.imageX+u*e.imageY+direction);
raydir.normalize();
- e.ray.set(eye, raydir);
+ e.ray.set(stereo_eye[e.whichEye], raydir);
}
rays.setFlag(RayPacket::NormalizedDirections);
+
+
} else {
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
+
Vector raydir(v*e.imageX+u*e.imageY+direction);
- e.ray.set(eye, raydir);
+
+ e.ray.set(stereo_eye[e.whichEye], raydir);
}
+
+
}
}
-void PinholeCamera::scaleFOV(double scale)
+void PinholeCamera::scaleFOV(Real scale)
{
- double fov_min = 0;
- double fov_max = 180;
- hfov = RtoD(2*atan(scale*tan(DtoR(hfov/2.))));
+ Real fov_min = 0;
+ Real fov_max = 180;
+ hfov = RtoD(2*Atan(scale*Tan(DtoR(hfov/2))));
hfov = Clamp(hfov, fov_min, fov_max);
- vfov = RtoD(2*atan(scale*tan(DtoR(vfov/2.))));
+ vfov = RtoD(2*Atan(scale*Tan(DtoR(vfov/2))));
vfov = Clamp(vfov, fov_min, fov_max);
setup();
}
@@ -165,10 +199,11 @@
setup();
}
-void PinholeCamera::dolly(double scale)
+void PinholeCamera::dolly(Real scale)
{
- Vector dir = lookat - eye;
- eye += dir*scale;
+ Vector d = (lookat - eye) * scale;
+ eye += d;
+ // lookat += d; // Maybe we need two types of dolly. // Maybe not.
setup();
}
@@ -188,7 +223,6 @@
}
Vector lookdir(eye-lookat);
- double length = lookdir.length();
AffineTransform frame;
frame.initWithBasis(v.normal(), u.normal(), lookdir.normal(), cen);
@@ -203,18 +237,14 @@
setup();
}
-void PinholeCamera::autoview(double new_fov)
+void PinholeCamera::autoview(const BBox bbox)
{
- BBox bbox(Point(-1,-1,0.2), Point(1,1,2.2));
- // double ratio = tan(DtoR(vfov/2))/tan(DtoR(hfov/2));
- hfov = new_fov;
- vfov = RtoD(2*atan(tan(DtoR(hfov/2))));
Vector diag(bbox.diagonal());
- double w=diag.length();
+ Real w=diag.length();
Vector lookdir(eye-lookat);
lookdir.normalize();
- double scale = 1.0/(2*tan(DtoR(hfov/2.0)));
- double length = w*scale;
+ Real scale = 1/(2*Tan(DtoR(hfov/2)));
+ Real length = w*scale;
lookat = bbox.center();
eye = lookat+lookdir*length;
setup();
Modified: trunk/Model/Cameras/PinholeCamera.h
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.h (original)
+++ trunk/Model/Cameras/PinholeCamera.h Tue Dec 6 16:58:03 2005
@@ -14,24 +14,37 @@
class PinholeCamera : public Camera {
public:
+ PinholeCamera( const Point &eye_, const Point &lookat_, const Vector
&up_, Real fov_ ) :
+ eye( eye_ ), lookat( lookat_ ), up( up_ ), hfov( fov_ ),
stereo_offset( 0.0 ) { setup(); }
PinholeCamera(const vector<string>& args);
virtual ~PinholeCamera();
virtual void makeRays(RayPacket&) const;
// Camera manipulation
- virtual void scaleFOV(double);
+ virtual void scaleFOV(Real);
virtual void translate(Vector);
- virtual void dolly(double);
+ virtual void dolly(Real);
virtual void transform(AffineTransform t, TransformCenter);
- virtual void autoview(double fov);
- virtual Point project(const Point &point) const; // project a 3D
point to the camera image plane
+ virtual void autoview(const BBox bbox);
+ virtual Point project(const Point &point) const; // project a 3D point
to the camera image plane
+ virtual void output( std::ostream &os );
+
static Camera* create(const vector<string>& args);
+
+ virtual Point getPosition() const { return eye; }
+ virtual Point getLookAt() const { return lookat; };
+ virtual Vector getUp() const { return up; };
+
+ virtual void reset( const Point &eye_, const Vector &up_, const Point
&lookat_ ) {
+ eye = eye_; up = up_; lookat = lookat_; setup(); };
+
private:
void setup();
Point eye;
Point lookat;
Vector up;
- double hfov, vfov, width, height, nearZ; // x and y field of view,
+ Real stereo_offset;
+ Real hfov, vfov, width, height, nearZ; // x and y field of view,
// width and height of image
plane
// distance from eye to image
plane
bool normalizeRays;
Copied: trunk/Model/Cameras/StereoPinholeCamera.cc (from r751,
branches/itanium2/Model/Cameras/StereoPinholeCamera.cc)
==============================================================================
--- branches/itanium2/Model/Cameras/StereoPinholeCamera.cc (original)
+++ trunk/Model/Cameras/StereoPinholeCamera.cc Tue Dec 6 16:58:03 2005
@@ -157,7 +157,7 @@
void StereoPinholeCamera::makeRays(RayPacket& rays) const
{
- ASSERT(rays.getFlags() & RayPacket::HaveImageCoordinates);
+ ASSERT(rays.getFlag(RayPacket::HaveImageCoordinates) );
rays.setFlag(RayPacket::ConstantOrigin);
@@ -172,7 +172,6 @@
raydir.normalize();
e.ray.set(stereo_eye[which], raydir);
- e.importance = 1.0;
}
rays.setFlag(RayPacket::NormalizedDirections);
@@ -186,7 +185,6 @@
Vector raydir = v[which]*e.imageX + u[which]*e.imageY +
direction[which];
e.ray.set(stereo_eye[which], raydir);
- e.importance = 1.0;
}
}
Modified: trunk/Model/Groups/BVH.cc
==============================================================================
--- trunk/Model/Groups/BVH.cc (original)
+++ trunk/Model/Groups/BVH.cc Tue Dec 6 16:58:03 2005
@@ -263,7 +263,7 @@
delete [] objValues;
}
else {
- throw InternalError("Unknown build mode: "+buildMode, __FILE__,
__LINE__);
+ throw InternalError("Unknown build mode: "+buildMode, __FILE__, __LINE__
);
}
@@ -281,12 +281,12 @@
if(node->left > 0){
stack[nstack++] = node->left;
if(nstack >= MAXDEPTH)
- throw InternalError("Depth of BVH exceeds maximum depth:
"+to_string(MAXDEPTH)+", must change MAXDEPTH in "+__FILE__, __FILE__,
__LINE__);
+ throw InternalError("Depth of BVH exceeds maximum depth:
"+to_string(MAXDEPTH)+", must change MAXDEPTH in "+__FILE__, __FILE__,
__LINE__ );
}
if(node->right > 0){
stack[nstack++] = node->right;
if(nstack >= MAXDEPTH)
- throw InternalError("Depth of BVH exceeds maximum depth:
"+to_string(MAXDEPTH)+", must change MAXDEPTH in "+__FILE__, __FILE__,
__LINE__);
+ throw InternalError("Depth of BVH exceeds maximum depth:
"+to_string(MAXDEPTH)+", must change MAXDEPTH in "+__FILE__, __FILE__,
__LINE__ );
}
}
Modified: trunk/Model/Groups/CMakeLists.txt
==============================================================================
--- trunk/Model/Groups/CMakeLists.txt (original)
+++ trunk/Model/Groups/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,6 +1,24 @@
SET (Manta_Groups_SRCS
+ Groups/BVH.h
Groups/BVH.cc
+ Groups/GriddedGroup.h
Groups/GriddedGroup.cc
+ Groups/Group.h
Groups/Group.cc
+ Groups/KDTree.h
+ Groups/KDTree.cc
+ Groups/TransparentKDTree.h
+ Groups/TransparentKDTree.cc
+ Groups/KDTreeLoader.h
+ Groups/KDTreeLoader.cc
+ Groups/FrustumKDTree.h
+ Groups/FrustumKDTree.cc
+ Groups/PsiGammaTable.cc
+ Groups/PsiGammaTable.h
+ Groups/RealisticBvh.h
+ Groups/RealisticBvh.cc
+ Groups/VolumeGrid.h
+ Groups/varray.h
+
)
Copied: trunk/Model/Groups/FrustumKDTree.cc (from r751,
branches/itanium2/Model/Groups/FrustumKDTree.cc)
==============================================================================
--- branches/itanium2/Model/Groups/FrustumKDTree.cc (original)
+++ trunk/Model/Groups/FrustumKDTree.cc Tue Dec 6 16:58:03 2005
@@ -102,8 +102,8 @@
// Check to make sure the ray packet is big enough and has the
// correct flags set.
if ((rays.getSize() == 1) ||
- (!rays.getFlags( RayPacket::ConstantOrigin )) ||
- (!rays.getFlags( RayPacket::ConstantDirections ))) {
+ (!rays.getFlag( RayPacket::ConstantOrigin )) ||
+ (!rays.getFlag( RayPacket::ConstantSigns ))) {
// If not call normal kdtree ray intersect.
KDTree::intersect( context, rays );
Copied: trunk/Model/Groups/KDTree.cc (from r751,
branches/itanium2/Model/Groups/KDTree.cc)
==============================================================================
--- branches/itanium2/Model/Groups/KDTree.cc (original)
+++ trunk/Model/Groups/KDTree.cc Tue Dec 6 16:58:03 2005
@@ -124,7 +124,7 @@
if (mailbox.not_mapped( (RayTriangleMailbox::RayNumber)ray, triIdx )) {
- if(/*mailbox.not_mapped( ray, triIdx ) &&*/ intersect_triangle3_edge(
&origin, &direction, &tri[0], &t, &u, &v, &tri.edge1, &tri.edge2 )) {
+ if(/*mailbox.not_mapped( ray, triIdx ) &&*/ intersect_triangle3_edge(
&origin[0], &direction[0], &tri[0][0], &t, &u, &v, &tri.edge1, &tri.edge2 )) {
// Check to see if the t value is closer.
if (t < maxDist) {
@@ -162,6 +162,7 @@
// As a side effect this also computes the sign mask for the box
intersection.
rays.normalizeDirections();
rays.computeInverseDirections();
+ rays.computeSigns();
RayTriIntersectUserData isectData;
@@ -174,7 +175,7 @@
if (Intersection::intersectAaBox( bbox,
minDist, maxDist,
e.ray,
- e.signMask,
+ e.sign,
e.inverseDirection )) {
// Determine the actual minimum distance.
Copied: trunk/Model/Groups/KDTree.h (from r751,
branches/itanium2/Model/Groups/KDTree.h)
==============================================================================
--- branches/itanium2/Model/Groups/KDTree.h (original)
+++ trunk/Model/Groups/KDTree.h Tue Dec 6 16:58:03 2005
@@ -35,7 +35,6 @@
#include <Interface/RayPacket.h>
-#include <Model/Materials/LambertianAlt.h>
#include <Model/Primitives/PrimitiveCommon.h>
#include <Interface/Texture.h>
Copied: trunk/Model/Groups/RealisticBvh.cc (from r751,
branches/itanium2/Model/Groups/RealisticBvh.cc)
==============================================================================
--- branches/itanium2/Model/Groups/RealisticBvh.cc (original)
+++ trunk/Model/Groups/RealisticBvh.cc Tue Dec 6 16:58:03 2005
@@ -167,6 +167,7 @@
void RealisticBvh::intersect(const RenderContext& context, RayPacket& rays)
const {
rays.computeInverseDirections();
+ rays.computeSigns();
// Intersect the ray packet with the bounds of this node.
bool bbox_intersect[RayPacket::MaxSize];
@@ -178,7 +179,7 @@
// Check to see if the ray hits this node's bounding box.
Real min_t, max_t;
bbox_intersect[i] = Intersection::intersectAaBox( bounds,
min_t, max_t, e.ray,
-
e.signMask,
e.inverseDirection,
+
e.sign,
e.inverseDirection,
(Real)0,
e.hitInfo.minT()
);
}
@@ -196,12 +197,12 @@
++begin;
// Determine the first child for the first ray in the packet.
- first_child = rays.get( begin ).signMask[ split_axis ];
+ first_child = rays.get( begin ).sign[ split_axis ];
// Find the end of this run.
end = begin;
while ((end < rays.getSize()) && (bbox_intersect[end]) &&
- (rays.get( begin ).signMask[ split_axis ] ==
first_child))
+ (rays.get( begin ).sign[ split_axis ] == first_child))
++end;
if ((end > begin) && (begin < rays.getSize())) {
Copied: trunk/Model/Groups/TransparentKDTree.cc (from r751,
branches/itanium2/Model/Groups/TransparentKDTree.cc)
==============================================================================
--- branches/itanium2/Model/Groups/TransparentKDTree.cc (original)
+++ trunk/Model/Groups/TransparentKDTree.cc Tue Dec 6 16:58:03 2005
@@ -145,7 +145,7 @@
float t, u, v;
// if (intersectTriangle3Edge( direction, origin, tri.edge1,
tri.edge2, tri[0], t, u, v )) {
- if(intersect_triangle3_edge( &origin, &direction, &tri[0],
&t, &u, &v, &tri.edge1, &tri.edge2 )) {
+ if(intersect_triangle3_edge( &origin[0], &direction[0],
&tri[0][0], &t, &u, &v, &tri.edge1, &tri.edge2 )) {
// Check to see if the t value is closer.
if ((t > sample_t) && (t < maxDist)) {
@@ -242,10 +242,11 @@
void TransparentKDTree::intersect(const RenderContext& context, RayPacket&
rays) const
{
- // Normalize and compute inverse directions,
- // As a side effect this also computes the sign mask for the box
intersection.
+ // Normalize and compute inverse directions,
+ // As a side effect this also computes the sign mask for the box
intersection.
rays.normalizeDirections();
- rays.computeInverseDirections();
+ rays.computeInverseDirections();
+ rays.computeSigns();
RayTriIntersectUserData isectData;
@@ -258,7 +259,7 @@
if (Intersection::intersectAaBox( bbox,
minDist, maxDist,
e.ray,
-
e.signMask,
+
e.sign,
e.inverseDirection )) {
// Determine the actual minimum distance.
Copied: trunk/Model/Groups/TransparentKDTree.h (from r751,
branches/itanium2/Model/Groups/TransparentKDTree.h)
==============================================================================
--- branches/itanium2/Model/Groups/TransparentKDTree.h (original)
+++ trunk/Model/Groups/TransparentKDTree.h Tue Dec 6 16:58:03 2005
@@ -36,7 +36,6 @@
#include <Interface/RayPacket.h>
#include <Model/Groups/Group.h>
-#include <Model/Materials/LambertianAlt.h>
#include <Model/Primitives/PrimitiveCommon.h>
#define KDNODE_AXIS_MASK 0x0003
Modified: trunk/Model/Instances/Instance.cc
==============================================================================
--- trunk/Model/Instances/Instance.cc (original)
+++ trunk/Model/Instances/Instance.cc Tue Dec 6 16:58:03 2005
@@ -43,11 +43,11 @@
{
RayPacketData raydata;
RayPacket instance_rays(raydata, rays.getSize(), rays.getDepth(),
- rays.getFlags());
- double scales[RayPacket::MaxSize];
- double inv_scales[RayPacket::MaxSize];
+ rays.getAllFlags());
+ Real scales[RayPacket::MaxSize];
+ Real inv_scales[RayPacket::MaxSize];
- if(rays.getFlags() & RayPacket::ConstantOrigin){
+ if(rays.getFlag(RayPacket::ConstantOrigin)){
RayPacket::Element& e0 = rays.get(0);
Point o = transform_inv * e0.ray.origin();
@@ -58,9 +58,9 @@
Vector dir = transform_inv * e.ray.direction();
- double length = dir.length();
+ Real length = dir.length();
inv_scales[i] = length;
- double ilength = 1./length;
+ Real ilength = 1/length;
scales[i] = ilength;
te.ray.set(o, dir*ilength);
te.hitInfo.reset(e.hitInfo.minT()*length);
@@ -73,9 +73,9 @@
Point o = transform_inv * e.ray.origin();
Vector dir = transform_inv * e.ray.direction();
- double length = dir.length();
+ Real length = dir.length();
inv_scales[i] = length;
- double ilength = 1./length;
+ Real ilength = 1/length;
scales[i] = ilength;
te.ray.set(o, dir*ilength);
te.hitInfo.reset(e.hitInfo.minT()*length);
@@ -87,10 +87,10 @@
RayPacket::Element& te = instance_rays.get(i);
if(te.hitInfo.wasHit()){
// Instance was hit
- double s = scales[i];
+ Real s = scales[i];
if(e.hitInfo.hit(te.hitInfo.minT()*s, material, this, tex)){
// Instance is now the closest
- double is = inv_scales[i];
+ Real is = inv_scales[i];
e.hitInfo.scratchpad<MPTscale>() =
MPTscale(te.hitInfo.hitMaterial(),
te.hitInfo.hitPrimitive(),
te.hitInfo.hitTexCoordMapper(),
@@ -102,7 +102,7 @@
void Instance::computeNormal(const RenderContext& context, RayPacket& rays)
const
{
- double old_minT[RayPacket::MaxSize];
+ Real old_minT[RayPacket::MaxSize];
Ray old_rays[RayPacket::MaxSize];
// Save the original rays
@@ -112,10 +112,10 @@
Point o = transform_inv * e.ray.origin();
Vector dir = transform_inv * e.ray.direction();
- double scale = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
+ Real scale = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
e.ray.set(o, dir*scale);
old_minT[i] = e.hitInfo.minT();
- double inv_scale = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
+ Real inv_scale = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
e.hitInfo.scaleT(inv_scale);
}
rays.resetFlag(RayPacket::HaveHitPositions);
@@ -165,7 +165,7 @@
void Instance::computeTexCoords2(const RenderContext& context,
RayPacket& rays) const
{
- double old_minT[RayPacket::MaxSize];
+ Real old_minT[RayPacket::MaxSize];
Ray old_rays[RayPacket::MaxSize];
// Save the original rays
@@ -176,10 +176,10 @@
Point o = transform_inv * e.ray.origin();
Vector dir = transform_inv * e.ray.direction();
- double scale = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
+ Real scale = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
e.ray.set(o, dir*scale);
old_minT[i] = e.hitInfo.minT();
- double inv_scale = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
+ Real inv_scale = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
e.hitInfo.scaleT(inv_scale);
}
rays.resetFlag(RayPacket::HaveHitPositions);
@@ -207,7 +207,7 @@
void Instance::computeTexCoords3(const RenderContext& context,
RayPacket& rays) const
{
- double old_minT[RayPacket::MaxSize];
+ Real old_minT[RayPacket::MaxSize];
Ray old_rays[RayPacket::MaxSize];
// Save the original rays
@@ -218,10 +218,10 @@
Point o = transform_inv * e.ray.origin();
Vector dir = transform_inv * e.ray.direction();
- double scale = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
+ Real scale = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
e.ray.set(o, dir*scale);
old_minT[i] = e.hitInfo.minT();
- double inv_scale = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
+ Real inv_scale = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
e.hitInfo.scaleT(inv_scale);
}
rays.resetFlag(RayPacket::HaveHitPositions);
Modified: trunk/Model/Instances/InstanceRST.cc
==============================================================================
--- trunk/Model/Instances/InstanceRST.cc (original)
+++ trunk/Model/Instances/InstanceRST.cc Tue Dec 6 16:58:03 2005
@@ -20,15 +20,16 @@
// but this seems easier: pass in the three axes and make sure that the
// transformed lengths are all the same
Vector v1 = transform * Vector(1,0,0);
- double l1 = v1.normalize();
+ Real l1 = v1.normalize();
Vector v2 = transform * Vector(0,1,0);
- double l2 = v2.normalize();
+ Real l2 = v2.normalize();
Vector v3 = transform * Vector(0,0,1);
- double l3 = v3.normalize();
+ Real l3 = v3.normalize();
scale = l1;
- inv_scale = 1./l1;
- if(SCIRun::Abs(l1-l2)/SCIRun::Abs(l1) > 1.e-10 ||
SCIRun::Abs(l1-l3)/SCIRun::Abs(l1) > 1.e-10) {
+ inv_scale = 1/l1;
+ if(SCIRun::Abs(l1-l2)/SCIRun::Abs(l1) > (Real)1.e-10 ||
+ SCIRun::Abs(l1-l3)/SCIRun::Abs(l1) > (Real)1.e-10) {
ostringstream msg;
msg << "Nonuniform scale for InstanceRST, scalefactor=[" << l1 << ' '
<< l2 << ' ' << l3 << ']';
@@ -59,9 +60,9 @@
{
RayPacketData raydata;
RayPacket instance_rays(raydata, rays.getSize(), rays.getDepth(),
- rays.getFlags());
+ rays.getAllFlags());
- if(rays.getFlags() & RayPacket::ConstantOrigin){
+ if(rays.getFlag(RayPacket::ConstantOrigin)){
RayPacket::Element& e0 = rays.get(0);
Point o = transform_inv * e0.ray.origin();
@@ -105,7 +106,7 @@
void InstanceRST::computeNormal(const RenderContext& context, RayPacket&
rays) const
{
- double old_minT[RayPacket::MaxSize];
+ Real old_minT[RayPacket::MaxSize];
Ray old_rays[RayPacket::MaxSize];
// Save the original rays
@@ -169,7 +170,7 @@
void InstanceRST::computeTexCoords2(const RenderContext& context,
RayPacket& rays) const
{
- double old_minT[RayPacket::MaxSize];
+ Real old_minT[RayPacket::MaxSize];
Ray old_rays[RayPacket::MaxSize];
// Save the original rays
@@ -209,7 +210,7 @@
void InstanceRST::computeTexCoords3(const RenderContext& context,
RayPacket& rays) const
{
- double old_minT[RayPacket::MaxSize];
+ Real old_minT[RayPacket::MaxSize];
Ray old_rays[RayPacket::MaxSize];
// Save the original rays
Modified: trunk/Model/Instances/InstanceRST.h
==============================================================================
--- trunk/Model/Instances/InstanceRST.h (original)
+++ trunk/Model/Instances/InstanceRST.h Tue Dec 6 16:58:03 2005
@@ -44,8 +44,8 @@
AffineTransform transform;
AffineTransform transform_inv;
- double scale;
- double inv_scale;
+ Real scale;
+ Real inv_scale;
};
}
Modified: trunk/Model/Instances/InstanceRT.cc
==============================================================================
--- trunk/Model/Instances/InstanceRT.cc (original)
+++ trunk/Model/Instances/InstanceRT.cc Tue Dec 6 16:58:03 2005
@@ -58,9 +58,9 @@
{
RayPacketData raydata;
RayPacket instance_rays(raydata, rays.getSize(), rays.getDepth(),
- rays.getFlags());
+ rays.getAllFlags());
- if(rays.getFlags() & RayPacket::ConstantOrigin){
+ if(rays.getFlag(RayPacket::ConstantOrigin)){
RayPacket::Element& e0 = rays.get(0);
Point o = transform_inv * e0.ray.origin();
Modified: trunk/Model/Instances/InstanceST.cc
==============================================================================
--- trunk/Model/Instances/InstanceST.cc (original)
+++ trunk/Model/Instances/InstanceST.cc Tue Dec 6 16:58:03 2005
@@ -16,7 +16,7 @@
uniform_scale = true;
else
uniform_scale = false;
- inv_scale = Vector(1./scale.x(), 1./scale.y(), 1./scale.z());
+ inv_scale = Vector(1/scale.x(), 1/scale.y(), 1/scale.z());
}
InstanceST::~InstanceST()
@@ -39,13 +39,13 @@
void InstanceST::intersect(const RenderContext& context, RayPacket& rays)
const
{
RayPacketData raydata;
- RayPacket instance_rays(raydata, rays.getSize(), rays.getDepth(),
rays.getFlags());
+ RayPacket instance_rays(raydata, rays.getSize(), rays.getDepth(),
rays.getAllFlags());
- double scales[RayPacket::MaxSize];
- double inv_scales[RayPacket::MaxSize];
+ Real scales[RayPacket::MaxSize];
+ Real inv_scales[RayPacket::MaxSize];
if(uniform_scale){
- double iscale = inv_scale.x();
- if(rays.getFlags() & RayPacket::ConstantOrigin){
+ Real iscale = inv_scale.x();
+ if(rays.getFlag(RayPacket::ConstantOrigin)){
RayPacket::Element& e = rays.get(0);
Point o( Vector(e.ray.origin()-translation)*iscale );
for(int i = 0;i<rays.getSize();i++){
@@ -63,16 +63,16 @@
}
}
} else {
- if(rays.getFlags() & RayPacket::ConstantOrigin){
+ if(rays.getFlag(RayPacket::ConstantOrigin)){
RayPacket::Element& e = rays.get(0);
Point o(Vector(e.ray.origin()-translation)*inv_scale);
for(int i = 0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
RayPacket::Element& te = instance_rays.get(i);
Vector dir(e.ray.direction()*inv_scale);
- double length = dir.length();
+ Real length = dir.length();
inv_scales[i] = length;
- double ilength = 1./length;
+ Real ilength = 1/length;
scales[i] = ilength;
te.ray.set(o, dir*ilength);
te.hitInfo.reset(e.hitInfo.minT()*length);
@@ -82,9 +82,9 @@
RayPacket::Element& e = rays.get(i);
RayPacket::Element& te = instance_rays.get(i);
Vector dir(e.ray.direction()*inv_scale);
- double length = dir.length();
+ Real length = dir.length();
scales[i] = length;
- double ilength = 1./length;
+ Real ilength = 1/length;
inv_scales[i] = ilength;
te.ray.set(Point((Vector(e.ray.origin())-translation)*inv_scale),
dir*ilength);
@@ -94,7 +94,7 @@
}
instance->intersect(context, instance_rays);
if(uniform_scale){
- double s = scale.x();
+ Real s = scale.x();
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
RayPacket::Element& te = instance_rays.get(i);
@@ -113,16 +113,17 @@
RayPacket::Element& e = rays.get(i);
RayPacket::Element& te = instance_rays.get(i);
if(te.hitInfo.wasHit()){
- // Instance was hit
- double s = scales[i];
- if(e.hitInfo.hit(te.hitInfo.minT()*s, material, this, tex)){
- // Instance is now the closest
- double is = inv_scales[i];
- e.hitInfo.scratchpad<MPTscale>() =
MPTscale(te.hitInfo.hitMaterial(),
-
te.hitInfo.hitPrimitive(),
-
te.hitInfo.hitTexCoordMapper(),
- s, is);
- }
+ // Instance was hit
+ Real s = scales[i];
+ if(e.hitInfo.hit(te.hitInfo.minT()*s, material, this, tex)){
+ // Instance is now the closest
+ Real is = inv_scales[i];
+ e.hitInfo.scratchpad<MPTscale>() =
+ MPTscale(te.hitInfo.hitMaterial(),
+ te.hitInfo.hitPrimitive(),
+ te.hitInfo.hitTexCoordMapper(),
+ s, is);
+ }
}
}
}
@@ -130,12 +131,12 @@
void InstanceST::computeNormal(const RenderContext& context, RayPacket&
rays) const
{
- double old_minT[RayPacket::MaxSize];
+ Real old_minT[RayPacket::MaxSize];
Point old_origins[RayPacket::MaxSize];
Ray old_rays[RayPacket::MaxSize];
if(uniform_scale){
// Save the original origins and minT
- double is = inv_scale.x();
+ Real is = inv_scale.x();
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
old_origins[i] = e.ray.origin();
@@ -149,11 +150,11 @@
RayPacket::Element& e = rays.get(i);
old_rays[i] = e.ray;
Vector dir(e.ray.direction()*inv_scale);
- double ilength = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
+ Real ilength = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
e.ray.set(Point((Vector(e.ray.origin())-translation)*inv_scale),
dir*ilength);
old_minT[i] = e.hitInfo.minT();
- double length = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
+ Real length = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
e.hitInfo.scaleT(length);
}
}
@@ -211,12 +212,12 @@
void InstanceST::computeTexCoords2(const RenderContext& context,
RayPacket& rays) const
{
- double old_minT[RayPacket::MaxSize];
+ Real old_minT[RayPacket::MaxSize];
Point old_origins[RayPacket::MaxSize];
Ray old_rays[RayPacket::MaxSize];
if(uniform_scale){
// Save the original origins and minT
- double is = inv_scale.x();
+ Real is = inv_scale.x();
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
old_origins[i] = e.ray.origin();
@@ -230,11 +231,11 @@
RayPacket::Element& e = rays.get(i);
old_rays[i] = e.ray;
Vector dir(e.ray.direction()*inv_scale);
- double ilength = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
+ Real ilength = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
e.ray.set(Point((Vector(e.ray.origin())-translation)*inv_scale),
dir*ilength);
old_minT[i] = e.hitInfo.minT();
- double length = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
+ Real length = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
e.hitInfo.scaleT(length);
}
}
@@ -270,12 +271,12 @@
void InstanceST::computeTexCoords3(const RenderContext& context,
RayPacket& rays) const
{
- double old_minT[RayPacket::MaxSize];
+ Real old_minT[RayPacket::MaxSize];
Point old_origins[RayPacket::MaxSize];
Ray old_rays[RayPacket::MaxSize];
if(uniform_scale){
// Save the original origins and minT
- double is = inv_scale.x();
+ Real is = inv_scale.x();
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
old_origins[i] = e.ray.origin();
@@ -289,11 +290,11 @@
RayPacket::Element& e = rays.get(i);
old_rays[i] = e.ray;
Vector dir(e.ray.direction()*inv_scale);
- double ilength = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
+ Real ilength = rays.get(i).hitInfo.scratchpad<MPTscale>().scale;
e.ray.set(Point((Vector(e.ray.origin())-translation)*inv_scale),
dir*ilength);
old_minT[i] = e.hitInfo.minT();
- double length = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
+ Real length = rays.get(i).hitInfo.scratchpad<MPTscale>().inv_scale;
e.hitInfo.scaleT(length);
}
}
Modified: trunk/Model/Instances/InstanceT.cc
==============================================================================
--- trunk/Model/Instances/InstanceT.cc (original)
+++ trunk/Model/Instances/InstanceT.cc Tue Dec 6 16:58:03 2005
@@ -34,9 +34,9 @@
{
RayPacketData raydata;
RayPacket instance_rays(raydata, rays.getSize(), rays.getDepth(),
- rays.getFlags());
+ rays.getAllFlags());
- if(rays.getFlags() & RayPacket::ConstantOrigin){
+ if(rays.getFlag(RayPacket::ConstantOrigin)){
RayPacket::Element& e = rays.get(0);
Point O(e.ray.origin()-translation);
for(int i = 0;i<rays.getSize();i++){
Modified: trunk/Model/Lights/CMakeLists.txt
==============================================================================
--- trunk/Model/Lights/CMakeLists.txt (original)
+++ trunk/Model/Lights/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,3 +1,6 @@
SET (Manta_Lights_SRCS
- Lights/PointLight.cc)
+ Lights/PointLight.h
+ Lights/PointLight.cc
+ Lights/HeadLight.h
+ Lights/HeadLight.cc)
Modified: trunk/Model/Lights/PointLight.cc
==============================================================================
--- trunk/Model/Lights/PointLight.cc (original)
+++ trunk/Model/Lights/PointLight.cc Tue Dec 6 16:58:03 2005
@@ -16,13 +16,15 @@
{
}
-const Point& PointLight::getCenter() const
-{
- return position;
-}
+void PointLight::computeLight( Color &resultColor, Vector &lightDirection,
+ const RenderContext &/*context*/,
+ RayPacket::Element &e ) const {
-const Color& PointLight::getColor() const
-{
- return color;
+ // Specify the color.
+ resultColor = color;
+
+ // Compute the light direction.
+ lightDirection = (position - e.hitPosition);
+
}
Modified: trunk/Model/Lights/PointLight.h
==============================================================================
--- trunk/Model/Lights/PointLight.h (original)
+++ trunk/Model/Lights/PointLight.h Tue Dec 6 16:58:03 2005
@@ -13,8 +13,10 @@
virtual ~PointLight();
virtual void preprocess(const PreprocessContext&);
- virtual const Point& getCenter() const;
- virtual const Color& getColor() const;
+
+ virtual void computeLight( Color &resultColor, Vector
&lightDirection,
+ const RenderContext &context,
RayPacket::Element &e ) const;
+
private:
Point position;
Color color;
Modified: trunk/Model/Materials/CMakeLists.txt
==============================================================================
--- trunk/Model/Materials/CMakeLists.txt (original)
+++ trunk/Model/Materials/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,13 +1,21 @@
-
-
SET (Manta_Materials_SRCS
+ Materials/AmbientOcclusion.h
+ Materials/AmbientOcclusion.cc
+ Materials/Checker.h
Materials/Checker.cc
- Materials/Dielectric.cc
+# Materials/Dielectric.h
+# Materials/Dielectric.cc
+ Materials/Flat.h
Materials/Flat.cc
+ Materials/Lambertian.h
Materials/Lambertian.cc
+ Materials/LitMaterial.h
Materials/LitMaterial.cc
+ Materials/MetalMaterial.h
Materials/MetalMaterial.cc
+ Materials/NormalMaterial.h
+ Materials/NormalMaterial.cc # Shade the material using it's normal.
+ Materials/Phong.h
Materials/Phong.cc
- Materials/AmbientOcclusion.cc
)
Modified: trunk/Model/Materials/Checker.cc
==============================================================================
--- trunk/Model/Materials/Checker.cc (original)
+++ trunk/Model/Materials/Checker.cc Tue Dec 6 16:58:03 2005
@@ -31,8 +31,8 @@
else
rays.computeTextureCoordinates2(context);
RayPacket::Element& e0 = rays.get(0);
- double vv1 = Dot(e0.texCoords, v1);
- double vv2 = Dot(e0.texCoords, v2);
+ Real vv1 = Dot(e0.texCoords, v1);
+ Real vv2 = Dot(e0.texCoords, v2);
if(vv1<0)
vv1=-vv1+1;
if(vv2<0)
@@ -49,12 +49,12 @@
int which = which0;
while(stop < rays.getSize()){
RayPacket::Element& e = rays.get(stop);
- double vv1 = Dot(e.texCoords, v1);
- double vv2 = Dot(e.texCoords, v2);
+ Real vv1 = Dot(e.texCoords, v1);
+ Real vv2 = Dot(e.texCoords, v2);
if(vv1<0)
- vv1=-vv1+1;
+ vv1=-vv1+1;
if(vv2<0)
- vv2=-vv2+1;
+ vv2=-vv2+1;
int i1 = (int)vv1;
int i2 = (int)vv2;
which = (i1+i2)%2;
Modified: trunk/Model/Materials/Dielectric.cc
==============================================================================
--- trunk/Model/Materials/Dielectric.cc (original)
+++ trunk/Model/Materials/Dielectric.cc Tue Dec 6 16:58:03 2005
@@ -1,3 +1,30 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institute, University of Utah.
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ */
#include <Model/Materials/Dielectric.h>
#include <Core/Math/ipow.h>
@@ -10,15 +37,15 @@
#include <Interface/Renderer.h>
#include <Interface/Scene.h>
#include <Interface/ShadowAlgorithm.h>
-#include <Core/Util/NotFinished.h>
+#include <Core/Math/Trig.h>
using namespace Manta;
-Dielectric::Dielectric(const Color& diffuse, const Color& specular,
- int specpow, double n, double nt)
- : diffuse(diffuse), specular(specular), specpow(specpow),
- n(n), nt(nt)
+Dielectric::Dielectric(const Texture<Real>* n, const Texture<Real>* nt,
+ const Texture<Color>* sigma_a)
+ : n(n), nt(nt), sigma_a(sigma_a)
{
+
}
Dielectric::~Dielectric()
@@ -27,142 +54,200 @@
void Dielectric::shade(const RenderContext& context, RayPacket& rays) const
{
- // Shade a bunch of rays. We know that they all have the same intersected
- // object and are all of the same material
-
- rays.normalizeDirections();
+ if(rays.getDepth() >= context.scene->getRenderParameters().maxDepth)
+ {
+ activeLights->getAmbientLight()->computeAmbient(context, rays);
+ for(int i=0;i<rays.getSize();i++)
+ {
+ RayPacket::Element& e = rays.get(i);
+ rays.setResult(i, e.ambientLight);
+ }
+ return;
+ }
+
- // Compute normals
+ rays.computeHitPositions();
+ rays.normalizeDirections();
rays.computeNormals(context);
+ if (!(rays.getFlags(rays.HaveUnitNormals)))
+ {
+ // I would like to replace this with a call to
+ // rays.normalizeNormals() but need to add it.
+ fprintf(stderr, "Dielectric assumes unit normals\n");
+ exit(-1);
+ }
- // Compute ambient contributions for all rays
- activeLights->getAmbientLight()->computeAmbient(context, rays);
+ Real n_values[RayPacket::MaxSize];
+ Real nt_values[RayPacket::MaxSize];
+ Color sigma_a_values[RayPacket::MaxSize];
+
+ n->mapValues(context, rays, n_values);
+ nt->mapValues(context, rays, nt_values);
+ sigma_a->mapValues(context, rays, sigma_a_values);
+
+ Vector refl_dirs[RayPacket::MaxSize];
+ Vector refr_dirs[RayPacket::MaxSize];
+ Real fresnel_coeffs[RayPacket::MaxSize]; // might be better to compute
+ Color beers_colors[RayPacket::MaxSize];
+ Real beers_coeffs[RayPacket::MaxSize];
+ bool internally_reflected[RayPacket::MaxSize];
+ bool apply_beers[RayPacket::MaxSize];
+ bool kill_ray[RayPacket::MaxSize];
- RayPacketData data;
- int start = 0;
- do {
- RayPacket shadowRays(data, 0, rays.getDepth(), 0);
- int end = context.shadowAlgorithm->computeShadows(context, activeLights,
- rays, start,
shadowRays);
-
- if(shadowRays.getFlags() & RayPacket::NormalizedDirections){
- for(int i=start;i<end;i++){
- RayPacket::Element& e = rays.get(i);
- Color totalDiffuse(e.ambientLight);
- Color totalSpecular = Color::black();
- for(int j=e.shadowBegin;j<e.shadowEnd;j++){
- RayPacket::Element& s = shadowRays.get(j);
- if(!s.hitInfo.wasHit()){
- double cos_theta = Dot(s.ray.direction(), e.normal);
- totalDiffuse += s.light*cos_theta;
- Vector H = s.ray.direction()-e.ray.direction();
- H.normalize();
- double cos_alpha = Dot(H, e.normal);
- if(cos_alpha > 0)
- totalSpecular += s.light * ipow(cos_alpha, specpow);
- }
- }
- rays.setResult(i, diffuse*totalDiffuse+specular*totalSpecular);
- }
- } else {
- for(int i=start;i<end;i++){
- RayPacket::Element& e = rays.get(i);
- Color totalDiffuse(e.ambientLight);
- Color totalSpecular = Color::black();
- for(int j=e.shadowBegin;j<e.shadowEnd;j++){
- RayPacket::Element& s = shadowRays.get(j);
- if(!s.hitInfo.wasHit()){
- s.ray.normalizeDirection();
- double cos_theta = Dot(s.ray.direction(), e.normal);
- totalDiffuse += s.light*cos_theta;
- Vector H = s.ray.direction()-e.ray.direction();
- H.normalize();
- double cos_alpha = Dot(H, e.normal);
- if(cos_alpha > 0)
- totalSpecular += s.light * ipow(cos_alpha, specpow);
- }
- }
- rays.setResult(i, diffuse*totalDiffuse+specular*totalSpecular);
- }
- }
- start = end;
- } while(start < rays.getSize());
-
-
- int maxdepth = 5;
- if(rays.getDepth() < maxdepth) {
- // Compute refractions
- double *c = new double[rays.getSize()];
- double *tst = new double[rays.getSize()];
- Color *col = new Color[rays.getSize()];
- RayPacketData rfdata;
- RayPacket refr_rays(rfdata, rays.getSize(), rays.getDepth()+1,
- RayPacket::NormalizedDirections);
- refr_rays.useLocalColors();
- rays.computeHitPositions();
-
- for(int i=0;i<rays.getSize();i++){
+ int num_internal = 0;
+ int num_branch = 0;
+
+ for(int i=0;i<rays.getSize();i++)
+ {
RayPacket::Element& e = rays.get(i);
- Vector d = e.ray.direction();
- Vector norm = e.normal;
- tst[i] = 1-((n*n*(1-Dot(d,e.normal)*Dot(d,e.normal)))/(nt*nt));
- Vector refr_dir = ((n*(d-norm*Dot(d,norm)))/nt)-(norm*tst[i]);
- RayPacket::Element& r = refr_rays.get(i);
- double x = refr_dir.x()*0.00001-e.hitPosition.x();
- double y = refr_dir.y()*0.00001-e.hitPosition.y();
- double z = refr_dir.z()*0.00001-e.hitPosition.z();
- r.ray.set(Point(x,y,z), refr_dir);
-
- if(Dot(d,norm) < 0) {
- c[i] = -Dot(e.ray.direction(), e.normal);
- col[i] = Color::white();
- }
- else {
- c[i] = Dot(refr_dir, e.normal);
- double tmpt = e.hitInfo.minT();
- col[i] = e.color->attenuate(-tmpt);
- }
- }
-
- // Compute reflections
- RayPacketData rdata;
- RayPacket refl_rays(rdata, rays.getSize(), rays.getDepth()+1,
- RayPacket::NormalizedDirections);
- refl_rays.useLocalColors();
- double *refl = new double[rays.getSize()];
- for(int i=0;i<rays.getSize();i++) {
- double R0 = ((n-1)*(n-1))/((n+1)*(n+1));
- refl[i] = R0 + ((1-R0)*(1-c[i])*(1-c[i])*(1-c[i])*(1-c[i])*(1-c[i]));
+
+ if ( e.importance < (Real)0.05 )
+ {
+ kill_ray[i] = true;
+ continue;
+ }
+ else
+ {
+ kill_ray[i] = false;
+ }
+
+ Vector N = e.normal;
+ Real n_dot_v = Dot(N, e.ray.direction());
+ Real eta_tmp;
+ Real eta_tmp_inv;
+ bool was_incoming = ( n_dot_v < 0 );
+ if ( was_incoming )
+ {
+ eta_tmp = n_values[i]/nt_values[i];
+ eta_tmp_inv = 1 / eta_tmp;
+ n_dot_v = -n_dot_v;
+ apply_beers[i] = false;
+ beers_coeffs[i] = 1;// allows blind multiplication
+ }
+ else
+ {
+ N = -N;
+ eta_tmp = nt_values[i]/n_values[i];
+ eta_tmp_inv = 1 / eta_tmp;
+ apply_beers[i] = true;
+ beers_colors[i] = sigma_a_values[i].Pow(e.hitInfo.minT());
+ beers_coeffs[i] = beers_colors[i].Mean();
+ }
+
+ Real cosine = 1 + (n_dot_v*n_dot_v - 1) * (eta_tmp_inv*eta_tmp_inv);
+ if ( cosine <= 0 )
+ {
+ // total internal reflection
+ Vector refl_dir = e.ray.direction() + 2*n_dot_v*N;
+ internally_reflected[i] = true;
+ refl_dirs[i] = refl_dir;
+ num_internal++;
+ }
+ else
+ {
+ cosine = (cosine > 0) ? Sqrt(cosine) : 0;
+ // Real cos_min = ( cosine > n_dot_v ) ? n_dot_v : cosine;
+ Real k = 1 - cosine;
+ k*=k*k*k*k;
+
+ Real r0 = (n_values[i] - nt_values[i]) / (n_values[i] +
nt_values[i]);
+ r0 *= r0;
+ Real R = r0*(1-k) + k;
+
+ Vector refr_dir = (e.ray.direction()*eta_tmp_inv +
+ (n_dot_v*eta_tmp_inv - cosine) * N);
+ Vector refl_dir = e.ray.direction() + 2*n_dot_v*N;
+
+ internally_reflected[i] = false;
+ num_branch++;
+ refl_dirs[i] = refl_dir;
+ refr_dirs[i] = refr_dir;
+ fresnel_coeffs[i] = R;
+ }
+ }
+
+ // okay we've got everything ready now
+
+ RayPacketData total_internal_data;
+ RayPacketData reflected_data;
+ RayPacketData refracted_data;
+
+ RayPacket internal_rays(total_internal_data, num_internal,
rays.getDepth()+1, RayPacket::NormalizedDirections);
+ RayPacket reflected_rays(reflected_data, num_branch, rays.getDepth()+1,
RayPacket::NormalizedDirections);
+ RayPacket refracted_rays(refracted_data, num_branch, rays.getDepth()+1,
RayPacket::NormalizedDirections);
+
+ internal_rays.useLocalColors();
+ reflected_rays.useLocalColors();
+ refracted_rays.useLocalColors();
+
+ // for accessing ray packet elements between the 3 sets (or 2 pairs really)
+ int internal_counter = 0;
+ int branch_counter = 0;
+ // fill in the raypackets
+ for (int i = 0; i < rays.getSize(); i++)
+ {
RayPacket::Element& e = rays.get(i);
- Vector refl_dir = e.ray.direction() - e.normal*(2*Dot(e.normal,
e.ray.direction()));
- RayPacket::Element& r = refl_rays.get(i);
- double x = refl_dir.x()*0.00001+e.hitPosition.x();
- double y = refl_dir.y()*0.00001+e.hitPosition.y();
- double z = refl_dir.z()*0.00001+e.hitPosition.z();
- r.ray.set(Point(x,y,z), refl_dir);
- }
-
- // Store Color
- refl_rays.resetHit();
- refr_rays.resetHit();
- context.renderer->traceRays(context, refl_rays);
- context.renderer->traceRays(context, refr_rays);
- for(int i=0;i<rays.getSize();i++){
+ if (kill_ray[i])
+ continue;
+
+ if (internally_reflected[i])
+ {
+ RayPacket::Element& r = internal_rays.get(internal_counter);
+ r.ray.set(e.hitPosition, refl_dirs[i]);
+ r.importance = e.importance * beers_coeffs[i];
+ internal_counter++;
+ }
+ else
+ {
+ RayPacket::Element& refl = reflected_rays.get(branch_counter);
+ refl.ray.set(e.hitPosition, refl_dirs[i]);
+ refl.importance = e.importance * fresnel_coeffs[i] *
beers_coeffs[i];
+ RayPacket::Element& refr = refracted_rays.get(branch_counter);
+ refr.ray.set(e.hitPosition, refr_dirs[i]);
+ refr.importance = e.importance * (1 - fresnel_coeffs[i]) *
beers_coeffs[i];
+ branch_counter++;
+ }
+ }
+
+ // fire them off
+ context.renderer->traceRays(context, reflected_rays);
+ context.renderer->traceRays(context, refracted_rays);
+ context.renderer->traceRays(context, internal_rays);
+
+ internal_counter = 0;
+ branch_counter = 0;
+ // compute their results
+ for (int i = 0; i < rays.getSize(); i++)
+ {
RayPacket::Element& e = rays.get(i);
- RayPacket::Element& rl = refl_rays.get(i);
- RayPacket::Element& rf = refr_rays.get(i);
- if(tst[i] < 0) {
- *e.color = col[i]*(*rl.color);
- }
- else {
- *e.color = col[i]*(((*rl.color) * refl[i]) +
- ((*rf.color) * (1-refl[i])));
- }
- }
-
- delete [] c;
- delete [] tst;
- delete [] refl;
- delete [] col;
+ if (kill_ray[i])
+ {
+ rays.setResult(i, Color::black());
+ continue;
+ }
+
+ if (internally_reflected[i])
+ {
+ RayPacket::Element& r = internal_rays.get(internal_counter);
+
+ rays.setResult(i, *r.color);
+ internal_counter++;
+ }
+ else
+ {
+ RayPacket::Element& refl = reflected_rays.get(branch_counter);
+ RayPacket::Element& refr = refracted_rays.get(branch_counter);
+
+ rays.setResult(i, (Color::white()*fresnel_coeffs[i])*(*refl.color)
+
+ (Color::white()*(1-fresnel_coeffs[i]))*(*refr.color)
);
+
+ branch_counter++;
+ }
+
+ if (apply_beers[i])
+ {
+ *e.color *= beers_colors[i];
+ }
}
}
+
Modified: trunk/Model/Materials/Dielectric.h
==============================================================================
--- trunk/Model/Materials/Dielectric.h (original)
+++ trunk/Model/Materials/Dielectric.h Tue Dec 6 16:58:03 2005
@@ -2,24 +2,62 @@
#ifndef Manta_Model_Dielectric_h
#define Manta_Model_Dielectric_h
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institute, University of Utah.
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+ */
+
#include <Model/Materials/LitMaterial.h>
#include <Core/Color/Color.h>
+#include <Interface/Texture.h>
+#include <Model/Textures/Constant.h>
-namespace Manta{
+namespace Manta
+{
class LightSet;
- class Dielectric : public LitMaterial {
+ class Dielectric : public LitMaterial
+ {
public:
- Dielectric(const Color& diffuse, const Color& specular, int specpow,
- double n, double nt);
- virtual ~Dielectric();
+ Dielectric(const Real n, const Real nt, const Color
&sigma_a)
+ : n(new Constant<Real>(n)),
+ nt(new Constant<Real>(nt)),
+ sigma_a(new Constant<Color>(sigma_a))
+ { }
+
+ Dielectric(const Texture<Real>* n, const Texture<Real>* nt,
+ const Texture<Color>* sigma_a);
+ ~Dielectric();
- virtual void shade(const RenderContext& context, RayPacket& rays) const;
+ void shade(const RenderContext& context, RayPacket& rays) const;
+
private:
- Color diffuse;
- Color specular;
- int specpow;
- double n, nt;
+ const Texture<Real>* n;
+ const Texture<Real>* nt;
+ const Texture<Color>* sigma_a;
};
}
Modified: trunk/Model/Materials/Lambertian.cc
==============================================================================
--- trunk/Model/Materials/Lambertian.cc (original)
+++ trunk/Model/Materials/Lambertian.cc Tue Dec 6 16:58:03 2005
@@ -40,40 +40,31 @@
// Compute ambient contributions for all rays
activeLights->getAmbientLight()->computeAmbient(context, rays);
+ // We normalized directions for proper dot product computation.
+ rays.normalizeDirections();
+
RayPacketData data;
int start = 0;
+
do {
RayPacket shadowRays(data, 0, rays.getDepth(), 0);
int end = context.shadowAlgorithm->computeShadows(context, activeLights,
rays, start,
shadowRays);
- if(shadowRays.getFlags() & RayPacket::NormalizedDirections){
+ // We normalized directions for proper dot product computation.
+ shadowRays.normalizeDirections();
+
for(int i=start;i<end;i++){
- RayPacket::Element& e = rays.get(i);
- Color totalLight(e.ambientLight);
- for(int j=e.shadowBegin;j<e.shadowEnd;j++){
- RayPacket::Element& s = shadowRays.get(j);
- if(!s.hitInfo.wasHit()){
- double cos_theta = Dot(s.ray.direction(), e.normal);
- totalLight += s.light*cos_theta;
- }
- }
- rays.setResult(i, colors[i]*totalLight);
+ RayPacket::Element& e = rays.get(i);
+ Color totalLight(e.ambientLight);
+ for(int j=e.shadowBegin;j<e.shadowEnd;j++){
+ RayPacket::Element& s = shadowRays.get(j);
+ if(!s.hitInfo.wasHit()){
+ ColorComponent cos_theta = Dot(s.ray.direction(), e.normal);
+ totalLight += s.light*cos_theta;
+ }
+ }
+ rays.setResult(i, colors[i]*totalLight);
}
- } else {
- for(int i=start;i<end;i++){
- RayPacket::Element& e = rays.get(i);
- Color totalLight(e.ambientLight);
- for(int j=e.shadowBegin;j<e.shadowEnd;j++){
- RayPacket::Element& s = shadowRays.get(j);
- if(!s.hitInfo.wasHit()){
- s.ray.normalizeDirection();
- double cos_theta = Dot(s.ray.direction(), e.normal);
- totalLight += s.light*cos_theta;
- }
- }
- rays.setResult(i, colors[i]*totalLight);
- }
- }
start = end;
} while(start < rays.getSize());
}
Modified: trunk/Model/Materials/Lambertian.h
==============================================================================
--- trunk/Model/Materials/Lambertian.h (original)
+++ trunk/Model/Materials/Lambertian.h Tue Dec 6 16:58:03 2005
@@ -13,6 +13,7 @@
public:
Lambertian(const Color& color);
Lambertian(const Texture<Color>* colorfn);
+ Lambertian() { };
virtual ~Lambertian();
virtual void shade(const RenderContext& context, RayPacket& rays) const;
Modified: trunk/Model/Materials/MetalMaterial.cc
==============================================================================
--- trunk/Model/Materials/MetalMaterial.cc (original)
+++ trunk/Model/Materials/MetalMaterial.cc Tue Dec 6 16:58:03 2005
@@ -31,93 +31,46 @@
void MetalMaterial::shade(const RenderContext& context, RayPacket& rays)
const
{
- // Shade a bunch of rays. We know that they all have the same intersected
- // object and are all of the same material
-
rays.normalizeDirections();
-
- // Compute normals
rays.computeNormals(context);
-
- // Compute colors
Color specular[RayPacket::MaxSize];
specular_reflectance->mapValues(context, rays, specular);
- RayPacketData data;
- int start = 0;
- do {
- RayPacket shadowRays(data, 0, rays.getDepth(), 0);
- int end = context.shadowAlgorithm->computeShadows(context, activeLights,
- rays, start,
shadowRays);
-
- if(shadowRays.getFlags() & RayPacket::NormalizedDirections){
- for(int i=start;i<end;i++){
- RayPacket::Element& e = rays.get(i);
- Color totalSpecular = Color::black();
-
- // for the shadows
- for(int j=e.shadowBegin;j<e.shadowEnd;j++){
- RayPacket::Element& s = shadowRays.get(j);
- if(!s.hitInfo.wasHit()){
- Vector H = s.ray.direction()-e.ray.direction();
- H.normalize();
- double cos_alpha = Dot(H, e.normal);
- if(cos_alpha > 0)
- totalSpecular += s.light*ipow(cos_alpha, phong_exponent);
- }
- }
- rays.setResult(i, specular[i]*totalSpecular);
- }
- } else {
- for(int i=start;i<end;i++){
- RayPacket::Element& e = rays.get(i);
- Color totalSpecular = Color::black();
- for(int j=e.shadowBegin;j<e.shadowEnd;j++){
- RayPacket::Element& s = shadowRays.get(j);
- if(!s.hitInfo.wasHit()){
- s.ray.normalizeDirection();
- Vector H = s.ray.direction()-e.ray.direction();
- H.normalize();
- double cos_alpha = Dot(H, e.normal);
- if(cos_alpha > 0)
- totalSpecular += s.light*ipow(cos_alpha, phong_exponent);
- }
- }
- rays.setResult(i, specular[i]*totalSpecular);
- }
- }
- start = end;
- } while(start < rays.getSize());
-
// Compute reflections
- if(rays.getDepth() < context.scene->getRenderParameters().maxDepth){
+ if(rays.getDepth() < context.scene->getRenderParameters().maxDepth)
+ {
rays.computeHitPositions();
RayPacketData rdata;
RayPacket refl_rays(rdata, rays.getSize(), rays.getDepth()+1,
RayPacket::NormalizedDirections);
refl_rays.useLocalColors();
- for(int i=0;i<rays.getSize();i++){
- RayPacket::Element& e = rays.get(i);
- Vector refl_dir = e.ray.direction() - e.normal*(2*Dot(e.normal,
e.ray.direction()));
- RayPacket::Element& r = refl_rays.get(i);
- r.ray.set(e.hitPosition, refl_dir);
+ for(int i=0;i<rays.getSize();i++)
+ {
+ RayPacket::Element& e = rays.get(i);
+ Vector refl_dir = e.ray.direction() - e.normal*(2*Dot(e.normal,
e.ray.direction()));
+ RayPacket::Element& r = refl_rays.get(i);
+ r.ray.set(e.hitPosition, refl_dir);
}
refl_rays.resetHit();
context.renderer->traceRays(context, refl_rays);
- for(int i=0;i<rays.getSize();i++){
- RayPacket::Element& e = rays.get(i);
- RayPacket::Element& r = refl_rays.get(i);
- double cosine = -Dot(e.normal, e.ray.direction());
- if(cosine < 0)
- cosine =-cosine;
-
- float k = 1 - cosine;
- k*=k*k*k*k;
-
- Color R = specular[i] * (1-k) + Color::white()*k;
+ for(int i=0;i<rays.getSize();i++) {
+ RayPacket::Element& e = rays.get(i);
+ RayPacket::Element& r = refl_rays.get(i);
+
+ // compute Schlick Fresnel approximation
+ Real cosine = -Dot(e.normal, e.ray.direction());
+ if(cosine < 0) cosine =-cosine;
+ Real k = 1 - cosine;
+ k*=k*k*k*k;
+
+ // Doing the explicit cast to ColorComponent here, so that we
+ // don't do things like multiply all the colors by a double,
+ // thus promoting those expressions when we don't need to.
+ ColorComponent kc = (ColorComponent)k;
+ Color R = specular[i] * (1-kc) + Color::white()*kc;
- *e.color += R * *r.color;
+ *e.color = R * (*r.color);
}
}
}
Modified: trunk/Model/Materials/Phong.cc
==============================================================================
--- trunk/Model/Materials/Phong.cc (original)
+++ trunk/Model/Materials/Phong.cc Tue Dec 6 16:58:03 2005
@@ -14,26 +14,31 @@
using namespace Manta;
-Phong::Phong(const Color& diffuse, const Color& specular, int specpow,
- double refl)
+Phong::Phong(const Color& diffuse, const Color& specular,
+ int specpow, ColorComponent refl)
: specpow(specpow)
{
diffusetex = new Constant<Color>(diffuse);
speculartex = new Constant<Color>(specular);
- refltex = new Constant<double>(refl);
+ refltex = new Constant<ColorComponent>(refl);
do_refl = (refl != 0);
}
Phong::Phong(const Texture<Color>* diffusetex,
- const Texture<Color>* speculartex,
- int specpow, const Texture<double>* refltex)
+ const Texture<Color>* speculartex,
+ int specpow, const Texture<ColorComponent>* refltex)
: diffusetex(diffusetex), speculartex(speculartex), refltex(refltex),
specpow(specpow)
{
do_refl=true;
- const Constant<double>* rtest = dynamic_cast<const
Constant<double>*>(refltex);
- if(rtest && rtest->getValue() == 0)
- do_refl =false;
+ if (refltex) {
+ const Constant<ColorComponent>* rtest =
+ dynamic_cast<const Constant<ColorComponent>*>(refltex);
+ if(rtest && rtest->getValue() == 0)
+ do_refl =false;
+ } else {
+ do_refl = false;
+ }
}
Phong::~Phong()
@@ -52,8 +57,6 @@
diffusetex->mapValues(context, rays, diffuse);
Color specular[RayPacket::MaxSize];
speculartex->mapValues(context, rays, specular);
- double refl[RayPacket::MaxSize];
- refltex->mapValues(context, rays, refl);
// Compute normals
rays.computeNormals(context);
@@ -61,68 +64,58 @@
// Compute ambient contributions for all rays
activeLights->getAmbientLight()->computeAmbient(context, rays);
+ // We normalized directions for proper dot product computation.
+ rays.normalizeDirections();
+
RayPacketData data;
int start = 0;
+
do {
RayPacket shadowRays(data, 0, rays.getDepth(), 0);
int end = context.shadowAlgorithm->computeShadows(context, activeLights,
rays, start,
shadowRays);
-
- if(shadowRays.getFlags() & RayPacket::NormalizedDirections){
- for(int i=start;i<end;i++){
- RayPacket::Element& e = rays.get(i);
- Color totalDiffuse(e.ambientLight);
- Color totalSpecular = Color::black();
- for(int j=e.shadowBegin;j<e.shadowEnd;j++){
- RayPacket::Element& s = shadowRays.get(j);
- if(!s.hitInfo.wasHit()){
- double cos_theta = Dot(s.ray.direction(), e.normal);
- totalDiffuse += s.light*cos_theta;
- Vector H = s.ray.direction()-e.ray.direction();
- double cos_alpha = Dot(H, e.normal);
- if(cos_alpha > 0){
- double length = H.length();
- totalSpecular += s.light * ipow(cos_alpha/length, specpow);
- }
- }
- }
- rays.setResult(i, diffuse[i]*totalDiffuse+specular[i]*totalSpecular);
- }
- } else {
- for(int i=start;i<end;i++){
- RayPacket::Element& e = rays.get(i);
- Color totalDiffuse(e.ambientLight);
- Color totalSpecular = Color::black();
- for(int j=e.shadowBegin;j<e.shadowEnd;j++){
- RayPacket::Element& s = shadowRays.get(j);
- if(!s.hitInfo.wasHit()){
- s.ray.normalizeDirection();
- double cos_theta = Dot(s.ray.direction(), e.normal);
- totalDiffuse += s.light*cos_theta;
- Vector H = s.ray.direction()-e.ray.direction();
- double cos_alpha = Dot(H, e.normal);
- if(cos_alpha > 0){
- double length = H.length();
- totalSpecular += s.light * ipow(cos_alpha/length, specpow);
- }
- }
- }
- rays.setResult(i, diffuse[i]*totalDiffuse+specular[i]*totalSpecular);
+
+ // We normalized directions for proper dot product computation.
+ shadowRays.normalizeDirections();
+
+ for(int i=start;i<end;i++){
+ RayPacket::Element& e = rays.get(i);
+ // Initialize with the ambient contribution.
+ Color totalDiffuse(e.ambientLight);
+ Color totalSpecular = Color::black();
+ for(int j=e.shadowBegin;j<e.shadowEnd;j++){
+ RayPacket::Element& s = shadowRays.get(j);
+ if(!s.hitInfo.wasHit()){
+ // Not in shadow, so compute the direct and specular contributions.
+ ColorComponent cos_theta = Dot(s.ray.direction(), e.normal);
+ totalDiffuse += s.light*cos_theta;
+ Vector H = s.ray.direction()-e.ray.direction();
+ ColorComponent cos_alpha = Dot(H, e.normal);
+ if(cos_alpha > 0){
+ ColorComponent length = H.length();
+ totalSpecular += s.light * ipow(cos_alpha/length, specpow);
+ }
+ }
}
+ rays.setResult(i, diffuse[i]*totalDiffuse+specular[i]*totalSpecular);
}
start = end;
} while(start < rays.getSize());
// Compute reflections
if(do_refl && rays.getDepth() <
context.scene->getRenderParameters().maxDepth){
+ ColorComponent refl[RayPacket::MaxSize];
+ refltex->mapValues(context, rays, refl);
+
rays.computeHitPositions();
RayPacketData rdata;
RayPacket refl_rays(rdata, rays.getSize(), rays.getDepth()+1,
- RayPacket::NormalizedDirections);
+ RayPacket::NormalizedDirections);
refl_rays.useLocalColors();
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
- Vector refl_dir = e.ray.direction() - e.normal*(2*Dot(e.normal,
e.ray.direction()));
+ Vector refl_dir = (e.ray.direction() -
+ e.normal*(2*Dot(e.normal, e.ray.direction() )));
RayPacket::Element& r = refl_rays.get(i);
r.ray.set(e.hitPosition, refl_dir);
}
Modified: trunk/Model/Materials/Phong.h
==============================================================================
--- trunk/Model/Materials/Phong.h (original)
+++ trunk/Model/Materials/Phong.h Tue Dec 6 16:58:03 2005
@@ -2,6 +2,7 @@
#ifndef Manta_Model_Phong_h
#define Manta_Model_Phong_h
+#include <MantaTypes.h>
#include <Model/Materials/LitMaterial.h>
#include <Core/Color/Color.h>
#include <Interface/Texture.h>
@@ -11,17 +12,19 @@
class Phong : public LitMaterial {
public:
- Phong(const Color& diffuse, const Color& specular, int specpow,
- double refl);
+
+ // Note if refl == 0 the phong shader won't cast a reflected
ray.
+ Phong(const Color& diffuse, const Color& specular,
+ int specpow, ColorComponent refl = 0);
Phong(const Texture<Color>* diffuse, const Texture<Color>* specular,
- int specpow, const Texture<double>* refl);
+ int specpow, const Texture<ColorComponent>* refl);
virtual ~Phong();
virtual void shade(const RenderContext& context, RayPacket& rays) const;
private:
const Texture<Color>* diffusetex;
const Texture<Color>* speculartex;
- const Texture<double>* refltex;
+ const Texture<ColorComponent>* refltex;
int specpow;
bool do_refl;
};
Modified: trunk/Model/MiscObjects/CMakeLists.txt
==============================================================================
--- trunk/Model/MiscObjects/CMakeLists.txt (original)
+++ trunk/Model/MiscObjects/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,4 +1,8 @@
SET (Manta_MiscObjects_SRCS
+ MiscObjects/Difference.h
MiscObjects/Difference.cc
+ MiscObjects/Intersection.h
MiscObjects/Intersection.cc
+ MiscObjects/CuttingPlane.h
+ MiscObjects/CuttingPlane.cc
)
Copied: trunk/Model/MiscObjects/CuttingPlane.cc (from r751,
branches/itanium2/Model/MiscObjects/CuttingPlane.cc)
==============================================================================
--- branches/itanium2/Model/MiscObjects/CuttingPlane.cc (original)
+++ trunk/Model/MiscObjects/CuttingPlane.cc Tue Dec 6 16:58:03 2005
@@ -30,10 +30,11 @@
// Send a new ray packet with new ray origins.
RayPacketData new_data;
- RayPacket new_rays( new_data, rays.getSize(), rays.getDepth(),
rays.getFlags() );
+ RayPacket new_rays( new_data, rays.getSize(), rays.getDepth(),
rays.getAllFlags() );
rays.normalizeDirections();
rays.computeInverseDirections();
+ rays.computeSigns();
// Map between rays in original packet and new packet in case some
rays are skipped.
int packet_map[RayPacket::MaxSize];
@@ -54,7 +55,7 @@
// Check to see if the ray intersects the bounding box.
if (Intersection::intersectAaBox( bounds, box_min, box_max,
-
e.ray, e.signMask, e.inverseDirection )) {
+
e.ray, e.sign, e.inverseDirection )) {
// Intersect the ray with the plane.
Intersection::intersectPlane( plane_point,
plane_normal, plane_t[new_i], e.ray );
Modified: trunk/Model/MiscObjects/Difference.cc
==============================================================================
--- trunk/Model/MiscObjects/Difference.cc (original)
+++ trunk/Model/MiscObjects/Difference.cc Tue Dec 6 16:58:03 2005
@@ -9,7 +9,7 @@
Difference::Difference(Object* object1, Object* object2)
: object1(object1), object2(object2)
{
- throw InternalError("Difference not yet implemented", __FILE__, __LINE__);
+ throw InternalError("Difference not yet implemented", __FILE__, __LINE__ );
}
Difference::~Difference()
@@ -31,10 +31,10 @@
{
RayPacketData raydata1;
RayPacket object1_rays(raydata1, rays.getSize(), rays.getDepth(),
- rays.getFlags());
+ rays.getAllFlags());
RayPacketData raydata2;
RayPacket object2_rays(raydata2, rays.getSize(), rays.getDepth(),
- rays.getFlags());
+ rays.getAllFlags());
for(int i = 0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
Modified: trunk/Model/MiscObjects/Intersection.cc
==============================================================================
--- trunk/Model/MiscObjects/Intersection.cc (original)
+++ trunk/Model/MiscObjects/Intersection.cc Tue Dec 6 16:58:03 2005
@@ -34,10 +34,10 @@
{
RayPacketData raydata1;
RayPacket object1_rays(raydata1, rays.getSize(), rays.getDepth(),
- rays.getFlags());
+ rays.getAllFlags());
RayPacketData raydata2;
RayPacket object2_rays(raydata2, rays.getSize(), rays.getDepth(),
- rays.getFlags());
+ rays.getAllFlags());
for(int i = 0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
Copied: trunk/Model/Primitives/BvhTriangleMesh.cc (from r751,
branches/itanium2/Model/Primitives/BvhTriangleMesh.cc)
==============================================================================
--- branches/itanium2/Model/Primitives/BvhTriangleMesh.cc (original)
+++ trunk/Model/Primitives/BvhTriangleMesh.cc Tue Dec 6 16:58:03 2005
@@ -98,7 +98,7 @@
bbox_intersect[i] = Intersection::intersectAaBox(
node->bounds,
min_t, max_t,
e.ray,
-
e.signMask,
e.inverseDirection,
+
e.sign,
e.inverseDirection,
(Real)0,
e.hitInfo.minT()
);
}
@@ -116,12 +116,12 @@
++begin;
// Determine the first child for the first ray in the packet.
- first_child = rays.get( begin ).signMask[ node->split_axis ];
+ first_child = rays.get( begin ).sign[ node->split_axis ];
// Find the end of this run.
end = begin;
while ((end < rays.getSize()) && (bbox_intersect[end]) &&
- (rays.get( begin ).signMask[ node->split_axis ] ==
first_child))
+ (rays.get( begin ).sign[ node->split_axis ] ==
first_child))
++end;
if ((end > begin) && (begin < rays.getSize())) {
@@ -305,6 +305,7 @@
void BvhTriangleMesh::intersect (const RenderContext& context, RayPacket&
rays) const {
rays.computeInverseDirections();
+ rays.computeSigns();
// Intersect the ray packet with this mesh.
intersect_internal( root, context, rays );
Modified: trunk/Model/Primitives/CMakeLists.txt
==============================================================================
--- trunk/Model/Primitives/CMakeLists.txt (original)
+++ trunk/Model/Primitives/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,26 +1,34 @@
SET (Manta_Primitives_SRCS
+ Primitives/BvhTriangleMesh.cc
+ Primitives/BvhTriangleMesh.h
+ Primitives/Cone.cc
+ Primitives/Cone.h
+ Primitives/Cube.cc
+ Primitives/Cube.h
+ Primitives/Disk.cc
+ Primitives/Disk.h
+ Primitives/HeavyTriangle.cc
+ Primitives/HeavyTriangle.h
+ Primitives/Heightfield.cc
+ Primitives/Heightfield.h
+ Primitives/Hemisphere.cc
+ Primitives/Hemisphere.h
Primitives/Parallelogram.cc
+ Primitives/Parallelogram.h
+ Primitives/ParticleBVH.cc
+ Primitives/ParticleBVH.h
Primitives/PrimitiveCommon.cc
+ Primitives/PrimitiveCommon.h
Primitives/Sphere.cc
+ Primitives/Sphere.h
Primitives/SuperEllipsoid.cc
- Primitives/Cube.cc
- Primitives/Cone.cc
- Primitives/Triangle.cc
- Primitives/HeavyTriangle.cc
+ Primitives/SuperEllipsoid.h
Primitives/TexTriangle.cc
+ Primitives/TexTriangle.h
+ Primitives/Triangle.cc
+ Primitives/Triangle.h
Primitives/VertexColoredTriangle.cc
- Primitives/Disk.cc
- Primitives/Hemisphere.cc
- Primitives/Heightfield.cc
- Primitives/ParticleBVH.cc
+ Primitives/VertexColoredTriangle.h
)
-# Should be include known broken objects?
-IF(BUILD_BROKEN)
- SET (Manta_Primitives_SRCS
- Manta_Primitives_SRCS
- Primitives/Cube.cc
- Primitives/Cone.cc
- )
-ENDIF(BUILD_BROKEN)
Modified: trunk/Model/Primitives/Cone.cc
==============================================================================
--- trunk/Model/Primitives/Cone.cc (original)
+++ trunk/Model/Primitives/Cone.cc Tue Dec 6 16:58:03 2005
@@ -3,12 +3,12 @@
#include <Interface/RayPacket.h>
#include <Core/Geometry/BBox.h>
#include <Core/Util/NotFinished.h>
-#include <math.h>
+#include <Core/Math/Trig.h>
using namespace Manta;
using namespace std;
-Cone::Cone(Material* mat, const Point& bottom, const Point& top, double Rb,
double Rt)
+Cone::Cone(Material* mat, const Point& bottom, const Point& top, Real Rb,
Real Rt)
: PrimitiveCommon(mat, this), bottom(bottom), top(top), Rb(Rb), Rt(Rt)
{
}
@@ -27,109 +27,109 @@
void Cone::intersect(const RenderContext&, RayPacket& rays) const
{
- if(rays.getFlags() & RayPacket::ConstantOrigin) {
+ if(rays.getFlag(RayPacket::ConstantOrigin)) {
RayPacket::Element& e0 = rays.get(0);
Point Pa = bottom + Rb * (top - bottom) / (Rb-Rt);
- double btx = (top.x()-bottom.x())*(top.x()-bottom.x());
- double bty = (top.y()-bottom.y())*(top.y()-bottom.y());
- double btz = (top.z()-bottom.z())*(top.z()-bottom.z());
- double lbt = sqrt(btx+bty+btz);
- double RbRt = Rb-Rt;
- double hyp = sqrt(lbt*lbt + RbRt*RbRt);
+ Real btx = (top.x()-bottom.x())*(top.x()-bottom.x());
+ Real bty = (top.y()-bottom.y())*(top.y()-bottom.y());
+ Real btz = (top.z()-bottom.z())*(top.z()-bottom.z());
+ Real lbt = Sqrt(btx+bty+btz);
+ Real RbRt = Rb-Rt;
+ Real hyp = Sqrt(lbt*lbt + RbRt*RbRt);
Vector Va = (top-bottom) / lbt;
- // double tgAlpha = (Rb-Rt) / lbt;
- double cosA = RbRt/hyp;
- double sinA = lbt/hyp;
- double cosA2 = cosA*cosA;
- double sinA2 = sinA*sinA;
+ // Real tgAlpha = (Rb-Rt) / lbt;
+ Real cosA = RbRt/hyp;
+ Real sinA = lbt/hyp;
+ Real cosA2 = cosA*cosA;
+ Real sinA2 = sinA*sinA;
Point P(xform * e0.ray.origin());
Vector dP(P - Pa);
for(int i=0; i<rays.getSize(); i++) {
RayPacket::Element& e = rays.get(i);
Vector V(xform * e.ray.direction());
Vector tv = V;
- double dist_scale = tv.normalize();
- double a = (cosA2*Dot(V-Dot(V,Va)*Va, V-Dot(V,Va)*Va))-
- (sinA2*Dot(V,Va)*Dot(V,Va));
- double b = 2*cosA2*Dot(V-Dot(V,Va)*Va, dP-Dot(dP,Va)*Va)-
- 2*sinA2*Dot(V,Va)*Dot(dP,Va);
- double c = cosA2*Dot(dP-Dot(dP,Va)*Va,
- dP-Dot(dP,Va)*Va)-
- sinA2*Dot(dP,Va)*Dot(dP,Va);
-
- double d = sqrt(b*b-4*a*c);
-
+ Real dist_scale = tv.normalize();
+ Real a = ((cosA2*Dot(V-Dot(V,Va)*Va, V-Dot(V,Va)*Va))-
+ (sinA2*Dot(V,Va)*Dot(V,Va)));
+ Real b = (2*cosA2*Dot(V-Dot(V,Va)*Va, dP-Dot(dP,Va)*Va)-
+ 2*sinA2*Dot(V,Va)*Dot(dP,Va));
+ Real c = (cosA2*Dot(dP-Dot(dP,Va)*Va,
+ dP-Dot(dP,Va)*Va)-
+ sinA2*Dot(dP,Va)*Dot(dP,Va));
+
+ Real d = Sqrt(b*b-4*a*c);
+
if(d > 0.0) {
- double t1 = (-b+d)/(2*a);
- double t2 = (-b-d)/(2*a);
-
- if(t1 < t2) {
- double temp = t1;
- t1 = t2;
- t2 = temp;
- }
-
- double z1 = P.z()+t1*V.z();
- double z2 = P.z()+t2*V.z();
- if(t1>0 && z1 > 0.0 && z1 < 1.0) {
- e.hitInfo.hit(t1/dist_scale, material, this, tex);
- }
- if(t2>0 && z2 > 0.0 && z2 < 1.0) {
- e.hitInfo.hit(t2/dist_scale, material, this, tex);
- }
+ Real t1 = (-b+d)/(2*a);
+ Real t2 = (-b-d)/(2*a);
+
+ if(t1 < t2) {
+ Real temp = t1;
+ t1 = t2;
+ t2 = temp;
+ }
+
+ Real z1 = P.z()+t1*V.z();
+ Real z2 = P.z()+t2*V.z();
+ if(t1>0 && z1 > 0 && z1 < 1) {
+ e.hitInfo.hit(t1/dist_scale, material, this, tex);
+ }
+ if(t2>0 && z2 > 0 && z2 < 1) {
+ e.hitInfo.hit(t2/dist_scale, material, this, tex);
+ }
}
}
}
else {
Point Pa = bottom + Rb * (top - bottom) / (Rb-Rt);
- double btx = (top.x()-bottom.x())*(top.x()-bottom.x());
- double bty = (top.y()-bottom.y())*(top.y()-bottom.y());
- double btz = (top.z()-bottom.z())*(top.z()-bottom.z());
- double lbt = sqrt(btx+bty+btz);
- double RbRt = Rb-Rt;
- double hyp = sqrt(lbt*lbt + RbRt*RbRt);
-
+ Real btx = (top.x()-bottom.x())*(top.x()-bottom.x());
+ Real bty = (top.y()-bottom.y())*(top.y()-bottom.y());
+ Real btz = (top.z()-bottom.z())*(top.z()-bottom.z());
+ Real lbt = Sqrt(btx+bty+btz);
+ Real RbRt = Rb-Rt;
+ Real hyp = Sqrt(lbt*lbt + RbRt*RbRt);
+
Vector Va = (top-bottom) / lbt;
- // double tgAlpha = (Rb-Rt) / lbt;
- double cosA = RbRt/hyp;
- double sinA = lbt/hyp;
- double cosA2 = cosA*cosA;
- double sinA2 = sinA*sinA;
+ // Real tgAlpha = (Rb-Rt) / lbt;
+ Real cosA = RbRt/hyp;
+ Real sinA = lbt/hyp;
+ Real cosA2 = cosA*cosA;
+ Real sinA2 = sinA*sinA;
for(int i=0; i<rays.getSize(); i++) {
RayPacket::Element& e = rays.get(i);
Point P(xform * e.ray.origin());
Vector dP(P - Pa);
Vector V(xform * e.ray.direction());
Vector tv = V;
- double dist_scale = tv.normalize();
- double a = (cosA2*Dot(V-Dot(V,Va)*Va, V-Dot(V,Va)*Va))-
- (sinA2*Dot(V,Va)*Dot(V,Va));
- double b = 2*cosA2*Dot(V-Dot(V,Va)*Va, dP-Dot(dP,Va)*Va)-
- 2*sinA2*Dot(V,Va)*Dot(dP,Va);
- double c = cosA2*Dot(dP-Dot(dP,Va)*Va, dP-Dot(dP,Va)*Va)-
- sinA2*Dot(dP,Va)*Dot(dP,Va);
-
- double d = sqrt(b*b-4*a*c);
-
- if(d > 0.0) {
- double t1 = (-b+d)/(2*a);
- double t2 = (-b-d)/(2*a);
-
- if(t1 < t2) {
- double temp = t1;
- t1 = t2;
- t2 = temp;
- }
-
- double z1 = P.z()+t1*V.z();
- double z2 = P.z()+t2*V.z();
- if(t1>0 && z1 > 0.0 && z1 < 1.0) {
- e.hitInfo.hit(t1/dist_scale, material, this, tex);
- }
- if(t2>0 && z2 > 0.0 && z2 < 1.0) {
- e.hitInfo.hit(t2/dist_scale, material, this, tex);
- }
+ Real dist_scale = tv.normalize();
+ Real a = ((cosA2*Dot(V-Dot(V,Va)*Va, V-Dot(V,Va)*Va))-
+ (sinA2*Dot(V,Va)*Dot(V,Va)));
+ Real b = (2*cosA2*Dot(V-Dot(V,Va)*Va, dP-Dot(dP,Va)*Va)-
+ 2*sinA2*Dot(V,Va)*Dot(dP,Va));
+ Real c = (cosA2*Dot(dP-Dot(dP,Va)*Va, dP-Dot(dP,Va)*Va)-
+ sinA2*Dot(dP,Va)*Dot(dP,Va));
+
+ Real d = Sqrt(b*b-4*a*c);
+
+ if(d > 0) {
+ Real t1 = (-b+d)/(2*a);
+ Real t2 = (-b-d)/(2*a);
+
+ if(t1 < t2) {
+ Real temp = t1;
+ t1 = t2;
+ t2 = temp;
+ }
+
+ Real z1 = P.z()+t1*V.z();
+ Real z2 = P.z()+t2*V.z();
+ if(t1>0 && z1 > 0 && z1 < 1) {
+ e.hitInfo.hit(t1/dist_scale, material, this, tex);
+ }
+ if(t2>0 && z2 > 0 && z2 < 1) {
+ e.hitInfo.hit(t2/dist_scale, material, this, tex);
+ }
}
}
}
@@ -143,7 +143,7 @@
RayPacket::Element& e = rays.get(i);
#if 0
Vector xn(xform.project(e.hitPosition).asVector());
- xn.z(0.0);
+ xn.z(0);
Vector v=ixform.project(xn);
v.normalize();
e.normal = v;
Modified: trunk/Model/Primitives/Cone.h
==============================================================================
--- trunk/Model/Primitives/Cone.h (original)
+++ trunk/Model/Primitives/Cone.h Tue Dec 6 16:58:03 2005
@@ -12,7 +12,7 @@
class Cone : public PrimitiveCommon, public TexCoordMapper {
public:
- Cone(Material* mat, const Point& bottom, const Point& top, double Rb,
double Rt);
+ Cone(Material* mat, const Point& bottom, const Point& top, Real Rb, Real
Rt);
virtual ~Cone();
virtual void computeBounds(const PreprocessContext& context,
@@ -26,7 +26,7 @@
private:
Point bottom, top;
- double Rb, Rt;
+ Real Rb, Rt;
AffineTransform xform, ixform;
};
}
Modified: trunk/Model/Primitives/Cube.cc
==============================================================================
--- trunk/Model/Primitives/Cube.cc (original)
+++ trunk/Model/Primitives/Cube.cc Tue Dec 6 16:58:03 2005
@@ -4,30 +4,74 @@
#include <Core/Math/MiscMath.h>
#include <Core/Math/MinMax.h>
+#include <Model/Intersections/AxisAlignedBox.h>
+
using namespace Manta;
using namespace std;
using SCIRun::Abs;
Cube::Cube(Material* mat, const Point& anch, double w, double h, double d)
- : PrimitiveCommon(mat), anchor(anch), w(w), h(h), d(d)
+ : PrimitiveCommon(mat)
{
+
+ bbox[0] = anch;
+ bbox[1] = anch + Vector(w,h,d);
+#if 0
xmin = anchor.x(); xmax = xmin + w;
ymin = anchor.y(); ymax = ymin + h;
zmin = anchor.z(); zmax = zmin + d;
+#endif
}
Cube::~Cube()
{
}
-void Cube::computeBounds(const PreprocessContext&, BBox& bbox) const
+void Cube::computeBounds(const PreprocessContext&, BBox& bbox_) const
{
- bbox.extendByPoint(Point(xmin, ymin, zmin));
- bbox.extendByPoint(Point(xmax, ymax, zmax));
+ // bbox.extendByPoint(Point(xmin, ymin, zmin));
+ // bbox.extendByPoint(Point(xmax, ymax, zmax));
+ bbox_.extendByPoint( bbox[0] );
+ bbox_.extendByPoint( bbox[1] );
}
void Cube::intersect(const RenderContext&, RayPacket& rays) const
-{
+{
+
+ // Intersection algorithm requires inverse directions computed.
+ rays.computeInverseDirections();
+ rays.computeSigns();
+
+ // Iterate over each ray.
+ for (int i=0;i<rays.getSize();++i) {
+
+ RayPacket::Element &e = rays.get(i);
+
+ Real tmin, tmax;
+
+ // Check for an intersection.
+ if (Intersection::intersectAaBox( bbox,
+ tmin,
+ tmax,
+ e.ray,
+ e.sign,
+ e.inverseDirection/*,
+
e.hitInfo.minT()*/)) {
+
+ // Check to see if we are inside the box.
+ if (tmin > 0.0) {
+ e.hitInfo.hit( tmin, material, this, tex );
+ }
+
+ // And use the max intersection if we are.
+ else
+ e.hitInfo.hit( tmax, material, this, tex );
+ }
+
+ }
+
+
+#if 0
using SCIRun::Max;
using SCIRun::Min;
rays.computeInverseDirections();
@@ -120,6 +164,8 @@
}
}
}
+
+#endif
}
@@ -127,17 +173,24 @@
{
rays.computeHitPositions();
for(int i=0; i<rays.getSize(); i++) {
+
RayPacket::Element& e = rays.get(i);
- if (Abs(e.hitPosition.x() - xmin) < 0.0001)
+
+ if (Abs(e.hitPosition.x() - bbox[0][0]) < 0.0001)
e.normal = Vector(-1, 0, 0 );
- else if (Abs(e.hitPosition.x() - xmax) < 0.0001)
+
+ else if (Abs(e.hitPosition.x() - bbox[1][0]) < 0.0001)
e.normal = Vector( 1, 0, 0 );
- else if (Abs(e.hitPosition.y() - ymin) < 0.0001)
+
+ else if (Abs(e.hitPosition.y() - bbox[0][1]) < 0.0001)
e.normal = Vector( 0,-1, 0 );
- else if (Abs(e.hitPosition.y() - ymax) < 0.0001)
+
+ else if (Abs(e.hitPosition.y() - bbox[1][1]) < 0.0001)
e.normal = Vector( 0, 1, 0 );
- else if (Abs(e.hitPosition.z() - ymin) < 0.0001)
+
+ else if (Abs(e.hitPosition.z() - bbox[0][2]) < 0.0001)
e.normal = Vector( 0, 0,-1 );
+
else
e.normal = Vector( 0, 0, 1 );
}
Modified: trunk/Model/Primitives/Cube.h
==============================================================================
--- trunk/Model/Primitives/Cube.h (original)
+++ trunk/Model/Primitives/Cube.h Tue Dec 6 16:58:03 2005
@@ -4,6 +4,7 @@
#include <Model/Primitives/PrimitiveCommon.h>
#include <Core/Geometry/PointVector.h>
+#include <Core/Geometry/BBox.h>
namespace Manta
{
@@ -11,6 +12,8 @@
class Cube : public PrimitiveCommon {
public:
Cube(Material* mat, const Point& anch, double w, double h, double d);
+ Cube(Material *mat, const Point &min_, const Point &max_ ) :
+ PrimitiveCommon( mat ), bbox( min_, max_ ) { }
~Cube();
virtual void computeBounds(const PreprocessContext& context,
@@ -19,11 +22,14 @@
virtual void computeNormal(const RenderContext& context, RayPacket
&rays) const;
private:
+ BBox bbox;
+#if 0
Point anchor;
double w,h,d;
double xmin, xmax;
double ymin, ymax;
double zmin, zmax;
+#endif
};
}
Modified: trunk/Model/Primitives/Disk.cc
==============================================================================
--- trunk/Model/Primitives/Disk.cc (original)
+++ trunk/Model/Primitives/Disk.cc Tue Dec 6 16:58:03 2005
@@ -5,13 +5,13 @@
using namespace Manta;
using namespace std;
-Disk::Disk(Material* mat, const Point& center, const Vector& n, double
radius, const Vector& axis) : PrimitiveCommon(mat, this), _c(center), _n(n),
_r(radius), _partial(false), _minTheta(0.0), _maxTheta(2.0 * M_PI) {
+Disk::Disk(Material* mat, const Point& center, const Vector& n, Real radius,
const Vector& axis) : PrimitiveCommon(mat, this), _c(center), _n(n),
_r(radius), _partial(false), _minTheta(0.0), _maxTheta(2.0 * M_PI) {
_n.normalize();
_d = -Dot(_n, _c);
setupAxes(axis);
}
-Disk::Disk(Material* mat, const Point& center, const Vector& n, double
radius, const Vector& axis, double minTheta, double maxTheta) :
PrimitiveCommon(mat, this), _c(center), _n(n), _r(radius), _partial(true),
_minTheta(minTheta), _maxTheta(maxTheta) {
+Disk::Disk(Material* mat, const Point& center, const Vector& n, Real radius,
const Vector& axis, Real minTheta, Real maxTheta) : PrimitiveCommon(mat,
this), _c(center), _n(n), _r(radius), _partial(true), _minTheta(minTheta),
_maxTheta(maxTheta) {
_n.normalize();
_d = -Dot(_n, _c);
setupAxes(axis);
@@ -20,20 +20,22 @@
Disk::~Disk() {
}
-void Disk::computeBounds(const PreprocessContext& context, BBox& bbox) const
{
+void Disk::computeBounds(const PreprocessContext& /*context*/,
+ BBox& bbox) const
+{
bbox.extendByDisc(_c, _n, _r);
}
-void Disk::intersect(const RenderContext& context, RayPacket& rays) const {
+void Disk::intersect(const RenderContext& /*context*/, RayPacket& rays)
const {
int i, numRays(rays.getSize());
- const static double EPSILON(1.0e-6);
+ static const Real EPSILON(1.0e-6);
Point rayO;
Vector rayD;
- double denom, t;
+ Real denom, t;
- if (rays.getFlags() & RayPacket::ConstantOrigin) {
+ if (rays.getFlag(RayPacket::ConstantOrigin)) {
rayO = rays.get(0).ray.origin();
- double nDotO(Dot(_n, rayO));
+ Real nDotO(Dot(_n, rayO));
for (i = 0; i < numRays; i++) {
RayPacket::Element& e(rays.get(i));
@@ -41,10 +43,10 @@
denom = Dot(_n, rayD);
if ((denom < -EPSILON) || (denom > EPSILON)) {
- t = -(_d + nDotO) / denom;
- if (checkBounds(rayO + t * rayD)) {
- e.hitInfo.hit(t, material, this, tex);
- }
+ t = -(_d + nDotO) / denom;
+ if (checkBounds(rayO + t * rayD)) {
+ e.hitInfo.hit(t, material, this, tex);
+ }
}
}
} else {
@@ -55,17 +57,18 @@
denom = Dot(_n, rayD);
if ((denom < -EPSILON) || (denom > EPSILON)) {
- t = -(_d + Dot(_n, rayO)) / denom;
- if (checkBounds(rayO + t * rayD)) {
- e.hitInfo.hit(t, material, this, tex);
- }
+ t = -(_d + Dot(_n, rayO)) / denom;
+ if (checkBounds(rayO + t * rayD)) {
+ e.hitInfo.hit(t, material, this, tex);
+ }
}
}
}
}
-void Disk::computeNormal(const RenderContext& context, RayPacket& rays)
const {
+void Disk::computeNormal(const RenderContext& /*context*/,
+ RayPacket& rays) const {
int i, numRays(rays.getSize());
for (i = 0; i < numRays; i++) {
@@ -77,12 +80,13 @@
rays.setFlag(RayPacket::HaveNormals & RayPacket::HaveUnitNormals);
}
-void Disk::computeTexCoords2(const RenderContext& context, RayPacket& rays)
const {
+void Disk::computeTexCoords2(const RenderContext& /*context*/,
+ RayPacket& rays) const {
int i, numRays(rays.getSize());
Point p;
// compute hit locations if necessary
- if (!(rays.getFlags() & RayPacket::HaveHitPositions))
+ if (!(rays.getFlag(RayPacket::HaveHitPositions)))
rays.computeHitPositions();
// set 2-d texture coordinates as returned by getTexCoords()
@@ -97,12 +101,13 @@
rays.setFlag(RayPacket::HaveTexture2);
}
-void Disk::computeTexCoords3(const RenderContext& context, RayPacket& rays)
const {
+void Disk::computeTexCoords3(const RenderContext& /*context*/,
+ RayPacket& rays) const {
int i, numRays(rays.getSize());
Point p;
// compute hit locations if necessary
- if (!(rays.getFlags() & RayPacket::HaveHitPositions))
+ if (!(rays.getFlag(RayPacket::HaveHitPositions)))
rays.computeHitPositions();
// set 3-d texture coordinates to be the hit locations
@@ -124,16 +129,16 @@
**/
bool Disk::checkBounds(const Point& p) const {
Vector dir(p - _c);
- double dist(dir.normalize());
+ Real dist(dir.normalize());
if (dist > _r)
return false;
if (_partial) {
- double theta(atan2(Dot(_v, dir), Dot(_u, dir)));
+ Real theta(atan2(Dot(_v, dir), Dot(_u, dir)));
- if (theta < 0.0)
- theta = 2.0 * M_PI + theta;
+ if (theta < 0)
+ theta = 2 * (Real)M_PI + theta;
if ((theta < _minTheta) || (theta > _maxTheta))
return false;
}
@@ -151,7 +156,7 @@
* given vector.
**/
void Disk::setupAxes(const Vector& axis) {
- const static double EPSILON(1.0e-6);
+ static const Real EPSILON(1.0e-6);
_u = axis;
_u.normalize();
@@ -176,13 +181,13 @@
**/
void Disk::getTexCoords(Point& p) const {
Vector dir(p - _c);
- double dist(dir.normalize()), theta;
+ Real dist(dir.normalize()), theta;
theta = atan2(Dot(_v, dir), Dot(_u, dir));
if (theta < 0.0)
- theta = 2.0 * M_PI + theta;
+ theta = 2 * (Real)M_PI + theta;
- p = Point(dist / _r, (theta - _minTheta) / (_maxTheta - _minTheta), 0.0);
+ p = Point(dist / _r, (theta - _minTheta) / (_maxTheta - _minTheta), 0);
}
Modified: trunk/Model/Primitives/Disk.h
==============================================================================
--- trunk/Model/Primitives/Disk.h (original)
+++ trunk/Model/Primitives/Disk.h Tue Dec 6 16:58:03 2005
@@ -9,8 +9,8 @@
namespace Manta {
class Disk : public PrimitiveCommon, public TexCoordMapper {
public:
- Disk(Material* mat, const Point& center, const Vector& n, double radius,
const Vector& axis);
- Disk(Material* mat, const Point& center, const Vector& n, double radius,
const Vector& axis, double minTheta, double maxTheta);
+ Disk(Material* mat, const Point& center, const Vector& n, Real radius,
const Vector& axis);
+ Disk(Material* mat, const Point& center, const Vector& n, Real radius,
const Vector& axis, Real minTheta, Real maxTheta);
virtual ~Disk();
virtual void computeBounds(const PreprocessContext& context, BBox& bbox)
const;
@@ -24,7 +24,7 @@
bool _partial;
Point _c;
Vector _n, _u, _v;
- double _d, _r, _minTheta, _maxTheta;
+ Real _d, _r, _minTheta, _maxTheta;
bool checkBounds(const Point& p) const;
void setupAxes(const Vector& axis);
Modified: trunk/Model/Primitives/HeavyTriangle.cc
==============================================================================
--- trunk/Model/Primitives/HeavyTriangle.cc (original)
+++ trunk/Model/Primitives/HeavyTriangle.cc Tue Dec 6 16:58:03 2005
@@ -29,23 +29,23 @@
RayPacket::Element& e = rays.get(i);
const Vector& dir(e.ray.direction());
Vector o(p1 - e.ray.origin());
-
- double det=Dot(n,dir);
- if(det>1.e-9 || det < -1.e-9) {
- double idet = 1./det;
+
+ Real det=Dot(n,dir);
+ if(det > (Real)1.e-9 || det < (Real)-1.e-9) {
+ Real idet = 1/det;
Vector DX(Cross(dir, o));
- double A=-Dot(DX, e2)*idet;
- if(A>0.0 && A<1.0) {
- double B=Dot(DX, e1)*idet;
- if(B>0.0 && A+B<1.0) {
- double t=Dot(n, o)*idet;
- if (e.hitInfo.hit(t, material, this, tex)){
+ Real A=-Dot(DX, e2)*idet;
+ if( A>0 && A<1 ) {
+ Real B=Dot(DX, e1)*idet;
+ if( B>0 && A+B<1 ) {
+ Real t=Dot(n, o)*idet;
+ if (e.hitInfo.hit(t, material, this, tex)){
TriangleHit& th = e.hitInfo.scratchpad<TriangleHit>();
th.a = A;
th.b = B;
}
- }
+ }
}
}
}
@@ -56,8 +56,8 @@
{
rays.computeHitPositions();
- if (rays.getFlags() & RayPacket::HaveNormals){
- if (rays.getFlags() & RayPacket::HaveUnitNormals)
+ if (rays.getFlag(RayPacket::HaveNormals)){
+ if (rays.getFlag(RayPacket::HaveUnitNormals))
return;
int nrays = rays.getSize();
Modified: trunk/Model/Primitives/Heightfield.cc
==============================================================================
--- trunk/Model/Primitives/Heightfield.cc (original)
+++ trunk/Model/Primitives/Heightfield.cc Tue Dec 6 16:58:03 2005
@@ -41,7 +41,7 @@
//
--------------------------------------------------------------------------------------
// --- Constructor
//
--------------------------------------------------------------------------------------
-Heightfield::Heightfield(Material * material, char * fileName, const Point &
minBound, const Point & maxBound, double scale)
+Heightfield::Heightfield(Material * material, char * fileName, const Point &
minBound, const Point & maxBound, Real scale)
: PrimitiveCommon(material), m_Box(minBound, maxBound)
{
readHeightfieldFile(fileName, &m_Nx, &m_Ny, &m_Data);
@@ -61,7 +61,8 @@
//
--------------------------------------------------------------------------------------
// --- Get the Bounding Box
//
--------------------------------------------------------------------------------------
-void Heightfield::computeBounds(const PreprocessContext & context, BBox &
bbox) const
+void Heightfield::computeBounds(const PreprocessContext& /*context*/,
+ BBox & bbox) const
{
bbox.extendByPoint(m_Box.getMin());
bbox.extendByPoint(m_Box.getMax());
@@ -71,16 +72,17 @@
//
--------------------------------------------------------------------------------------
// --- Test whether the ray intersects the Heightfield or not
//
--------------------------------------------------------------------------------------
-void Heightfield::intersect(const RenderContext & context, RayPacket & rays)
const
+void Heightfield::intersect(const RenderContext& /*context*/,
+ RayPacket& rays) const
{
Vector diagonal;
Point hitPoint;
int hitLattice[2], stop[2], di[2], ind;
- double tnext[2], dtd[2], far[2], zm[2], datam[2], cellSize[2];
- double tnear, tfar, zenter, texit, zexit;
+ Real tnext[2], dtd[2], far[2], zm[2], datam[2], cellSize[2];
+ Real tnear, tfar, zenter, texit, zexit;
bool validtcells[2];
- if (!(rays.getFlags() & RayPacket::NormalizedDirections))
+ if (!(rays.getFlag(RayPacket::NormalizedDirections)))
{
rays.normalizeDirections();
rays.setFlag(RayPacket::NormalizedDirections);
@@ -111,8 +113,8 @@
tnear = 0.0;
diagonal = m_Box.diagonal();
- cellSize[0] = diagonal.x() / (double)m_Nx;
- cellSize[1] = diagonal.y() / (double)m_Ny;
+ cellSize[0] = diagonal.x() / (Real)m_Nx;
+ cellSize[1] = diagonal.y() / (Real)m_Ny;
hitPoint = ray.origin() + (ray.direction() * tnear);
hitLattice[0] = (int)((hitPoint.x() - m_Box.getMin().x()) / cellSize[0]);
@@ -131,15 +133,15 @@
dtd[0] = fabs(cellSize[0] / ray.direction().x());
dtd[1] = fabs(cellSize[1] / ray.direction().y());
- if (di[0] == 1) far[0] = m_Box.getMin().x() + cellSize[0] *
(double)(hitLattice[0] + 1);
- else far[0] = m_Box.getMin().x() + cellSize[0] *
(double)(hitLattice[0] );
- if (di[1] == 1) far[1] = m_Box.getMin().y() + cellSize[1] *
(double)(hitLattice[1] + 1);
- else far[1] = m_Box.getMin().y() + cellSize[1] *
(double)(hitLattice[1] );
+ if (di[0] == 1) far[0] = m_Box.getMin().x() + cellSize[0] *
(Real)(hitLattice[0] + 1);
+ else far[0] = m_Box.getMin().x() + cellSize[0] *
(Real)(hitLattice[0] );
+ if (di[1] == 1) far[1] = m_Box.getMin().y() + cellSize[1] *
(Real)(hitLattice[1] + 1);
+ else far[1] = m_Box.getMin().y() + cellSize[1] *
(Real)(hitLattice[1] );
tnext[0] = (far[0] - ray.origin().x()) / ray.direction().x();
tnext[1] = (far[1] - ray.origin().y()) / ray.direction().y();
- while(true)
+ for(;;)
{
zenter = ray.origin().z() + (tnear * ray.direction().z());
texit = Min(tnext[0], tnext[1]);
@@ -154,14 +156,14 @@
if (!(zm[0] > datam[1] || zm[1] < datam[0]))
{
- double a, b, c;
- double sx, dx, sy, dy;
+ Real a, b, c;
+ Real sx, dx, sy, dy;
Point pe;
- double ce[2], z[4];
+ Real ce[2], z[4];
pe = ray.origin() + ray.direction() * tnear;
- ce[0] = pe.x() - (m_Box.getMin().x() + cellSize[0] *
(double)(hitLattice[0]));
- ce[1] = pe.y() - (m_Box.getMin().y() + cellSize[1] *
(double)(hitLattice[1]));
+ ce[0] = pe.x() - (m_Box.getMin().x() + cellSize[0] *
(Real)(hitLattice[0]));
+ ce[1] = pe.y() - (m_Box.getMin().y() + cellSize[1] *
(Real)(hitLattice[1]));
sx = ce[0] / cellSize[0];
sy = ce[1] / cellSize[1];
@@ -179,7 +181,7 @@
if (a == 0.0)
{
- double tcell, u, v;
+ Real tcell, u, v;
tcell = -c / b;
u = sx + tcell * dx;
@@ -194,13 +196,13 @@
}
else
{
- double delta = b*b - 4.0*a*c;
+ Real delta = b*b - 4*a*c;
if (delta >= 0.0)
{
- double tcells[2], a2, u, v, tcell;
+ Real tcells[2], a2, u, v, tcell;
delta = sqrt(delta);
- a2 = 2.0 * a;
+ a2 = 2 * a;
tcells[0] = (-b - delta) / a2;
tcells[1] = (-b + delta) / a2;
@@ -243,7 +245,8 @@
//
--------------------------------------------------------------------------------------
// --- Set the normals
//
--------------------------------------------------------------------------------------
-void Heightfield::computeNormal(const RenderContext & context, RayPacket &
rays) const
+void Heightfield::computeNormal(const RenderContext& /*context*/,
+ RayPacket& rays) const
{
int i, numRays(rays.getSize());
@@ -263,13 +266,13 @@
// --- Rescale the height of the data to fit the Box
// --- according to the given percentage of the size of the box to which the
data should be rescaled
//
--------------------------------------------------------------------------------------
-void Heightfield::rescaleDataHeight(double scale)
+void Heightfield::rescaleDataHeight(Real scale)
{
using SCIRun::Min;
using SCIRun::Max;
unsigned int i, j;
- double min, max, factor, margin;
+ Real min, max, factor, margin;
min = m_Data[0][0];
max = min;
@@ -281,7 +284,7 @@
}
factor = m_Box.getMax().z() - m_Box.getMin().z();
- margin = factor * (1.0 - scale) * 0.5;
+ margin = factor * (1 - scale) * (Real)0.5;
factor *= scale / (max - min);
for(i=0; i<=m_Nx; i++)
@@ -293,9 +296,9 @@
//
--------------------------------------------------------------------------------------
// --- Read the given file and returns nx, ny and the data
//
--------------------------------------------------------------------------------------
-void Heightfield::readHeightfieldFile(char * fileName, unsigned int * pnx,
unsigned int * pny, double *** pdata)
+void Heightfield::readHeightfieldFile(char * fileName, unsigned int * pnx,
unsigned int * pny, Real *** pdata)
{
- double minz, maxz;
+ Real minz, maxz;
int nx, ny, i, j;
float ** data;
@@ -324,10 +327,10 @@
*pnx = nx;
*pny = ny;
- ALLOCATE2DARRAY(*pdata, nx+1, ny+1, double);
+ ALLOCATE2DARRAY(*pdata, nx+1, ny+1, Real);
for(i=0; i<=nx; i++)
for(j=0; j<=ny; j++)
- (*pdata)[i][j] = (double)data[i][j];
+ (*pdata)[i][j] = (Real)data[i][j];
// DELETE2DARRAY(data, nx+1);
}
Modified: trunk/Model/Primitives/Heightfield.h
==============================================================================
--- trunk/Model/Primitives/Heightfield.h (original)
+++ trunk/Model/Primitives/Heightfield.h Tue Dec 6 16:58:03 2005
@@ -14,21 +14,21 @@
public:
- Heightfield(Material * material, char * fileName, const
Point & minBound, const Point & maxBound, double scale = 0.95);
+ Heightfield(Material * material, char * fileName, const
Point & minBound, const Point & maxBound, Real scale = 0.95);
virtual ~Heightfield();
virtual void computeBounds(const PreprocessContext & context, BBox &
bbox) const;
virtual void intersect(const RenderContext & context, RayPacket &
rays) const;
virtual void computeNormal(const RenderContext & context, RayPacket &
rays) const;
- virtual void rescaleDataHeight(double scale);
- virtual void readHeightfieldFile(char * fileName, unsigned int * pnx,
unsigned int * pny, double *** pdata);
+ virtual void rescaleDataHeight(Real scale);
+ virtual void readHeightfieldFile(char * fileName, unsigned int * pnx,
unsigned int * pny, Real *** pdata);
private:
BBox m_Box;
unsigned int m_Nx;
unsigned int m_Ny;
- double ** m_Data;
+ Real ** m_Data;
};
}
Modified: trunk/Model/Primitives/Hemisphere.cc
==============================================================================
--- trunk/Model/Primitives/Hemisphere.cc (original)
+++ trunk/Model/Primitives/Hemisphere.cc Tue Dec 6 16:58:03 2005
@@ -9,7 +9,7 @@
using namespace Manta;
using namespace std;
-Hemisphere::Hemisphere(Material* material, const Point& center, double
radius, const Vector& normal)
+Hemisphere::Hemisphere(Material* material, const Point& center, Real radius,
const Vector& normal)
: PrimitiveCommon(material, this), _c(center), _r(radius), _n(normal) {
setupAxes();
}
@@ -23,8 +23,8 @@
void Hemisphere::intersect(const RenderContext&, RayPacket& rays) const {
int i, numRays(rays.getSize()),
- rpFlags(rays.getFlags() & (RayPacket::ConstantOrigin |
RayPacket::NormalizedDirections));
- double a, b, c, disc, r, t;
+ rpFlags(rays.getAllFlags() & (RayPacket::ConstantOrigin |
RayPacket::NormalizedDirections));
+ Real a, b, c, disc, r, t;
Point rayO;
Vector rayD, tRayO;
@@ -139,10 +139,11 @@
}
}
-void Hemisphere::computeNormal(const RenderContext& context, RayPacket&
rays) const {
+void Hemisphere::computeNormal(const RenderContext& /*context*/,
+ RayPacket& rays) const {
int i, numRays(rays.getSize());
- if (!(rays.getFlags() & RayPacket::HaveHitPositions))
+ if (!(rays.getFlag(RayPacket::HaveHitPositions)))
rays.computeHitPositions();
for (i = 0; i < numRays; i++) {
@@ -157,9 +158,9 @@
void Hemisphere::computeTexCoords2(const RenderContext& context, RayPacket&
rays) const {
int i, numRays(rays.getSize());
Vector n;
- double theta, phi;
+ Real theta, phi;
- if (!(rays.getFlags() & RayPacket::HaveUnitNormals))
+ if (!(rays.getFlag(RayPacket::HaveUnitNormals)))
computeNormal(context, rays);
for (i = 0; i < numRays; i++) {
@@ -177,7 +178,7 @@
int i, numRays(rays.getSize());
Vector n;
- if (!(rays.getFlags() & RayPacket::HaveHitPositions))
+ if (!(rays.getFlag(RayPacket::HaveHitPositions)))
rays.computeHitPositions();
for (i = 0; i < numRays; i++) {
@@ -199,12 +200,12 @@
}
void Hemisphere::setupAxes() {
- const static double EPSILON(1.0e-6);
+ static const Real EPSILON(1.0e-6);
- _u = Vector(1.0, 0.0, 0.0);
+ _u = Vector(1, 0, 0);
_v = Cross(_n, _u);
if (_v.length2() < EPSILON) {
- _u = Vector(0.0, 1.0, 0.0);
+ _u = Vector(0, 1, 0);
_v = Cross(_n, _u);
}
_v.normalize();
Modified: trunk/Model/Primitives/Hemisphere.h
==============================================================================
--- trunk/Model/Primitives/Hemisphere.h (original)
+++ trunk/Model/Primitives/Hemisphere.h Tue Dec 6 16:58:03 2005
@@ -8,7 +8,7 @@
namespace Manta {
class Hemisphere : public PrimitiveCommon, public TexCoordMapper {
public:
- Hemisphere(Material* material, const Point& center, double radius, const
Vector& normal);
+ Hemisphere(Material* material, const Point& center, Real radius, const
Vector& normal);
virtual ~Hemisphere();
virtual void computeBounds(const PreprocessContext& context, BBox& bbox)
const;
@@ -20,7 +20,7 @@
private:
Point _c;
- double _r;
+ Real _r;
Vector _n, _u, _v;
bool checkBounds(const Point& p) const;
Modified: trunk/Model/Primitives/Parallelogram.cc
==============================================================================
--- trunk/Model/Primitives/Parallelogram.cc (original)
+++ trunk/Model/Primitives/Parallelogram.cc Tue Dec 6 16:58:03 2005
@@ -47,51 +47,51 @@
// affect this value. You should be doing this dot product against
// normalized vectors anyway.
rays.normalizeDirections();
- if(rays.getFlags() & RayPacket::ConstantOrigin && rays.getSize()>1){
+ if(rays.getAllFlags() & RayPacket::ConstantOrigin && rays.getSize()>1){
RayPacket::Element& e0 = rays.get(0);
- double num = d-Dot(normal, e0.ray.origin());
+ Real num = d-Dot(normal, e0.ray.origin());
Point a(e0.ray.origin()-anchor);
- double o1 = Dot(a, v1);
- double o2 = Dot(a, v2);
+ Real o1 = Dot(a, v1);
+ Real o2 = Dot(a, v2);
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
- double dt=Dot(e.ray.direction(), normal);
- if(Abs(dt) < 1.e-6)
- continue;
- double t=num/dt;
+ Real dt=Dot(e.ray.direction(), normal);
+ if(Abs(dt) < (Real)1.e-6)
+ continue;
+ Real t=num/dt;
if(t>e.hitInfo.minT())
- continue;
+ continue;
Vector vi(e.ray.direction()*t);
- double a1 = Dot(v1, vi)+o1;
- if (a1 < 0.0 || a1 > 1.0)
- continue;
- double a2 = Dot(v2, vi)+o2;
- if (a2 < 0.0 || a2 > 1.0)
- continue;
-
+ Real a1 = Dot(v1, vi)+o1;
+ if (a1 < 0 || a1 > 1)
+ continue;
+ Real a2 = Dot(v2, vi)+o2;
+ if (a2 < 0 || a2 > 1)
+ continue;
+
if(e.hitInfo.hit(t, material, this, tex))
- e.hitInfo.scratchpad<Point>() = Point(a1, a2, 0);
+ e.hitInfo.scratchpad<Point>() = Point(a1, a2, 0);
}
} else {
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
- double dt=Dot(e.ray.direction(), normal);
- if(Abs(dt) < 1.e-6)
- continue;
- double t=(d-Dot(normal, e.ray.origin()))/dt;
+ Real dt=Dot(e.ray.direction(), normal);
+ if(Abs(dt) < (Real)1.e-6)
+ continue;
+ Real t=(d-Dot(normal, e.ray.origin()))/dt;
if(t>e.hitInfo.minT())
- continue;
+ continue;
Point p(e.ray.origin()+e.ray.direction()*t);
Vector vi(p-anchor);
- double a1 = Dot(v1, vi);
- if (a1 < 0.0 || a1 > 1.0)
- continue;
- double a2 = Dot(v2, vi);
- if (a2 < 0.0 || a2 > 1.0)
- continue;
-
+ Real a1 = Dot(v1, vi);
+ if (a1 < 0 || a1 > 1)
+ continue;
+ Real a2 = Dot(v2, vi);
+ if (a2 < 0 || a2 > 1)
+ continue;
+
if(e.hitInfo.hit(t, material, this, tex))
- e.hitInfo.scratchpad<Point>() = Point(a1, a2, 0);
+ e.hitInfo.scratchpad<Point>() = Point(a1, a2, 0);
}
}
}
Modified: trunk/Model/Primitives/Parallelogram.h
==============================================================================
--- trunk/Model/Primitives/Parallelogram.h (original)
+++ trunk/Model/Primitives/Parallelogram.h Tue Dec 6 16:58:03 2005
@@ -25,7 +25,7 @@
Point anchor;
Vector v1, v2;
Vector normal;
- double d;
+ Real d;
};
}
Modified: trunk/Model/Primitives/PrimitiveCommon.cc
==============================================================================
--- trunk/Model/Primitives/PrimitiveCommon.cc (original)
+++ trunk/Model/Primitives/PrimitiveCommon.cc Tue Dec 6 16:58:03 2005
@@ -5,7 +5,7 @@
using namespace Manta;
-UniformMapper default_map;
+static UniformMapper default_map;
PrimitiveCommon::PrimitiveCommon(Material* material,
const TexCoordMapper* in_tex)
Modified: trunk/Model/Primitives/PrimitiveCommon.h
==============================================================================
--- trunk/Model/Primitives/PrimitiveCommon.h (original)
+++ trunk/Model/Primitives/PrimitiveCommon.h Tue Dec 6 16:58:03 2005
@@ -4,13 +4,16 @@
#include <Interface/Primitive.h>
-namespace Manta{
+namespace Manta {
class Material;
class PrimitiveCommon : public Primitive {
public:
PrimitiveCommon(Material* material, const TexCoordMapper* tex = 0);
+ PrimitiveCommon() { }; // Empty default constructor (used
for an array of some primitive)
virtual ~PrimitiveCommon();
+ // Note that this preprocess method sets up the activeLights
for the associated
+ // material (not sure what happens for shared materials)
virtual void preprocess(const PreprocessContext&);
virtual void setTexCoordMapper(const TexCoordMapper* new_tex);
protected:
Modified: trunk/Model/Primitives/Sphere.cc
==============================================================================
--- trunk/Model/Primitives/Sphere.cc (original)
+++ trunk/Model/Primitives/Sphere.cc Tue Dec 6 16:58:03 2005
@@ -3,15 +3,16 @@
#include <Interface/RayPacket.h>
#include <Core/Geometry/BBox.h>
#include <Core/Math/MiscMath.h>
+#include <Core/Math/Trig.h>
using namespace Manta;
using namespace std;
using SCIRun::Clamp;
-Sphere::Sphere(Material* material, const Point& center, double radius)
- : PrimitiveCommon(material, this), center(center), radius(radius)
+Sphere::Sphere(Material* material, const Point& center, Real radius)
+: PrimitiveCommon(material, this), center(center), radius(radius)
{
- inv_radius = 1./radius;
+ inv_radius = 1/radius;
}
Sphere::~Sphere()
@@ -30,75 +31,75 @@
for(int i = 0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
Vector OC=center-e.ray.origin();
- double tca=Dot(OC, e.ray.direction());
- double l2oc=OC.length2();
- double rad2=radius*radius;
+ Real tca=Dot(OC, e.ray.direction());
+ Real l2oc=OC.length2();
+ Real rad2=radius*radius;
if(l2oc <= rad2){
// Inside the sphere
- double t2hc=rad2-l2oc+tca*tca;
- double thc=sqrt(t2hc);
- double t=tca+thc;
- e.hitInfo.hit(material, this, t);
+ Real t2hc=rad2-l2oc+tca*tca;
+ Real thc=Sqrt(t2hc);
+ Real t=tca+thc;
+ e.hitInfo.hit(t, material, this, tex);
} else {
- if(tca < 0.0){
+ if(tca < 0){
// Behind ray, no intersections...
} else {
- double t2hc=rad2-l2oc+tca*tca;
- if(t2hc <= 0.0){
+ Real t2hc=rad2-l2oc+tca*tca;
+ if(t2hc <= 0){
// Ray misses, no intersections
} else {
- double thc=sqrt(t2hc);
- e.hitInfo.hit(material, this, tca-thc);
- e.hitInfo.hit(material, this, tca+thc);
+ Real thc=Sqrt(t2hc);
+ e.hitInfo.hit(tca-thc, material, this, tex);
+ e.hitInfo.hit(tca+thc, material, this, tex);
}
}
}
}
-#endif
- switch(rays.getFlags() &
(RayPacket::ConstantOrigin|RayPacket::NormalizedDirections)){
+#else
+ switch(rays.getAllFlags() &
(RayPacket::ConstantOrigin|RayPacket::NormalizedDirections)){
case RayPacket::ConstantOrigin|RayPacket::NormalizedDirections:
{
// Rays of constant origin and normalized directions
RayPacket::Element& e0 = rays.get(0);
Vector O(e0.ray.origin()-center);
- double C = Dot(O, O) - radius*radius;
+ Real C = Dot(O, O) - radius*radius;
for(int i = 0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
const Vector& D(e.ray.direction());
- double B = Dot(O, D);
- double disc = B*B-C;
+ Real B = Dot(O, D);
+ Real disc = B*B-C;
if(disc >= 0){
- double r = sqrt(disc);
- double t0 = -(r+B);
+ Real r = Sqrt(disc);
+ Real t0 = -(r+B);
if(t0 > 0){
e.hitInfo.hit(t0, material, this, tex);
} else {
- double t1 = r-B;
+ Real t1 = r-B;
e.hitInfo.hit(t1, material, this, tex);
}
}
}
}
- break;
+ break;
case RayPacket::ConstantOrigin:
{
// Rays of constant origin for not normalized directions
RayPacket::Element& e0 = rays.get(0);
Vector O(e0.ray.origin()-center);
- double C = Dot(O, O) - radius*radius;
+ Real C = Dot(O, O) - radius*radius;
for(int i = 0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
const Vector& D(e.ray.direction());
- double A = Dot(D, D);
- double B = Dot(O, D);
- double disc = B*B-A*C;
+ Real A = Dot(D, D);
+ Real B = Dot(O, D);
+ Real disc = B*B-A*C;
if(disc >= 0){
- double r = sqrt(disc);
- double t0 = -(r+B)/A;
+ Real r = Sqrt(disc);
+ Real t0 = -(r+B)/A;
if(t0 > 0){
e.hitInfo.hit(t0, material, this, tex);
} else {
- double t1 = (r-B)/A;
+ Real t1 = (r-B)/A;
e.hitInfo.hit(t1, material, this, tex);
}
}
@@ -112,16 +113,16 @@
RayPacket::Element& e = rays.get(i);
Vector O(e.ray.origin()-center);
const Vector& D(e.ray.direction());
- double B = Dot(O, D);
- double C = Dot(O, O) - radius*radius;
- double disc = B*B-C;
+ Real B = Dot(O, D);
+ Real C = Dot(O, O) - radius*radius;
+ Real disc = B*B-C;
if(disc >= 0){
- double r = sqrt(disc);
- double t0 = -(r+B);
+ Real r = Sqrt(disc);
+ Real t0 = -(r+B);
if(t0 > 0){
e.hitInfo.hit(t0, material, this, tex);
} else {
- double t1 = r-B;
+ Real t1 = r-B;
e.hitInfo.hit(t1, material, this, tex);
}
}
@@ -135,17 +136,17 @@
RayPacket::Element& e = rays.get(i);
Vector O(e.ray.origin()-center);
const Vector& D(e.ray.direction());
- double A = Dot(D, D);
- double B = Dot(O, D);
- double C = Dot(O, O) - radius*radius;
- double disc = B*B-A*C;
+ Real A = Dot(D, D);
+ Real B = Dot(O, D);
+ Real C = Dot(O, O) - radius*radius;
+ Real disc = B*B-A*C;
if(disc >= 0){
- double r = sqrt(disc);
- double t0 = -(r+B)/A;
+ Real r = Sqrt(disc);
+ Real t0 = -(r+B)/A;
if(t0 > 0){
e.hitInfo.hit(t0, material, this, tex);
} else {
- double t1 = (r-B)/A;
+ Real t1 = (r-B)/A;
e.hitInfo.hit(t1, material, this, tex);
}
}
@@ -153,6 +154,7 @@
}
break;
}
+#endif
}
void Sphere::computeNormal(const RenderContext&, RayPacket& rays) const
@@ -173,10 +175,14 @@
for(int i = 0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
Vector n = (e.hitPosition-center)*inv_radius;
- double angle = Clamp(n.z(), -1.0, 1.0);
- double theta = acos(angle);
- double phi = atan2(n.x(), n.y());
- e.texCoords = Point((phi+M_PI)*(1./(2*M_PI)), theta*(1./M_PI), 0);
+ Real angle = Clamp(n.z(), (Real)-1, (Real)1);
+ Real theta = Acos(angle);
+ Real phi = Atan2(n.x(), n.y());
+ Real x = (phi+(Real)M_PI)*((Real)0.5*(Real)M_1_PI);
+ Real y = theta*(Real)M_1_PI;
+ e.texCoords = Point(x,
+ y,
+ 0);
}
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
@@ -188,11 +194,12 @@
for(int i = 0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
Vector n = (e.hitPosition-center)*inv_radius;
- double angle = Clamp(n.z(), -1.0, 1.0);
- double theta = acos(angle);
- double phi = atan2(n.x(), n.y());
- e.texCoords = Point((phi+M_PI)*(1./(2*M_PI)), theta*(1./M_PI), 0);
+ Real angle = Clamp(n.z(), (Real)-1, (Real)1);
+ Real theta = Acos(angle);
+ Real phi = Atan2(n.x(), n.y());
+ e.texCoords = Point((phi+(Real)M_PI)*((Real)0.5*(Real)M_1_PI),
+ theta*(Real)M_1_PI,
+ 0);
}
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
-
Modified: trunk/Model/Primitives/Sphere.h
==============================================================================
--- trunk/Model/Primitives/Sphere.h (original)
+++ trunk/Model/Primitives/Sphere.h Tue Dec 6 16:58:03 2005
@@ -9,7 +9,7 @@
namespace Manta {
class Sphere : public PrimitiveCommon, public TexCoordMapper {
public:
- Sphere(Material* material, const Point& center, double radius);
+ Sphere(Material* material, const Point& center, Real radius);
virtual ~Sphere();
virtual void computeBounds(const PreprocessContext& context,
@@ -22,8 +22,8 @@
RayPacket& rays) const;
private:
Point center;
- double radius;
- double inv_radius;
+ Real radius;
+ Real inv_radius;
};
}
Modified: trunk/Model/Primitives/SuperEllipsoid.cc
==============================================================================
--- trunk/Model/Primitives/SuperEllipsoid.cc (original)
+++ trunk/Model/Primitives/SuperEllipsoid.cc Tue Dec 6 16:58:03 2005
@@ -1,67 +1,77 @@
+#include <iostream>
+
#include <Model/Primitives/SuperEllipsoid.h>
#include <Interface/RayPacket.h>
#include <Core/Geometry/BBox.h>
#include <Core/Math/MinMax.h>
#include <Core/Math/MiscMath.h>
+#include <Core/Math/Trig.h>
using namespace std;
using namespace SCIRun;
using namespace Manta;
-#define GOLDENMEAN 0.61803398874989484820
-#define BRACKETWIDTH 1.e-3
+#define GOLDENMEAN (Real)0.61803398874989484820
+#define BRACKETWIDTH (Real)1.e-3
#define MAXNEWTONITER 10
SuperEllipsoid::SuperEllipsoid(
Material *material,
- double alpha,
- double beta )
+ Point const ¢er,
+ Real radius,
+ Real alpha,
+ Real beta )
: PrimitiveCommon( material, this ),
two_over_alpha( 2. / alpha ),
two_over_beta( 2. / beta ),
alpha_over_beta( alpha / beta )
{
+ inv_radius = 1 / radius;
+ two_over_alpha = 2 / alpha;
+ two_over_beta = 2 / beta;
+ alpha_over_beta = alpha / beta;
}
SuperEllipsoid::~SuperEllipsoid()
{
}
-inline double SuperEllipsoid::functionValue(
+inline Real SuperEllipsoid::functionValue(
Point const &location ) const
{
- double x_power = pow( fabs( location.x() ), two_over_alpha );
- double y_power = pow( fabs( location.y() ), two_over_alpha );
- double z_power = pow( fabs( location.z() ), two_over_beta );
- return pow( x_power + y_power, alpha_over_beta ) + z_power - 1.;
+ Real x_power = SCIRun::Pow( SCIRun::Abs( location.x() ), two_over_alpha );
+ Real y_power = SCIRun::Pow( SCIRun::Abs( location.y() ), two_over_alpha );
+ Real z_power = SCIRun::Pow( SCIRun::Abs( location.z() ), two_over_beta );
+ return pow( x_power + y_power, alpha_over_beta ) + z_power - 1;
}
-inline Vector const SuperEllipsoid::functionGradient(
+inline Vector SuperEllipsoid::functionGradient(
Point const &location,
- double &value ) const
+ Real &value ) const
{
- double x_power = pow( fabs(location.x() ), two_over_alpha );
- double y_power = pow( fabs(location.y() ), two_over_alpha );
- double z_power = pow( fabs(location.z() ), two_over_beta );
- double x_and_y_power = pow( x_power + y_power, alpha_over_beta - 1. );
- value = x_and_y_power * ( x_power + y_power ) + z_power - 1.;
+ Real x_power = SCIRun::Pow( SCIRun::Abs(location.x() ), two_over_alpha );
+ Real y_power = SCIRun::Pow( SCIRun::Abs(location.y() ), two_over_alpha );
+ Real z_power = SCIRun::Pow( SCIRun::Abs(location.z() ), two_over_beta );
+ Real x_and_y_power = pow( x_power + y_power, alpha_over_beta - 1 );
+ value = x_and_y_power * ( x_power + y_power ) + z_power - 1;
return Vector( two_over_beta * x_and_y_power * x_power / location.x(),
two_over_beta * x_and_y_power * y_power / location.y(),
two_over_beta * z_power / location.z() );
}
-inline Vector const SuperEllipsoid::logarithmFunctionGradient(
+inline Vector SuperEllipsoid::logarithmFunctionGradient(
Point const &location,
- double &value ) const
+ Real &value ) const
{
- double x_power = pow( fabs(location.x() ), two_over_alpha );
- double y_power = pow( fabs(location.y() ), two_over_alpha );
- double z_power = pow( fabs(location.z() ), two_over_beta );
- double x_and_y_power = pow( x_power + y_power, 1. - alpha_over_beta ) *
z_power + x_power + y_power;
+ Real x_power = SCIRun::Pow( SCIRun::Abs(location.x() ), two_over_alpha );
+ Real y_power = SCIRun::Pow( SCIRun::Abs(location.y() ), two_over_alpha );
+ Real z_power = SCIRun::Pow( SCIRun::Abs(location.z() ), two_over_beta );
+ Real x_and_y_power = (SCIRun::Pow( x_power + y_power, 1 - alpha_over_beta )
+ * z_power + x_power + y_power);
value = log( pow( x_power + y_power, alpha_over_beta ) + z_power );
return Vector( two_over_beta * x_power / ( location.x() * x_and_y_power ),
two_over_beta * y_power / ( location.y() * x_and_y_power ),
- two_over_beta / ( location.z() * ( 1. + pow( x_power +
y_power, alpha_over_beta ) / z_power ) ) );
+ two_over_beta / ( location.z() * ( 1 + pow( x_power +
y_power, alpha_over_beta ) / z_power ) ) );
}
void SuperEllipsoid::computeBounds(
@@ -78,76 +88,93 @@
rays.computeInverseDirections();
for( int i = 0; i < rays.getSize(); ++i ) {
RayPacket::Element& e( rays.get(i) );
+ Vector offset_center = e.ray.origin() - center;
// First check if the ray hits the bounding box and whether it could
// remotely produce a hit of interest.
- double t1 = ( -1.01 - e.ray.origin().x() ) * e.inverseDirection.x();
- double t2 = ( 1.01 - e.ray.origin().x() ) * e.inverseDirection.x();
- if ( t1 > t2 )
- SWAP( t1, t2 );
- double tnear = t1;
- double tfar = t2;
- t1 = ( -1.01 - e.ray.origin().y() ) * e.inverseDirection.y();
- t2 = ( 1.01 - e.ray.origin().y() ) * e.inverseDirection.y();
- if ( t1 > t2 )
- SWAP( t1, t2 );
- tnear = SCIRun::Max( t1, tnear );
- tfar = SCIRun::Min( t2, tfar );
- t1 = ( -1.01 - e.ray.origin().z() ) * e.inverseDirection.z();
- t2 = ( 1.01 - e.ray.origin().z() ) * e.inverseDirection.z();
- if ( t1 > t2 )
- SWAP( t1, t2 );
- tnear = SCIRun::Max( SCIRun::Max( t1, tnear ), T_EPSILON );
- tfar = SCIRun::Min( SCIRun::Min( t2, tfar ), e.hitInfo.minT() );
+ // TODO: Maybe factor this out into a common routine?
+ Real tnear, tfar, t1, t2;
+ t1 = ( -radius - offset_center.x() ) * e.inverseDirection.x();
+ t2 = ( radius - offset_center.x() ) * e.inverseDirection.x();
+ if( t1 > t2 ) {
+ Real temp = t1;
+ t1 = t2;
+ t2 = temp;
+ }
+ tnear = t1;
+ tfar = t2;
+ t1 = ( -radius - offset_center.y() ) * e.inverseDirection.y();
+ t2 = ( radius - offset_center.y() ) * e.inverseDirection.y();
+ if( t1 > t2 ) {
+ Real temp = t1;
+ t1 = t2;
+ t2 = temp;
+ }
+ using SCIRun::Max;
+ using SCIRun::Min;
+ tnear = Max( t1, tnear );
+ tfar = Min( t2, tfar );
+ t1 = ( -radius - offset_center.z() ) * e.inverseDirection.z();
+ t2 = ( radius - offset_center.z() ) * e.inverseDirection.z();
+ if( t1 > t2 ) {
+ Real temp = t1;
+ t1 = t2;
+ t2 = temp;
+ }
+ tnear = Max( Max( t1, tnear ), (Real)T_EPSILON );
+ tfar = Min( Min( t2, tfar ), e.hitInfo.minT() );
+
if ( tnear > tfar || tfar <= T_EPSILON || tnear >= e.hitInfo.minT() )
continue;
// A few preliminary early exit tests...
- double near_value, far_value;
- double near_deriv = Dot( functionGradient(
+ Real near_value, far_value;
+ Real near_deriv = Dot( functionGradient(
( e.ray.origin() + tnear *
e.ray.direction() ),
near_value ),
e.ray.direction() );
- double far_deriv = Dot( functionGradient(
+ Real far_deriv = Dot( functionGradient(
( e.ray.origin() + tfar * e.ray.direction()
),
far_value ),
e.ray.direction() );
- if ( ( near_value < T_EPSILON && far_value < T_EPSILON ) ||
- ( near_value * far_value > 0. && near_deriv * far_deriv > 0. ) )
+ if ( ( near_value < (Real)T_EPSILON && far_value < (Real)T_EPSILON ) ||
+ ( near_value * far_value > 0 && near_deriv * far_deriv > 0 ) )
continue;
// Try to find the minimum of the super ellipsoid function using the
// Golden Section Search. We'll use this to bracket the root.
if ( near_deriv * far_deriv <= 0 ) {
- double a_bracket = tnear;
- double b_bracket = tfar;
- double left = GOLDENMEAN * a_bracket + ( 1. - GOLDENMEAN ) * b_bracket;
- double left_value = functionValue( e.ray.origin() + left *
e.ray.direction() );
- double right = ( 1. - GOLDENMEAN ) * a_bracket + GOLDENMEAN *
b_bracket;
- double right_value = functionValue( e.ray.origin() + right *
e.ray.direction() );
- while( fabs( b_bracket - a_bracket ) > BRACKETWIDTH ) {
+ Real a_bracket = tnear;
+ Real b_bracket = tfar;
+ Real left = GOLDENMEAN * a_bracket + ( 1 - GOLDENMEAN ) * b_bracket;
+ Real left_value = functionValue(
+ Point( (offset_center + left * e.ray.direction() ) * inv_radius ));
+ Real right = ( 1 - GOLDENMEAN ) * a_bracket + GOLDENMEAN * b_bracket;
+ Real right_value = functionValue(
+ Point( (offset_center + right * e.ray.direction() ) * inv_radius ));
+ while( SCIRun::Abs( b_bracket - a_bracket ) > BRACKETWIDTH ) {
if ( left_value < right_value ) {
b_bracket = right;
right = left;
right_value = left_value;
- left = GOLDENMEAN * a_bracket + ( 1. - GOLDENMEAN ) * b_bracket;
+ left = GOLDENMEAN * a_bracket + ( 1 - GOLDENMEAN ) * b_bracket;
left_value = functionValue( e.ray.origin() + left *
e.ray.direction() );
} else {
a_bracket = left;
left = right;
left_value = right_value;
- right = ( 1. - GOLDENMEAN ) * a_bracket + GOLDENMEAN * b_bracket;
+ right = ( 1 - GOLDENMEAN ) * a_bracket + GOLDENMEAN * b_bracket;
right_value = functionValue( e.ray.origin() + right *
e.ray.direction() );
}
}
// If our minimum is positive, we missed the superquadric - it
// couldn't have crossed zero.
- if ( right_value >= -T_EPSILON )
+ if ( right_value >= (Real)-T_EPSILON )
continue;
// Narrow the range with the location of the minimum found
- if ( right_value * near_value < 0. ) {
+ if ( right_value * near_value < 0 ) {
tfar = right;
far_value = right_value;
} else {
@@ -161,19 +188,19 @@
// search on the logarithm of the super ellipsoid function to find the
// root. If Newton's method flies off, we just reset it with a
// bisection step.
- if ( near_value * far_value >= 0. )
+ if ( near_value * far_value >= 0 )
continue;
- double troot = ( tnear + tfar ) * 0.5;
- double root_value;
- double root_deriv = Dot( logarithmFunctionGradient(
+ Real troot = ( tnear + tfar ) * (Real)0.5;
+ Real root_value;
+ Real root_deriv = Dot( logarithmFunctionGradient(
e.ray.origin() + troot * e.ray.direction(),
root_value ),
e.ray.direction() );
int iterations = 0;
- while ( fabs( tfar - tnear ) >= T_EPSILON &&
- fabs( root_value ) >= T_EPSILON &&
+ while ( SCIRun::Abs( tfar - tnear ) >= (Real)T_EPSILON &&
+ SCIRun::Abs( root_value ) >= (Real)T_EPSILON &&
++iterations < MAXNEWTONITER ) {
- if ( root_value * near_value < 0. ) {
+ if ( root_value * near_value < 0 ) {
tfar = troot;
far_value = root_value;
} else {
@@ -182,7 +209,7 @@
}
troot -= root_value / root_deriv;
if ( troot <= tnear || troot >= tfar )
- troot = ( tnear + tfar ) * 0.5;
+ troot = ( tnear + tfar ) * (Real)0.5;
root_deriv = Dot( logarithmFunctionGradient(
e.ray.origin() + troot * e.ray.direction(),
root_value ),
@@ -200,7 +227,7 @@
RenderContext const &,
RayPacket &rays ) const
{
- double ignored;
+ Real ignored;
rays.computeHitPositions();
for( int i = 0; i < rays.getSize(); i++ ) {
RayPacket::Element &e( rays.get( i ) );
@@ -217,11 +244,12 @@
rays.computeHitPositions();
for( int i = 0; i < rays.getSize(); i++ ) {
RayPacket::Element &e( rays.get( i ) );
- double angle = Clamp( e.hitPosition.z(), -1.0, 1.0 );
- double theta = acos( angle );
- double phi = atan2( e.hitPosition.x(), e.hitPosition.y() );
- e.texCoords = Point( ( phi + M_PI ) * ( 1. / ( 2 * M_PI ) ),
- theta * ( 1. / M_PI ),
+ Vector n = ( e.hitPosition - center ) * inv_radius;
+ Real angle = Clamp( n.z(), (Real)-1, (Real)1 );
+ Real theta = Acos( angle );
+ Real phi = Atan2( n.x(), n.y() );
+ e.texCoords = Point( ( phi + (Real)M_PI ) * (Real)( 0.5 * M_1_PI ),
+ theta * (Real)M_1_PI,
0. );
}
rays.setFlag( RayPacket::HaveTexture2 | RayPacket::HaveTexture3 );
@@ -234,11 +262,12 @@
rays.computeHitPositions();
for( int i = 0; i < rays.getSize(); i++ ) {
RayPacket::Element &e = rays.get( i );
- double angle = Clamp( e.hitPosition.z(), -1.0, 1.0 );
- double theta = acos( angle );
- double phi = atan2( e.hitPosition.x(), e.hitPosition.y() );
- e.texCoords = Point( ( phi + M_PI ) * ( 1. / ( 2 * M_PI ) ),
- theta * ( 1. / M_PI ),
+ Vector n = ( e.hitPosition - center ) * inv_radius;
+ Real angle = Clamp( n.z(), (Real)-1, (Real)1 );
+ Real theta = Acos( angle );
+ Real phi = Atan2( n.x(), n.y() );
+ e.texCoords = Point( ( phi + (Real)M_PI ) * (Real)( 0.5 * M_1_PI ),
+ theta * (Real)M_1_PI,
0. );
}
rays.setFlag( RayPacket::HaveTexture2 | RayPacket::HaveTexture3 );
Modified: trunk/Model/Primitives/SuperEllipsoid.h
==============================================================================
--- trunk/Model/Primitives/SuperEllipsoid.h (original)
+++ trunk/Model/Primitives/SuperEllipsoid.h Tue Dec 6 16:58:03 2005
@@ -9,7 +9,8 @@
namespace Manta {
class SuperEllipsoid : public PrimitiveCommon, public TexCoordMapper {
public:
- SuperEllipsoid(Material* material, double alpha, double beta);
+ SuperEllipsoid(Material* material, const Point& center, Real radius,
+ Real alpha, Real beta);
virtual ~SuperEllipsoid();
virtual void computeBounds(const PreprocessContext& context,
@@ -21,12 +22,15 @@
virtual void computeTexCoords3(const RenderContext& context,
RayPacket& rays) const;
private:
- double functionValue(const Point& location) const;
- Vector const functionGradient(const Point& location, double& value )
const;
- Vector const logarithmFunctionGradient(const Point& location, double&
value ) const;
- double two_over_alpha;
- double two_over_beta;
- double alpha_over_beta;
+ Real functionValue(const Point& location) const;
+ inline Vector functionGradient(const Point& location, Real& value )
const;
+ inline Vector logarithmFunctionGradient(const Point& location, Real&
value ) const;
+ Point center;
+ Real radius;
+ Real inv_radius;
+ Real two_over_alpha;
+ Real two_over_beta;
+ Real alpha_over_beta;
};
}
Modified: trunk/Model/Primitives/TexTriangle.cc
==============================================================================
--- trunk/Model/Primitives/TexTriangle.cc (original)
+++ trunk/Model/Primitives/TexTriangle.cc Tue Dec 6 16:58:03 2005
@@ -44,7 +44,8 @@
}
//Performs the exact same operation as computeTexCoords3
-void TexTriangle::computeTexCoords2(const RenderContext& context, RayPacket&
rays) const
+void TexTriangle::computeTexCoords2(const RenderContext& /*context*/,
+ RayPacket& rays) const
{
int nrays = rays.getSize();
for(int i=0; i<nrays; i++) {
@@ -60,7 +61,8 @@
}
-void TexTriangle::computeTexCoords3(const RenderContext& context, RayPacket&
rays) const
+void TexTriangle::computeTexCoords3(const RenderContext& /*context*/,
+ RayPacket& rays) const
{
int nrays = rays.getSize();
for(int i=0; i<nrays; i++) {
Modified: trunk/Model/Primitives/Triangle.cc
==============================================================================
--- trunk/Model/Primitives/Triangle.cc (original)
+++ trunk/Model/Primitives/Triangle.cc Tue Dec 6 16:58:03 2005
@@ -5,6 +5,8 @@
#include <iostream>
#include <sgi_stl_warnings_on.h>
+#include <Model/Intersections/TriangleEdge.h>
+
using namespace Manta;
using namespace std;
@@ -33,31 +35,40 @@
Vector _e1 = p2-p1;
Vector _e2 = p3-p1;
- Vector _n = Cross(_e1, _e2);
+ // Vector _n = Cross(_e1, _e2);
for(int i=0; i<rays.getSize(); i++) {
RayPacket::Element& e = rays.get(i);
- const Vector& dir(e.ray.direction());
Vector o(p1 - e.ray.origin());
-
- double det=Dot(_n,dir);
+
+#if 0
+ const Vector& dir(e.ray.direction());
+ Real det=Dot(_n,dir);
if(det>1.e-9 || det < -1.e-9) {
- double idet = 1./det;
+ Real idet = 1./det;
Vector DX(Cross(dir, o));
- double A =-Dot(DX, _e2)*idet;
+ Real A =-Dot(DX, _e2)*idet;
if(A>0.0 && A<1.0) {
- double B = Dot(DX, _e1)*idet;
- if(B>0.0 && A+B<1.0) {
- double t=Dot(_n, o)*idet;
- if (e.hitInfo.hit(t, material, this, tex)){
- TriangleHit& th = e.hitInfo.scratchpad<TriangleHit>();
- th.a = A;
- th.b = B;
+ Real B = Dot(DX, _e1)*idet;
+ if(B>0.0 && A+B<1.0) {
+ Real t=Dot(_n, o)*idet;
+#endif
+
+ Real t, A, B;
+
+ bool h = Intersection::intersectTriangleEdge( t, A, B, e.ray, _e1,
_e2, p1 );
+
+ if (h && e.hitInfo.hit(t, material, this, tex)){
+ TriangleHit& th = e.hitInfo.scratchpad<TriangleHit>();
+ th.a = A;
+ th.b = B;
}
- }
+#if 0
+ }
}
}
+#endif
}
}
@@ -66,8 +77,8 @@
{
rays.computeHitPositions();
- if (rays.getFlags() & RayPacket::HaveNormals){
- if (rays.getFlags() & RayPacket::HaveUnitNormals)
+ if (rays.getFlag(RayPacket::HaveNormals)){
+ if (rays.getFlag(RayPacket::HaveUnitNormals))
return;
int nrays = rays.getSize();
Modified: trunk/Model/Primitives/Triangle.h
==============================================================================
--- trunk/Model/Primitives/Triangle.h (original)
+++ trunk/Model/Primitives/Triangle.h Tue Dec 6 16:58:03 2005
@@ -11,9 +11,10 @@
class Triangle : public PrimitiveCommon {
public:
struct TriangleHit{
- double a,b;
+ Real a,b;
};
+ Triangle() { };
Triangle(Material* mat, const Point& _p1, const Point& _p2, const Point&
_p3);
virtual ~Triangle();
Modified: trunk/Model/Readers/CMakeLists.txt
==============================================================================
--- trunk/Model/Readers/CMakeLists.txt (original)
+++ trunk/Model/Readers/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,4 +1,9 @@
SET (Manta_Readers_SRCS
- Readers/PlyReader.cc
- Readers/rply/rply.c)
+ Readers/glm/glm.h
+ Readers/glm/glm.cc)
+
+# Apple places malloc.h in /usr/include/malloc/malloc.h
+IF (APPLE)
+ INCLUDE_DIRECTORIES(/usr/include/malloc/)
+ENDIF (APPLE)
\ No newline at end of file
Modified: trunk/Model/TexCoordMappers/CMakeLists.txt
==============================================================================
--- trunk/Model/TexCoordMappers/CMakeLists.txt (original)
+++ trunk/Model/TexCoordMappers/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,6 +1,9 @@
SET (Manta_TexCoordMappers_SRCS
+ TexCoordMappers/UniformMapper.h
TexCoordMappers/UniformMapper.cc
+ TexCoordMappers/SphericalMapper.h
TexCoordMappers/SphericalMapper.cc
+ TexCoordMappers/LinearMapper.h
TexCoordMappers/LinearMapper.cc
)
Modified: trunk/Model/TexCoordMappers/SphericalMapper.cc
==============================================================================
--- trunk/Model/TexCoordMappers/SphericalMapper.cc (original)
+++ trunk/Model/TexCoordMappers/SphericalMapper.cc Tue Dec 6 16:58:03
2005
@@ -2,14 +2,15 @@
#include <Model/TexCoordMappers/SphericalMapper.h>
#include <Interface/RayPacket.h>
#include <Core/Math/MiscMath.h>
+#include <Core/Math/Trig.h>
using namespace Manta;
using SCIRun::Clamp;
-SphericalMapper::SphericalMapper(const Point& center, double radius)
+SphericalMapper::SphericalMapper(const Point& center, Real radius)
: center(center), radius(radius)
{
- inv_radius = 1./radius;
+ inv_radius = 1/radius;
}
SphericalMapper::~SphericalMapper()
@@ -23,11 +24,13 @@
for(int i = 0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
Vector n = e.hitPosition-center;
- double w = n.normalize() * inv_radius;
- double angle = Clamp(n.z(), -1.0, 1.0);
- double theta = acos(angle);
- double phi = atan2(n.x(), n.y());
- e.texCoords = Point((phi+M_PI)*(1./(2*M_PI)), theta*(1./M_PI), w);
+ Real w = n.normalize() * inv_radius;
+ Real angle = Clamp(n.z(), (Real)-1, (Real)1);
+ Real theta = Acos(angle);
+ Real phi = Atan2(n.x(), n.y());
+ e.texCoords = Point((phi+(Real)M_PI)*(Real)(0.5*M_1_PI),
+ theta*(Real)M_1_PI,
+ w);
}
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
@@ -39,11 +42,13 @@
for(int i = 0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
Vector n = e.hitPosition-center;
- double w = n.normalize() * inv_radius;
- double angle = Clamp(n.z(), -1.0, 1.0);
- double theta = acos(angle);
- double phi = atan2(n.x(), n.y());
- e.texCoords = Point((phi+M_PI)*(1./(2*M_PI)), theta*(1./M_PI), w);
+ Real w = n.normalize() * inv_radius;
+ Real angle = Clamp(n.z(), (Real)-1, (Real)1);
+ Real theta = Acos(angle);
+ Real phi = Atan2(n.x(), n.y());
+ e.texCoords = Point((phi+(Real)M_PI)*(Real)(0.5*M_1_PI),
+ theta*(Real)M_1_PI,
+ w);
}
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
Modified: trunk/Model/TexCoordMappers/SphericalMapper.h
==============================================================================
--- trunk/Model/TexCoordMappers/SphericalMapper.h (original)
+++ trunk/Model/TexCoordMappers/SphericalMapper.h Tue Dec 6 16:58:03
2005
@@ -9,7 +9,7 @@
class SphericalMapper : public TexCoordMapper {
public:
- SphericalMapper(const Point& center, double radius);
+ SphericalMapper(const Point& center, Real radius);
virtual ~SphericalMapper();
virtual void computeTexCoords2(const RenderContext& context,
@@ -21,8 +21,8 @@
SphericalMapper& operator=(const SphericalMapper&);
Point center;
- double radius;
- double inv_radius;
+ Real radius;
+ Real inv_radius;
};
}
Modified: trunk/Model/Textures/CheckerTexture.cc
==============================================================================
--- trunk/Model/Textures/CheckerTexture.cc (original)
+++ trunk/Model/Textures/CheckerTexture.cc Tue Dec 6 16:58:03 2005
@@ -34,12 +34,12 @@
rays.computeTextureCoordinates2(context);
for(int i=0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
- double vv1 = Dot(e.texCoords, v1);
- double vv2 = Dot(e.texCoords, v2);
+ Real vv1 = Dot(e.texCoords, v1);
+ Real vv2 = Dot(e.texCoords, v2);
if(vv1<0)
- vv1=-vv1+1;
+ vv1=-vv1+1;
if(vv2<0)
- vv2=-vv2+1;
+ vv2=-vv2+1;
int i1 = (int)vv1;
int i2 = (int)vv2;
int which = (i1+i2)%2;
Modified: trunk/Model/Textures/CheckerTexture.h
==============================================================================
--- trunk/Model/Textures/CheckerTexture.h (original)
+++ trunk/Model/Textures/CheckerTexture.h Tue Dec 6 16:58:03 2005
@@ -3,6 +3,7 @@
#define Manta_Model_CheckerTexture_h
#include <Interface/Texture.h>
+#include <Core/Geometry/PointVector.h>
namespace Manta {
class RayPacket;
Modified: trunk/Model/Textures/Constant.h
==============================================================================
--- trunk/Model/Textures/Constant.h (original)
+++ trunk/Model/Textures/Constant.h Tue Dec 6 16:58:03 2005
@@ -16,9 +16,9 @@
virtual void mapValues(const RenderContext& context, RayPacket& rays,
ValueType results[]) const;
- ValueType getValue() const {
- return value;
- }
+ ValueType getValue() const { return value; }
+ void setValue( const ValueType value_ ) { value = value_; }
+
private:
Constant(const Constant&);
Constant& operator=(const Constant&);
Modified: trunk/Model/Textures/ImageTexture.cc
==============================================================================
--- trunk/Model/Textures/ImageTexture.cc (original)
+++ trunk/Model/Textures/ImageTexture.cc Tue Dec 6 16:58:03 2005
@@ -1,3 +1,4 @@
+<<<<<<< .working
#include <Model/Textures/ImageTexture.h>
#include <Interface/RayPacket.h>
@@ -88,3 +89,155 @@
}
}
+=======
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institue, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include <Model/Textures/ImageTexture.h>
+#include <Interface/RayPacket.h>
+#include <Interface/Image.h>
+
+#include <Core/Exceptions/InternalError.h>
+
+#include <Core/Geometry/PointVector.h>
+#include <Core/Math/MiscMath.h>
+#include <Core/Math/Trig.h>
+
+namespace Manta {
+ template< class ValueType >
+ ImageTexture< ValueType >::ImageTexture(const Image* image):
+ scale(VectorT< ScalarType, 2 >(1,1)),
+ interpolation_method(NearestNeighbor),
+ u_edge(Wrap), v_edge(Wrap)
+ {
+ bool stereo;
+ int xres, yres;
+ image->getResolution(stereo, xres, yres);
+ if (stereo) {
+ throw SCIRun::InternalError( "ImageTexture doesn't support stereo
currently", __FILE__, __LINE__);
+ }
+ texture.resize(xres, yres);
+
+ // Now copy over the data
+ for(int y = 0; y < yres; y++) {
+ for(int x = 0; x < xres; x+=Fragment::MaxFragmentSize) {
+ int end = x + Fragment::MaxFragmentSize;
+ if (end > xres) end = xres;
+ Fragment fragment(0, x, end, y);
+ image->get(fragment);
+ for(int i = 0; i < fragment.getSize(); i++) {
+ texture(x+i, y) = fragment.get(i).color;
+ }
+ }
+ }
+ }
+
+ template< class ValueType >
+ void ImageTexture< ValueType >::mapValues(RenderContext const &context,
+ RayPacket &rays,
+ ValueType results[] ) const
+ {
+ rays.computeTextureCoordinates2( context );
+ PointT<ScalarType, 2> tex_coords[RayPacket::MaxSize];
+
+ // Grab the texture coordinates
+ for( int i = 0; i < rays.getSize(); ++i ) {
+ RayPacket::Element &e = rays.get( i );
+ tex_coords[i] = PointT<ScalarType, 2>(e.texCoords.x(),
e.texCoords.y());
+ tex_coords[i].multiplyBy(scale);
+ }
+
+ int xres = texture.dim1();
+ int yres = texture.dim2();
+
+ // Grab the textures and do the interpolation as needed
+ switch (interpolation_method) {
+ case Bilinear:
+ {
+ for( int i = 0; i < rays.getSize(); ++i) {
+ ScalarType x = tex_coords[i].x();
+ ScalarType y = tex_coords[i].y();
+ int x_low, y_low, x_high, y_high;
+ ScalarType x_weight_high, y_weight_high;
+
+ BL_edge_behavior(x, u_edge, xres, x_low, x_high, x_weight_high);
+ BL_edge_behavior(y, v_edge, yres, y_low, y_high, y_weight_high);
+
+ // Do the interpolation
+ Color a, b;
+ a = ( texture(x_low, y_low )*(1-x_weight_high) +
+ texture(x_high, y_low )* x_weight_high);
+ b = ( texture(x_low, y_high)*(1-x_weight_high) +
+ texture(x_high, y_high)* x_weight_high);
+ results[i] = a*(1-y_weight_high) + b*y_weight_high;
+ }
+ }
+ break;
+ case NearestNeighbor:
+ {
+ for( int i = 0; i < rays.getSize(); ++i) {
+ int tx = NN_edge_behavior(static_cast<int>(tex_coords[i].x()*xres),
+ u_edge, texture.dim1());
+ int ty = NN_edge_behavior(static_cast<int>(tex_coords[i].y()*yres),
+ v_edge, texture.dim2());
+ results[i] = texture(tx, ty);
+ }
+ }
+ break;
+ }
+ } // end mapValues
+
+ template< class ValueType >
+ void ImageTexture< ValueType >::setEdgeBehavior(int new_behavior,
+ int& edge) {
+ switch (new_behavior) {
+ case Wrap:
+ case Clamp:
+ edge = new_behavior;
+ break;
+ default:
+ throw SCIRun::InternalError( "ImageTexture::setEdgeBehavior doesn't
support this edge behavior", __FILE__, __LINE__);
+ break;
+ }
+ }
+
+ template< class ValueType >
+ void ImageTexture< ValueType >::setInterpolationMethod(int new_method) {
+ switch (new_method) {
+ case NearestNeighbor:
+ case Bilinear:
+ interpolation_method = new_method;
+ break;
+ default:
+ throw SCIRun::InternalError( "ImageTexture::setInterpolationMethod
doesn't support this interpolation method", __FILE__, __LINE__);
+ break;
+ }
+ }
+
+} // end namespace Manta
+>>>>>>> .merge-right.r751
Modified: trunk/Model/Textures/ImageTexture.h
==============================================================================
--- trunk/Model/Textures/ImageTexture.h (original)
+++ trunk/Model/Textures/ImageTexture.h Tue Dec 6 16:58:03 2005
@@ -1,3 +1,4 @@
+<<<<<<< .working
#ifndef Manta_Model_ImageTexture_h
#define Manta_Model_ImageTexture_h
@@ -43,3 +44,200 @@
#endif
#endif
+=======
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institue, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+/*
+ Author: James Bigler
+ Date: Nov. 2005
+
+ This class is used for 2D texturing. The constructor takes an Image
+ class and makes a copy of it while converting it to type Color. No
+ sense in converting everytime you want to do lookups.
+
+ Some basic texturing parameters are supported. Bilinear and nearest
+ neighbor interpolation methods can be selected after construction.
+ You can also select to wrap boundaries or clamp them. You should
+ also be able to set these via a transaction as well.
+
+ With bilinear interpolation with wrapped boundaries will interpolate
+ across the edges.
+*/
+
+#ifndef Manta_Model_ImageTexture_h
+#define Manta_Model_ImageTexture_h
+
+#include <Interface/Texture.h>
+#include <Core/Geometry/PointVector.h>
+
+#include <Core/Containers/Array2.h>
+#include <Core/Math/MiscMath.h>
+
+namespace Manta {
+
+ class RayPacket;
+ class RenderContext;
+ class Image;
+
+ // Whatever type ValueType ends up being, it needs to have
+ // ValueType::ScalarType defined. I'm not sure what to do for
+ // things that aren't. If the occasion arrises such that you need
+ // something else, then you should make this a double template on
+ // ScalarType.
+ template< typename ValueType >
+ class ImageTexture : public Texture< ValueType > {
+ public:
+ ImageTexture(const Image* image);
+ virtual ~ImageTexture() {}
+
+ virtual void mapValues(RenderContext const &context,
+ RayPacket &rays,
+ ValueType results[] ) const;
+
+ template<class TU, class TV>
+ void setScale(const TU& u_scale, const TV& v_scale) {
+ // We don't know if T will match ValueType::ScalarType, so we
+ // need to copy the components over one at a time to do the
+ // implicit cast.
+ scale[0] = static_cast<ScalarType>(u_scale);
+ scale[1] = static_cast<ScalarType>(v_scale);
+ }
+
+ enum {
+ NearestNeighbor,
+ Bilinear
+ };
+
+ enum {
+ Wrap,
+ Clamp
+ };
+
+ void setUEdgeBehavior(int new_behavior) {
+ setEdgeBehavior(new_behavior, u_edge);
+ }
+ void setVEdgeBehavior(int new_behavior) {
+ setEdgeBehavior(new_behavior, v_edge);
+ }
+
+ void setInterpolationMethod(int new_method);
+
+ private:
+ typedef typename ValueType::ScalarType ScalarType;
+
+ inline void BL_edge_behavior(ScalarType val, int behavior, int size,
+ int& low, int& high,
+ ScalarType& weight_high) const {
+ switch (behavior) {
+ case Wrap:
+ // When we wrap [0,1] maps to [0, 1, ..., size-1, 0]. This is
+ // so we interpolate from texture[size-1] to texture[0].
+ val *= size;
+ low = static_cast<int>(val);
+ weight_high = val - low;
+ // If val is negative then we need to look right (negative)
+ // for the high interpolant.
+ if (val >= 0) {
+ high = low + 1;
+ } else {
+ high = low - 1;
+ // Here we get our negative index from [0..-size-1]. Add
+ // size back in and you get the right shift. You need to
+ // make sure you do the %size afterwards, though. This will
+ // catch the case where low%size + size == size.
+ low = low%size + size;
+ high = high%size + size;
+ // If val was negative then weight_high will also be
+ // negative. We don't need a negative number for
+ // interpolation.
+ weight_high = -weight_high;
+ }
+ low %= size;
+ high %= size;
+ break;
+ case Clamp:
+ if (val < 0) {
+ low = 0;
+ high = 0;
+ weight_high = 0;
+ } else {
+ val *= size-1;
+ low = static_cast<int>(val);
+ if (low > size-2) {
+ low = size-2;
+ weight_high = 0;
+ } else {
+ weight_high = val - low;
+ }
+ high = low + 1;
+ }
+ break;
+ }
+ }
+ inline int NN_edge_behavior(int val, int behavior, int size) const {
+ int result;
+ switch (behavior) {
+ case Wrap:
+ if (val >= 0)
+ // result will be [0,size-1]
+ result = val % size;
+ else
+ // val%size -> [-(size-1),0]
+ // val%size+size-1 -> [0,size-1]
+ result = val%size + size-1;
+ break;
+ case Clamp:
+ result = SCIRun::Clamp(val, 0, size-1);
+ break;
+ }
+ return result;
+ }
+
+ void setEdgeBehavior(int new_behavior, int& edge);
+
+ private:
+ // We make a copy of the data
+ SCIRun::Array2<ValueType> texture;
+ // You can scale the normal [(0,0)..(1,1)] texture coordinates,
+ VectorT< ScalarType, 2 > scale;
+ // Linear, nearest neighbor?
+ int interpolation_method;
+ // Edge behavior
+ int u_edge, v_edge;
+ };
+
+} // end namespace Manta
+
+#ifdef __GNUG__
+// This should instead be a configure variable...
+#include <Model/Textures/ImageTexture.cc>
+#endif
+
+#endif // Manta_Model_ImageTexture_h
+>>>>>>> .merge-right.r751
Modified: trunk/Model/Textures/MarbleTexture.cc
==============================================================================
--- trunk/Model/Textures/MarbleTexture.cc (original)
+++ trunk/Model/Textures/MarbleTexture.cc Tue Dec 6 16:58:03 2005
@@ -4,6 +4,7 @@
#include <Core/Geometry/PointVector.h>
#include <Core/Math/Noise.h>
#include <Core/Math/MiscMath.h>
+#include <Core/Math/Trig.h>
namespace Manta {
@@ -11,12 +12,12 @@
MarbleTexture< ValueType >::MarbleTexture(
ValueType const &value1,
ValueType const &value2,
- double const scale,
- double const fscale,
- double const tscale,
+ Real const scale,
+ Real const fscale,
+ Real const tscale,
int const octaves,
- double const lacunarity,
- double const gain )
+ Real const lacunarity,
+ Real const gain )
: value1( value1 ),
value2( value2 ),
scale ( scale ),
@@ -43,7 +44,9 @@
for( int i = 0; i < rays.getSize(); i++ ) {
RayPacket::Element &e = rays.get( i );
Point T = e.texCoords.multipliedBy(scale * fscale);
- double value = 0.5 * cos( e.texCoords.x() * scale + tscale *
Turbulence( T, octaves, lacunarity, gain ) ) * 0.5;
+ ColorComponent value = (Real)0.25 *
+ Cos( e.texCoords.x() * scale + tscale *
+ (Real)Turbulence( T, octaves, lacunarity, gain ) );
results[ i ] = SCIRun::Interpolate( value1, value2, value );
}
}
Modified: trunk/Model/Textures/MarbleTexture.h
==============================================================================
--- trunk/Model/Textures/MarbleTexture.h (original)
+++ trunk/Model/Textures/MarbleTexture.h Tue Dec 6 16:58:03 2005
@@ -13,12 +13,12 @@
MarbleTexture(
ValueType const &value1,
ValueType const &value2,
- double const scale,
- double const fscale,
- double const tscale,
+ Real const scale,
+ Real const fscale,
+ Real const tscale,
int const octaves,
- double const lacunarity,
- double const gain );
+ Real const lacunarity,
+ Real const gain );
virtual ~MarbleTexture();
virtual void mapValues(
RenderContext const &context,
@@ -32,12 +32,12 @@
ValueType value1;
ValueType value2;
- double scale;
- double fscale;
- double tscale;
+ Real scale;
+ Real fscale;
+ Real tscale;
int octaves;
- double lacunarity;
- double gain;
+ Real lacunarity;
+ Real gain;
};
}
Modified: trunk/Readers/BART/parse.cc
==============================================================================
--- trunk/Readers/BART/parse.cc (original)
+++ trunk/Readers/BART/parse.cc Tue Dec 6 16:58:03 2005
@@ -53,11 +53,11 @@
using namespace Manta;
//global holders created when BARTReader.cc calls parsefile
-Scene *myScene;
-Group *myGroup;
-LightSet *myLights;
+static Scene *myScene;
+static Group *myGroup;
+static LightSet *myLights;
-Material *currentMaterial = new Flat(Color(RGB(0.5,0.5,0.5)));
+static Material *currentMaterial = new Flat(Color(RGB(0.5,0.5,0.5)));
/*----------------------------------------------------------------------
parseComment()
@@ -334,7 +334,7 @@
}
currentMaterial = new Phong(Color(RGB(dif[X],dif[Y],dif[Z])),
Color(RGB(spc[X],spc[Y],spc[Z])), //assume
white spec
- int(4.0*phong_pow),
+ int(4*phong_pow),
t);
NOT_FINISHED("WARNING: Material ambient ignored" );
NOT_FINISHED("WARNING: Material index of refraction ignored");
@@ -354,7 +354,7 @@
}
currentMaterial = new Phong(Color(RGB(kd*col[X],kd*col[Y],kd*col[Z])),
Color(RGB(ks*1.0,ks*1.0,ks*1.0)), //assume
white spec
- int(4.0*phong_pow),
+ int(4*phong_pow),
t);
NOT_FINISHED("WARNING: Material index of refraction ignored");
}
@@ -928,7 +928,6 @@
PositionKey* PKeys;
RotationKey* RKeys;
Animation* animation=0;
- struct AnimationList* animationlist;
if(fscanf(fp,"%s",name)!=1)
{
@@ -943,9 +942,10 @@
exit(1);
}
- /* insert a new animation in the AnimationList */
- animationlist=
- (struct AnimationList*) calloc(1, sizeof(struct AnimationList));
+// struct AnimationList* animationlist;
+// /* insert a new animation in the AnimationList */
+// animationlist=
+// (struct AnimationList*) calloc(1, sizeof(struct AnimationList));
/* put the newly allocated a list somewhere,
* e.g.,
Modified: trunk/Readers/CMakeLists.txt
==============================================================================
--- trunk/Readers/CMakeLists.txt (original)
+++ trunk/Readers/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,4 +1,7 @@
+
+
+
SET (READERS_SOURCES)
SET (READERS_SOURCES ${READERS_SOURCES}
BART/animation.c
@@ -11,3 +14,4 @@
ADD_LIBRARY (Manta_Readers ${READERS_SOURCES})
TARGET_LINK_LIBRARIES(Manta_Readers SCIRun_Core Manta_Model)
+
Modified: trunk/SCIRun/Core/CMakeLists.txt
==============================================================================
--- trunk/SCIRun/Core/CMakeLists.txt (original)
+++ trunk/SCIRun/Core/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,4 +1,6 @@
+SET (CMAKE_VERBOSE_MAKEFILE TRUE)
+
SET (SCIRUN_SOURCES)
SET (SCIRUN_SOURCES ${SCIRUN_SOURCES}
Containers/StringUtil.cc
@@ -21,12 +23,48 @@
)
SET (SCIRUN_SOURCES ${SCIRUN_SOURCES}
- Thread/CleanupManager.cc
- Thread/Runnable.cc
- Thread/Thread.cc
- Thread/ThreadError.cc
- Thread/ThreadGroup.cc
- Thread/WorkQueue.cc
+ Math/MiscMath.cc
+ )
+
+SET (SCIRUN_SOURCES ${SCIRUN_SOURCES}
+
+ Thread/AtomicCounter.h
+ Thread/Barrier.h
+ Thread/CleanupManager.h
+ Thread/CleanupManager.cc
+ Thread/ConditionVariable.h
+ Thread/CrowdMonitor.h
+ Thread/FutureValue.h
+ Thread/Guard.h
+ Thread/Mailbox.h
+ Thread/Mutex.h
+ Thread/MutexPool.h
+ Thread/MutexPool.cc
+ Thread/Parallel.h
+ Thread/Parallel1.h
+ Thread/Parallel2.h
+ Thread/Parallel3.h
+ Thread/ParallelBase.h
+ Thread/ParallelBase.cc
+ Thread/RecursiveMutex.h
+ Thread/Reducer.h
+ Thread/Runnable.h
+ Thread/Runnable.cc
+ Thread/Semaphore.h
+ Thread/SimpleReducer.h
+ Thread/SimpleReducer.cc
+ Thread/Thread.h
+ Thread/Thread.cc
+ Thread/ThreadError.h
+ Thread/ThreadError.cc
+ Thread/ThreadGroup.h
+ Thread/ThreadGroup.cc
+ Thread/ThreadPool.h
+ Thread/Time.h
+ Thread/WorkQueue.h
+ Thread/WorkQueue.cc
+
+
)
# If we are using SPROC on IRIX then add these files
@@ -44,13 +82,23 @@
# MESSAGE("Using Pthreads")
SET (SCIRUN_SOURCES ${SCIRUN_SOURCES}
Thread/Thread_pthreads.cc
- Thread/Thread_unix.cc
- Thread/Time_unix.cc
- )
+ Thread/Thread_unix.cc )
+
+ # Check to see if mmtimer is available.
+ IF(EXISTS /usr/include/sn/mmtimer.h)
+ SET(SCIRUN_SOURCES ${SCIRUN_SOURCES}
+ Thread/Time_altix.cc)
+ ELSE(EXISTS /usr/include/sn/mmtimer.h)
+ SET(SCIRUN_SOURCES ${SCIRUN_SOURCES}
+ Thread/Time_unix.cc)
+ ENDIF(EXISTS /usr/include/sn/mmtimer.h)
+
ENDIF (CMAKE_USE_PTHREADS_INIT)
SET (SCIRUN_SOURCES ${SCIRUN_SOURCES}
Util/DebugStream.cc
+ Util/Timer.h
+ Util/Timer.cc
)
ADD_LIBRARY (SCIRun_Core ${SCIRUN_SOURCES})
Modified: trunk/StandAlone/CMakeLists.txt
==============================================================================
--- trunk/StandAlone/CMakeLists.txt (original)
+++ trunk/StandAlone/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -10,6 +10,46 @@
SCIRun_Core)
TARGET_LINK_LIBRARIES(manta ${CMAKE_THREAD_LIBS_INIT}
- ${OPENGL_LIBRARIES}
- ${X11_LIBRARIES}
- -lm)
+ ${OPENGL_LIBRARIES}
+ ${X11_LIBRARIES}
+ -lm)
+
+
+ADD_EXECUTABLE(barrier_test barrier_test.cc)
+TARGET_LINK_LIBRARIES(barrier_test SCIRun_Core
+ ${CMAKE_THREAD_LIBS_INIT})
+
+ADD_EXECUTABLE(frust-test frust-test.cc)
+TARGET_LINK_LIBRARIES(frust-test Manta_Engine
+ Manta_UserInterface
+ Manta_Model
+ Manta_Image
+ Manta_Interface
+ Manta_Core
+ SCIRun_Core
+ ${CMAKE_THREAD_LIBS_INIT}
+ )
+
+SET (BUILD_V3C1_TOOLS 0 CACHE BOOL "Include .v3c1 tools")
+IF (BUILD_V3C1_TOOLS)
+ ADD_EXECUTABLE(v3c1_tools v3c1_tools.cc)
+ TARGET_LINK_LIBRARIES(v3c1_tools SCIRun_Core Manta_Core Manta_Model)
+ TARGET_LINK_LIBRARIES(v3c1_tools ${CMAKE_THREAD_LIBS_INIT}
+ ${OPENGL_LIBRARIES}
+ ${X11_LIBRARIES}
+ -lm)
+ENDIF(BUILD_V3C1_TOOLS)
+
+IF(SGI_LINUX)
+ ADD_EXECUTABLE(mf_stream_test mf_stream_test.cc
+ ../fox/MediaFusionBridge.cc)
+ TARGET_LINK_LIBRARIES(mf_stream_test Manta_Engine
+ Manta_UserInterface
+ Manta_Model
+ Manta_Image
+ Manta_Interface
+ Manta_Core
+ SCIRun_Core
+ ${CMAKE_THREAD_LIBS_INIT}
+ )
+ENDIF(SGI_LINUX)
Modified: trunk/StandAlone/manta.cc
==============================================================================
--- trunk/StandAlone/manta.cc (original)
+++ trunk/StandAlone/manta.cc Tue Dec 6 16:58:03 2005
@@ -4,7 +4,11 @@
#include <Core/Util/Args.h>
#include <Interface/Callback.h>
#include <Interface/Scene.h>
+#include <Interface/Object.h>
+#include <Interface/Camera.h>
#include <Interface/UserInterface.h>
+#include <Interface/Context.h>
+#include <Core/Geometry/BBox.h>
#include <Core/Exceptions/Exception.h>
#include <Core/Exceptions/InternalError.h>
#include <Core/Thread/Time.h>
@@ -23,9 +27,10 @@
#include <ieeefp.h>
#endif
-Scene* createDefaultScene();
+static Scene* createDefaultScene();
-void printList(ostream& out, const RTRTInterface::listType& list, int
spaces=0)
+static void
+printList(ostream& out, const RTRTInterface::listType& list, int spaces=0)
{
for(int i=0;i<spaces;i++)
out << ' ';
@@ -38,7 +43,7 @@
out << "\n";
}
-void usage(RTRTInterface* rtrt)
+static void usage(RTRTInterface* rtrt)
{
cerr << "Usage: manta [options]\n";
cerr << "Valid options are:\n";
@@ -61,11 +66,12 @@
printList(cerr, rtrt->listPixelSamplers(), 4);
cerr << " -camera S - User camera model S, valid cameras are:\n";
printList(cerr, rtrt->listCameras(), 4);
-#if NOTFINISHED
+ cerr << " -bbcamera - Positions the lookat in the center of the\n";
+ cerr << " scene, and the eye point far enough away to\n";
+ cerr << " see the entire scene.\n";
cerr << " -renderer S - Use renderer S, valid renderers are:\n";
printList(cerr, rtrt->listRenderers(), 2);
cerr << " -scene S - Render Scene S\n";
-#endif
exit(1);
}
@@ -74,15 +80,15 @@
BenchHelper(RTRTInterface* rtrt, long numFrames);
void start(int, int);
void stop(int, int);
-
+
private:
- RTRTInterface* rtrt;
+ RTRTInterface* rtrt;
double startTime;
long numFrames;
};
BenchHelper::BenchHelper(RTRTInterface* rtrt, long numFrames)
- : rtrt(rtrt), numFrames(numFrames)
+: rtrt(rtrt), numFrames(numFrames)
{
}
@@ -94,9 +100,10 @@
void BenchHelper::stop(int, int)
{
double dt = Time::currentSeconds()-startTime;
- double fps = static_cast<double>(numFrames)/dt;
- cout << "Benchmark completed in " << dt << " seconds (" << numFrames << "
frames, " << fps << " frames per second)\n";
- rtrt->finish();
+ double fps = numFrames/dt;
+ // cout << "Benchmark completed in " << dt << " seconds (" << numFrames <<
" frames, " << fps << " frames per second)\n";
+ std::cout << fps << std::endl;
+ rtrt->finish();
delete this;
}
@@ -107,12 +114,11 @@
fpsetmask(FP_X_OFL|FP_X_DZ|FP_X_INV);
#endif
-
// Copy args into a vector<string>
vector<string> args;
for(int i=1;i<argc;i++)
args.push_back(argv[i]);
-
+
try {
RTRTInterface* rtrt = createRTRT();
if(getenv("MANTA_SCENEPATH"))
@@ -126,51 +132,52 @@
throw InternalError("default load balancer not found",
__FILE__, __LINE__);
if(!rtrt->selectImageTraverser("tiled"))
- throw InternalError("default image traverser not found",
- __FILE__, __LINE__);
+ throw InternalError("default image traverser not found", __FILE__,
__LINE__ );
if(!rtrt->selectPixelSampler("singlesample"))
- throw InternalError("default pixel sampler not found",
- __FILE__, __LINE__);
+ throw InternalError("default pixel sampler not found", __FILE__,
__LINE__ );
if(!rtrt->selectRenderer("raytracer"))
- throw InternalError("default renderer not found", __FILE__, __LINE__);
+ throw InternalError("default renderer not found", __FILE__, __LINE__ );
if(!rtrt->selectShadowAlgorithm("hard"))
- throw InternalError("default shadow algorithm not found",
- __FILE__, __LINE__);
+ throw InternalError("default shadow algorithm not found", __FILE__,
__LINE__ );
Camera* currentCamera = rtrt->createCamera("pinhole(-eye 3 3 2 -lookat 0
0 0.3 -up 0 0 1 -fov 60)");
if(!currentCamera)
- throw InternalError("cannot create default camera", __FILE__,
__LINE__);
+ throw InternalError("cannot create default camera", __FILE__, __LINE__
);
int xres = 512, yres = 512;
bool channelCreated=false;
+ bool stereo = false;
bool haveUI = false;
+ bool compute_bb_camera = false;
int argc = static_cast<int>(args.size());
for(int i=0;i<argc;i++){
string arg = args[i];
if(arg == "-help"){
- usage(rtrt);
+ usage(rtrt);
} else if(arg == "-bench"){
- long numFrames = 100;
- long warmup = 10;
- if(getLongArg(i, args, numFrames)){
- getLongArg(i, args, warmup);
- }
- BenchHelper* b = new BenchHelper(rtrt, numFrames);
- // Ask for two callbacks, one at frame "warmup", and one at
- // frame warmup+numFrames
- rtrt->addOneShotCallback(RTRTInterface::Absolute, warmup,
- Callback::create(b, &BenchHelper::start));
- rtrt->addOneShotCallback(RTRTInterface::Absolute, warmup+numFrames,
- Callback::create(b, &BenchHelper::stop));
+ long numFrames = 100;
+ long warmup = 10;
+ if(getLongArg(i, args, numFrames)){
+ getLongArg(i, args, warmup);
+ }
+ BenchHelper* b = new BenchHelper(rtrt,
numFrames);
+ // Ask for two callbacks, one at frame
"warmup", and one at
+ // frame warmup+numFrames
+
rtrt->addOneShotCallback(RTRTInterface::Absolute, warmup,
+
Callback::create(b,
&BenchHelper::start));
+
rtrt->addOneShotCallback(RTRTInterface::Absolute, warmup+numFrames,
+
Callback::create(b,
&BenchHelper::stop));
} else if(arg == "-camera"){
- string s;
- if(!getStringArg(i, args, s))
- usage(rtrt);
- currentCamera = rtrt->createCamera(s);
- if(!currentCamera){
- cerr << "Error creating camera: " << s << ", available cameras
are:\n";
- printList(cerr, rtrt->listCameras());
- exit(1);
- }
+ string s;
+ if(!getStringArg(i, args, s))
+ usage(rtrt);
+ currentCamera = rtrt->createCamera(s);
+ if(!currentCamera){
+ cerr << "Error creating camera: " <<
s << ", available cameras are:\n";
+ printList(cerr, rtrt->listCameras());
+ exit(1);
+ }
+ } else if(arg == "-bbcamera"){
+ compute_bb_camera = true;
} else if(arg == "-idlemode"){
string s;
if(!getStringArg(i, args, s))
@@ -181,133 +188,145 @@
exit(1);
}
} else if(arg == "-imagedisplay"){
- string s;
- if(!getStringArg(i, args, s))
- usage(rtrt);
- if(!rtrt->createChannel(s, currentCamera, false, xres, yres)){
- cerr << "Invalid image display: " << s << ", available image
displays are:\n";
- printList(cerr, rtrt->listImageDisplays());
- exit(1);
- }
- channelCreated=true;
+ string s;
+ if(!getStringArg(i, args, s))
+ usage(rtrt);
+ if(!rtrt->createChannel(s, currentCamera,
stereo, xres, yres)){
+ cerr << "Invalid image display: " <<
s << ", available image displays are:\n";
+ printList(cerr,
rtrt->listImageDisplays());
+ exit(1);
+ }
+ channelCreated=true;
} else if(arg == "-imagetraverser"){
- string s;
- if(!getStringArg(i, args, s))
- usage(rtrt);
- if(!rtrt->selectImageTraverser(s)){
- cerr << "Invalid image traverser: " << s << ", available image
traversers are:\n";
- printList(cerr, rtrt->listImageTraversers());
- exit(1);
- }
+ string s;
+ if(!getStringArg(i, args, s))
+ usage(rtrt);
+ if(!rtrt->selectImageTraverser(s)){
+ cerr << "Invalid image traverser: "
<< s << ", available image traversers are:\n";
+ printList(cerr,
rtrt->listImageTraversers());
+ exit(1);
+ }
} else if(arg == "-imagetype"){
- string s;
- if(!getStringArg(i, args, s))
- usage(rtrt);
- if(!rtrt->selectImageType(s)){
- cerr << "Invalid image type: " << s << ", available image types
are:\n";
- printList(cerr, rtrt->listImageTypes());
- exit(1);
- }
+ string s;
+ if(!getStringArg(i, args, s))
+ usage(rtrt);
+ if(!rtrt->selectImageType(s)){
+ cerr << "Invalid image type: " << s
<< ", available image types are:\n";
+ printList(cerr,
rtrt->listImageTypes());
+ exit(1);
+ }
} else if(arg == "-loadbalancer"){
- string s;
- if(!getStringArg(i, args, s))
- usage(rtrt);
- if(!rtrt->selectLoadBalancer(s)){
- cerr << "Invalid load balancer: " << s << ", available load
balancers are:\n";
- printList(cerr, rtrt->listLoadBalancers());
- exit(1);
- }
+ string s;
+ if(!getStringArg(i, args, s))
+ usage(rtrt);
+ if(!rtrt->selectLoadBalancer(s)){
+ cerr << "Invalid load balancer: " <<
s << ", available load balancers are:\n";
+ printList(cerr,
rtrt->listLoadBalancers());
+ exit(1);
+ }
} else if(arg == "-np"){
- long np;
- if(!getLongArg(i, args, np))
- usage(rtrt);
- rtrt->changeNumWorkers(static_cast<int>(np));
+ long np;
+ if(!getLongArg(i, args, np))
+ usage(rtrt);
+ rtrt->changeNumWorkers(static_cast<int>(np));
} else if(arg == "-pixelsampler"){
- string s;
- if(!getStringArg(i, args, s))
- usage(rtrt);
- if(!rtrt->selectPixelSampler(s)){
- cerr << "Invalid pixel sampler: " << s << ", available pixel
samplers are:\n";
- printList(cerr, rtrt->listPixelSamplers());
- exit(1);
- }
+ string s;
+ if(!getStringArg(i, args, s))
+ usage(rtrt);
+ if(!rtrt->selectPixelSampler(s)){
+ cerr << "Invalid pixel sampler: " <<
s << ", available pixel samplers are:\n";
+ printList(cerr,
rtrt->listPixelSamplers());
+ exit(1);
+ }
} else if(arg == "-renderer"){
- string s;
- if(!getStringArg(i, args, s))
- usage(rtrt);
- if(!rtrt->selectRenderer(s)){
- cerr << "Invalid renderer: " << s << ", available renderers are:\n";
- printList(cerr, rtrt->listRenderers());
- exit(1);
- }
+ string s;
+ if(!getStringArg(i, args, s))
+ usage(rtrt);
+ if(!rtrt->selectRenderer(s)){
+ cerr << "Invalid renderer: " << s <<
", available renderers are:\n";
+ printList(cerr,
rtrt->listRenderers());
+ exit(1);
+ }
} else if(arg == "-res"){
- if(!getResolutionArg(i, args, xres, yres)){
- cerr << "Error parsing resolution: " << args[i+1] << '\n';
- usage(rtrt);
- }
+ if(!getResolutionArg(i, args, xres, yres)){
+ cerr << "Error parsing resolution: "
<< args[i+1] << '\n';
+ usage(rtrt);
+ }
+ } else if(arg == "-stereo") {
+ stereo = true;
+
} else if(arg == "-scene"){
- if(rtrt->haveScene())
- cerr << "WARNING: multiple scenes specified, will use last one\n";
- string scene;
- if(!getStringArg(i, args, scene))
- usage(rtrt);
- if(!rtrt->readScene(scene)){
- cerr << "Error reading scene: " << scene << '\n';
- exit(1);
- }
+ if(rtrt->haveScene())
+ cerr << "WARNING: multiple scenes
specified, will use last one\n";
+ string scene;
+ if(!getStringArg(i, args, scene))
+ usage(rtrt);
+ if(!rtrt->readScene(scene)){
+ cerr << "Error reading scene: " <<
scene << '\n';
+ exit(1);
+ }
} else if(arg == "-shadows"){
- string s;
- if(!getStringArg(i, args, s))
- usage(rtrt);
- if(!rtrt->selectShadowAlgorithm(s)){
- cerr << "Invalid shadow algorithm: " << s << ", available shadow
algorithms are:\n";
- printList(cerr, rtrt->listShadowAlgorithms());
- exit(1);
- }
+ string s;
+ if(!getStringArg(i, args, s))
+ usage(rtrt);
+ if(!rtrt->selectShadowAlgorithm(s)){
+ cerr << "Invalid shadow algorithm: "
<< s << ", available shadow algorithms are:\n";
+ printList(cerr,
rtrt->listShadowAlgorithms());
+ exit(1);
+ }
} else if(arg == "-ui"){
- string s;
- if(!getStringArg(i, args, s))
- usage(rtrt);
- UserInterface* ui = rtrt->createUserInterface(s);
- if(!ui){
- cerr << "Unknown user interface: " << s << ", available user
interfaces are:\n";
- printList(cerr, rtrt->listUserInterfaces());
- exit(1);
- }
- ui->startup();
- haveUI = true;
+ string s;
+ if(!getStringArg(i, args, s))
+ usage(rtrt);
+ UserInterface* ui =
rtrt->createUserInterface(s);
+ if(!ui){
+ cerr << "Unknown user interface: " <<
s << ", available user interfaces are:\n";
+ printList(cerr,
rtrt->listUserInterfaces());
+ exit(1);
+ }
+ ui->startup();
+ haveUI = true;
} else {
- cerr << "Unknown argument: " << arg << '\n';
- usage(rtrt);
+ cerr << "Unknown argument: " << arg << '\n';
+ usage(rtrt);
}
}
if(!haveUI){
UserInterface* ui = rtrt->createUserInterface("X");
if(!ui){
- cerr << "Cannot find default user interface: X, available user
interfaces are:\n";
- printList(cerr, rtrt->listUserInterfaces());
- exit(1);
+ cerr << "Cannot find default user interface:
X, available user interfaces are:\n";
+ printList(cerr, rtrt->listUserInterfaces());
+ exit(1);
}
ui->startup();
- }
- if(!channelCreated){
- rtrt->createChannel("opengl", currentCamera, false, xres, yres);
}
if(!rtrt->haveScene()){
rtrt->setScene(createDefaultScene());
}
+ if(compute_bb_camera) {
+ BBox bbox;
+ PreprocessContext ppc;
+ rtrt->getScene()->getObject()->computeBounds(ppc, bbox);
+ currentCamera->autoview(bbox);
+ }
+ if(!channelCreated){
+ rtrt->createChannel("opengl", currentCamera, stereo, xres, yres);
+ }
rtrt->beginRendering(true);
delete rtrt;
+ } catch (SCIRun::Exception *e) {
+ cerr << "Caught exception: " << e->message() << std::endl << std::endl;
+ exit(1);
} catch (SCIRun::Exception& e) {
cerr << "Caught exception: " << e.message() << '\n';
if(e.stackTrace())
cerr << "Stack trace: " << e.stackTrace() << '\n';
exit(1);
-
+
} catch (std::exception e){
cerr << "Caught std exception: " << e.what() << '\n';
exit(1);
-
+
} catch(...){
cerr << "Caught unknown exception\n";
exit(1);
@@ -318,10 +337,13 @@
#include <Interface/LightSet.h>
#include <Model/AmbientLights/ConstantAmbient.h>
#include <Model/Backgrounds/ConstantBackground.h>
+#include <Model/Backgrounds/TextureBackground.h>
#include <Model/Lights/PointLight.h>
#include <Model/Textures/Constant.h>
#include <Model/Textures/CheckerTexture.h>
+#include <Model/Textures/MarbleTexture.h>
#include <Model/Materials/Phong.h>
+#include <Model/Materials/Flat.h>
#include <Model/Groups/Group.h>
#include <Model/Primitives/Parallelogram.h>
#include <Model/Primitives/Sphere.h>
@@ -332,31 +354,55 @@
// Create a default scene. This scene is used for benchmarks, so
// please do not change it. Please create a new scene instead
Scene* scene = new Scene();
+
+ // Set only one of these #ifs to 1.
+#if 1
scene->setBackground(new
ConstantBackground(ColorDB::getNamedColor("SkyBlue3")*0.5));
- Material* red=new Phong(Color(RGBColor(.6,0,0)),
- Color(RGBColor(.6,.6,.6)), 32, 0.4);
+#elif 0
+ scene->setBackground(new TextureBackground(new
Constant<Color>(Color(RGBColor(.2,1,1))), Vector(0,1,0)));
+#elif 0
+ scene->setBackground(new TextureBackground
+ (new MarbleTexture<Color>(Color(RGB(0.1,0.2,0.5)),
+ Color(RGB(0.7,0.8,1.0)),
+ 1.0, 1.0, 15.0,
+ 6, 2.0, 0.6 ),
+ Vector(0,1,0)));
+#elif 0
+ scene->setBackground(new TextureBackground
+ (new CheckerTexture<Color>(Color(RGBColor(1,0,0)),
+ Color(RGBColor(0,0,1)),
+ Vector(10,0,0),
+ Vector(0,10,0)),
+ Vector(0,1,0)));
+#endif
+ Material* red=new Phong(Color(RGBColor(.6,0,0)),
+ Color(RGBColor(.6,.6,.6)), 32,
(ColorComponent)0.4);
+
Material* plane_matl = new Phong(new
CheckerTexture<Color>(Color(RGBColor(.6,.6,.6)),
-
Color(RGBColor(0,0,0)),
- Vector(1,0,0),
- Vector(0,1,0)),
- new
Constant<Color>(Color(RGBColor(.6,.6,.6))),
- 32,
- new CheckerTexture<double>(0.2, 0.5,
- Vector(1,0,0),
- Vector(0,1,0)));
-
-
+
Color(RGBColor(0,0,0)),
+
Vector(1,0,0),
+
Vector(0,1,0)),
+
new
Constant<Color>(Color(RGBColor(.6,.6,.6))),
+
32,
+
new
CheckerTexture<ColorComponent>
+ ((ColorComponent)0.2,
+ (ColorComponent)0.5,
+ Vector(1,0,0),
+ Vector(0,1,0)));
+
+
Group* world = new Group();
Primitive* floor = new Parallelogram(plane_matl, Point(-20,-20,0),
- Vector(40,0,0), Vector(0,40,0));
+
Vector(40,0,0), Vector(0,40,0));
// Setup world-space texture coordinates for the checkerboard floor
UniformMapper* uniformmap = new UniformMapper();
floor->setTexCoordMapper(uniformmap);
world->add(floor);
+ // red = new Flat(Color(RGBColor(1,0.1,0.2)));
world->add(new Sphere(red, Point(0,0,1.2), 1.0));
scene->setObject(world);
-
+
LightSet* lights = new LightSet();
lights->add(new PointLight(Point(0,5,8), Color(RGBColor(.6,.1,.1))));
lights->add(new PointLight(Point(5,0,8), Color(RGBColor(.1,.6,.1))));
Modified: trunk/UserInterface/CMakeLists.txt
==============================================================================
--- trunk/UserInterface/CMakeLists.txt (original)
+++ trunk/UserInterface/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -1,5 +1,15 @@
-ADD_LIBRARY (Manta_UserInterface PromptUI.cc XWindowUI.cc)
+ADD_LIBRARY (Manta_UserInterface
+ PromptUI.h
+ PromptUI.cc
+ XWindowUI.h
+ XWindowUI.cc
+ NullUI.h
+ AutomatorUI.h
+ AutomatorUI.cc
+ CameraPathAutomator.h
+ CameraPathAutomator.cc
+ )
TARGET_LINK_LIBRARIES(Manta_UserInterface Manta_Interface
Manta_Core_XUtils Manta_Core)
TARGET_LINK_LIBRARIES(Manta_UserInterface ${OPENGL_LIBRARIES}
${X11_LIBRARIES})
Modified: trunk/UserInterface/PromptUI.cc
==============================================================================
--- trunk/UserInterface/PromptUI.cc (original)
+++ trunk/UserInterface/PromptUI.cc Tue Dec 6 16:58:03 2005
@@ -1,8 +1,38 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institue, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
#include <UserInterface/PromptUI.h>
+#include <UserInterface/AutomatorUI.h>
#include <Interface/RTRTInterface.h>
-#include <Core/Util/Args.h>
+#include <Interface/Camera.h>
#include <Interface/ShadowAlgorithm.h>
+#include <Core/Util/Args.h>
#include <Core/Exceptions/Exception.h>
#include <Core/Thread/Runnable.h>
#include <Core/Thread/Thread.h>
@@ -18,21 +48,22 @@
using SCIRun::Exception;
using SCIRun::Thread;
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP
SETUP
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
UserInterface* PromptUI::create(const vector<string>& args,
- RTRTInterface *rtrt_int) {
- UserInterface *newUI = new PromptUI(args, rtrt_int);
- // Probably need to create a thread and start it going.
+ RTRTInterface *manta_interface_) {
- return newUI;
+ return new PromptUI( args, manta_interface_ );
}
-PromptUI::PromptUI(const vector<string>& args, RTRTInterface *rtrt_int):
- rtrt_int(rtrt_int)
+PromptUI::PromptUI(const vector<string>& args, RTRTInterface
*manta_interface_) :
+ manta_interface( manta_interface_ ),
+ current_channel( 0 )
{
- cout << "PromptUI::PromptUI created with args = (";
- for(unsigned int i = 0; i < args.size(); i++)
- cout << args[1] << ", ";
- cout << ")\n";
}
PromptUI::~PromptUI() {
@@ -42,89 +73,252 @@
(new Thread(this, "Manta User Interface"))->detach();
}
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// RUN RUN RUN RUN RUN RUN RUN RUN RUN RUN RUN RUN RUN RUN RUN
R
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
void PromptUI::run() {
- cout << "Prompt User Interface starting up...\n";
- cout << "What is thy bidding my master?\n";
- cout << "It's a desaster. It's Skywalker we're after.\n";
- cout << "But if he could be turned to the dark side?\n";
- cout << "Yes, he'd be a powerful ally. Another dark Jedi!\n";
- cout << "He will join us or die...!\n";
-
- for (;;) {
- cout << "manta> ";
-
- // Get the prompt
- const int buf_size = 1000;
- char command_buf[buf_size];
- // Never use gets as it is unsafe to use (security).
- fgets(command_buf, buf_size, stdin);
+ char buffer[256];
+
+ while (1) {
+
+ // Read in a line from stdin.
+ cin.getline( buffer, 255 );
- // Parse the command
- vector<string> args;
try {
- parseArgs(string(command_buf), args);
- } catch (Exception& e) {
- cerr << e.message() << '\n';
- continue;
- }
- if (args.size() < 1)
- // No arguments
- continue;
- string command = args[0];
-
- if (command == "show") {
- show(args);
- } else if (command == "quit") {
- // kill the rtrt engine and stop
- cout << "Are you sure you wish to kill everything (y/n)? ";
- int response = fgetc(stdin);
- if (response == 'y' || response == 'Y') {
- cout << "Goodbye!\n";
- Thread::exitAll(0);
- } else {
- cout << "\nNot quitting.\n";
- }
- } else if (command == "quitUI") {
- cout << "PromptUI going away!\n";
- return;
- } else if (command == "help") {
- cout << "The following commands are recognized:\n\n";
- cout << "\tquit - stops the manta engine and exits the program\n";
- cout << "\tquitUI - stops this user interface thread.\n";
- cout << "\tshow S - show attributes specified by S (blank to see
usage).\n";
- } else {
- cout << "Unknown command: "<<command<<". Type help\n";
+ // Process the command.
+ processCommand( buffer );
+ }
+ catch (SCIRun::Exception &e) {
+ cerr << e.message() << std::endl;
+ }
+ catch (SCIRun::Exception *e) {
+ cerr << e->message() << std::endl;
}
}
}
-void PromptUI::show(const vector<string>& args) {
- if (args.size() < 2) {
- // Print usage for show
- cout << "Options for show\n";
- cout << "\tshadows\n";
- cout << "\tnumworkers\n";
+void PromptUI::processCommand( const string &input_line ) {
+
+ // Each line of input should contain:
+ // -option value"( -args ... )"
+ // Everything between the value( and ) will be passed to the
manta_interface
+ // as a string. Note the quotes are unnecessary
+
+ // cerr << "Input line: " << input_line << endl;
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Find the option string.
+ string::const_iterator iter = input_line.begin();
+
+ // Skip leading whitespace.
+ while ((iter != input_line.end()) &&
+ (((*iter) == ' ') ||
+ ((*iter) == '\t')))
+ ++iter;
+
+ // Make sure the first character is a '-'
+ if (*iter != '-') {
return;
}
- string command = args[1];
- vector<string> results;
- if (rtrt_int->queryState(command, results)) {
- // the command was sucessful
- if (command == "shadows") {
- if (results.size() != 2) {
- cerr << "queryState returned the wrong number of args for shadows.
Wanted 2 and got "<<results.size()<<".\n";
- return;
+
+ string::const_iterator begin = iter;
+
+ // Advance to white space.
+ while ((iter != input_line.end()) &&
+ !(((*iter) == ' ') ||
+ ((*iter) == '\t')))
+ ++iter;
+
+ // Found the option string.
+ string option_string( begin, iter );
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Find the value string.
+
+ // Skip white space
+ while ((iter != input_line.end()) &&
+ (((*iter) == ' ') ||
+ ((*iter) == '\t')))
+ ++iter;
+
+ begin = iter;
+
+ // Find either a space or the end of the line.
+ while ((iter != input_line.end()) &&
+ !(((*iter) == ' ') ||
+ ((*iter) == '(')))
+ ++iter;
+
+ // Check to see if args are specified.
+ if (*iter == '(') {
+
+ while ((iter != input_line.end()) &&
+ !((*iter) == ')'))
+ ++iter;
+
+ // Advance one past the closing ')'
+ if (iter != input_line.end())
+ ++iter;
+ }
+
+ string value_string( begin, iter );
+
+ // cerr << "Parsed directive: option: " << option_string << " value: " <<
value_string << std::endl;
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Match the option string to a known option.
+
+ try {
+
+ if (option_string == "-help") {
+ printHelp();
+ }
+ else if (option_string == "-bench") {
+ }
+ else if (option_string == "-camera") {
+ manta_interface->addTransaction( "select camera",
+ Callback::create( this,
&PromptUI::mantaCamera, value_string ));
+ }
+ else if (option_string == "-idlemode") {
+ }
+ else if (option_string == "-imagetraverser") {
+ manta_interface->addTransaction( "select imagetraverser",
+ Callback::create( this,
&PromptUI::mantaImageTraverser, value_string ));
+ }
+ else if (option_string == "-loadbalancer") {
+ }
+ else if (option_string == "-np") {
+ }
+ else if (option_string == "-pixelsampler") {
+ }
+ else if (option_string == "-renderer") {
+ }
+ else if (option_string == "-scene") {
+ }
+ else if (option_string == "-shadows") {
+ }
+ else if (option_string == "-ui") {
+ UserInterface *ui = manta_interface->createUserInterface( value_string
);
+
+ // Make sure a ui was created.
+ if (ui == 0) {
+ return;
}
- cout << "Current shadow algorithm is ("<<results[0]<<") with specs
("<<results[1]<<")\n";
- } else if (command == "numworkers") {
- if (results.size() != 1) {
- cerr << "queryState returned the wrong number of args for numworkers.
Wanted 1 and got "<<results.size()<<".\n";
- return;
+
+ // Check to see if the ui is a Automator.
+ AutomatorUI *automator = dynamic_cast<AutomatorUI *>( ui );
+ if (automator != 0) {
+
+ // Set the termination callback so we know when the automator
finishes.
+ automator->set_terminate_callback( Callback::create( this,
&PromptUI::automatorComplete ));
}
- cout << "Number of workers are "<<results[0]<<".\n";
+
+ // Start the ui.
+ ui->startup();
}
- } else {
- cout << "Unknown option \""<<command<<"\" for show\n";
+ else if (option_string == "-quit") {
+
+ Thread::exitAll( 0 );
+ }
+
+ } catch (SCIRun::Exception *e) {
+ cerr << "Caught exception: " << e->message() << std::endl << std::endl;
+ } catch (SCIRun::Exception& e) {
+ cerr << "Caught exception: " << e.message() << '\n';
+ if(e.stackTrace())
+ cerr << "Stack trace: " << e.stackTrace() << '\n';
+ } catch (std::exception e){
+ cerr << "Caught std exception: " << e.what() << '\n';
+
+ } catch(...){
+ cerr << "Caught unknown exception\n";
+ }
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// TRANSACTION CALLBACKS TRANSACTION CALLBACKS TRANSACTION CALLBACKS
TRANSAC
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+void PromptUI::mantaCamera( string text ) {
+
+ // Create the camera.
+ Camera *new_camera = manta_interface->createCamera( text );
+ if (new_camera == 0) {
+ std::cerr << "Could not select camera " << text << std::endl;
+ return;
+ }
+
+ // Get the old camera.
+ Camera *old_camera = manta_interface->getCamera( current_channel );
+
+ // Replace the camera.
+ manta_interface->setCamera( current_channel, new_camera );
+
+ delete old_camera;
+}
+
+void PromptUI::mantaImageTraverser( string text ) {
+
+ manta_interface->selectImageTraverser( text );
+}
+
+void PromptUI::automatorComplete() {
+
+ std::cout << "PROMPT_UI_AUTOMATOR_COMPLETE" << std::endl;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP HELP
HELP
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+void PromptUI::printHelp() {
+
+ cerr << "Usage: manta [options]\n";
+ cerr << "Valid options are:\n";
+ cerr << " -help - Print this message and exit\n";
+ cerr << " -bench [N [M]] - Time N frames after an M frame warmup period
and print out the framerate,\n";
+ cerr << " default N=100, M=10\n";
+ cerr << " -np N - Use N processors\n";
+ cerr << " -res NxM - Use N by M pixels for rendering (needs the
x).\n";
+ cerr << " -imagedisplay S - Use image display mode named S, valid modes
are:\n";
+ printList(cerr, manta_interface->listImageDisplays(), 4);
+ cerr << " -imagetype S - Use image display mode named S, valid modes
are:\n";
+ printList(cerr, manta_interface->listImageTypes(), 4);
+ cerr << " -ui S - Use the user interface S, valid options
are:\n";
+ printList(cerr, manta_interface->listUserInterfaces(), 4);
+ cerr << " -shadows S - Use S mode for rendering shadows, valid modes
are:\n";
+ printList(cerr, manta_interface->listShadowAlgorithms(), 4);
+ cerr << " -imagetraverser S - Use S method for image traversing, valid
modes are:\n";
+ printList(cerr, manta_interface->listImageTraversers(), 4);
+ cerr << " -pixelsampler S - Use S method for pixel sampling, valid modes
are:\n";
+ printList(cerr, manta_interface->listPixelSamplers(), 4);
+ cerr << " -camera S - User camera model S, valid cameras are:\n";
+ printList(cerr, manta_interface->listCameras(), 4);
+ cerr << " -renderer S - Use renderer S, valid renderers are:\n";
+ printList(cerr, manta_interface->listRenderers(), 2);
+ cerr << " -scene S - Render Scene S\n";
+}
+
+// This method prints a list of options.
+void PromptUI::printList( ostream& out, const RTRTInterface::listType& list,
int spaces ) {
+
+ for(int i=0;i<spaces;i++)
+ out << ' ';
+
+ for(RTRTInterface::listType::const_iterator iter = list.begin();
+ iter != list.end(); ++iter){
+ if(iter != list.begin())
+ out << ", ";
+ out << *iter;
}
+ out << "\n";
}
Modified: trunk/UserInterface/PromptUI.h
==============================================================================
--- trunk/UserInterface/PromptUI.h (original)
+++ trunk/UserInterface/PromptUI.h Tue Dec 6 16:58:03 2005
@@ -1,8 +1,35 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institue, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
#ifndef RTRT_PromptUI_h
#define RTRT_PromptUI_h
+#include <Interface/RTRTInterface.h>
#include <Interface/UserInterface.h>
#include <Core/Thread/Runnable.h>
@@ -15,24 +42,52 @@
using namespace std;
class RTRTInterface;
-
+
+
/////////////////////////////////////////////////////////////////////////////
+
/////////////////////////////////////////////////////////////////////////////
+ // PromptUI is a userinterface which listens on STDIN for command line
+ // directives and then changes manta's state. The directives match
bin/manta
+ // command line args.
+ //
+ // PromptUI is designed to be driven by a perl script for batch benchmarks.
+ //
+ // In general, manta outputs performance information on STDOUT and outputs
+ // all other warnings and messages on STDERR. PromptUI will listen on STDIN
+ // but by default won't output anything on STDOUT unless an error occurs.
+ //
+
/////////////////////////////////////////////////////////////////////////////
+
/////////////////////////////////////////////////////////////////////////////
class PromptUI: public UserInterface, public SCIRun::Runnable {
+ protected:
+ RTRTInterface *manta_interface;
+
+ // Channel that the ui is operating on.
+ int current_channel;
+
+ // Helper methods.
+ void printHelp();
+ void printList( ostream& out, const RTRTInterface::listType& list, int
spaces=0 );
+
+ void processCommand( const string &input_line );
+
+ // Transaction callbacks
+ void mantaCamera( string text );
+ void mantaImageTraverser( string text );
+
+ void automatorComplete();
+
public:
PromptUI(const vector<string>& args, RTRTInterface *rtrt_int);
virtual ~PromptUI();
+ // UserInterface method.
virtual void startup();
+ // Runnable method.
virtual void run();
static UserInterface* create(const vector<string>& args,
- RTRTInterface *rtrt_int);
-
- protected:
- // This is a pointer to the interface we will use to interact with manta.
- RTRTInterface *rtrt_int;
-
- void show(const vector<string>& args);
+ RTRTInterface *manta_interface_ );
private:
PromptUI(const PromptUI&);
Modified: trunk/UserInterface/XWindowUI.cc
==============================================================================
--- trunk/UserInterface/XWindowUI.cc (original)
+++ trunk/UserInterface/XWindowUI.cc Tue Dec 6 16:58:03 2005
@@ -5,6 +5,8 @@
#include <Interface/RTRTInterface.h>
#include <Interface/Transaction.h>
#include <Interface/XWindow.h>
+#include <Interface/Scene.h>
+#include <Interface/Object.h>
#include <Core/Exceptions/ErrnoException.h>
#include <Core/Exceptions/InternalError.h>
#include <Core/Geometry/AffineTransform.h>
@@ -13,7 +15,7 @@
#include <Core/Thread/Runnable.h>
#include <Core/Thread/Thread.h>
#include <Core/XUtils/XHelper.h>
-
+#include <Core/Geometry/BBox.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <errno.h>
@@ -80,13 +82,13 @@
// Open the display and setup file descriptors for threads
if(pipe(xpipe) == -1){
- throw ErrnoException("XWindowUI pipe", errno, __FILE__, __LINE__);
+ throw ErrnoException( "XWindowUI pipe", errno, __FILE__, __LINE__ );
}
dpy = XOpenDisplay(NULL);
if(!dpy)
- throw InternalError("XOpenDisplay failed", __FILE__, __LINE__);
+ throw InternalError("XOpenDisplay failed", __FILE__, __LINE__ );
if(XAddConnectionWatch(dpy, connection_watch,
reinterpret_cast<XPointer>(this)) == 0)
- throw InternalError("XAddConnectionWatch failed", __FILE__, __LINE__);
+ throw InternalError("XAddConnectionWatch failed", __FILE__, __LINE__ );
if(xfds.size() == 0){
// XAddConnectionWatch must be broken. To fix it, we look at the
@@ -94,7 +96,8 @@
// file descriptors are between the two.
int tmp_pipe[2];
if(pipe(tmp_pipe) == -1)
- throw ErrnoException("XWindowUI pipe2", errno, __FILE__, __LINE__);
+ throw ErrnoException("XWindowUI pipe2", errno, __FILE__, __LINE__ );
+
for(int i=xpipe[1]+1; i<tmp_pipe[0];i++)
addConnection(i);
}
@@ -174,14 +177,15 @@
}
int s = select(max+1, &readfds, 0, 0, 0);
if(s == -1)
- throw ErrnoException("XWindowUI select", errno, __FILE__, __LINE__);
+ throw ErrnoException("XWindowUI select", errno, __FILE__, __LINE__ );
if(FD_ISSET(xpipe[0], &readfds)){
// Process the pipe...
int token;
ssize_t s = read(xpipe[0], &token, sizeof(token));
if(s != sizeof(token))
- throw ErrnoException("XWindowUI read pipe", errno, __FILE__,
__LINE__);
+ throw ErrnoException("XWindowUI read pipe", errno,
+ __FILE__, __LINE__ );
switch(token){
case TOKEN_NOOP:
break;
@@ -191,15 +195,15 @@
xlock.lock();
break;
default:
- throw InternalError("XWindowUI::Unknown token in pipe",
- __FILE__, __LINE__);
+ throw InternalError("XWindowUI::Unknown token in pipe",
+ __FILE__, __LINE__ );
}
}
bool have_some = false;
for(vector<int>::iterator iter = xfds.begin(); iter != xfds.end();
iter++){
if(FD_ISSET(*iter, &readfds)){
- XProcessInternalConnection(dpy, *iter);
- have_some = true;
+ XProcessInternalConnection(dpy, *iter);
+ have_some = true;
}
}
if(have_some){
@@ -227,7 +231,7 @@
int token = TOKEN_LOCK;
ssize_t s = write(xpipe[1], &token, sizeof(int));
if(s != sizeof(int)){
- throw ErrnoException("XWindowUI write 3", errno, __FILE__, __LINE__);
+ throw ErrnoException("XWindowUI write 3", errno, __FILE__, __LINE__ );
}
xlock.lock();
}
@@ -283,15 +287,14 @@
KeyEventCallbackType* press,
KeyEventCallbackType* release)
{
- cerr << description << ": " << (void*)key << '\n';
+ // cerr << description << ": " << (void*)key << '\n';
if(key == 0)
- throw InternalError("tried to register invalid key: "+description,
- __FILE__, __LINE__);
+ throw InternalError("tried to register invalid key: "+description,
__FILE__, __LINE__ );
for(vector<KeyTab>::iterator iter = keys.begin();
iter != keys.end(); iter++){
if(key == iter->key && state == iter->state)
- throw InternalError("Two functions mapped to the same key:
"+description+" and "+iter->description, __FILE__, __LINE__);
+ throw InternalError("Two functions mapped to the same key:
"+description+" and "+iter->description, __FILE__, __LINE__ );
}
KeyTab entry;
entry.key = key;
@@ -306,11 +309,11 @@
const string& description,
MouseEventCallbackType* event)
{
- cerr << description << ": " << button << '\n';
+ // cerr << description << ": " << button << '\n';
for(vector<MouseTab>::iterator iter = mouse.begin();
iter != mouse.end(); iter++){
if(button == iter->button && state == iter->state)
- throw InternalError("Two functions mapped to the same mouse button:
"+description+" and "+iter->description, __FILE__, __LINE__);
+ throw InternalError("Two functions mapped to the same mouse button:
"+description+" and "+iter->description, __FILE__, __LINE__ );
}
MouseTab entry;
entry.state = state;
@@ -323,6 +326,7 @@
void XWindowUI::changeResolution(int, int, int channel,
int new_xres, int new_yres)
{
+ // cerr << "Resolution: " << new_xres << " " << new_yres << endl;
rtrt_interface->changeResolution(channel, new_xres, new_yres, true);
}
@@ -395,6 +399,9 @@
register_key(0, XStringToKeysym("v"),
"autoview",
Callback::create(this, &XWindowUI::autoview));
+ register_key(0, XStringToKeysym("c"),
+ "output camera",
+ Callback::create(this, &XWindowUI::output_camera));
register_key(0, XStringToKeysym("Escape"),
"quit after this frame, press again to immediately quit",
Callback::create(this, &XWindowUI::quitkey));
@@ -461,9 +468,19 @@
void XWindowUI::autoview(unsigned int, unsigned long, int channel)
{
Camera* camera = rtrt_interface->getCamera(channel);
+ BBox bbox;
+ PreprocessContext ppc;
+ rtrt_interface->getScene()->getObject()->computeBounds(ppc, bbox);
rtrt_interface->addTransaction("autoview",
Callback::create(camera, &Camera::autoview,
- autoview_fov));
+ bbox));
+}
+
+void XWindowUI::output_camera(unsigned int, unsigned long, int channel)
+{
+ Camera* camera = rtrt_interface->getCamera(channel);
+ rtrt_interface->addTransaction("output camera",
+ Callback::create<Camera,std::ostream
&>(camera, &Camera::output, std::cout));
}
void XWindowUI::mouse_fov(unsigned int, unsigned int,
@@ -476,9 +493,9 @@
} else {
// Zoom in/out.
XWindow* window = windows[channel];
- double xmotion= double(ias.last_x - mouse_x)/window->xres;
- double ymotion= double(ias.last_y - mouse_y)/window->yres;
- double scale;
+ Real xmotion= Real(ias.last_x - mouse_x)/window->xres;
+ Real ymotion= Real(ias.last_y - mouse_y)/window->yres;
+ Real scale;
if (Abs(xmotion) > Abs(ymotion))
scale = xmotion;
else
@@ -505,8 +522,8 @@
{
InteractionState& ias = interactions[channel];
XWindow* window = windows[channel];
- double xpos = 2.0*mouse_x/window->xres - 1.0;
- double ypos = 1.0 - 2.0*mouse_y/window->yres;
+ Real xpos = (Real)2*mouse_x/window->xres - 1;
+ Real ypos = 1 - (Real)2*mouse_y/window->yres;
if(event == ButtonPress){
ias.rotate_from = projectToSphere(xpos, ypos, trackball_radius);
} else {
@@ -535,8 +552,8 @@
ias.last_y = mouse_y;
} else {
XWindow* window = windows[channel];
- double xmotion = double(ias.last_x-mouse_x)/window->xres;
- double ymotion = -double(ias.last_y-mouse_y)/window->yres;
+ Real xmotion = Real(ias.last_x-mouse_x)/window->xres;
+ Real ymotion = -Real(ias.last_y-mouse_y)/window->yres;
Vector translation(xmotion*translate_speed, ymotion*translate_speed, 0);
Camera* camera = rtrt_interface->getCamera(channel);
@@ -557,10 +574,10 @@
ias.last_y = mouse_y;
} else {
XWindow* window = windows[channel];
- double xmotion = -double(ias.last_x-mouse_x)/window->xres;
- double ymotion = double(ias.last_y-mouse_y)/window->yres;
+ Real xmotion = -Real(ias.last_x-mouse_x)/window->xres;
+ Real ymotion = Real(ias.last_y-mouse_y)/window->yres;
- double scale;
+ Real scale;
if (Abs(xmotion)>Abs(ymotion))
scale=xmotion;
else
@@ -730,18 +747,18 @@
}
}
-Vector XWindowUI::projectToSphere(double x, double y, double radius) const
+Vector XWindowUI::projectToSphere(Real x, Real y, Real radius) const
{
x /= radius;
y /= radius;
- double rad2 = x*x+y*y;
+ Real rad2 = x*x+y*y;
if(rad2 > 1){
- double rad = sqrt(rad2);
+ Real rad = Sqrt(rad2);
x /= rad;
y /= rad;
return Vector(x,y,0);
} else {
- double z = sqrt(1-rad2);
+ Real z = Sqrt(1-rad2);
return Vector(x,y,z);
}
}
Modified: trunk/UserInterface/XWindowUI.h
==============================================================================
--- trunk/UserInterface/XWindowUI.h (original)
+++ trunk/UserInterface/XWindowUI.h Tue Dec 6 16:58:03 2005
@@ -69,6 +69,8 @@
void prockey(unsigned int, unsigned long, int);
void quitkey(unsigned int, unsigned long, int);
void autoview(unsigned int, unsigned long, int);
+
+ void output_camera(unsigned int, unsigned long, int);
void mouse_fov(unsigned int, unsigned int, int, int, int, int);
void mouse_translate(unsigned int, unsigned int, int, int, int, int);
@@ -78,7 +80,7 @@
void animation_callback(int, int, bool&);
// Utility functions
- Vector projectToSphere(double x, double y, double radius) const;
+ Vector projectToSphere(Real x, Real y, Real radius) const;
// This is a pointer to the interface we will use to interact with manta.
RTRTInterface *rtrt_interface;
@@ -124,12 +126,12 @@
vector<InteractionState> interactions;
// Interaction parameters
- double fov_speed;
- double translate_speed;
- double dolly_speed;
- double rotate_speed;
- double autoview_fov;
- double trackball_radius;
+ Real fov_speed;
+ Real translate_speed;
+ Real dolly_speed;
+ Real rotate_speed;
+ Real autoview_fov;
+ Real trackball_radius;
XWindowUI(const XWindowUI&);
XWindowUI& operator=(const XWindowUI&);
Modified: trunk/scenes/CMakeLists.txt
==============================================================================
--- trunk/scenes/CMakeLists.txt (original)
+++ trunk/scenes/CMakeLists.txt Tue Dec 6 16:58:03 2005
@@ -22,6 +22,13 @@
TARGET_LINK_LIBRARIES(scene_0 ${manta_scene_link})
ENDIF(SCENE_0)
+# Just a cube.
+SET(SCENE_CUBE 0 CACHE BOOL "Just a Cube")
+IF(SCENE_CUBE)
+ ADD_LIBRARY(scene_cube cube.cc)
+ TARGET_LINK_LIBRARIES(scene_cube ${manta_scene_link})
+ENDIF(SCENE_CUBE)
+
# Read in a BART scene.
SET(SCENE_BARTREADER 0 CACHE BOOL "BART Reader")
IF(SCENE_BARTREADER)
@@ -50,5 +57,24 @@
TARGET_LINK_LIBRARIES(scene_ParticleBVHTest ${manta_scene_link})
ENDIF(SCENE_PARTICLEBVHTEST)
-############################################################
+# Boeing 777 Test Scene.
+SET(SCENE_BOEING777 0 CACHE BOOL "Boeing 777 Test Scene")
+IF(SCENE_BOEING777)
+ ADD_LIBRARY(scene_boeing777 boeing777.cc)
+ TARGET_LINK_LIBRARIES(scene_boeing777 ${manta_scene_link})
+ENDIF(SCENE_BOEING777)
+
+# volume
+SET(SCENE_VOLUME 0 CACHE BOOL "volume rendering")
+IF(SCENE_VOLUME)
+ ADD_LIBRARY(scene_volume volume.cc)
+ TARGET_LINK_LIBRARIES(scene_volume ${manta_scene_link})
+ENDIF(SCENE_VOLUME)
+
+SET(SCENE_OBJVIEWER 0 CACHE BOOL "Wavefront Obj file viewer.")
+IF(SCENE_OBJVIEWER)
+ ADD_LIBRARY(scene_objviewer objviewer.cc)
+ TARGET_LINK_LIBRARIES(scene_objviewer ${manta_scene_link})
+ENDIF(SCENE_OBJVIEWER)
+
Modified: trunk/scenes/primtest.cc
==============================================================================
--- trunk/scenes/primtest.cc (original)
+++ trunk/scenes/primtest.cc Tue Dec 6 16:58:03 2005
@@ -51,8 +51,8 @@
{
std::cout << "Make_scene args: " << args.size() << std::endl;
- double scale = 1;
- double texscale = 20;
+ Real scale = 1;
+ Real texscale = 20;
int numx = 8;
int numy = 8;
string primtype = "sphere";
@@ -66,10 +66,10 @@
for(int i=0;i<argc;i++){
string arg = args[i];
if(arg == "-scale"){
- if(!getDoubleArg(i, args, scale))
+ if(!getArg<Real>(i, args, scale))
throw IllegalArgument("scene primtest -scale", i, args);
} else if(arg == "-texscale"){
- if(!getDoubleArg(i, args, texscale))
+ if(!getArg<Real>(i, args, texscale))
throw IllegalArgument("scene primtest -texscale", i, args);
} else if(arg == "-num"){
if(!getResolutionArg(i, args, numx, numy))
@@ -105,7 +105,8 @@
int max = SCIRun::Max(numx, numy);
if(material == "redphong")
- matl=new Phong(Color(RGB(.6,0,0)), Color(RGB(.6,.6,.6)), 32, 0.4);
+ matl=new Phong(Color(RGB(.6,0,0)), Color(RGB(.6,.6,.6)),
+ 32, (ColorComponent)0.4);
else if(material == "redlambertian")
matl=new Lambertian(Color(RGB(.6,0,0)));
else if(material == "metal")
@@ -117,7 +118,7 @@
Vector(0,1,0)*texscale),
new Constant<Color>(Color(RGB(.6,.6,.6))),
32,
- new Constant<double>(0));
+ new Constant<ColorComponent>(0));
else if(material == "checker2")
matl = new Phong(new CheckerTexture<Color>(Color(RGB(.6,.6,.6)),
Color(RGB(.6,0,0)),
@@ -125,12 +126,14 @@
Vector(0,1,0)*texscale),
new Constant<Color>(Color(RGB(.6,.6,.6))),
32,
- new CheckerTexture<double>(0.2, 0.5,
- Vector(1,0,0)*texscale,
- Vector(0,1,0)*texscale));
+ new CheckerTexture<ColorComponent>
+ ((ColorComponent)0.2,
+ (ColorComponent)0.5,
+ Vector(1,0,0)*texscale,
+ Vector(0,1,0)*texscale));
else if(material == "checker3")
- matl = new Checker(new Phong(Color(RGB(.6,.6,.6)), Color(RGB(.6,.6,.6)),
32, 0.2),
- new Phong(Color(RGB(.6,0,0)), Color(RGB(.6,.6,.6)),
32, 0.5),
+ matl = new Checker(new Phong(Color(RGB(.6,.6,.6)), Color(RGB(.6,.6,.6)),
32, (ColorComponent)0.2),
+ new Phong(Color(RGB(.6,0,0)), Color(RGB(.6,.6,.6)),
32, (ColorComponent)0.5),
Vector(1,0,0)*texscale, Vector(0,1,0)*texscale);
else if(material == "marble")
{
@@ -140,7 +143,7 @@
10.0, 1.0, 15.0, 6, 2.0, 0.6 ),
new Constant<Color>(Color(RGB(.6,.6,.6))),
32,
- new Constant<double>(0));
+ new Constant<ColorComponent>(0));
mapr = new UniformMapper();
}
else if(material == "wood")
@@ -173,9 +176,15 @@
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
int idx = j*numx+i;
+<<<<<<< .working
double radius = (idx+1)/static_cast<double>(numx*numy)*scale/max;
Point p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 : 0.)*scale*2,
(numy>1 ? j/static_cast<double>(numy-1) - 0.5 : 0.)*scale*2,
+=======
+ Real radius = (idx+1)/((numx*numy)*scale/max);
+ Point p((i/static_cast<Real>(numx-1) - (Real)0.5)*scale*2,
+ (j/static_cast<Real>(numy-1) - (Real)0.5)*scale*2,
+>>>>>>> .merge-right.r751
0);
Primitive* prim = new Sphere( matl, p, radius );
if ( mapr )
@@ -183,12 +192,36 @@
group->add( prim );
}
}
+<<<<<<< .working
+=======
+ } else if (primtype == "simplesuperellipsoid"){
+ for(int i=0;i<numx;i++){
+ for(int j=0;j<numy;j++){
+ int idx = j*numx+i;
+ Real radius = (idx+1)/((numx*numy)*scale/max);
+ Real alpha = (i+1)/static_cast<Real>(numx)*2;
+ Real beta = (j+1)/static_cast<Real>(numy)*2;
+ Point p((i/static_cast<Real>(numx-1) - (Real)0.5)*scale*2,
+ (j/static_cast<Real>(numy-1) - (Real)0.5)*scale*2,
+ 0);
+ Primitive* prim = new SuperEllipsoid( matl, p, radius, alpha, beta );
+ if ( mapr )
+ prim->setTexCoordMapper( mapr );
+ group->add( prim );
+ }
+ }
+>>>>>>> .merge-right.r751
} else if(primtype == "simplebox"){
Vector p2(scale/max, scale/max, scale/max);
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
+<<<<<<< .working
Point p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 : 0.)*scale*2,
(numy>1 ? j/static_cast<double>(numy-1) - 0.5 : 0.)*scale*2,
+=======
+ Point p((i/static_cast<Real>(numx-1) - (Real)0.5)*scale*2,
+ (j/static_cast<Real>(numy-1) - (Real)0.5)*scale*2,
+>>>>>>> .merge-right.r751
0);
Primitive* prim = new Cube( matl, p-p2, p2.x()*1.156, p2.y()*1.156,
p2.z()*1.156 );
if ( mapr )
@@ -219,7 +252,7 @@
Point p2(scale/max/1.414, scale/max/1.414, scale/max/1.414);
Primitive* o1 = new Cube(matl, Point(-p2.x(), -p2.y(), -p2.z()),
p2.x()*2, p2.y()*2, p2.z()*2);
Primitive* o2 = new Sphere(matl, Point(0,0,0), scale/max);
- double s = scale/max/1.414*2*(1+1.e-10);
+ Real s = scale/max/(Real)1.414*2*(Real)(1+1.e-10);
LinearMapper* map = new LinearMapper(Point(0,0,0),
Vector(s,0,0),
Vector(0,s,0),
@@ -262,11 +295,21 @@
if(arraytype == "spin"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
+<<<<<<< .working
Vector p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 :
0.)*scale*2,
(numy>1 ? j/static_cast<double>(numy-1) - 0.5 :
0.)*scale*2,
+=======
+ Vector p((i/static_cast<Real>(numx-1) - (Real)0.5)*scale*2,
+ (j/static_cast<Real>(numy-1) - (Real)0.5)*scale*2,
+>>>>>>> .merge-right.r751
0);
+<<<<<<< .working
double a1 = i/static_cast<double>(numx)*M_PI*2;
double a2 = j/static_cast<double>(numy)*M_PI*2;
+=======
+ Real a1 = i/static_cast<Real>(numx-1)*(Real)M_PI*2;
+ Real a2 = j/static_cast<Real>(numy-1)*(Real)M_PI*2;
+>>>>>>> .merge-right.r751
AffineTransform t;
t.initWithIdentity();
t.rotate(Vector(0,1,0), a1);
@@ -278,8 +321,13 @@
} else if(arraytype == "shift"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
+<<<<<<< .working
Vector p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 :
0.)*scale*2,
(numy>1 ? j/static_cast<double>(numy-1) - 0.5 :
0.)*scale*2,
+=======
+ Vector p((i/static_cast<Real>(numx-1) - (Real)0.5)*scale*2,
+ (j/static_cast<Real>(numy-1) - (Real)0.5)*scale*2,
+>>>>>>> .merge-right.r751
0);
group->add(new InstanceT(spinprim, p));
}
@@ -287,35 +335,55 @@
} else if(arraytype == "scale"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
+<<<<<<< .working
Vector p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 :
0.)*scale*2,
(numy>1 ? j/static_cast<double>(numy-1) - 0.5 :
0.)*scale*2,
+=======
+ Vector p((i/static_cast<Real>(numx-1) - (Real)0.5)*scale*2,
+ (j/static_cast<Real>(numy-1) - (Real)0.5)*scale*2,
+>>>>>>> .merge-right.r751
0);
int idx = j*numx+i;
- double scale = (idx+1)/static_cast<double>(numx*numy);
+ Real scale = (idx+1)/static_cast<Real>(numx*numy);
group->add(new InstanceST(spinprim, Vector(scale, scale, scale),
p));
}
}
} else if(arraytype == "nuscale"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
+<<<<<<< .working
Vector p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 :
0.)*scale*2,
(numy>1 ? j/static_cast<double>(numy-1) - 0.5 :
0.)*scale*2,
+=======
+ Vector p((i/static_cast<Real>(numx-1) - (Real)0.5)*scale*2,
+ (j/static_cast<Real>(numy-1) - (Real)0.5)*scale*2,
+>>>>>>> .merge-right.r751
0);
- double xscale = (i+1)/static_cast<double>(numx);
- double yscale = (j+1)/static_cast<double>(numy);
+ Real xscale = (i+1)/static_cast<Real>(numx);
+ Real yscale = (j+1)/static_cast<Real>(numy);
group->add(new InstanceST(spinprim, Vector(xscale, yscale, 1), p));
}
}
} else if(arraytype == "spinscale"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
+<<<<<<< .working
Vector p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 :
0.)*scale*2,
(numy>1 ? j/static_cast<double>(numy-1) - 0.5 :
0.)*scale*2,
+=======
+ Vector p((i/static_cast<Real>(numx-1) - (Real)0.5)*scale*2,
+ (j/static_cast<Real>(numy-1) - (Real)0.5)*scale*2,
+>>>>>>> .merge-right.r751
0);
+<<<<<<< .working
double a1 = i/static_cast<double>(numx)*M_PI*2;
double a2 = j/static_cast<double>(numy)*M_PI*2;
+=======
+ Real a1 = i/static_cast<Real>(numx-1)*(Real)M_PI*2;
+ Real a2 = j/static_cast<Real>(numy-1)*(Real)M_PI*2;
+>>>>>>> .merge-right.r751
int idx = j*numx+i;
- double scale = (idx+1)/static_cast<double>(numx*numy);
+ Real scale = (idx+1)/static_cast<Real>(numx*numy);
AffineTransform t;
t.initWithIdentity();
t.scale(Vector(scale, scale, scale));
@@ -328,13 +396,23 @@
} else if(arraytype == "spinscale2"){
for(int i=0;i<numx;i++){
for(int j=0;j<numy;j++){
+<<<<<<< .working
Vector p((numx>1 ? i/static_cast<double>(numx-1) - 0.5 :
0.)*scale*2,
(numy>1 ? j/static_cast<double>(numy-1) - 0.5 :
0.)*scale*2,
+=======
+ Vector p((i/static_cast<Real>(numx-1) - (Real)0.5)*scale*2,
+ (j/static_cast<Real>(numy-1) - (Real)0.5)*scale*2,
+>>>>>>> .merge-right.r751
0);
+<<<<<<< .working
double a1 = i/static_cast<double>(numx)*M_PI*2;
double a2 = j/static_cast<double>(numy)*M_PI*2;
+=======
+ Real a1 = i/static_cast<Real>(numx-1)*(Real)M_PI*2;
+ Real a2 = j/static_cast<Real>(numy-1)*(Real)M_PI*2;
+>>>>>>> .merge-right.r751
int idx = j*numx+i;
- double scale = (idx+1)/static_cast<double>(numx*numy);
+ Real scale = (idx+1)/static_cast<Real>(numx*numy);
AffineTransform t;
t.initWithIdentity();
t.scale(Vector(scale, scale, scale));
Modified: trunk/tests/perftest/perftest1.cc
==============================================================================
--- trunk/tests/perftest/perftest1.cc (original)
+++ trunk/tests/perftest/perftest1.cc Tue Dec 6 16:58:03 2005
@@ -41,7 +41,7 @@
Scene scene;
scene.setObject(&s);
- RenderContext c(0, 0, 0, 1, 0, 0, 0, 0, &shadows, 0, &scene);
+ RenderContext c(0, 0, 0, 1, 0, 0, 0, 0, &shadows, 0, &scene, 0);
RayPacketData data;
// Variant 2 - use one of the next two lines
RayPacket rays(data, RayPacket::MaxSize, 0,
RayPacket::NormalizedDirections);
- [MANTA] r752 - in trunk: . Core Core/Color Core/Geometry Core/Math Core/Shm Core/Util Engine Engine/Control Engine/Display Engine/IdleModes Engine/ImageTraversers Engine/ImageTraversers/AFR Engine/LoadBalancers Engine/PixelSamplers Engine/Renderers Engine/Shadows Image Interface Model Model/AmbientLights Model/Backgrounds Model/Cameras Model/Groups Model/Instances Model/Intersections Model/Lights Model/Materials Model/MiscObjects Model/Primitives Model/Readers Model/Readers/glm Model/TexCoordMappers Model/Textures Readers Readers/BART SCIRun/Core StandAlone UserInterface fox histx scenes tests/perftest, sparker, 12/06/2005
Archive powered by MHonArc 2.6.16.