Text archives Help
- From: aek@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r512 - in trunk: Interface Model/Groups scenes
- Date: Mon, 29 Aug 2005 14:28:21 -0600 (MDT)
Author: aek
Date: Mon Aug 29 14:28:20 2005
New Revision: 512
Added:
trunk/scenes/acceltest.cc
Modified:
trunk/Interface/HitInfo.h
trunk/Interface/RayPacket.h
trunk/Model/Groups/GriddedGroup.cc
trunk/scenes/CMakeLists.txt
Log:
* scenes/acceltest.cc
* scenes/CMakeLists.txt
Added acceleration structure test scene. This reads MPM data as in
6620 into a group to test acceleration structures
* Model/Groups/GriddedGroup.cc
Fixed a copy/paste mistake in an error message
* Interface/HitInfo.h
* Interface/RayPacket.h
Added code to split a ray packet out based on a mask value. Shouldn't
be used with shadow ray packets. Needs more testing.
Modified: trunk/Interface/HitInfo.h
==============================================================================
--- trunk/Interface/HitInfo.h (original)
+++ trunk/Interface/HitInfo.h Mon Aug 29 14:28:20 2005
@@ -5,6 +5,7 @@
#include <Interface/Parameters.h>
#include <Core/Util/Assert.h>
#include <stdlib.h>
+#include <algorithm>
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
#pragma set woff 1424
@@ -54,7 +55,7 @@
~HitInfo()
{
}
-
+
inline void reset() {
hitMatl = 0;
min_t = MAXT;
@@ -103,12 +104,12 @@
static const size_t MaxScratchpadSize = 128;
template<class T> T& scratchpad() {
-
+
// This pragma relates to the following expression being
// constant (which it is). Since sizeof(T) is evaluated after
// the preprocessor, we can't get around not doing it here like
// this.
-
+
# if defined(__sgi) && !defined(__GNUC__)
# pragma set woff 1209
ASSERT(sizeof(T) <= MaxScratchpadSize);
@@ -118,7 +119,18 @@
# endif
return *(T*)scratchpad_data;
}
-
+
+ void swap(
+ HitInfo &that )
+ {
+ std::swap( hitPrim, that.hitPrim );
+ std::swap( hitMatl, that.hitMatl );
+ std::swap( hitTex, that.hitTex );
+ std::swap( min_t, that.min_t );
+ for ( int i = 0; i < MaxScratchpadSize; ++i )
+ std::swap( scratchpad_data[ i ], that.scratchpad_data[ i ] );
+ }
+
private:
HitInfo(const HitInfo&);
HitInfo& operator=(const HitInfo&);
Modified: trunk/Interface/RayPacket.h
==============================================================================
--- trunk/Interface/RayPacket.h (original)
+++ trunk/Interface/RayPacket.h Mon Aug 29 14:28:20 2005
@@ -7,6 +7,7 @@
#include <Interface/HitInfo.h>
#include <Interface/Primitive.h>
#include <Interface/TexCoordMapper.h>
+#include <algorithm>
namespace Manta {
class RayPacketData;
@@ -40,6 +41,48 @@
{
}
+ /**
+ * Split the packet based on a mask of booleans. The current packet
+ * will be modified to be reduced to just those elements for which the
+ * mask is false, while the elements for which it is true will be
+ * returned in a new packet. Elements in each new packet may be
+ * reordered. This does the minimum copying possible - it is most
+ * efficient if the mask has all false before all true.
+ *
+ * @param mask an array of booleans controlling the split
+ * @return a ray packet with all of the "true" elements
+ */
+ RayPacket split(
+ bool *mask )
+ {
+ int low = -1;
+ int high = size;
+ for ( ; ; )
+ {
+ for ( ++low; low < high && !mask[ low ]; ++low );
+ for ( --high; low < high && mask[ high ]; --high );
+ if ( low >= high )
+ break;
+ std::swap( data[ low ].localColor, data[ high ].localColor );
+ std::swap( data[ low ].color, data[ high ].color );
+ std::swap( data[ low ].imageX, data[ high ].imageX );
+ std::swap( data[ low ].imageY, data[ high ].imageY );
+ std::swap( data[ low ].whichEye, data[ high ].whichEye );
+ std::swap( data[ low ].ray, data[ high ].ray );
+ data[ low ].hitInfo.swap( data[ high ].hitInfo );
+ std::swap( data[ low ].normal, data[ high ].normal );
+ std::swap( data[ low ].hitPosition, data[ high ].hitPosition );
+ std::swap( data[ low ].texCoords, data[ high ].texCoords );
+ std::swap( data[ low ].inverseDirection, data[ high
].inverseDirection );
+ std::swap( data[ low ].ambientLight, data[ high ].ambientLight );
+ std::swap( data[ low ].shadowBegin, data[ high ].shadowBegin );
+ std::swap( data[ low ].shadowEnd, data[ high ].shadowEnd );
+ }
+ int old_size = low;
+ size = low;
+ return RayPacket( *this, low, old_size - low );
+ }
+
int getFlags() const {
return flags;
}
@@ -92,7 +135,7 @@
return data[which];
}
#endif // SWIG
-
+
void setPixel(int which, int whichEye, double imageX, double imageY,
Color* color) {
data[which].color = color;
Modified: trunk/Model/Groups/GriddedGroup.cc
==============================================================================
--- trunk/Model/Groups/GriddedGroup.cc (original)
+++ trunk/Model/Groups/GriddedGroup.cc Mon Aug 29 14:28:20 2005
@@ -30,7 +30,7 @@
throw IllegalArgument("GriddedGroup -cellfactor", i, args);
gotCellfactor = true;
} else {
- throw IllegalArgument("BeamShadows", i, args);
+ throw IllegalArgument("GriddedGroup", i, args);
}
}
if(!gotCellfactor)
Modified: trunk/scenes/CMakeLists.txt
==============================================================================
--- trunk/scenes/CMakeLists.txt (original)
+++ trunk/scenes/CMakeLists.txt Mon Aug 29 14:28:20 2005
@@ -36,5 +36,12 @@
TARGET_LINK_LIBRARIES(scene_primtest ${manta_scene_link})
ENDIF(SCENE_PRIMTEST)
+# Test different acceleration structures.
+SET(SCENE_ACCELTEST 0 CACHE BOOL "Acceleration Test")
+IF(SCENE_ACCELTEST)
+ ADD_LIBRARY(scene_acceltest acceltest.cc)
+ TARGET_LINK_LIBRARIES(scene_acceltest ${manta_scene_link})
+ENDIF(SCENE_ACCELTEST)
+
############################################################
Added: trunk/scenes/acceltest.cc
==============================================================================
--- (empty file)
+++ trunk/scenes/acceltest.cc Mon Aug 29 14:28:20 2005
@@ -0,0 +1,88 @@
+
+#include <Core/Exceptions/IllegalArgument.h>
+#include <Core/Util/Args.h>
+#include <Interface/Context.h>
+#include <Interface/LightSet.h>
+#include <Interface/RTRTInterface.h>
+#include <Interface/Scene.h>
+#include <Model/AmbientLights/ArcAmbient.h>
+#include <Model/Backgrounds/LinearBackground.h>
+#include <Model/Groups/GriddedGroup.h>
+#include <Model/Groups/Group.h>
+#include <Model/Lights/PointLight.h>
+#include <Model/Materials/Phong.h>
+#include <Model/Primitives/Sphere.h>
+
+#include <Core/Math/MinMax.h>
+#include <sgi_stl_warnings_off.h>
+#include <string>
+#include <vector>
+#include <iostream>
+#include <fstream>
+#include <sgi_stl_warnings_on.h>
+
+using namespace Manta;
+using namespace std;
+
+extern "C"
+Scene* make_scene(
+ const ReadContext &context,
+ const vector< string > &args )
+{
+
+ Group *world = 0;
+ string model_name = "/usr/sci/data/Geometry/particle/sd022-crop.mpm";
+ int argc = static_cast< int >( args.size() );
+ for ( int i = 0; i < argc; i++ ) {
+ string arg = args[ i ];
+ if ( arg == "-group" ) {
+ string s;
+ if ( !getStringArg( i, args, s ) )
+ throw IllegalArgument("scene acceltest -group", i, args);
+ world = context.rtrt_int->makeGroup( s );
+ if ( world == 0 )
+ throw IllegalArgument( "scene acceltest -group", i, args );
+ } else if ( arg == "-model" ) {
+ if ( !getStringArg( i, args, model_name ) )
+ throw IllegalArgument( "scene acceltest -model", i, args );
+ } else {
+ cerr << "Valid options for scene acceltest:" << endl
+ << " -group spec - Sets the group or acceleration structure to
use" << endl
+ << " -model file - MPM particle set model to show" << endl;
+ throw IllegalArgument( "scene acceltest", i, args );
+ }
+ }
+ if ( !world )
+ world = new Group();
+
+ Material *material = new Phong( Color( RGB( 0.6, 0.0, 0.0 ) ),
+ Color( RGB( 0.6, 0.6, 0.6 ) ), 32, 0.4 );
+
+ ifstream in( model_name.c_str() );
+ if ( !in.is_open() )
+ throw IllegalArgument( "Couldn't load model: " + model_name, 0, args );
+ int number_of_particles, number_of_variables, radius_index;
+ in >> number_of_particles >> number_of_variables >> radius_index;
+ float data[ number_of_variables ];
+ for ( int particle = 0; particle < number_of_particles; ++particle )
+ {
+ for ( int variable = 0; variable < number_of_variables; ++variable )
+ in >> data[ variable ];
+ world->add( new Sphere( material,
+ Point( data[ 0 ], data[ 1 ], data[ 2 ] ),
+ radius_index > 0 ? data[ radius_index ] : 1.0 )
);
+ }
+
+ Scene *scene = new Scene();
+ scene->setBackground( new LinearBackground( Color( RGB( 0.2, 0.4, 0.9 ) ),
+ Color( RGB( 0.0, 0.0, 0.0 ) ),
+ Vector( 0.0, 1.0, 0.0 ) ) );
+ scene->setObject( world );
+ LightSet *lights = new LightSet();
+ lights->add( new PointLight( Point( 5.0, 5.0, 8.0), Color( RGB( 2.0, 2.0 ,
2.0 ) ) ) );
+ lights->setAmbientLight( new ArcAmbient( Color( RGB( 0.1, 0.3, 0.8 ) ),
+ Color( RGB( 0.8, 0.6, 0.6 ) ),
+ Vector( 0.0, 1.0, 0.0 ) ) );
+ scene->setLights( lights );
+ return scene;
+}
- [MANTA] r512 - in trunk: Interface Model/Groups scenes, aek, 08/29/2005
Archive powered by MHonArc 2.6.16.