Panda3D
|
00001 // Filename: movieTexture.I 00002 // Created by: jyelon (01Aug2007) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: MovieTexture::get_video_length 00018 // Access: Published 00019 // Description: Returns the length of the video. 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE double MovieTexture:: 00022 get_video_length() const { 00023 CDReader cdata(_cycler); 00024 return cdata->_video_length; 00025 } 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: MovieTexture::get_video_width 00029 // Access: Published 00030 // Description: Returns the width in texels of the source video 00031 // stream. This is not necessarily the width of the 00032 // actual texture, since the texture may have been 00033 // expanded to raise it to a power of 2. 00034 //////////////////////////////////////////////////////////////////// 00035 INLINE int MovieTexture:: 00036 get_video_width() const { 00037 CDReader cdata(_cycler); 00038 return cdata->_video_width; 00039 } 00040 00041 //////////////////////////////////////////////////////////////////// 00042 // Function: MovieTexture::get_video_height 00043 // Access: Published 00044 // Description: Returns the height in texels of the source video 00045 // stream. This is not necessarily the height of the 00046 // actual texture, since the texture may have been 00047 // expanded to raise it to a power of 2. 00048 //////////////////////////////////////////////////////////////////// 00049 INLINE int MovieTexture:: 00050 get_video_height() const { 00051 CDReader cdata(_cycler); 00052 return cdata->_video_height; 00053 } 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: MovieTexture::get_tex_scale 00057 // Access: Published 00058 // Description: Returns a scale pair that is suitable for applying to 00059 // geometry via NodePath::set_tex_scale(), which will 00060 // convert texture coordinates on the geometry from the 00061 // range 0..1 into the appropriate range to render the 00062 // video part of the texture. 00063 // 00064 // This is necessary in the event the video source is 00065 // not a power of two and set_power_2() is true. In 00066 // this case, the video image will be mapped to the 00067 // lower-left corner of the texture, and the rest of the 00068 // texture space will be unused; so we will need to 00069 // remap any texture coordinates to fill the space 00070 // correctly. 00071 //////////////////////////////////////////////////////////////////// 00072 INLINE LVecBase2f MovieTexture:: 00073 get_tex_scale() const { 00074 CDReader cdata(_cycler); 00075 if (cdata->_video_width == 0 || 00076 cdata->_video_height == 0 || 00077 _x_size == 0 || 00078 _y_size == 0) { 00079 return LVecBase2f(1.0f, 1.0f); 00080 } 00081 return LVecBase2f((float)cdata->_video_width / _x_size, 00082 (float)cdata->_video_height / _y_size); 00083 } 00084