Author: eudoxos
Date: 2008-09-28 14:37:30 +0200 (Sun, 28 Sep 2008)
New Revision: 1530

Added:
   trunk/scripts/simple-scene-video.py
Modified:
   trunk/core/Omega.cpp
   trunk/core/Omega.hpp
   trunk/gui/SConscript
   trunk/gui/py/utils.py
   trunk/gui/qt3/GLSimulationPlayerViewer.cpp
   trunk/gui/qt3/GLSimulationPlayerViewer.hpp
   trunk/gui/qt3/GLViewer.cpp
   trunk/gui/qt3/GLViewer.hpp
   trunk/gui/qt3/QtGUI-python.cpp
   trunk/gui/qt3/YadeQtMainWindow.hpp
   trunk/gui/qt3/qt.py
   trunk/scripts/simple-scene-player.py
Log:
1. 3d view now has by default a OSD with iteration number, simulation time and 
virtual time. This can be toggled (all combinations) by pressing 'D' (which 
used to mean toggling d+ynamic flag...?) and set also from python with 
GLView.timeMask='rvi' (Real,Virtual,Iteration) and so on.
2. Simulation player displays real time and wall clock loaded from db (insted 
of bogus values of system clock when the player is being run)
3. new periodic SnapshotEngine that takes snapshots of any GL view to numbered 
PNG files.
4. new function qt.makeSimulationVideo that makes video _while running the 
simulation_.
5. qt.createVideo renamed to qt.makePlayerVideo
6. Added Omega method to query computation duration.
7. An example of using qt.makeSimulationVideo is in new file 
scripts/simple-scene-video.py



Modified: trunk/core/Omega.cpp
===================================================================
--- trunk/core/Omega.cpp        2008-09-26 09:42:13 UTC (rev 1529)
+++ trunk/core/Omega.cpp        2008-09-28 12:37:30 UTC (rev 1530)
@@ -56,6 +56,7 @@
 ptime Omega::getMsStartingSimulationTime(){return msStartingSimulationTime;}
 time_duration Omega::getSimulationPauseDuration(){return 
simulationPauseDuration;}
 Real Omega::getComputationTime(){ return 
(microsec_clock::local_time()-msStartingSimulationTime-simulationPauseDuration).total_milliseconds()/1e3;
 }
+time_duration Omega::getComputationDuration(){return 
microsec_clock::local_time()-msStartingSimulationTime-simulationPauseDuration;}
 
 
 void Omega::reset(){

Modified: trunk/core/Omega.hpp
===================================================================
--- trunk/core/Omega.hpp        2008-09-26 09:42:13 UTC (rev 1529)
+++ trunk/core/Omega.hpp        2008-09-28 12:37:30 UTC (rev 1530)
@@ -148,6 +148,7 @@
                
                Real            getSimulationTime();
                Real            getComputationTime();
+               time_duration getComputationDuration();
                void            incrementSimulationTime();
                
                void init();

Modified: trunk/gui/SConscript
===================================================================
--- trunk/gui/SConscript        2008-09-26 09:42:13 UTC (rev 1529)
+++ trunk/gui/SConscript        2008-09-28 12:37:30 UTC (rev 1530)
@@ -24,7 +24,7 @@
                                'qt3/QtGeneratedSimulationPlayer.ui',
                                'qt3/QtSimulationPlayer.cpp',
                                ],
-                       LIBS=env['LIBS']+['yade-base',
+                       LIBS=env['LIBS']+linkPythonUI+[
                                'yade-opengl',
                                'yade-serialization',
                                'XMLFormatManager',
@@ -34,8 +34,10 @@
                                'PositionOrientationRecorder',
                                'sqlite3x',
                                'FilterEngine',
-                               '$QGLVIEWER_LIB']+linkPythonUI,
-                       CPPPATH=env['CPPPATH']+['qt3']),
+                               '$QGLVIEWER_LIB'],
+                       CPPPATH=env['CPPPATH']+['qt3']
+               ),
+               
env.SharedLibrary('SnapshotEngine',['qt3/SnapshotEngine.cpp'],LIBS=env['LIBS']+['QtGUI'],CPPPATH=env['CPPPATH']+['qt3']),
        ])
 
 if 'EMBED_PYTHON' in env['CPPDEFINES']:

