Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r593 - in branches/itanium2: Engine/Control Interface UserInterface fox
- Date: Mon, 3 Oct 2005 23:24:06 -0600 (MDT)
Author: abe
Date: Mon Oct 3 23:24:05 2005
New Revision: 593
Added:
branches/itanium2/fox/FMantaRecorder.cc
branches/itanium2/fox/FMantaRecorder.h
Modified:
branches/itanium2/Engine/Control/RTRT.h
branches/itanium2/Interface/RTRTInterface.h
branches/itanium2/UserInterface/AutomatorUI.cc
branches/itanium2/UserInterface/AutomatorUI.h
branches/itanium2/UserInterface/CameraPathAutomator.cc
branches/itanium2/UserInterface/CameraPathAutomator.h
branches/itanium2/fox/CMakeLists.txt
branches/itanium2/fox/FMantaNavigator.h
branches/itanium2/fox/FMantaQuakeNav.cc
branches/itanium2/fox/FMantaQuakeNav.h
branches/itanium2/fox/FMantaTrackballNav.h
branches/itanium2/fox/FMantaWindow.cc
branches/itanium2/fox/FMantaWindow.h
Log:
Added gui for creating, saving, and running camera paths.
Access under the Camera menu in bin/dm_demo.
There are several outstanding issues and I wouldn't say that the code is 100%
stable.
Here are some basic instructions:
Recording:
1.) Select Camera->Camera Paths
2.) Select the Record tab
3.) Specify a "Sample Interval" this is the number of times per second that a
control point will be created.
4.) Specify "Total samples" 200 is a good starting place.
5.) Press Record.
6.) Move the camera around the gui until all samples have been recorded (or
press "Stop").
7.) Press Preview*
8.) Select Play tab.
9.) Press Play (watch the path play back)
10.) Select the Record tab**
11.) Press Save to write to a file if necessary.
Playing back:
1.) Select Camera->Camera Paths
2.) Press Load and choose a camera path file.
3.) Adjust delta time (the number of seconds between each camera update).
4.) Adjust delta t (the amount the spline parameter t changes between
updates)
5.) Press Play**
After a run through a path completes the actual number of elapsed frames will
print out and the average fps.
Outstanding Issues:
* You must press Preview before pressing Save
** You can only play a path once.
A fox/FMantaRecorder.cc
M fox/FMantaTrackballNav.h
A fox/FMantaRecorder.h
M fox/FMantaWindow.cc
M fox/FMantaWindow.h
M fox/FMantaQuakeNav.cc
M fox/FMantaQuakeNav.h
M fox/FMantaNavigator.h
M fox/CMakeLists.txt
M UserInterface/AutomatorUI.h
M UserInterface/CameraPathAutomator.cc
M UserInterface/CameraPathAutomator.h
M UserInterface/AutomatorUI.cc
M Interface/RTRTInterface.h
M Engine/Control/RTRT.h
Modified: branches/itanium2/Engine/Control/RTRT.h
==============================================================================
--- branches/itanium2/Engine/Control/RTRT.h (original)
+++ branches/itanium2/Engine/Control/RTRT.h Mon Oct 3 23:24:05 2005
@@ -131,7 +131,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);
Modified: branches/itanium2/Interface/RTRTInterface.h
==============================================================================
--- branches/itanium2/Interface/RTRTInterface.h (original)
+++ branches/itanium2/Interface/RTRTInterface.h Mon Oct 3 23:24:05 2005
@@ -152,6 +152,7 @@
// Query functions
virtual bool queryState(const string& what, vector<string>& results) = 0;
+ virtual int getCurrentFrame() const = 0;
// Transactions
virtual void addTransaction(TransactionBase*) = 0;
Modified: branches/itanium2/UserInterface/AutomatorUI.cc
==============================================================================
--- branches/itanium2/UserInterface/AutomatorUI.cc (original)
+++ branches/itanium2/UserInterface/AutomatorUI.cc Mon Oct 3 23:24:05
2005
@@ -35,9 +35,10 @@
using namespace Manta;
using namespace SCIRun;
-AutomatorUI::AutomatorUI( RTRTInterface *manta_interface_, int
warmup_frames_ ) :
+AutomatorUI::AutomatorUI( RTRTInterface *manta_interface_, int
warmup_frames_, bool is_detached_ ) :
manta_interface( manta_interface_ ),
warmup_frames( warmup_frames_ ),
+ is_detached( is_detached_ ),
startup_semaphore( "AutomatorUI semaphore", 0 )
{
}
@@ -66,10 +67,13 @@
void AutomatorUI::startup() {
- // Create a detached thread for the automator.
+ // Create a thread for the automator.
Thread *t = new Thread( this, "AutomatorUI" );
- t->setDaemon( true );
- t->detach();
+
+ if ( is_detached ) {
+ t->setDaemon( true );
+ t->detach();
+ }
}
void AutomatorUI::release_automator(int, int) {
Modified: branches/itanium2/UserInterface/AutomatorUI.h
==============================================================================
--- branches/itanium2/UserInterface/AutomatorUI.h (original)
+++ branches/itanium2/UserInterface/AutomatorUI.h Mon Oct 3 23:24:05
2005
@@ -62,13 +62,16 @@
// Number of frames to wait before starting.
int warmup_frames;
+
+ // Is the thread detached (should it wait for a join?)
+ bool is_detached;
protected:
inline RTRTInterface *getMantaInterface() { return manta_interface; };
public:
// Renderer will release the semaphore after "warmup_frames" have been
rendered
- AutomatorUI( RTRTInterface *manta_interface_, int warmup_frames_ = 0 );
+ AutomatorUI( RTRTInterface *manta_interface_, int warmup_frames_ = 0,
bool is_detached_ = true );
virtual ~AutomatorUI() { };
// This method must be implemented by Automator implementations.
Modified: branches/itanium2/UserInterface/CameraPathAutomator.cc
==============================================================================
--- branches/itanium2/UserInterface/CameraPathAutomator.cc (original)
+++ branches/itanium2/UserInterface/CameraPathAutomator.cc Mon Oct 3
23:24:05 2005
@@ -50,13 +50,37 @@
// SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP
SETU
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
+CameraPathAutomator::CameraPathAutomator( RTRTInterface *manta_interface_,
int channel_, int warmup_frames,
+ Point *eye_, Point *lookat_,
Vector *up_, int total_points_,
+ Real delta_t_, Real delta_time_ )
+ :
+ AutomatorUI( manta_interface_, warmup_frames ),
+ channel( channel_ ),
+ delta_t( delta_t_ ),
+ delta_time( delta_time_ ),
+ total_points( total_points_ )
+{
+ eye = new Point[total_points];
+ lookat = new Point[total_points];
+ up = new Vector[total_points];
+
+ memcpy( eye, eye_, total_points*sizeof(Point) );
+ memcpy( lookat, lookat_, total_points*sizeof(Point) );
+ memcpy( up, up_, total_points*sizeof(Vector) );
+}
+
+
+
CameraPathAutomator::CameraPathAutomator( RTRTInterface *manta_interface_,
int channel_,
- int warmup_frames, const string
&file_name ) :
+ int warmup_frames, const string
&file_name,
+ Real delta_t_, Real delta_time_ ) :
AutomatorUI( manta_interface_, warmup_frames ),
- channel( channel_ )
+ channel( channel_ ),
+ delta_t( delta_t_ ),
+ delta_time( delta_time_ )
+
{
- delta_t = 0.25;
- delta_time = 0.1;
+
total_points = 0;
vector<string> args;
@@ -68,7 +92,7 @@
// Load the input file.
FILE *file = fopen( file_name.c_str(), "r" );
if (file == 0) {
- throw ErrnoException( "Cannot open camera path file: " + file_name,
+ throw new ErrnoException( "Cannot open camera path file: " + file_name,
errno, __FILE__, __LINE__ );
}
@@ -120,13 +144,13 @@
if (name == "delta_t") {
if (!getArg(i,args,delta_t)) {
sprintf(error_message, "CameraPathAutomator input line: %d",
line_num );
- throw IllegalArgument(error_message, i, args);
+ throw new IllegalArgument(error_message, i, args);
}
}
else if (name == "delta_time") {
if (!getArg(i,args,delta_time)) {
sprintf(error_message, "CameraPathAutomator input line: %d",
line_num );
- throw IllegalArgument(error_message, i, args);
+ throw new IllegalArgument(error_message, i, args);
}
}
else if (name == "control") {
@@ -144,21 +168,21 @@
if (args[i] == "-eye") {
if (!getPointArg(i,args,eye_)) {
sprintf(error_message, "CameraPathAutomator -eye input line:
%d", line_num );
- throw IllegalArgument(error_message, i, args);
+ throw new IllegalArgument(error_message, i, args);
}
got_eye = true;
}
else if (args[i] == "-lookat") {
if (!getPointArg(i,args,lookat_)) {
sprintf(error_message, "CameraPathAutomator -lookat input line:
%d", line_num );
- throw IllegalArgument(error_message, i, args);
+ throw new IllegalArgument(error_message, i, args);
}
got_lookat = true;
}
else if (args[i] == "-up") {
if (!getVectorArg(i,args,up_)) {
sprintf(error_message, "CameraPathAutomator -up input line: %d",
line_num );
- throw IllegalArgument(error_message, i, args);
+ throw new IllegalArgument(error_message, i, args);
}
got_up = true;
}
@@ -174,7 +198,7 @@
}
else {
sprintf(error_message, "CameraPathAutomator incomplete spec input
line: %d", line_num );
- throw IllegalArgument(error_message, line_num, args);
+ throw new IllegalArgument(error_message, line_num, args);
}
}
@@ -238,6 +262,9 @@
Point current_eye, current_lookat;
Vector current_up;
+ int start_frame = getMantaInterface()->getCurrentFrame();
+ Real start_seconds = SCIRun::Time::currentSeconds();
+
std::cerr << "Beginning camera path " << total_points
<< " control points." << std::endl;
@@ -280,6 +307,11 @@
while ((SCIRun::Time::currentSeconds()-start_time) < delta_time);
}
}
+
+ int total_frames = getMantaInterface()->getCurrentFrame() - start_frame;
+
+ std::cerr << "Path complete. " << total_frames
+ << " frames. Avg fps: " <<
(Real)total_frames/(SCIRun::Time::currentSeconds()-start_seconds) <<
std::endl;
}
///////////////////////////////////////////////////////////////////////////////
@@ -294,5 +326,33 @@
getMantaInterface()->getCamera( channel )->reset( eye_, up_, lookat_ );
}
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// WRITE PATH WRITE PATH WRITE PATH WRITE PATH WRITE PATH WRITE PATH
WRIT
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+void CameraPathAutomator::write_path( const string &file_name ) {
+
+ FILE *file = fopen( file_name.c_str(), "w" );
+ if (file == 0) {
+ throw new ErrnoException( "Cannot open camera path file: " + file_name,
+ errno, __FILE__, __LINE__ );
+ }
+ // Output the delta t and delta time.
+ fprintf( file, "delta_t(%f)\n", delta_t );
+ fprintf( file, "delta_time(%f)\n", delta_time );
+
+ // Output the control points.
+ for (int i=0; i<total_points; ++i) {
+ fprintf( file, "control( -eye %f %f %f ", eye[i][0], eye[i][1],
eye[i][2] );
+ fprintf( file, "-lookat %f %f %f ", lookat[i][0], lookat[i][1],
lookat[i][2] );
+ fprintf( file, "-up %f %f %f ", up[i][0], up[i][1],
up[i][2] );
+ fprintf( file, ")\n");
+ }
+
+ // Terminate with newline.
+ fprintf( file, "\n" );
+ fclose( file );
+}
Modified: branches/itanium2/UserInterface/CameraPathAutomator.h
==============================================================================
--- branches/itanium2/UserInterface/CameraPathAutomator.h (original)
+++ branches/itanium2/UserInterface/CameraPathAutomator.h Mon Oct 3
23:24:05 2005
@@ -60,7 +60,12 @@
int channel;
public:
- CameraPathAutomator( RTRTInterface *manta_interface_, int channel_, int
warmup_, const string &file_name );
+ CameraPathAutomator( RTRTInterface *manta_interface_, int channel_, int
warmup_, const string &file_name,
+ Real delta_t_ = 0.2, Real delta_time_ = 0.2 );
+
+ CameraPathAutomator( RTRTInterface *manta_interface_, int channel_, int
warmup_,
+ Point *eye_, Point *lookat_, Vector *up_, int
total_points_,
+ Real delta_t_ = 0.2, Real delta_time_ = 0.2 );
~CameraPathAutomator();
// Create method called by RTRT_register.
@@ -71,6 +76,19 @@
// This method is called by the manta rendering thread to update the
camera.
void mantaSetCamera( const Point eye_, const Point lookat_, const Vector
up_ );
+
+ // This may be called to write the camera path to a specified file in
the correct format.
+ void write_path( const string &file_name );
+
+ // Accessors.
+ inline int get_total_points() { return total_points; };
+
+ inline Real get_delta_t() { return delta_t; };
+ inline void set_delta_t( Real delta_t_ ) { delta_t = delta_t_; };
+
+ inline Real get_delta_time() { return delta_time; };
+ inline void set_delta_time( Real delta_time_ ) { delta_time =
delta_time_; };
+
};
};
Modified: branches/itanium2/fox/CMakeLists.txt
==============================================================================
--- branches/itanium2/fox/CMakeLists.txt (original)
+++ branches/itanium2/fox/CMakeLists.txt Mon Oct 3 23:24:05 2005
@@ -29,6 +29,8 @@
FMantaUniformNav.cc
FMantaTrackballNav.h
FMantaTrackballNav.cc
+ FMantaRecorder.h
+ FMantaRecorder.cc
# FMantaTextureChooser.h
# FMantaTextureChooser.cc
# FMantaMaterialChooser.h
@@ -47,7 +49,7 @@
- SET(FOX_X11_LIBRARIES m)
+ SET(FOX_X11_LIBRARIES m jpeg png tiff)
# Append Xcursor if it is available.
FIND_LIBRARY( FOUND_XCURSOR NAMES Xcursor PATHS /usr/X11R6/lib )
Modified: branches/itanium2/fox/FMantaNavigator.h
==============================================================================
--- branches/itanium2/fox/FMantaNavigator.h (original)
+++ branches/itanium2/fox/FMantaNavigator.h Mon Oct 3 23:24:05 2005
@@ -40,8 +40,9 @@
virtual void setControlSpeed( Real new_speed ) = 0;
virtual void resetToCamera( const Point &eye, const Point
&lookat, const Vector &up ) { };
+ virtual void getCamera ( Point &eye, Point &lookat, Vector &up )
const { };
};
};
-#endif
\ No newline at end of file
+#endif
Modified: branches/itanium2/fox/FMantaQuakeNav.cc
==============================================================================
--- branches/itanium2/fox/FMantaQuakeNav.cc (original)
+++ branches/itanium2/fox/FMantaQuakeNav.cc Mon Oct 3 23:24:05 2005
@@ -140,28 +140,40 @@
viewElevAngle = (float)atan2(dZ,dV)/TORADS;
}
-///////////////////////////////////////////////////////////////////////////////
-// Transaction callback for manta thread.
-// THIS FUNCTION IS NOT CALLED BY THE FOX THREAD.
-void FMantaQuakeNav::mantaThreadCallback() const {
-
- // Get a pointer to the camera.
- Camera *manta_camera = manta_interface->getCamera( manta_channel );
+void FMantaQuakeNav::getCamera ( Point &eye, Point &lookat, Vector &up )
const {
// Transform a default eye, up, and lookat.
double Azi=viewDirAngle*TORADS , Elev=viewElevAngle*TORADS;
+
float dX=(float)(cos(Azi)*cos(Elev)),
dY=(float)(sin(Azi)*cos(Elev)),
dZ=(float)sin(Elev);
- Point eye ( posX, posY, height );
- Point lookat( posX+dX, posY+dY, height+dZ );
- Vector up ( 0.0, 0.0, 1.0 );
+
+ eye = Point( posX, posY, height );
+ lookat = Point( posX+dX, posY+dY, height+dZ );
+ up = Vector( 0.0, 0.0, 1.0 );
+
/* for y-up
Point eye ( posX, posY, height );
Point lookat( posX+dX, -(height+dZ), posY+dY );
Vector up ( 0.0, 1.0, 0.0 );
*/
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Transaction callback for manta thread.
+// THIS FUNCTION IS NOT CALLED BY THE FOX THREAD.
+void FMantaQuakeNav::mantaThreadCallback() const {
+
+ // Get a pointer to the camera.
+ Camera *manta_camera = manta_interface->getCamera( manta_channel );
+
+ Point eye_, lookat_;
+ Vector up_;
+
+ getCamera( eye_, lookat_, up_ );
// Apply it to the camera.
- manta_camera->reset( eye, up, lookat );
+ manta_camera->reset( eye_, up_, lookat_ );
}
Modified: branches/itanium2/fox/FMantaQuakeNav.h
==============================================================================
--- branches/itanium2/fox/FMantaQuakeNav.h (original)
+++ branches/itanium2/fox/FMantaQuakeNav.h Mon Oct 3 23:24:05 2005
@@ -124,6 +124,7 @@
void setControlSpeed( Real new_speed ) { translateStepSize =
new_speed; };
void resetToCamera( const Point &eye, const Point &lookat, const Vector
&up );
+ void getCamera ( Point &eye, Point &lookat, Vector &up ) const ;
// Transaction callback for manta thread.
Added: branches/itanium2/fox/FMantaRecorder.cc
==============================================================================
--- (empty file)
+++ branches/itanium2/fox/FMantaRecorder.cc Mon Oct 3 23:24:05 2005
@@ -0,0 +1,348 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Silicon Graphics Inc. Mountain View California.
+
+ 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 <fox/FMantaRecorder.h>
+
+#include <SCIRun/Core/Thread/Time.h>
+
+using namespace FX;
+using namespace Manta;
+using namespace fox_manta;
+
+FXDEFMAP(FMantaRecorderDialog) FMantaRecorderDialogMap[] = {
+
//////////////////////////////////////////////////////////////////////////////
+ // Message_Type ID Message_Handler
+ FXMAPFUNC(SEL_COMMAND, FMantaRecorderDialog::ID_LOAD,
FMantaRecorderDialog::onLoad ),
+ FXMAPFUNC(SEL_COMMAND, FMantaRecorderDialog::ID_PLAY,
FMantaRecorderDialog::onPlay ),
+ FXMAPFUNC(SEL_COMMAND, FMantaRecorderDialog::ID_RECORD,
FMantaRecorderDialog::onRecord ),
+ FXMAPFUNC(SEL_COMMAND, FMantaRecorderDialog::ID_STOP,
FMantaRecorderDialog::onStop ),
+ FXMAPFUNC(SEL_COMMAND, FMantaRecorderDialog::ID_SAVE,
FMantaRecorderDialog::onSave ),
+ FXMAPFUNC(SEL_COMMAND, FMantaRecorderDialog::ID_PREVIEW,
FMantaRecorderDialog::onPreview ),
+ FXMAPFUNC(SEL_TIMEOUT, FMantaRecorderDialog::ID_RECORD_CHORE,
FMantaRecorderDialog::onRecordChore )
+};
+
+FXIMPLEMENT(FMantaRecorderDialog,FXDialogBox,FMantaRecorderDialogMap,ARRAYNUMBER(FMantaRecorderDialogMap));
+
+FMantaRecorderDialog::FMantaRecorderDialog( FMantaWindow *manta_window_,
+ 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 )
+
+ :
+
+ FXDialogBox ( manta_window_->getApp(), name, opts, x, y, w, h, pl, pr, pt,
pb, hs, vs ),
+ manta_window( manta_window_ ),
+ automator( 0 )
+
+{
+
+ // Create the tab book.
+ tab_book = new FXTabBook( this, 0, 0, LAYOUT_FILL );
+
+
//////////////////////////////////////////////////////////////////////////////
+ // Play tab.
+ play_tab = new FXTabItem( tab_book, "Play", 0 );
+ FXVerticalFrame *play_tab_frame = new FXVerticalFrame( tab_book,
FRAME_THICK|FRAME_RAISED );
+
+ load_button = new FXButton( play_tab_frame, "Load", 0, this, ID_LOAD );
+
+ FXHorizontalFrame *frame = new FXHorizontalFrame( play_tab_frame );
+ new FXLabel( frame, "File: " );
+ file_name_field = new FXTextField( frame, 32 );
+ file_name_field->disable();
+
+ play_group = new FXVerticalFrame( play_tab_frame );
+ play_button = new FXButton( play_group, "Play", 0, this, ID_PLAY );
+ play_button->disable();
+
+ frame = new FXHorizontalFrame( play_group );
+ new FXLabel( frame, "Delta time: " );
+ play_time_spinner = new FXRealSpinner( frame, 5 );
+ play_time_spinner->setRange( 0.0, 999.0 );
+ play_time_spinner->setValue( 0.2 );
+ play_time_spinner->setIncrement( 0.05 );
+ play_time_spinner->disable();
+
+ frame = new FXHorizontalFrame( play_group );
+ new FXLabel( frame, "Delta t: " );
+ play_t_spinner = new FXRealSpinner( frame, 5 );
+ play_t_spinner->setValue( 0.2 );
+ play_t_spinner->setRange( 0.0, 1.0 );
+ play_t_spinner->setIncrement( 0.05 );
+ play_t_spinner->disable();
+
+
//////////////////////////////////////////////////////////////////////////////
+ // Record tab.
+ record_tab = new FXTabItem( tab_book, "Record", 0 );
+ FXVerticalFrame *record_tab_frame = new FXVerticalFrame( tab_book,
FRAME_THICK|FRAME_RAISED );
+
+ // Record option group
+ record_group = new FXVerticalFrame( record_tab_frame );
+
+ frame = new FXHorizontalFrame( record_group );
+ new FXLabel( frame, "Sample Interval: " );
+ record_interval = new FXRealSpinner( frame, 5 );
+ record_interval->setRange( 0.0, 999.0 );
+ record_interval->setIncrement( 0.05 );
+ record_interval->setValue( 0.2 );
+
+ frame = new FXHorizontalFrame( record_group );
+ new FXLabel( frame, "Total samples:" );
+ record_size = new FXSpinner( frame, 5 );
+ record_size->setRange( 1, 99999 );
+ record_size->setValue( 20 );
+
+ record_button = new FXButton( record_group, "Record", 0, this, ID_RECORD );
+
+ counter_text_field = new FXTextField( record_group, 32 );
+ counter_text_field->disable();
+
+ new FXHorizontalSeparator( record_tab_frame,
LAYOUT_FILL_X|SEPARATOR_GROOVE );
+ stop_button = new FXButton( record_group, "Stop", 0, this, ID_STOP );
+ stop_button->disable();
+
+ // Save option group.
+ save_group = new FXVerticalFrame( record_tab_frame );
+
+ frame = new FXHorizontalFrame( save_group );
+ new FXLabel( frame, "Delta time: " );
+ record_time_spinner = new FXRealSpinner( frame, 5 );
+ record_time_spinner->setRange( 0.0, 999.0 );
+ record_time_spinner->setIncrement( 0.05 );
+ record_time_spinner->disable();
+
+ frame = new FXHorizontalFrame( save_group );
+ new FXLabel( frame, "Delta t: " );
+ record_t_spinner = new FXRealSpinner( frame, 5 );
+ record_t_spinner->setRange( 0.0, 1.0 );
+ record_t_spinner->setIncrement( 0.05 );
+ record_t_spinner->disable();
+
+
+ frame = new FXHorizontalFrame( save_group );
+ preview_button = new FXButton( frame, "Preview", 0, this, ID_PREVIEW );
+ preview_button->disable();
+
+ save_button = new FXButton( frame, "Save", 0, this, ID_SAVE );
+ save_button->disable();
+}
+
+long FMantaRecorderDialog::onLoad ( FXObject *sender, FXSelector key, void
*data ) {
+
+ // Prompt the user for an input file name.
+ FXString file_name = FXFileDialog::getOpenFilename( this, "Camera path
file", ".", "*.txt" );
+ if (file_name.length() > 0) {
+
+ // Check to see if file can be opened.
+ FILE *file = 0;
+ if (file = fopen( file_name.text(), "r")) {
+ fclose( file );
+ }
+ else {
+ FXMessageBox::error(this,MBOX_OK,"Could not open
file.",file_name.text());
+ }
+
+ // Parse the file.
+ try {
+ automator = new CameraPathAutomator(
manta_window->getMantaInterface(), 0, 0,
+ file_name.text() );
+
+ } catch (SCIRun::Exception *e) {
+ FXMessageBox::error(this,MBOX_OK,"Error processing
file:",e->message());
+ }
+
+ // If parsing was successful.
+ if (automator) {
+
+ // Update delta t and time.
+ play_t_spinner->setValue( automator->get_delta_t() );
+ play_time_spinner->setValue( automator->get_delta_time() );
+
+ // Display the file name.
+ file_name_field->setText( file_name );
+ file_name_field->repaint();
+
+ // Enable the play buttons.
+ play_button->enable();
+ play_t_spinner->enable();
+ play_time_spinner->enable();
+
+ }
+ }
+
+ return 1;
+}
+
+long FMantaRecorderDialog::onPlay ( FXObject *sender, FXSelector key, void
*data ) {
+
+ // Get the desired delta_t and delta_time.
+ Real delta_t = play_t_spinner->getValue();
+ Real delta_time = play_time_spinner->getValue();
+ FXString file_name = file_name_field->getText();
+
+ // Set the delta's if they were changed.
+ automator->set_delta_t( delta_t );
+ automator->set_delta_time( delta_time );
+
+ // Disable the play buttons.
+ play_button->disable();
+ play_t_spinner->disable();
+ play_time_spinner->disable();
+
+ // Start the asynchronous thread.
+ automator->startup();
+
+ return 1;
+}
+
+long FMantaRecorderDialog::onRecord( FXObject *sender, FXSelector key, void
*data ) {
+
+ // Allocate storage for the camera positions.
+ total_record_points = record_size->getValue();
+ record_time_interval = record_interval->getValue();
+ record_iter = 0;
+
+ record_eye = new Point [total_record_points];
+ record_lookat = new Point [total_record_points];
+ record_up = new Vector[total_record_points];
+
+ stop_button->enable();
+
+ // Add a fox idle mode chore to record the camera position.
+ getApp()->addTimeout(this, ID_RECORD_CHORE, record_time_interval*1000.0, 0
);
+
+ return 1;
+}
+
+long FMantaRecorderDialog::onStop ( FXObject *sender, FXSelector key, void
*data ) {
+
+ stop_button->disable();
+ preview_button->enable();
+ getApp()->removeTimeout( this, ID_RECORD_CHORE );
+ return 1;
+}
+
+long FMantaRecorderDialog::onSave ( FXObject *sender, FXSelector key, void
*data ) {
+
+ FXString file_name = FXFileDialog::getSaveFilename( this, "Camera path
file", ".", "*.txt" );
+ if (file_name.length() > 0) {
+
+ try {
+ automator->write_path( file_name.text() );
+
+ // Display the control point recorded.
+ FXString counter_text;
+ counter_text.format( "Saved %d control points.",
automator->get_total_points() );
+
+ counter_text_field->setText( counter_text );
+ counter_text_field->repaint();
+
+ } catch (SCIRun::Exception *e) {
+ FXMessageBox::error(this,MBOX_OK,"Error saving file:",e->message());
+ }
+ }
+
+ return 1;
+}
+
+long FMantaRecorderDialog::onPreview ( FXObject *sender, FXSelector key,
void *data ) {
+
+ // Copy the data over to the play path tab.
+ automator = new CameraPathAutomator( manta_window->getMantaInterface(), 0,
0,
+ record_eye, record_lookat, record_up,
record_iter,
+ record_t_spinner->getValue(),
+ record_time_spinner->getValue() );
+
+ play_t_spinner->setValue( record_t_spinner->getValue() );
+ play_time_spinner->setValue( record_time_spinner->getValue() );
+
+ // Delete the data.
+ record_iter = 0;
+ delete [] record_eye;
+ delete [] record_lookat;
+ delete [] record_up;
+
+ // Enable playing or recording another path.
+ preview_button->disable();
+
+ play_button->enable();
+ record_button->enable();
+ save_button->enable();
+
+ return 1;
+}
+
+long FMantaRecorderDialog::onRecordChore( FXObject *sender, FXSelector key,
void *data ) {
+
+ // Record the current navigator camera position.
+ manta_window->getMantaFrame()->getNavigator()->getCamera(
record_eye[record_iter],
+
record_lookat[record_iter],
+
record_up[record_iter] );
+
+ // Determine the number of frames since last record.
+ Real current_frames = manta_window->getMantaInterface()->getCurrentFrame();
+ Real elasp_frames = current_frames - last_frames;
+
+ if (elasp_frames > 0) {
+ // Update the delta t estimate.
+ record_t_spinner->setValue( 1.0 / (elasp_frames) );
+ record_t_spinner->repaint();
+
+ // Determine the time since the last record.
+ Real current_time = SCIRun::Time::currentSeconds();
+ Real elasp_time = current_time - last_time;
+
+ // Update the delta t spinner.
+ record_time_spinner->setValue( elasp_time/elasp_frames );
+ record_time_spinner->repaint();
+
+ last_time = current_time;
+ };
+ last_frames = current_frames;
+
+ // Display the control point recorded.
+ FXString counter_text;
+ counter_text.format( "Control Point %d", record_iter );
+
+ counter_text_field->setText( counter_text );
+ counter_text_field->repaint();
+
+ // Increment to the next position.
+ ++record_iter;
+
+ // Send a timeout for the next record event.
+ if (record_iter < total_record_points) {
+ getApp()->addTimeout(this, ID_RECORD_CHORE, record_time_interval*1000.0,
0 );
+ }
+ else {
+ stop_button->disable();
+ preview_button->enable();
+ }
+
+ return 1;
+};
Added: branches/itanium2/fox/FMantaRecorder.h
==============================================================================
--- (empty file)
+++ branches/itanium2/fox/FMantaRecorder.h Mon Oct 3 23:24:05 2005
@@ -0,0 +1,138 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Silicon Graphics Inc. Mountain View California.
+
+ 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 __FMANTARECORDER_H__
+#define __FMANTARECORDER_H__
+
+#include <Interface/RTRTInterface.h>
+#include <UserInterface/CameraPathAutomator.h>
+
+#include <fox/FMantaWindow.h>
+#include <fox/FMantaUniformNav.h>
+#include <fox/FMantaQuakeNav.h>
+#include <fox/FMantaTrackballNav.h>
+#include <fox/FMantaWidgets.h>
+
+namespace fox_manta {
+
+ using namespace FX;
+ using namespace Manta;
+ using namespace std;
+
+ class FMantaWindow;
+
+
//////////////////////////////////////////////////////////////////////////////
+
//////////////////////////////////////////////////////////////////////////////
+ // Camera Path Recorder
+
//////////////////////////////////////////////////////////////////////////////
+
//////////////////////////////////////////////////////////////////////////////
+ class FMantaRecorderDialog : public FXDialogBox {
+ FXDECLARE(FMantaRecorderDialog)
+ private:
+
+ // Objects for playing paths.
+ FMantaWindow *manta_window;
+ CameraPathAutomator *automator;
+
+ // Objects for recording paths.
+ int total_record_points;
+ int record_iter;
+ Real record_time_interval;
+
+ // Storage during recording.
+ Point *record_eye;
+ Point *record_lookat;
+ Vector *record_up;
+
+ // Elasp time for recording.
+ Real last_frames;
+ Real last_time;
+
+ // Button groups
+ FXComposite *play_group;
+ FXComposite *record_group;
+ FXComposite *save_group;
+
+ // Tab items.
+ FXTabBook *tab_book;
+ FXTabItem *play_tab;
+ FXTabItem *record_tab;
+
+ // Play tab fields.
+ FXButton *load_button;
+ FXButton *play_button;
+ FXTextField *file_name_field;
+ FXRealSpinner *play_time_spinner;
+ FXRealSpinner *play_t_spinner;
+
+ // Record tab fields.
+ FXButton *record_button;
+ FXButton *stop_button;
+ FXTextField *counter_text_field;
+ FXButton *save_button;
+ FXButton *preview_button;
+
+ FXRealSpinner *record_interval;
+ FXSpinner *record_size;
+
+ FXRealSpinner *record_t_spinner; // 1 / Approx number of frames
between control points.
+ FXRealSpinner *record_time_spinner; // Approx time per frame.
+
+ public:
+ enum {
+ ID_LOAD = FXDialogBox::ID_LAST,
+ ID_PLAY,
+ ID_RECORD,
+ ID_STOP,
+ ID_SAVE,
+ ID_PREVIEW,
+ ID_RECORD_CHORE,
+ ID_LAST
+ };
+
+ FMantaRecorderDialog::FMantaRecorderDialog() { };
+ FMantaRecorderDialog( FMantaWindow *manta_window_,
+ const FXString &name, FXuint opts=DECOR_ALL,
+ FXint x=50,FXint y=50,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 create() { FXDialogBox::create(); };
+
+ long onLoad ( FXObject *sender, FXSelector key, void *data );
+ long onPlay ( FXObject *sender, FXSelector key, void *data );
+ long onRecord ( FXObject *sender, FXSelector key, void *data );
+ long onStop ( FXObject *sender, FXSelector key, void *data );
+ long onSave ( FXObject *sender, FXSelector key, void *data );
+ long onPreview ( FXObject *sender, FXSelector key, void *data );
+ long onRecordChore( FXObject *sender, FXSelector key, void *data );
+ };
+
+};
+
+
+#endif
Modified: branches/itanium2/fox/FMantaTrackballNav.h
==============================================================================
--- branches/itanium2/fox/FMantaTrackballNav.h (original)
+++ branches/itanium2/fox/FMantaTrackballNav.h Mon Oct 3 23:24:05 2005
@@ -50,7 +50,7 @@
void setMantaFrame( FMantaImageFrame *frame ) {
manta_frame = frame; };
void setTrackballRadius( Real trackball_radius_ ) {
trackball_radius = trackball_radius_; };
void setControlSpeed( Real new_speed ) {
control_speed = new_speed; };
- void resetToCamera( const Point &eye, const Point &lookat,
const Vector &up ) {
+ void resetToCamera( const Point &eye, const Point &lookat,
const Vector &up ) {
/* Trackball nav contains no camera state. */ };
// Methods called by the manta thread.
@@ -61,4 +61,4 @@
};
};
-#endif
\ No newline at end of file
+#endif
Modified: branches/itanium2/fox/FMantaWindow.cc
==============================================================================
--- branches/itanium2/fox/FMantaWindow.cc (original)
+++ branches/itanium2/fox/FMantaWindow.cc Mon Oct 3 23:24:05 2005
@@ -41,7 +41,9 @@
FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_ORTHO_CAMERA,
FMantaWindow::onCamera ),
FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_ENVIRONMENT_CAMERA,
FMantaWindow::onCamera ),
FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_FISHEYE_CAMERA,
FMantaWindow::onCamera ),
- FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_TEXT_CAMERA,
FMantaWindow::onCameraText ),
+ FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_TEXT_CAMERA,
FMantaWindow::onCameraText ),
+
+ FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_CAMERA_PATHS,
FMantaWindow::onCameraPath ),
// Shadows.
FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_HARD_SHADOWS,
FMantaWindow::onShadowAlgorithm ),
@@ -94,7 +96,10 @@
new FXMenuCommand( camera_menu, "Environment Camera", 0, this,
ID_ENVIRONMENT_CAMERA );
new FXMenuCommand( camera_menu, "Fish Eye Camera", 0, this,
ID_FISHEYE_CAMERA );
new FXMenuCommand( camera_menu, "Enter Text...", 0, this,
ID_TEXT_CAMERA );
- new FXMenuTitle ( menu_bar, "Camera", 0, camera_menu );
+ new FXMenuSeparator( camera_menu );
+ new FXMenuCommand( camera_menu, "Camera Paths", 0, this, ID_CAMERA_PATHS );
+
+ new FXMenuTitle ( menu_bar, "Camera", 0, camera_menu );
// Shadow Menu.
shadow_menu = new FXMenuPane( this );
@@ -160,6 +165,10 @@
camera_bookmark_list->setNumVisible( 5 );
new FXButton( frame, "Add", 0, this, ID_ADD_BOOKMARK );
+
+ // Camera paths dialog.
+ camera_path_dialog = new FMantaRecorderDialog( this, "Path Recorder" );
+ camera_path_dialog->hide();
}
void FMantaWindow::setExtraOptionsDialog( FXDialogBox *extra_options_dialog_
) {
@@ -305,6 +314,13 @@
}
return 1;
+}
+
+long FMantaWindow::onCameraPath( FXObject *sender, FXSelector key, void
*data ) {
+
+ camera_path_dialog->show( PLACEMENT_DEFAULT );
+
+ return 1;
}
long FMantaWindow::onShadowAlgorithm( FXObject *sender, FXSelector key, void
*data ) {
Modified: branches/itanium2/fox/FMantaWindow.h
==============================================================================
--- branches/itanium2/fox/FMantaWindow.h (original)
+++ branches/itanium2/fox/FMantaWindow.h Mon Oct 3 23:24:05 2005
@@ -8,6 +8,8 @@
#include <Engine/Display/GLXImageDisplay.h>
#include <fox/FMantaImageFrame.h>
+#include <fox/FMantaRecorder.h>
+
#include <vector>
namespace fox_manta {
@@ -15,7 +17,9 @@
using namespace FX;
using namespace Manta;
using std::vector;
-
+
+ class FMantaRecorderDialog;
+
// This is the main window for the Fox application.
// this class will have a pointer to the RTRTInterface (manta
interface)
// it will also be responsible for initializing manta as well as the
rest of
@@ -45,6 +49,8 @@
FXMenuCommand *extra_options;
FXDialogBox *extra_options_dialog;
+
+ FMantaRecorderDialog *camera_path_dialog;
FXRealSlider *speed_slider;
FXRealSlider *cutting_slider;
@@ -78,12 +84,13 @@
ID_NAVIGATOR_LIST,
ID_NAVIGATOR_TOGGLE,
- // Shadow options.
+ // Camera options.
ID_PINHOLE_CAMERA,
ID_ORTHO_CAMERA,
ID_ENVIRONMENT_CAMERA,
ID_FISHEYE_CAMERA,
ID_TEXT_CAMERA,
+ ID_CAMERA_PATHS,
// Shadow options.
ID_HARD_SHADOWS,
@@ -136,6 +143,7 @@
long onCuttingSlider ( FXObject *sender, FXSelector key,
void *data );
long onCuttingFlip ( FXObject *sender, FXSelector key,
void *data );
long onCameraBookmark ( FXObject *sender, FXSelector key,
void *data );
+ long onCameraPath ( FXObject *sender, FXSelector key, void *data );
long onNavigator ( FXObject *sender, FXSelector key,
void *data );
long onNavigatorToggle( FXObject *sender, FXSelector key,
void *data );
long onAddBookmark ( FXObject *sender, FXSelector key,
void *data );
- [MANTA] r593 - in branches/itanium2: Engine/Control Interface UserInterface fox, abe, 10/03/2005
Archive powered by MHonArc 2.6.16.