Browse Source

Added set_frame_fullscreen_quad and set_uv_range(MovieTexture)

Josh Yelon 18 years ago
parent
commit
06d661b62b

+ 13 - 0
panda/src/grutil/cardMaker.I

@@ -97,6 +97,19 @@ set_frame(const Vertexf &ll, const Vertexf &lr, const Vertexf &ur, const Vertexf
   _ul_pos = ul;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: CardMaker::set_frame_fullscreen_quad
+//       Access: Public
+//  Description: Sets the card to (-1,1,-1,1), which is appropriate
+//               if you plan to parent it to render2d and use it
+//               as a fullscreen quad.
+////////////////////////////////////////////////////////////////////
+INLINE void CardMaker::
+set_frame_fullscreen_quad()
+{
+  set_frame(-1,1,-1,1);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: CardMaker::set_color
 //       Access: Public

+ 13 - 0
panda/src/grutil/cardMaker.cxx

@@ -256,6 +256,19 @@ set_uv_range_cube(int face) {
   }
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: CardMaker::set_uv_range
+//       Access: Public
+//  Description: Sets the range of UV's that will be applied to the
+//               vertices appropriately to play a specified Movie.
+////////////////////////////////////////////////////////////////////
+void CardMaker::
+set_uv_range(const MovieTexture *movie) {
+  double maxu = (movie->get_video_width()*1.0) / movie->get_x_size();
+  double maxv = (movie->get_video_height()*1.0) / movie->get_y_size();
+  set_uv_range(TexCoordf(0.0,0.0), TexCoordf(maxu,maxv));
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: CardMaker::rescale_source_geometry
 //       Access: Private

+ 3 - 0
panda/src/grutil/cardMaker.h

@@ -25,6 +25,7 @@
 #include "pandaNode.h"
 #include "pointerTo.h"
 #include "namable.h"
+#include "movieTexture.h"
 
 ////////////////////////////////////////////////////////////////////
 //       Class : CardMaker
@@ -43,6 +44,7 @@ PUBLISHED:
   void set_uv_range(const TexCoord3f &ll, const TexCoord3f &lr, const TexCoord3f &ur, const TexCoord3f &ul);
   void set_uv_range(const LVector4f &x, const LVector4f &y, const LVector4f &z);
   void set_uv_range_cube(int face);
+  void set_uv_range(const MovieTexture *frame);
 
   INLINE void set_has_uvs(bool flag);
   INLINE void set_has_3d_uvs(bool flag);
@@ -50,6 +52,7 @@ PUBLISHED:
   INLINE void set_frame(float left, float right, float bottom, float top);
   INLINE void set_frame(const LVecBase4f &frame);
   INLINE void set_frame(const Vertexf &ll, const Vertexf &lr, const Vertexf &ur, const Vertexf &ul);
+  INLINE void set_frame_fullscreen_quad();
 
   INLINE void set_color(float r, float g, float b, float a);
   INLINE void set_color(const Colorf &color);

+ 32 - 31
panda/src/grutil/config_grutil.cxx

@@ -51,7 +51,6 @@ ConfigVariableDouble frame_rate_meter_scale
 ConfigVariableDouble frame_rate_meter_side_margins
 ("frame-rate-meter-side-margins", 0.5);
 
-
 ////////////////////////////////////////////////////////////////////
 //     Function: init_libgrutil
 //  Description: Initializes the library.  This must be called at
@@ -62,6 +61,14 @@ ConfigVariableDouble frame_rate_meter_side_margins
 ////////////////////////////////////////////////////////////////////
 void
 init_libgrutil() {
+  ConfigVariableBool use_movietexture
+    ("use-movietexture", false,
+     PRC_DESC("Panda contains a new animated texture class, MovieTexture. "
+              "Because it is not yet fully tested, the texture loader "
+              "will not use it unless this variable is set.  Eventually, "
+              "this config variable will go away and the new code will "
+              "be enabled all the time."));
+
   static bool initialized = false;
   if (initialized) {
     return;
@@ -75,40 +82,34 @@ init_libgrutil() {
 
   MovieTexture::init_type();
   MovieTexture::register_with_read_factory();
-  TexturePool *ts = TexturePool::get_global_ptr();
-  ts->register_texture_type(MovieTexture::make_texture, "inkblot dummyvideo");
+#ifdef HAVE_OPENCV
+  OpenCVTexture::init_type();
+  OpenCVTexture::register_with_read_factory();
+#endif
+#ifdef HAVE_FFMPEG
+  av_register_all();
+  FFMpegTexture::init_type();
+  FFMpegTexture::register_with_read_factory();
+#endif
 
 #ifdef HAVE_OPENCV
-  
-  {
-    OpenCVTexture::init_type();
-    OpenCVTexture::register_with_read_factory();
-    
-    PandaSystem *ps = PandaSystem::get_global_ptr();
-    ps->add_system("OpenCV");
-
-#ifndef HAVE_FFMPEG
-    // We use OpenCV to render AVI files only if ffmpeg is not
-    // available.
-    TexturePool *ts = TexturePool::get_global_ptr();
-    ts->register_texture_type(OpenCVTexture::make_texture, "avi");
+  PandaSystem *ps = PandaSystem::get_global_ptr();
+  ps->add_system("OpenCV");
 #endif
-  }
-#endif // HAVE_OPENCV
 
-#ifdef HAVE_FFMPEG
-  {
-    //configure all known codecs. Can take a few frames. 
-    av_register_all();
-    
-    FFMpegTexture::init_type();
-    FFMpegTexture::register_with_read_factory();
-    
-    PandaSystem *ps = PandaSystem::get_global_ptr();
-    ps->add_system("FFMpeg");
-    TexturePool *ts = TexturePool::get_global_ptr();
-    ts->register_texture_type(FFMpegTexture::make_texture, "avi mov mpg");
+  TexturePool *ts = TexturePool::get_global_ptr();
+  if (use_movietexture) {
+#if defined(HAVE_FFMPEG)
+    ts->register_texture_type(MovieTexture::make_texture, "avi mov mpg wmv asf flv nut ogm");
+#elif defined(HAVE_OPENCV)
+    ts->register_texture_type(OpenCVTexture::make_texture, "avi");
+#endif
+  } else {
+#if defined(HAVE_FFMPEG)
+    ts->register_texture_type(FFMpegTexture::make_texture, "avi mov mpg wmv asf flv nut ogm");
+#elif defined(HAVE_OPENCV)
+    ts->register_texture_type(OpenCVTexture::make_texture, "avi");
+#endif
   }
-#endif // HAVE_FFMPEG
 }
 

+ 1 - 0
panda/src/grutil/config_grutil.h

@@ -24,6 +24,7 @@
 #include "configVariableDouble.h"
 #include "configVariableString.h"
 #include "configVariableInt.h"
+#include "configVariableBool.h"
 
 NotifyCategoryDecl(grutil, EXPCL_PANDA_GRUTIL, EXPTP_PANDA_GRUTIL);