Modified: trunk/gui/py/utils.py
===================================================================
--- trunk/gui/py/utils.py       2008-09-26 09:42:13 UTC (rev 1529)
+++ trunk/gui/py/utils.py       2008-09-28 12:37:30 UTC (rev 1530)
@@ -198,3 +198,21 @@
                        o.bodies[i].mold.postProcessAttributes()
                return imp.number_of_facets
 
+def encodeVideoFromFrames(wildcard,out,renameNotOverwrite=True,fps=24):
+       import pygst,sys,gobject,os
+       pygst.require("0.10")
+       import gst
+       if renameNotOverwrite and os.path.exists(out):
+               i=0;
+               while(os.path.exists(out+"~%d"%i)): i+=1
+               os.rename(out,out+"~%d"%i); print "Output file `%s' already 
existed, old file renamed to `%s'"%(out,out+"~%d"%i)
+       print "Encoding video from %s to %s"%(wildcard,out)
+       pipeline=gst.parse_launch('multifilesrc location="%s" index=0 
caps="image/png,framerate=\(fraction\)%d/1" ! pngdec ! ffmpegcolorspace ! 
theoraenc sharpness=2 quality=32 ! oggmux ! filesink 
location="%s"'%(wildcard,fps,out))
+       bus=pipeline.get_bus()
+       bus.add_signal_watch()
+       mainloop=gobject.MainLoop();
+       bus.connect("message::eos",lambda bus,msg: mainloop.quit())
+       pipeline.set_state(gst.STATE_PLAYING)
+       mainloop.run()
+       pipeline.set_state(gst.STATE_NULL); pipeline.get_state()
+

Modified: trunk/gui/qt3/GLSimulationPlayerViewer.cpp
===================================================================
--- trunk/gui/qt3/GLSimulationPlayerViewer.cpp  2008-09-26 09:42:13 UTC (rev 
1529)
+++ trunk/gui/qt3/GLSimulationPlayerViewer.cpp  2008-09-28 12:37:30 UTC (rev 
1530)
@@ -18,6 +18,7 @@
 #include<boost/iostreams/filter/bzip2.hpp>
 #include<boost/iostreams/device/file.hpp>
 #include<boost/algorithm/string.hpp>
+#include<boost/date_time/posix_time/posix_time.hpp>
 
 #include<yade/lib-opengl/OpenGLWrapper.hpp>
 #include<yade/pkg-common/FilterEngine.hpp>
@@ -257,11 +258,23 @@
                        if(col_rgb_b>=0) 
b->geometricalModel->diffuseColor[2]=reader.getdouble(col_rgb_b);
                }
                Omega::instance().setCurrentIteration(con->executeint("select 
iter from 'records' where bodyTable='"+tableName+"';"));
+               
Omega::instance().getRootBody()->simulationTime=con->executedouble("select 
virtTime from 'records' where bodyTable='"+tableName+"';");
+               realTime=con->executedouble("select realTime from 'records' 
where bodyTable='"+tableName+"';");
+               wallClock=con->executedouble("select wallClock from 'records' 
where bodyTable='"+tableName+"';");
        }
        FOREACH(const shared_ptr<FilterEngine>& e, filters) { 
if(e->isActivated()) e->action(Omega::instance().getRootBody().get()); }
        return true;
 }
 
+string GLSimulationPlayerViewer::getRealTimeString(){
+       ostringstream oss;
+       posix_time::time_duration rt(0,0,(long)realTime,0);
+       oss<<posix_time::to_simple_string(rt)<<"."<<(long)(realTime*10)%10;
+       posix_time::ptime when=posix_time::from_time_t(wallClock);
+       oss<<" ("<<posix_time::to_simple_string(when)<<")";
+       return oss.str();
+}
+
 void GLSimulationPlayerViewer::bodyWire(bool wire)
 {
 //     FOREACH(shared_ptr<Body> b, *Omega::instance().getRootBody()->bodies)

Modified: trunk/gui/qt3/GLSimulationPlayerViewer.hpp
===================================================================
--- trunk/gui/qt3/GLSimulationPlayerViewer.hpp  2008-09-26 09:42:13 UTC (rev 
1529)
+++ trunk/gui/qt3/GLSimulationPlayerViewer.hpp  2008-09-28 12:37:30 UTC (rev 
1530)
@@ -28,6 +28,9 @@
                void tryFillingOutputPattern(); 
                bool useSQLite;
                shared_ptr<sqlite3x::sqlite3_connection> con;
+               //!  read from db, used in getRealTimeString() called in 
GLViewer::postDraw
+               Real wallClock, realTime;
+               virtual string getRealTimeString();
        public:
                list<string> snapshots;
                QtSimulationPlayer* simPlayer;

Modified: trunk/gui/qt3/GLViewer.cpp
===================================================================
--- trunk/gui/qt3/GLViewer.cpp  2008-09-26 09:42:13 UTC (rev 1529)
+++ trunk/gui/qt3/GLViewer.cpp  2008-09-28 12:37:30 UTC (rev 1530)
@@ -27,6 +27,7 @@
        renderer=_renderer;
        drawGridXYZ[0]=drawGridXYZ[1]=drawGridXYZ[2]=false;
        drawScale=true;
+       timeDispMask=TIME_REAL|TIME_VIRT|TIME_ITER;
        viewId = id;
        cut_plane = 0;
        cut_plane_delta = -2;
@@ -48,7 +49,7 @@
 
        setKeyDescription(Qt::Key_C,"Set scene center to the selected body (if 
any)");
        setKeyDescription(Qt::Key_C & Qt::ALT,"Set scene center to median body 
position");
-       setKeyDescription(Qt::Key_D,"Toggle Body::isDynamic on selection");
+       setKeyDescription(Qt::Key_D,"Toggle time display mask");
        setKeyDescription(Qt::Key_G,"Toggle grid");
        setKeyDescription(Qt::Key_X,"Toggle YZ grid (or: align manipulated clip 
plane normal with +X)");
        setKeyDescription(Qt::Key_Y,"Toggle XZ grid (or: align manipulated clip 
plane normal with +Y)");
@@ -206,7 +207,8 @@
        /* letters alphabetically */
        else if(e->key()==Qt::Key_C && selectedName() >= 0 && 
(*(Omega::instance().getRootBody()->bodies)).exists(selectedName())) 
setSceneCenter(manipulatedFrame()->position());
        else if(e->key()==Qt::Key_C && (e->state() & AltButton)){ 
displayMessage("Median centering"); centerMedianQuartile(); }
-       else if(e->key()==Qt::Key_D) wasDynamic=true;
+       //else if(e->key()==Qt::Key_D) wasDynamic=true;
+       else if(e->key()==Qt::Key_D) {timeDispMask+=1; 
if(timeDispMask>(TIME_REAL|TIME_VIRT|TIME_ITER))timeDispMask=0; }
        else if(e->key()==Qt::Key_G) {bool 
anyDrawn=drawGridXYZ[0]||drawGridXYZ[1]||drawGridXYZ[2]; for(int i=0; i<3; 
i++)drawGridXYZ[i]=!anyDrawn; }
        else if (e->key()==Qt::Key_M && selectedName() >= 0){
                if(!(isMoving=!isMoving)){displayMessage("Moving done."); 
mouseMovesCamera();}
@@ -490,9 +492,52 @@
                glPopMatrix();
        }
 
+       #define _W3 setw(3)<<setfill('0')
+       #define _W2 setw(2)<<setfill('0')
+       if(timeDispMask!=0){
+               const int lineHt=12;
+               unsigned x=10,y=height()-20;
+               glColor3v(Vector3r(1,1,1));
+               if(timeDispMask & GLViewer::TIME_VIRT){
+                       ostringstream oss;
+                       Real t=Omega::instance().getSimulationTime();
+                       unsigned 
min=((unsigned)t/60),sec=(((unsigned)t)%60),msec=((unsigned)(1e3*t))%1000,usec=((unsigned
 long)(1e6*t))%1000,nsec=((unsigned long)(1e9*t))%1000;
+                       if(min>0) 
oss<<_W2<<min<<":"<<_W2<<sec<<"."<<_W3<<msec<<"m"<<_W3<<usec<<"u"<<_W3<<nsec<<"n";
+                       else if (sec>0) 
oss<<_W2<<sec<<"."<<_W3<<msec<<"m"<<_W3<<usec<<"u"<<_W3<<nsec<<"n";
+                       else if (msec>0) 
oss<<_W3<<msec<<"m"<<_W3<<usec<<"u"<<_W3<<nsec<<"n";
+                       else if (usec>0) oss<<_W3<<usec<<"u"<<_W3<<nsec<<"n";
+                       else oss<<_W3<<nsec<<"ns";
+                       QGLViewer::drawText(x,y,oss.str());
+                       y-=lineHt;
+               }
+               glColor3v(Vector3r(0,.5,.5));
+               if(timeDispMask & GLViewer::TIME_REAL){
+                       QGLViewer::drawText(x,y,getRealTimeString() /* virtual, 
since player gets that from db */);
+                       y-=lineHt;
+               }
+               if(timeDispMask & GLViewer::TIME_ITER){
+                       ostringstream oss;
+                       oss<<"#"<<Omega::instance().getCurrentIteration()<<"\n";
+                       QGLViewer::drawText(x,y,oss.str());
+                       y-=lineHt;
+               }
+       }
        QGLViewer::postDraw();
 }
 
+string GLViewer::getRealTimeString(){
+       ostringstream oss;
+       time_duration t=Omega::instance().getComputationDuration();
+       unsigned d=t.hours()/24,h=t.hours()%24,m=t.minutes(),s=t.seconds();
+       oss<<"wall ";
+       if(d>0) oss<<d<<"days "<<_W2<<h<<":"<<_W2<<m<<":"<<_W2<<s;
+       else if(h>0) oss<<_W2<<h<<":"<<_W2<<m<<":"<<_W2<<s;
+       else oss<<_W2<<m<<":"<<_W2<<s;
+       return oss.str();
+}
+#undef _W2
+#undef _W3
+
 void GLViewer::closeEvent(QCloseEvent *e){
        //emit closeSignal(viewId);
        YadeQtMainWindow::self->closeView(this);
@@ -549,8 +594,10 @@
        QDomElement de=document.createElement("gridXYZ");
        string val; if(drawGridXYZ[0])val+="x"; if(drawGridXYZ[1])val+="y"; 
if(drawGridXYZ[2])val+="z";
        de.setAttribute("normals",val);
+       QDomElement de2=document.createElement("timeDisplay"); 
de2.setAttribute("mask",timeDispMask);
        QDomElement res=QGLViewer::domElement(name,document);
        res.appendChild(de);
+       res.appendChild(de2);
        return res;
 }
 
@@ -559,13 +606,12 @@
        QGLViewer::initFromDOMElement(element);
        QDomElement child=element.firstChild().toElement();
        while (!child.isNull()){
-               if (child.tagName()=="gridXYZ"){
-                       if (child.hasAttribute("normals")){
-                               string val=child.attribute("normals").lower();
-                               drawGridXYZ[0]=false; drawGridXYZ[1]=false; 
drawGridXYZ[2]=false;
-                               
if(val.find("x")!=string::npos)drawGridXYZ[0]=true; 
if(val.find("y")!=string::npos)drawGridXYZ[1]=true; 
if(val.find("z")!=string::npos)drawGridXYZ[2]=true;
-                       }
+               if (child.tagName()=="gridXYZ" && 
child.hasAttribute("normals")){
+                       string val=child.attribute("normals").lower();
+                       drawGridXYZ[0]=false; drawGridXYZ[1]=false; 
drawGridXYZ[2]=false;
+                       if(val.find("x")!=string::npos)drawGridXYZ[0]=true; 
if(val.find("y")!=string::npos)drawGridXYZ[1]=true; 
if(val.find("z")!=string::npos)drawGridXYZ[2]=true;
                }
+               if(child.tagName()=="timeDisplay" && 
child.hasAttribute("mask")) timeDispMask=atoi(child.attribute("mask").ascii());
                child = child.nextSibling().toElement();
        }
 }

Modified: trunk/gui/qt3/GLViewer.hpp
===================================================================
--- trunk/gui/qt3/GLViewer.hpp  2008-09-26 09:42:13 UTC (rev 1529)
+++ trunk/gui/qt3/GLViewer.hpp  2008-09-28 12:37:30 UTC (rev 1530)
@@ -55,6 +55,8 @@
                void centerMedianQuartile();
                bool                    drawGridXYZ[3];
                bool                    drawScale;
+               int timeDispMask;
+               enum{TIME_REAL=1,TIME_VIRT=2,TIME_ITER=4};
 
                GLViewer (int id, shared_ptr<OpenGLRenderingEngine> _renderer, 
QWidget * parent=0, QGLWidget * shareWidget=0);
                virtual ~GLViewer (){};
@@ -91,6 +93,8 @@
        protected :
                virtual void keyPressEvent(QKeyEvent *e);
                virtual void postDraw();
+               // overridden in the player that doesn't get time from system 
clock but from the db
+               virtual string getRealTimeString();
                virtual void closeEvent(QCloseEvent *e);
                virtual void postSelection(const QPoint& point);
                virtual void endSelection(const QPoint &point);

Modified: trunk/gui/qt3/QtGUI-python.cpp
===================================================================
--- trunk/gui/qt3/QtGUI-python.cpp      2008-09-26 09:42:13 UTC (rev 1529)
+++ trunk/gui/qt3/QtGUI-python.cpp      2008-09-28 12:37:30 UTC (rev 1530)
@@ -138,6 +138,8 @@
                string pyStr(){return string("<GLViewer for view 
#")+lexical_cast<string>(ensuredMainWindow()->viewNo(glv))+">";}
                void saveDisplayParameters(size_t 
n){glv->saveDisplayParameters(n);}
                void useDisplayParameters(size_t 
n){glv->useDisplayParameters(n);}
+               string get_timeDisp(){const int& m(glv->timeDispMask); string 
ret; if(m&GLViewer::TIME_REAL) ret+='r'; if(m&GLViewer::TIME_VIRT) ret+="v"; 
if(m&GLViewer::TIME_ITER) ret+="i"; return ret;}
+               void set_timeDisp(string s){int& m(glv->timeDispMask); m=0; 
FOREACH(char c, s){switch(c){case 'r': m|=GLViewer::TIME_REAL; break; case 'v': 
m|=GLViewer::TIME_VIRT; break; case 'i': m|=GLViewer::TIME_ITER; break; 
default: throw invalid_argument(string("Invalid flag for timeDisp: 
`")+c+"'");}}}
 };
 BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(pyGLViewer_center_overloads,center,0,1);
 
