Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r441 - in branches/itanium2: Model/Groups Model/Materials Model/MiscObjects fox scenes
- Date: Tue, 26 Jul 2005 18:14:59 -0600 (MDT)
Author: abe
Date: Tue Jul 26 18:14:51 2005
New Revision: 441
Modified:
branches/itanium2/Model/Groups/TransparentKDTree.cc
branches/itanium2/Model/Groups/TransparentKDTree.h
branches/itanium2/Model/Groups/kdtree.cc
branches/itanium2/Model/Groups/kdtree.h
branches/itanium2/Model/Materials/CMakeLists.txt
branches/itanium2/Model/Materials/CopyColorMaterial.cc
branches/itanium2/Model/Materials/CopyColorMaterial.h
branches/itanium2/Model/Materials/LambertianAlt.cc
branches/itanium2/Model/MiscObjects/CuttingPlane.h
branches/itanium2/fox/FMantaWidgets.h
branches/itanium2/fox/FMantaWindow.cc
branches/itanium2/fox/FMantaWindow.h
branches/itanium2/fox/fox_manta.cc
branches/itanium2/scenes/boeing777.cc
Log:
Added functionality to dm_demo to switch between opaque and transparent
rendering. Also added alpha slider for adjusting surface alpha.
Material demo is next.
M Model/Groups/TransparentKDTree.cc
M Model/Groups/TransparentKDTree.h
M Model/Groups/kdtree.cc
M Model/Groups/kdtree.h
M Model/Materials/LambertianAlt.cc
M Model/Materials/CopyColorMaterial.cc
M Model/Materials/CMakeLists.txt
M Model/Materials/CopyColorMaterial.h
M Model/MiscObjects/CuttingPlane.h
M fox/FMantaWindow.cc
M fox/FMantaWidgets.h
M fox/FMantaWindow.h
M fox/fox_manta.cc
M scenes/boeing777.cc
Modified: branches/itanium2/Model/Groups/TransparentKDTree.cc
==============================================================================
--- branches/itanium2/Model/Groups/TransparentKDTree.cc (original)
+++ branches/itanium2/Model/Groups/TransparentKDTree.cc Tue Jul 26 18:14:51
2005
@@ -72,13 +72,14 @@
// CONSTRUCTOR CONSTRUCTOR CONSTRUCTOR CONSTRUCTOR CONSTRUCTOR
CONSTRUCTOR
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
-TransparentKDTree::TransparentKDTree( KDTree *kdtree_, Real sample_alpha_ ) :
+TransparentKDTree::TransparentKDTree( KDTree *kdtree_, Material *material_,
Real sample_alpha_ ) :
+ material( material_ ),
rootNode( kdtree_->rootNode ),
triIndices( kdtree_->triIndices ),
tris( kdtree_->tris ),
normals( kdtree_->normals ),
- lambMat( kdtree_->lambMat ),
- sample_alpha( sample_alpha_ ) {
+ sample_alpha( sample_alpha_ )
+{
bbox.extendByBox( kdtree_->bbox );
}
@@ -143,7 +144,7 @@
}
}
}
-
+
////////////////////////////////////////////////////////////////////////////
// Check to see if any triangles need to be blended.
if (isectbuf->getLen()) {
@@ -169,7 +170,13 @@
// combine color and opacity
for (int i=0; (i<isectbuf->getLen()) && (ray_alpha < 0.95);
i++) {
- Color &sample_color = tris->get( array[i].triIdx
).payload;
+ Color &triangle_color = tris->get( array[i].triIdx
).payload;
+
+ Real scale = Abs(Dot( normals[array[i].triIdx*3],
direction ));
+ scale *= 0.75;
+ scale += 0.25;
+
+ Color sample_color = (triangle_color * scale);
ray_color += (sample_color*sample_alpha__) * (1.0 -
ray_alpha);
ray_alpha += sample_alpha__ * (1.0 - ray_alpha);
@@ -346,9 +353,10 @@
// If this is the first leaf, record the hit
and normal.
if (first_leaf) {
// Process the hit.
- e.hitInfo.hit(isectData.rayHit.t,
lambMat, this, 0 );
+ e.hitInfo.hit(isectData.rayHit.t,
material, this, 0 );
// Copy the normal into the scratch
pad.
+ // Used for shootOneRay type queries.
e.hitInfo.scratchpad<TransparentKDTree::TransparentKDTree::ScratchPadInfo>().normal
=
normals[isectData.rayHitTriIndex*3];
Modified: branches/itanium2/Model/Groups/TransparentKDTree.h
==============================================================================
--- branches/itanium2/Model/Groups/TransparentKDTree.h (original)
+++ branches/itanium2/Model/Groups/TransparentKDTree.h Tue Jul 26 18:14:51
2005
@@ -65,7 +65,8 @@
VArray<Triangle> *tris;
Vectorf *normals;
- LambertianAlt *lambMat;
+ Material *material;
+
Real sample_alpha;
// This method intersects a list of triangles with
the ray.
@@ -104,7 +105,10 @@
// Constructor.
// The transparent KDTree uses data owned by a normal
KDTree.
- TransparentKDTree( KDTree *kdtree_, Real
sample_alpha_ = 0.25 );
+ TransparentKDTree( KDTree *kdtree_, Material
*material_, Real sample_alpha_ = 0.25 );
+
+ void setAlpha( Real alpha_ ) { sample_alpha = alpha_;
};
+ Real getAlpha() const { return sample_alpha; };
// Primitive Interface.
void intersect(const RenderContext& context, RayPacket&
rays) const;
Modified: branches/itanium2/Model/Groups/kdtree.cc
==============================================================================
--- branches/itanium2/Model/Groups/kdtree.cc (original)
+++ branches/itanium2/Model/Groups/kdtree.cc Tue Jul 26 18:14:51 2005
@@ -188,8 +188,6 @@
int line = 0;
char line_buffer[128];
-
-
// Read in the file.
while (fgets( line_buffer, 127, f ) != NULL) {
@@ -603,9 +601,6 @@
}
}
- // create material
- lambMat = new LambertianAlt;
-
return 1;
}
@@ -811,7 +806,7 @@
e.normal =
normals[isectData.rayHitTriIndex*3];
// Check against the hit record, Note that
tex coord mapper is null.
- if (e.hitInfo.hit(isectData.rayHit.t,
lambMat, this, 0 )) {
+ if (e.hitInfo.hit(isectData.rayHit.t,
material, this, 0 )) {
e.hitInfo.scratchpad<ScratchPadInfo>().normal =
normals[isectData.rayHitTriIndex*3];
e.hitInfo.scratchpad<ScratchPadInfo>().payload =
tris->get(isectData.rayHitTriIndex).payload;
break;
Modified: branches/itanium2/Model/Groups/kdtree.h
==============================================================================
--- branches/itanium2/Model/Groups/kdtree.h (original)
+++ branches/itanium2/Model/Groups/kdtree.h Tue Jul 26 18:14:51 2005
@@ -253,7 +253,7 @@
VArray<Triangle> *tris;
Vectorf *normals;
- LambertianAlt *lambMat;
+ Material *material;
// This method intersects a list of triangles with
the ray.
int intersectTriangles(const Ray* ray, unsigned int
listBegin, int listSize, float maxDist, void *userData, const RenderContext
&context) const;
@@ -262,6 +262,9 @@
void _intersect(const Ray* ray, RayPacket::Element
&e, RayTriIntersectUserData &isectData, const RenderContext &context, float
_minDist=-1, float _maxDist=-1) const;
public:
+ // Constructor.
+ KDTree( Material *material_ ) : material( material_ )
{ };
+
// This structure is used to record info about the
hit.
struct ScratchPadInfo {
Vector normal; // Normal of the
intersected face.
Modified: branches/itanium2/Model/Materials/CMakeLists.txt
==============================================================================
--- branches/itanium2/Model/Materials/CMakeLists.txt (original)
+++ branches/itanium2/Model/Materials/CMakeLists.txt Tue Jul 26 18:14:51
2005
@@ -18,6 +18,7 @@
Materials/Phong.cc
Materials/LambertianAlt.h
Materials/LambertianAlt.cc
+ Materials/CopyColorMaterial.h
Materials/CopyColorMaterial.cc
Materials/NormalMaterial.h
Materials/NormalMaterial.cc # Shade the material using it's normal.
Modified: branches/itanium2/Model/Materials/CopyColorMaterial.cc
==============================================================================
--- branches/itanium2/Model/Materials/CopyColorMaterial.cc (original)
+++ branches/itanium2/Model/Materials/CopyColorMaterial.cc Tue Jul 26
18:14:51 2005
@@ -1,6 +1,5 @@
#include <Model/Materials/CopyColorMaterial.h>
-#include <Model/Groups/kdtree.h>
#include <Interface/Light.h>
#include <Interface/LightSet.h>
#include <Interface/Primitive.h>
@@ -11,35 +10,16 @@
#include <Model/Textures/Constant.h>
#include <Interface/Scene.h>
-using namespace Manta;
+#include <Model/Groups/kdtree.h>
-void CopyColorMaterial::preprocess(const PreprocessContext& context)
-{
-}
+using namespace Manta;
void CopyColorMaterial::shade(const RenderContext& context, RayPacket& rays)
const {
- // Copy colors from hit info.
- Color colors[RayPacket::MaxSize];
- Real inv255 = 1.0/255.0;
-
for (int i=0;i<rays.getSize();i++) {
RayPacket::Element& e = rays.get(i);
- unsigned int rgb = e.hitInfo.scratchpad<unsigned int>();
- colors[i] = Color(RGBColor(((rgb & 0xFF0000) >> 16)*inv255,
- ((rgb &
0x00FF00) >> 8)*inv255,
- ((rgb &
0x0000FF) >> 0)*inv255));
- rays.setResult( i, colors[i]);
+ Color result =
e.hitInfo.scratchpad<Kdtree::KDTree::ScratchPadInfo>().payload;
+ rays.setResult( i, result );
}
-
- // #endif
-}
-
-CopyColorMaterial::CopyColorMaterial():Material()
-{
- dummy = 0;
-}
-CopyColorMaterial::~CopyColorMaterial()
-{
}
Modified: branches/itanium2/Model/Materials/CopyColorMaterial.h
==============================================================================
--- branches/itanium2/Model/Materials/CopyColorMaterial.h (original)
+++ branches/itanium2/Model/Materials/CopyColorMaterial.h Tue Jul 26
18:14:51 2005
@@ -2,21 +2,19 @@
#ifndef Manta_Model_CopyColor_h
#define Manta_Model_CopyColor_h
-#include <Model/Materials/LitMaterial.h>
-#include <Core/Color/Color.h>
-#include <Interface/Texture.h>
-
+#include <Interface/Material.h>
+#include <Interface/Context.h>
+#include <Interface/RayPacket.h>
namespace Manta{
- class LightSet;
+ // This material is used with the KDTree's to copy a color out of the
+ // hit record which was computed during intersection.
class CopyColorMaterial : public Material {
public:
- CopyColorMaterial();
- virtual ~CopyColorMaterial();
- virtual void preprocess(const PreprocessContext&);
+ CopyColorMaterial() { }
+ virtual ~CopyColorMaterial() { }
+ virtual void preprocess(const PreprocessContext&) { }
virtual void shade(const RenderContext& context, RayPacket& rays) const;
- private:
- int dummy;
};
}
Modified: branches/itanium2/Model/Materials/LambertianAlt.cc
==============================================================================
--- branches/itanium2/Model/Materials/LambertianAlt.cc (original)
+++ branches/itanium2/Model/Materials/LambertianAlt.cc Tue Jul 26 18:14:51
2005
@@ -17,7 +17,18 @@
using namespace SCIRun;
void LambertianAlt::shade(const RenderContext& context, RayPacket& rays)
const {
-
+
+#if 0
+ for (int i=0;i<rays.getSize();i++) {
+ RayPacket::Element& e = rays.get(i);
+
+ Color result =
e.hitInfo.scratchpad<Kdtree::KDTree::ScratchPadInfo>().payload;
+
+ rays.setResult( i, result );
+ }
+#endif
+
+#if 0
// Copy colors from hit info.
Color colors[RayPacket::MaxSize];
Real inv255 = 1.0/255.0;
@@ -35,8 +46,13 @@
rays.setResult( i, result );
}
+#endif
#if 0
+ // Copy colors from hit info.
+ Color colors[RayPacket::MaxSize];
+ Real inv255 = 1.0/255.0;
+
for(int i=0;i<rays.getSize();i++) {
RayPacket::Element& e = rays.get(i);
Vector normal =
e.hitInfo.scratchpad<Kdtree::KDTree::ScratchPadInfo>().normal;
@@ -47,17 +63,21 @@
}
#endif
-#if 0
-
- Scene *scene = (Scene*)context.scene;
+ // Copy colors from hit info.
+ Color colors[RayPacket::MaxSize];
+ for(int i=0;i<rays.getSize();i++) {
+ RayPacket::Element& e = rays.get(i);
+ colors[i] =
e.hitInfo.scratchpad<Kdtree::KDTree::ScratchPadInfo>().payload;
+ };
+
// Compute ambient contributions for all rays
+ Scene *scene = (Scene*)context.scene;
scene->getLights()->getAmbientLight()->computeAmbient(context, rays);
// Compute the normals.
rays.computeNormals( context );
- // #if 0
RayPacketData data;
int start = 0;
@@ -81,14 +101,17 @@
for(int j=e.shadowBegin;j<e.shadowEnd;j++){
RayPacket::Element& s = shadowRays.get(j);
- // Add a pseudo diffuse term.
- double cos_theta = Dot( s.ray.direction(),
e.normal );
+ // Add a diffuse term.
+ Real cos_theta = Dot( s.ray.direction(),
e.normal );
+
+ totalLight *= Abs(cos_theta)*0.75 + 0.25;
+
totalLight += s.light*cos_theta*0.5;
// Check to see if the shadow ray hit
something.
if(!s.hitInfo.wasHit()){
totalLight += s.light*cos_theta*0.5;
- }
+ }
}
// Set the result..
@@ -97,5 +120,5 @@
start = end;
} while(start < rays.getSize());
- #endif
+
}
Modified: branches/itanium2/Model/MiscObjects/CuttingPlane.h
==============================================================================
--- branches/itanium2/Model/MiscObjects/CuttingPlane.h (original)
+++ branches/itanium2/Model/MiscObjects/CuttingPlane.h Tue Jul 26 18:14:51
2005
@@ -42,6 +42,7 @@
// Accessors.
const BBox &getBounds() { return bounds; };
Object *getObject() { return internal_object; };
+ void setObject( Object *object_ ) { internal_object =
object_; };
void getPlanePoint ( Point &result ) { result = plane_point;
};
void getPlaneNormal( Vector &result ) { result =
plane_normal; };
Modified: branches/itanium2/fox/FMantaWidgets.h
==============================================================================
--- branches/itanium2/fox/FMantaWidgets.h (original)
+++ branches/itanium2/fox/FMantaWidgets.h Tue Jul 26 18:14:51 2005
@@ -0,0 +1,10 @@
+
+
+#ifndef fox_FMANTAWIDGETS__H
+#define fox_FMANTAWIDGETS__H
+
+namespace fox_manta {
+
+};
+
+#endif
\ No newline at end of file
Modified: branches/itanium2/fox/FMantaWindow.cc
==============================================================================
--- branches/itanium2/fox/FMantaWindow.cc (original)
+++ branches/itanium2/fox/FMantaWindow.cc Tue Jul 26 18:14:51 2005
@@ -57,7 +57,10 @@
FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_TEXT_TRAVERSER,
FMantaWindow::onTraverserText ),
// Cutting planes.
- FXMAPFUNC(SEL_LEFTBUTTONPRESS, FMantaImageFrame::ID_PIXEL_SELECT,
FMantaWindow::onAddCuttingPlane )
+ FXMAPFUNC(SEL_LEFTBUTTONPRESS, FMantaImageFrame::ID_PIXEL_SELECT,
FMantaWindow::onAddCuttingPlane ),
+
+ // Other options.
+ FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_EXTRA_OPTIONS,
FMantaWindow::onExtraOptions )
};
FXIMPLEMENT(FMantaWindow,FXMainWindow,FMantaWindowMap,ARRAYNUMBER(FMantaWindowMap));
@@ -68,7 +71,8 @@
manta_interface( 0 ),
fast_quit( false ) ,
- cutting_snap( 1 )
+ cutting_snap( 1 ),
+ extra_options_dialog( 0 )
{
// Menu Bar.
menu_bar = new FXMenuBar( this, LAYOUT_FILL_X );
@@ -110,13 +114,15 @@
// Options menu.
options_menu = new FXMenuPane( this );
new FXMenuCheck( options_menu, "Snap Cutting Planes", new
FXDataTarget( cutting_snap ), FXDataTarget::ID_VALUE );
- cutting_flip = new FXMenuCommand( options_menu, "Flip Cutting Plane",
0, this, ID_CUTTING_FLIP );
+ cutting_flip = new FXMenuCommand( options_menu, "Flip Cutting
Plane", 0, this, ID_CUTTING_FLIP );
+ cutting_flip->disable();
+ extra_options = new FXMenuCommand( options_menu, "Extra Options", 0,
this, ID_EXTRA_OPTIONS );
+ extra_options->disable();
+
new FXMenuTitle( menu_bar, "Options", 0, options_menu );
-
// Create the content of the window.
FXComposite *frame = new FXHorizontalFrame( this, LAYOUT_FILL );
-
FXComposite *left_controls = new FXVerticalFrame( frame,
LAYOUT_FILL_Y|LAYOUT_LEFT );
FXComposite *viewers = new FXVerticalFrame( frame, LAYOUT_FILL
);
FXComposite *right_controls = new FXVerticalFrame( frame,
LAYOUT_FILL_Y|LAYOUT_RIGHT );
@@ -147,6 +153,25 @@
new FXButton( frame, "Add", 0, this, ID_ADD_BOOKMARK );
}
+void FMantaWindow::setExtraOptionsDialog( FXDialogBox *extra_options_dialog_
) {
+
+ extra_options_dialog = extra_options_dialog_;
+
+ // Check to see if it is safe to turn on the dialog box
+ if (extra_options_dialog)
+ extra_options->enable();
+ else
+ extra_options->disable();
+};
+
+void FMantaWindow::setSceneObject( Object *root_object_ ) {
+
+ manta_interface->addTransaction("Set Scene",
+
Callback::create(this,&FMantaWindow::mantaSetSceneObject,root_object_));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
// Quit the program.
long FMantaWindow::onQuit( FXObject *sender, FXSelector key, void *data ) {
@@ -398,7 +423,6 @@
cutting_slider->enable();
cutting_flip->enable();
cutting_slider->setValue( 0.0 );
-
}
else {
// Remove the cutting plane if one exists.
@@ -449,18 +473,29 @@
// Reset the new nav to this camera.
nav->resetToCamera( camera->getPosition(),
camera->getLookAt(), camera->getUp());
+ nav->setControlSpeed( speed_slider->getValue() );
manta_frame->setNavigator( nav );
return 0;
}
else {
-
- return manta_frame->getNavigator()->onKeyPress(
sender, key, data );
+ return manta_frame->getNavigator()->onKeyPress( sender, key,
data );
}
}
+long FMantaWindow::onExtraOptions( FXObject *sender, FXSelector key, void
*data ) {
+
+ // Check to see if the extra options dialog box has been specified.
+ if (extra_options_dialog) {
+ extra_options_dialog->create();
+ extra_options_dialog->show();
+ }
+
+ return 1;
+}
+
///////////////////////////////////////////////////////////////////////////////
void FMantaWindow::mantaThreadBookmark( const string camera_text ) {
@@ -659,3 +694,25 @@
cutting_plane->setPlaneNormal( normal );
}
}
+
+void FMantaWindow::mantaSetSceneObject( Object *root_object_ ) const {
+
+ // If a cutting plane is the root object, replace the cutting plane's
child
+ // otherwise replace the root object.
+ Scene *scene = manta_interface->getScene();
+ Object *root_object = scene->getObject();
+
+ // Check to see if the root object is already a cutting plane.
+ CuttingPlane *cutting_plane = dynamic_cast< CuttingPlane * >(
root_object );
+ if (cutting_plane != 0) {
+ cutting_plane->setObject( root_object_ );
+ }
+ else {
+ // Otherwise replace the whole scene
+ scene->setObject( root_object_ );
+ }
+
+}
+
+
+
Modified: branches/itanium2/fox/FMantaWindow.h
==============================================================================
--- branches/itanium2/fox/FMantaWindow.h (original)
+++ branches/itanium2/fox/FMantaWindow.h Tue Jul 26 18:14:51 2005
@@ -39,8 +39,13 @@
FXMenuPane *sampler_menu;
FXMenuPane *traverser_menu;
FXMenuPane *options_menu;
+
+
FXMenuCommand *cutting_flip;
+ FXMenuCommand *extra_options;
+ FXDialogBox *extra_options_dialog;
+
FXRealSlider *speed_slider;
FXRealSlider *cutting_slider;
int cutting_snap;
@@ -48,7 +53,7 @@
// Camera options.
FXListBox *camera_bookmark_list;
vector<string> camera_text_list;
-
+
// Navigator options.
FXListBox *navigator_list; // User data field will hold
pointer to navigator.
@@ -97,6 +102,9 @@
// Cutting planes.
ID_ADD_CUTTING_PLANE,
+ // Different scene options.
+ ID_EXTRA_OPTIONS,
+
ID_LAST
};
@@ -110,6 +118,9 @@
void addCameraBookmark ( const string &description, const
string &camera_text );
void addNavigatorOption( const string &description,
FMantaNavigator *nav );
+ void setExtraOptionsDialog( FXDialogBox
*extra_options_dialog_ );
+ void setSceneObject( Object *root_object_ );
+
const string &getCameraBookmark( int i ) { return
camera_text_list[i]; };
// Create the window.
@@ -132,6 +143,7 @@
long onPixelSamplerText( FXObject *sender, FXSelector key,
void *data );
long onTraverserText ( FXObject *sender, FXSelector key,
void *data );
long onAddCuttingPlane( FXObject *sender, FXSelector key,
void *data );
+ long onExtraOptions ( FXObject *sender, FXSelector key,
void *data );
// Accessors.
void setMantaInterface( RTRTInterface *manta_interface_, int
manta_channel_ ) {
@@ -163,6 +175,8 @@
void mantaMoveCuttingPlane( Real amount ) const;
void mantaFlipCuttingPlane() const;
+ // This method is called by the manta thread to change the
rendering mode.
+ void FMantaWindow::mantaSetSceneObject( Object *root_object_
) const;
};
};
Modified: branches/itanium2/fox/fox_manta.cc
==============================================================================
--- branches/itanium2/fox/fox_manta.cc (original)
+++ branches/itanium2/fox/fox_manta.cc Tue Jul 26 18:14:51 2005
@@ -26,6 +26,122 @@
using namespace Manta;
using namespace std;
+#include <Model/Groups/kdtree.h>
+#include <Model/Groups/TransparentKDTree.h>
+#include <Model/Materials/CopyColorMaterial.h>
+using namespace Manta::Kdtree;
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+// Digital Mockup Dialog Box.
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+class DmDemoDialog : public FXDialogBox {
+ FXDECLARE(DmDemoDialog)
+private:
+ FXListBox *render_mode_box;
+ FXRealSlider *alpha_slider;
+
+ FMantaWindow *manta_window;
+
+ KDTree *kdtree;
+ TransparentKDTree *transparent_kdtree;
+
+public:
+ enum {
+ ID_RENDER_MODE_SELECT = FXDialogBox::ID_LAST,
+ ID_ALPHA_SLIDER,
+ ID_LAST
+ };
+ DmDemoDialog() { };
+ DmDemoDialog( FMantaWindow *manta_window_,
+ KDTree *kdtree_, TransparentKDTree *transparent_kdtree_,
+ const
FXString &name, FXuint opts=DECOR_ALL,
+ FXint x=0,FXint y=0,FXint
w=0,FXint h=0,FXint pl=10,
+ FXint
pr=10,FXint pt=10,FXint pb=10,FXint hs=4,FXint vs=4 );
+
+ void setKdtrees( KDTree *kdtree_, TransparentKDTree
*transparent_kdtree_ ) {
+ kdtree = kdtree_; transparent_kdtree = transparent_kdtree_; }
+
+ void create() { FXDialogBox::create(); show( PLACEMENT_DEFAULT ); };
+
+ long onRenderModeSelect( FXObject *sender, FXSelector key, void *data
);
+ long onAlphaSlider ( FXObject *sender, FXSelector key, void *data
);
+
+};
+
+FXDEFMAP(DmDemoDialog) DmDemoDialogMap[] = {
+
//////////////////////////////////////////////////////////////////////////////
+ // Message_Type ID
Message_Handler
+ FXMAPFUNC(SEL_COMMAND, DmDemoDialog::ID_RENDER_MODE_SELECT,
DmDemoDialog::onRenderModeSelect ),
+ FXMAPFUNC(SEL_COMMAND, DmDemoDialog::ID_ALPHA_SLIDER,
DmDemoDialog::onAlphaSlider )
+};
+
+FXIMPLEMENT(DmDemoDialog,FXDialogBox,DmDemoDialogMap,ARRAYNUMBER(DmDemoDialogMap));
+
+
+DmDemoDialog::DmDemoDialog( FMantaWindow *manta_window_,
+
KDTree *kdtree_, TransparentKDTree
*transparent_kdtree_,
+
const FXString &name, FXuint opts,
+
FXint x,FXint y,FXint w,FXint h,FXint pl,
+
FXint pr,FXint pt,FXint pb,FXint hs,FXint
vs ) :
+ manta_window( manta_window_ ),
+ kdtree( kdtree_ ), transparent_kdtree( transparent_kdtree_ ),
+ FXDialogBox ( manta_window_->getApp(), name, opts, x, y, w, h, pl,
pr, pt, pb, hs, vs )
+{
+ FXHorizontalFrame *frame = new FXHorizontalFrame( this );
+
+ // Add render mode selection box.
+ render_mode_box = new FXListBox( frame, this, ID_RENDER_MODE_SELECT );
+ render_mode_box->appendItem( "Opaque Surfaces", 0, kdtree );
+ render_mode_box->appendItem( "Transparent Surfaces", 0,
transparent_kdtree );
+
+ // Add alpha slider.
+ frame = new FXHorizontalFrame( this, LAYOUT_FILL_X );
+ new FXLabel( frame, "Alpha: " );
+ alpha_slider = new FXRealSlider( frame, this, ID_ALPHA_SLIDER,
LAYOUT_FILL_X );
+ alpha_slider->setRange( 0.0, 1.0 );
+ alpha_slider->setValue( transparent_kdtree->getAlpha() );
+ alpha_slider->disable();
+
+}
+
+long DmDemoDialog::onRenderModeSelect( FXObject *sender, FXSelector key,
void *data ) {
+
+ // Determine which option selected.
+ int index = render_mode_box->getCurrentItem();
+ Object *new_root = (Object *)render_mode_box->getItemData( index );
+
+ if (new_root == kdtree) {
+ alpha_slider->disable();
+ }
+
+ if (new_root == transparent_kdtree) {
+ alpha_slider->enable();
+ }
+
+ manta_window->setSceneObject( new_root );
+
+ return 1;
+}
+
+long DmDemoDialog::onAlphaSlider ( FXObject *sender, FXSelector key,
void *data ) {
+
+ // Set the control speed for interaction.
+ Real alpha = *((double *)data);
+
+ manta_window->getMantaInterface()->addTransaction("Set Alpha",
+ Callback::create( transparent_kdtree,
&TransparentKDTree::setAlpha,alpha));
+
+ return 1;
+
+}
+
+
+//////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+
+
Scene* createDefaultScene();
int main( int argc, char *argv[]) {
@@ -101,6 +217,23 @@
if ((scene_text == 0) || (!manta_interface->readScene( scene_text )))
{
// Create a default scene.
manta_interface->setScene( createDefaultScene() );
+ }
+
+ // Check to see if the default scene was a kdtree.
+ Object *root_object = manta_interface->getScene()->getObject();
+
+ KDTree *kdtree = 0;
+ if ((kdtree = dynamic_cast<KDTree *>( root_object ))) {
+
+ std::cout << "Building transparent tree." << std::endl;
+
+ // Create a transparent kdtree.
+ TransparentKDTree *transparent_kdtree = new
TransparentKDTree( kdtree, new CopyColorMaterial );
+
+ // Create a new extra options dialog.
+ manta_window.setExtraOptionsDialog(
+ new DmDemoDialog( &manta_window, kdtree,
transparent_kdtree, "Digital Mockup Demo" ) );
+
}
// Check to see if a bookmark file was specified.
Modified: branches/itanium2/scenes/boeing777.cc
==============================================================================
--- branches/itanium2/scenes/boeing777.cc (original)
+++ branches/itanium2/scenes/boeing777.cc Tue Jul 26 18:14:51 2005
@@ -13,10 +13,12 @@
#include <Interface/LightSet.h>
#include <Interface/RTRTInterface.h>
#include <Interface/Scene.h>
+#include <Interface/Primitive.h>
#include <Model/AmbientLights/ArcAmbient.h>
#include <Model/Backgrounds/ConstantBackground.h>
#include <Model/Groups/Group.h>
#include <Model/Groups/kdtree.h>
+#include <Model/Groups/TransparentKDTree.h>
#include <Model/Lights/PointLight.h>
#include <Model/Lights/HeadLight.h>
#include <Model/Materials/Lambertian.h>
@@ -31,6 +33,9 @@
#include <Model/AmbientLights/ConstantAmbient.h>
#include <Model/MiscObjects/CuttingPlane.h>
+#include <Model/Materials/LambertianAlt.h>
+#include <Model/Materials/CopyColorMaterial.h>
+
#include <SCIRun/Core/Thread/Time.h>
using namespace Manta;
@@ -51,6 +56,7 @@
CuttingPlaneType cutting_type = CUTTING_NONE;
int workers_np = 1;
+ bool use_transparency = false;
// Parse args.i
for (int i=0;i<args.size();++i) {
@@ -63,6 +69,9 @@
if (!getIntArg(i, args, workers_np ))
throw IllegalArgument("boeing777 -np <num
build workers>", i, args);
}
+ else if (args[i] == "-transparent") {
+ use_transparency = true;
+ }
else if (args[i] == "-cutting") {
string cutting_string;
if (getPointArg(i, args, plane_point ) &&
getVectorArg(i, args, plane_normal)) {
@@ -80,16 +89,17 @@
cerr << "-file <filename>" << endl;
cerr << "-np <num build workers>" << endl;
cerr << "-cutting [<point> <normal>]" << endl;
+ cerr << "-transparent" << endl;
throw IllegalArgument( "boeing777", i, args );
}
}
// Create the scene.
Scene *scene = new Scene();
- Group *group = new Group();
+ Object *root_object = 0;
// Create a kd tree.
- KDTree *kdtree = new KDTree;
+ KDTree *kdtree = new KDTree( new LambertianAlt );
double start_time = Time::currentSeconds();
@@ -104,6 +114,13 @@
BBox bounds;
kdtree->computeBounds( bounds );
+ // Determine if we should start with a transparent kdtree or not.
+ Primitive *kd_primitive = kdtree;
+ if (use_transparency) {
+ kd_primitive = new TransparentKDTree( kdtree, new
CopyColorMaterial );
+ }
+
+
////////////////////////////////////////////////////////////////////////////
// Compute the middle of the model for a cutting plane.
if (cutting_type == CUTTING_DEFAULT) {
plane_point = bounds.center();
@@ -116,31 +133,20 @@
std::cout << "Cutting plane point: " << plane_point <<
std::endl;
std::cout << "Cutting plane normal: " << plane_normal <<
std::endl;
- group->add( new CuttingPlane( plane_point, plane_normal,
kdtree ) );
+ root_object = new CuttingPlane( plane_point, plane_normal,
kd_primitive );
}
else {
- group->add( kdtree );
+ root_object = kd_primitive;
}
LightSet *lights = new LightSet();
- // lights->add( new PointLight( Point(5000,5000,5000),
Color(RGB(1.0,1.0,1.0)) ));
lights->add( new HeadLight( 2.0, Color(RGB(1.0,1.0,1.0)) ));
-
- //lights->add( new PointLight( bounds.center() + Vector
-
- // group->add( new Sphere( new LambertianAlt(), Point(0,0,-11), 0.5 )
);
- // group->add( new Sphere( new LambertianAlt(), Point(0,0,-5 ), 0.25
) );
-
- // Add a light.
- // LightSet* lights = new LightSet();
- // lights->add( new PointLight(light_position,
Color(RGBColor(0.9,0.9,0.9) )));
-
lights->setAmbientLight( new ConstantAmbient(
Color(RGBColor(0.2,0.2,0.2) ) ));
scene->setLights(lights);
// Add the tree to the scene.
- scene->setObject( group );
+ scene->setObject( root_object );
// Set other important scene properties.
PinholeCamera *camera = new PinholeCamera( bounds[1], bounds[0],
Vector(0,1,0), 40.0 );
- [MANTA] r441 - in branches/itanium2: Model/Groups Model/Materials Model/MiscObjects fox scenes, abe, 07/26/2005
Archive powered by MHonArc 2.6.16.