Commits

Anonymous committed 700d458

VideoCanvas now videofile-independant. VideoTexture's must be created and attached

  • Participants
  • Parent commits 843f5f8

Comments (0)

Files changed (3)

File OgreVideoCanvas/include/OgreVideoCanvas.h

     void setVideoTexture(OgreVideoTexture*);
     void unsetVideoTexture();
 
-protected:
-    void _initVideoTexture(){};
 
 protected:
     SceneManager *mSceneMgr;
+    String mName;
     String mVideoFileName, mVideoBaseName;
     SceneNode *mCanvasNode;
     ManualObject *mCanvas;

File OgreVideoCanvas/src/OgreVideoCanvas.cpp

 #include "OgreVideoCanvas.h"
 
 //------------------------------------------------------------------------------
-OgreVideoCanvas::OgreVideoCanvas(const String &_filename, SceneManager *_sceneMgr)
+OgreVideoCanvas::OgreVideoCanvas(const String &_name, SceneManager *_sceneMgr)
     :mSceneMgr(_sceneMgr)
-    ,mVideoFileName(_filename)
+    ,mName(_name)
     ,mCanvas(NULL)
     ,mVideoTexture(NULL)
     ,mCanvasNode(NULL)
     ,mHeight(480)
     ,mTextureSize(1024)
 {
-    Ogre::String out;
-    Ogre::StringUtil::splitFilename(mVideoFileName, mVideoBaseName, out);
+
 }
 //------------------------------------------------------------------------------
 OgreVideoCanvas::~OgreVideoCanvas(void)
     float uMax = float(mWidth)  / mTextureSize;
     float vMax = float(mHeight) / mTextureSize;
 
-    mCanvas = mSceneMgr->createManualObject("Video Canvas " + mVideoBaseName);
+    // build a quad
+    mCanvas = mSceneMgr->createManualObject("Video Canvas " + mName);
     mCanvas->begin("BaseWhiteNoLighting", RenderOperation::OT_TRIANGLE_STRIP);
 
     mCanvas->position(-mWidth/2,  mHeight/2, 0);   mCanvas->textureCoord(uMin, vMax);     mCanvas->normal(Ogre::Vector3::NEGATIVE_UNIT_Z);
 
     mCanvas->end();
 
-    mCanvasNode = _parentNode->createChildSceneNode("Canvas Node " + mVideoBaseName);
+    // put it on a node
+    mCanvasNode = _parentNode->createChildSceneNode("Canvas Node " + mName);
     mCanvasNode ->attachObject(mCanvas);
     mCanvasNode->yaw(Degree(180.0));
     mCanvasNode->roll(Degree(180.0));
 
-     mCanvas->setMaterialName(0, "VideoCanvas/NoVideo");
+    // set default material (grey)
+    mCanvas->setMaterialName(0, "VideoCanvas/NoVideo");
 }
 //------------------------------------------------------------------------------
 void OgreVideoCanvas::nextFrame()
     mVideoTexture = NULL;
     mCanvas->setMaterialName(0, "VideoCanvas/NoVideo");
 }
-//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------

File ogre-testscene/ogre-testscene.cpp

 
 
         mCanvasNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("Canvas Node", Vector3(0, 100, 0));       
-        mVideoCanvas = new OgreVideoCanvas("../media/videos/liege.avi", mSceneMgr);
+        mVideoCanvas = new OgreVideoCanvas("liege", mSceneMgr);
         mVideoCanvas->buildCanvas(mCanvasNode);
         mVideoTexture = new OgreVideoTexture("../media/videos/liege.avi");
         mVideoCanvas->setVideoTexture(mVideoTexture);
 
         mCanvasNode2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Canvas Node2", Vector3(700, 100, 0));       
-        mVideoCanvas2 = new OgreVideoCanvas("../media/videos/indochine.avi", mSceneMgr);
+        mVideoCanvas2 = new OgreVideoCanvas("indochine", mSceneMgr);
         mVideoCanvas2->buildCanvas(mCanvasNode2);
         mVideoTexture2 = new OgreVideoTexture("../media/videos/indochine.avi");
         mVideoCanvas2->setVideoTexture(mVideoTexture2);