@@ -178,6 +180,7 @@
                
.add_property("sceneRadius",&pyGLViewer::get_sceneRadius,&pyGLViewer::set_sceneRadius)
                
.add_property("ortho",&pyGLViewer::get_orthographic,&pyGLViewer::set_orthographic)
                
.add_property("screenSize",&pyGLViewer::get_screenSize,&pyGLViewer::set_screenSize)
+               
.add_property("timeDisp",&pyGLViewer::get_timeDisp,&pyGLViewer::set_timeDisp)
                .def("fitAABB",&pyGLViewer::fitAABB)
                .def("fitSphere",&pyGLViewer::fitSphere)
                .def("showEntireScene",&pyGLViewer::showEntireScene)

Modified: trunk/gui/qt3/YadeQtMainWindow.hpp
===================================================================
--- trunk/gui/qt3/YadeQtMainWindow.hpp  2008-09-26 09:42:13 UTC (rev 1529)
+++ trunk/gui/qt3/YadeQtMainWindow.hpp  2008-09-28 12:37:30 UTC (rev 1530)
@@ -12,10 +12,10 @@
 #include<qpushbutton.h>
 #include<yade/lib-base/Logging.hpp>
 #include"YadeQtGeneratedMainWindow.h"
-#include"SimulationController.hpp"
-#include"QtFileGenerator.hpp"
-#include"QtSimulationPlayer.hpp"
-#include"QtGUIPreferences.hpp"
+#include<yade/gui-qt3/SimulationController.hpp>
+#include<yade/gui-qt3/QtFileGenerator.hpp>
+#include<yade/gui-qt3/QtSimulationPlayer.hpp>
+#include<yade/gui-qt3/QtGUIPreferences.hpp>
 
 class YadeQtMainWindow : public YadeQtGeneratedMainWindow
 {

Modified: trunk/gui/qt3/qt.py
===================================================================
--- trunk/gui/qt3/qt.py 2008-09-26 09:42:13 UTC (rev 1529)
+++ trunk/gui/qt3/qt.py 2008-09-28 12:37:30 UTC (rev 1530)
@@ -1,8 +1,42 @@
+# import module parts in c++ 
 from _qt import *
+
 if not isActive():
        raise ImportError("The Qt gui is not being used (run with -N QtGUI).")
 
-def 
createVideo(playerDb,out,viewerState=None,dispParamsNo=-1,stride=1,fps=24,postLoadHook=None):
+
+
+def 
makeSimulationVideo(output,realPeriod=1,virtPeriod=0,iterPeriod=0,viewNo=0,fps=24):
+       """Create video by running simulation. SnapshotEngine is added (and 
removed once done), temporary
+       files are deleted. The video is theora-encoded in the ogg container. 
Periodicity is controlled
+       in the same way as for PeriodicEngine (SnapshotEngine is a 
PeriodicEngine and realPeriod, virtPeriod 
+       and iterPeriod are passed to the new SnapshotEngine).
+
+       viewNo is 0-based GL view number. 0 is the primary view and will be 
created if it doesn't exist.
+       It is an error if viewNo>0 and the view doesn't exist.
+
+       The simulation will run until it stops by itself. Either set 
Omega().stopAtIteration or have an engine
+       that will call Omega().pause() at some point.
+
+       See makePlayerVideo for more documentation.
+       """
+       import os
+       from yade import utils,wrapper
+       o=wrapper.Omega()
+       # create primary view if none
+       if len(views())==0: View()
+       # remove existing SnaphotEngines
+       
se=wrapper.StandAloneEngine('SnapshotEngine',{'iterPeriod':iterPeriod,'realPeriod':realPeriod,'virtPeriod':virtPeriod,'fileBase':os.tmpnam(),'ignoreErrors':False,'viewNo':viewNo})
+       origEngines=o.engines; o.engines=[e for e in o.engines if 
e.name!='SnapshotEngine']+[se]
+       o.run(); o.wait();
+       wildcard=se['fileBase']+'%04d.png'
+       print "Number of frames:",len(se['savedSnapshots'])
+       
utils.encodeVideoFromFrames(wildcard,output,renameNotOverwrite=True,fps=fps)
+       for f in se['savedSnapshots']: os.remove(f)
+       o.engines=origEngines
+
+
+def 
makePlayerVideo(playerDb,out,viewerState=None,dispParamsNo=-1,stride=1,fps=24,postLoadHook=None):
        """Create video by replaying a simulation. Snapshots are taken to 
temporary files,
        encoded to a .ogg stream (theora codec); temps are deleted at the end.
 
@@ -16,10 +50,8 @@
 
        Necessary packages: python-gst0.10 gstreamer0.10-plugins-good 
python-gobject
        """
-       import pygst,sys,gobject,os
-       pygst.require("0.10")
-       import gst
-       from yade import qt
+       import sys,os
+       from yade import qt,utils
        # postLoadHook and viewerState have "" instead of None in the c++ 
interface
        wildcard,snaps=qt.runPlayerSession(
                playerDb,
@@ -28,19 +60,7 @@
                dispParamsNo=dispParamsNo,
                stride=stride,
                postLoadHook=(postLoadHook if postLoadHook else ''))
-       if(os.path.exists(out)):
-               i=0;
-               while(os.path.exists(out+"~%d"%i)): i+=1
-               os.rename(out,out+"~%d"%i); print "Output file `%s' already 
existed, old file renamed to `%s'"%(out,out+"~%d"%i)
-       print "Encoding video from %s (%d files total) to 
%s"%(wildcard,len(snaps),out)
-       pipeline=gst.parse_launch('multifilesrc location="%s" index=0 
caps="image/png,framerate=\(fraction\)%d/1" ! pngdec ! ffmpegcolorspace ! 
theoraenc sharpness=2 quality=32 ! oggmux ! filesink 
location="%s"'%(wildcard,fps,out))
-       bus=pipeline.get_bus()
-       bus.add_signal_watch()
-       mainloop=gobject.MainLoop();
-       bus.connect("message::eos",lambda bus,msg: mainloop.quit())
-       pipeline.set_state(gst.STATE_PLAYING)
-       mainloop.run()
-       pipeline.set_state(gst.STATE_NULL); pipeline.get_state()
+       
utils.encodeVideoFromFrames(wildcard,out,renameNotOverwrite=True,fps=fps)
        print "Cleaning snapshot files."
        for f in snaps: os.remove(f)
 

Modified: trunk/scripts/simple-scene-player.py
===================================================================
--- trunk/scripts/simple-scene-player.py        2008-09-26 09:42:13 UTC (rev 
1529)
+++ trunk/scripts/simple-scene-player.py        2008-09-28 12:37:30 UTC (rev 
1530)
@@ -21,18 +21,9 @@
        
MetaEngine('InteractionPhysicsMetaEngine',[EngineUnit('SimpleElasticRelationships')]),
        StandAloneEngine('ElasticContactLaw'),
        DeusExMachina('GravityEngine',{'gravity':[0,0,-9.81]}),
-       MetaEngine('PhysicalActionDamper',[
-               EngineUnit('CundallNonViscousForceDamping',{'damping':0.2}),
-               EngineUnit('CundallNonViscousMomentumDamping',{'damping':0.2})
-       ]),
-       MetaEngine('PhysicalActionApplier',[
-               EngineUnit('NewtonsForceLaw'),
-               EngineUnit('NewtonsMomentumLaw'),
-       ]),
-       
MetaEngine('PhysicalParametersMetaEngine',[EngineUnit('LeapFrogPositionIntegrator')]),
-       
MetaEngine('PhysicalParametersMetaEngine',[EngineUnit('LeapFrogOrientationIntegrator')]),
+       DeusExMachina('NewtonsDampedLaw',{'damping':0.2})
        ###
-       ### NOTE these extra engines.
+       ### NOTE this extra engine.
        ###
        
StandAloneEngine('SQLiteRecorder',{'recorders':['se3','rgb'],'dbFile':'/tmp/player.sqlite','iterPeriod':50})
 ]
@@ -47,8 +38,8 @@
 def setWire():
        o=Omega()
        for b in o.bodies: b.shape['wire']=True
-# you must have saved the viewer state by using Alt-S in the view...
+# you could have saved the viewer state by using Alt-S in the view...
 from yade import qt
-qt.createVideo('/tmp/player.sqlite','/tmp/player.ogg','/tmp/qglviewerState.xml',stride=10,fps=12,postLoadHook='setWire()')
+qt.makePlayerVideo('/tmp/player.sqlite','/tmp/player.ogg','/tmp/qglviewerState.xml',stride=10,fps=12,postLoadHook='setWire()')
 
 quit()

Added: trunk/scripts/simple-scene-video.py
===================================================================
--- trunk/scripts/simple-scene-video.py 2008-09-26 09:42:13 UTC (rev 1529)
+++ trunk/scripts/simple-scene-video.py 2008-09-28 12:37:30 UTC (rev 1530)
@@ -0,0 +1,39 @@
+#!/usr/local/bin/yade-trunk -x
+# -*- encoding=utf-8 -*-
+
+o=Omega()
+o.initializers=[
+       StandAloneEngine('PhysicalActionContainerInitializer'),
+       
MetaEngine('BoundingVolumeMetaEngine',[EngineUnit('InteractingSphere2AABB'),EngineUnit('InteractingBox2AABB'),EngineUnit('MetaInteractingGeometry2AABB')])
+       ]
+o.engines=[
+       StandAloneEngine('PhysicalActionContainerReseter'),
+       MetaEngine('BoundingVolumeMetaEngine',[
+               EngineUnit('InteractingSphere2AABB'),
+               EngineUnit('InteractingBox2AABB'),
+               EngineUnit('MetaInteractingGeometry2AABB')
+       ]),
+       StandAloneEngine('PersistentSAPCollider'),
+       MetaEngine('InteractionGeometryMetaEngine',[
+               
EngineUnit('InteractingSphere2InteractingSphere4SpheresContactGeometry'),
+               
EngineUnit('InteractingBox2InteractingSphere4SpheresContactGeometry')
+       ]),
+       
MetaEngine('InteractionPhysicsMetaEngine',[EngineUnit('SimpleElasticRelationships')]),
+       StandAloneEngine('ElasticContactLaw'),
+       DeusExMachina('GravityEngine',{'gravity':[0,0,-9.81]}),
+       DeusExMachina('NewtonsDampedLaw',{'damping':0.2})
+]
+from yade import utils
+o.bodies.append(utils.box(center=[0,0,0],extents=[.5,.5,.5],dynamic=False,color=[1,0,0],young=30e9,poisson=.3,density=2400))
+o.bodies.append(utils.sphere([0,0,2],1,color=[0,1,0],young=30e9,poisson=.3,density=2400))
+o.dt=.4*utils.PWaveTimeStep()
+
+
+from yade import qt
+o.stopAtIter=15000
+qt.makeSimulationVideo('/tmp/aa.ogg',iterPeriod=100,fps=12)
+
+
+
+
+


Property changes on: trunk/scripts/simple-scene-video.py
___________________________________________________________________
Name: svn:executable
   + *


_______________________________________________
Mailing list: https://launchpad.net/~yade-dev
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~yade-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to