POV-Ray : Newsgroups : povray.advanced-users : movie within Server Time
25 Nov 2024 01:26:57 EST (-0500)
  movie within (Message 1 to 10 of 100)  
Goto Latest 10 Messages Next 10 Messages >>>
From: dbwr
Subject: movie within
Date: 24 Jan 2004 23:18:12
Message: <40134384@news.povray.org>
Been reading posts for months, and haven't seen this
come up yet, but I'm sure someone has done this already.
I want to input a series of  image_mapped  jpg/gif/etc within
a scene - say 30 frames - to play on render plasma screen
(similar to DESK.pov sample) as camera pans past.  I don't
have the luxury of time like I used to, to figure these out.  POV
user for at least 6 years though. (not a newbie)  Thanks for input.


Post a reply to this message

From: Dan P
Subject: Re: movie within
Date: 24 Jan 2004 23:24:31
Message: <401344ff$1@news.povray.org>
"dbwr" <dbw### [at] netzeronet> wrote in message news:40134384@news.povray.org...
> Been reading posts for months, and haven't seen this
> come up yet, but I'm sure someone has done this already.
> I want to input a series of  image_mapped  jpg/gif/etc within
> a scene - say 30 frames - to play on render plasma screen
> (similar to DESK.pov sample) as camera pans past.  I don't
> have the luxury of time like I used to, to figure these out.  POV
> user for at least 6 years though. (not a newbie)  Thanks for input.

When you specify your image_map file name, use concat(str1, str2) to build
it from the frame_number value. In your case, you could do something like
this:

    ....
    image_map
    {
        png concat("file_", str(frame_number, -3), ".png")
    }
    ....

Note: str(frame_number, -3) pads zeros, which most software does it saves
frames. Change it to the number of zeros it pads.

Note: concat takes any number of string arguments, all of which get pieced
together.


Post a reply to this message

From: Marvin Taylor
Subject: Re: movie within
Date: 27 Jan 2004 18:09:19
Message: <4016ef9f$1@news.povray.org>
Dan P wrote:

> When you specify your image_map file name, use concat(str1, str2) to build
> it from the frame_number value. In your case, you could do something like
> this:
> 
>     ....
>     image_map
>     {
>         png concat("file_", str(frame_number, -3), ".png")
>     }
>     ....
> 

This requires your frame rate to exactly match that of the movie you are 
including.  A more consistent approach would be to interpolate based on 
'clock' rather than 'frame_number'.

(I frequently alter my frame rate when debugging).  The following seems 
to work as I expected it to do.  It returns the filename to be used in 
the image_map.

Cheers,
Marvin

////////////////////////////////////////////////////////////////////
//
// Return filename for an embedded movie.  Parameters are:
//   iclk = clock value for the first frame,
//   zclk = clock value for the first frame,
//   ifrm = the number of the first frame,
//   zfrm = the number of the last frame,
//   digs = the number of digits to pad (NEGATIVE),
//   base = Portion of filename to put before digits,
//   suff = Portion of filename to put after digits.
//
// NOTE: This should not be used when 'clock' is outside of the
// range of 'iclk' to 'zclk'.
//
// For example, from clock 0.0 to 1.0 the following will interpolate
// and return a string in the sequence "file000.png" to "file040.png"
//
//    EmbeddedMovie(0.0, 1.0, 0, 40, -3, "file", ".png" )
//
//
#macro EmbeddedMovie(iclk, zclk, ifrm, zfrm, digs, base, suff )
	#local nfrm = ifrm+(zfrm-ifrm)*(clock-iclk)/(zclk-iclk);
	concat(base, str(nfrm, digs, 0), suff)
#end


Post a reply to this message

From: Dan P
Subject: Re: movie within
Date: 27 Jan 2004 18:37:05
Message: <4016f621$1@news.povray.org>
"Marvin Taylor" <pov### [at] maltasoftcom> wrote in message
news:4016ef9f$1@news.povray.org...
> Dan P wrote:
<clip>
> This requires your frame rate to exactly match that of the movie you are
> including.  A more consistent approach would be to interpolate based on
> 'clock' rather than 'frame_number'.

A thing to consider when merging two movies with different frame rates is
whether the playback will be noticably inconsistent if the frame rate of the
embedded movie and the framerate of the containing movie are different. You
may have to "average" frames together in order to get a smoother
presentation. If the framerates don't share a common divisor, you'll find it
more challenging to average them together, but it's possible (that's how
they manage to show 24fps movies on 60fps television screen).

Averaging frames together also happens to be the way to do motion blur. The
following C program is a program I built to do just that with PPM files
(that povray can output):

The usage is simple:
blur x y x2 y2 file1.ppm, file2.ppm, file3.ppm, ...
x y x2 y2 grabs that rectangle out of the PPM file so that you can cut out
parts of an image.
It will average as many frames together as you provide on the command line.
I use pnmtopng to process the PPM's later to import into Flash.
Viva la Open Source, baby!


#include <stdio.h>
#include <stdlib.h>


unsigned *buffer = NULL;
char *page = NULL;
unsigned units = 0;
int frames = 0;
int width;
int height;
unsigned x;
unsigned y;
unsigned x2;
unsigned y2;
unsigned w;
unsigned h;



void load (char *path);
void readToken (FILE *stream, char *buf);
void blur();



int main (int argc, char **argv)
{
 int i = 1;

 x = atoi(argv[i++]);
 y = atoi(argv[i++]);
 x2 = atoi(argv[i++]);
 y2 = atoi(argv[i++]);

 w = x2 - x;
 h = y2 - y;

 while (argv[i] != NULL)
 {
  load(argv[i]);
  ++i;
  ++frames;
 }

 blur();

 free((void *) buffer);
 free((void *) page);

 return 0;
}



void blur()
{
 unsigned i;
 unsigned xn;
 unsigned yn;
 unsigned r;
 unsigned g;
 unsigned b;

 fprintf (stderr, "Blurring %u frames together.\n", frames);

 printf ("P6\n%d %d\n255\n", w, h);
 fprintf (stderr, "Building a %d by %d file.\n", w, h);

 for (yn = y ; yn < y2 ; yn++)
 {
  for (xn = x ; xn < x2 ; xn++)
  {
   i = (yn * (width * 3)) + (xn * 3);

   putchar (buffer[i++] / frames);
   putchar (buffer[i++] / frames);
   putchar (buffer[i] / frames);
  }
 }

 fflush(0);
}



void load (char *path)
{
 FILE *stream;
 char s_version[1024];
 char s_width[1024];
 char s_height[1024];
 char s_depth[1024];
 unsigned size;
 unsigned i;
 int c;


 if ((stream = fopen(path, "rb")) != NULL)
 {
  readToken(stream, s_version);
  readToken(stream, s_width);
  readToken(stream, s_height);
  readToken(stream, s_depth);

  width = atoi(s_width);
  height = atoi(s_height);

  if (buffer == NULL)
  {
   units = width * height * 3;
   buffer = (unsigned *) malloc(units * sizeof(int));
   page = (char *) malloc(units);

   fprintf (stderr,
     "Memory: %u for a %d x %d file.\n",
     units, width, height);

   for (i = 0 ; i < units ; i++)
   {
    buffer[i] = 0;
    page[i] = 0;
   }
  }

  i = 0;

  while ((c = fgetc(stream)) != EOF)
  {
   buffer[i++] += c;
  }

  fclose(stream);
 }
 else
 {
  fprintf (stderr, "  FAILED to read %s\n", path);
 }
}



void readToken (FILE *stream, char *buf)
{
 int c;
 c = fgetc(stream);

 while (c != EOF)
 {
  *(buf++) = c;

  c = fgetc(stream);

  if (isspace(c))
  {
   *buf = '\0';
   return;
  }
 }
}


Post a reply to this message

From: Warp
Subject: Re: movie within
Date: 27 Jan 2004 19:09:56
Message: <4016fdd4@news.povray.org>
Posting such code is like a red flag in front of a bull for a long-time
coder like me...
  It takes almost inhuman amounts of self-control to resist the temptation
of giving a lecture about good programming habits... :)

  Anyways, I have done a program with the same idea and with even more
features years ago:
  http://iki.fi/warp/PovUtils/average/

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Dan P
Subject: Re: movie within
Date: 27 Jan 2004 19:43:07
Message: <4017059b$1@news.povray.org>
"Warp" <war### [at] tagpovrayorg> wrote in message
news:4016fdd4@news.povray.org...
>   Posting such code is like a red flag in front of a bull for a long-time
> coder like me...
>   It takes almost inhuman amounts of self-control to resist the temptation
> of giving a lecture about good programming habits... :)
>
>   Anyways, I have done a program with the same idea and with even more
> features years ago:
>   http://iki.fi/warp/PovUtils/average/

Hey, you're the guy! You're the guy that taught me how to do it! I didn't
look at your code, yet I read your web-page a while back and was inspired by
it. I didn't realize that was you!!! I can't believe you're on this group -- 
I feel like I've bumped into a celebrity! You've had an impact on my life.
Thanks for putting together that web-page!


Post a reply to this message

From: Dan P
Subject: Re: movie within
Date: 27 Jan 2004 20:12:28
Message: <40170c7c$1@news.povray.org>
Okay, now you've got me all excited. A while back, I started to work on a
Motion Blur program that would import many different kinds of graphics to do
what your Averager did, only with a dialog-based interface. I even went and
bought Visual C++ .Net 2003 so I could use the CImage class. But, life got
in the way and I let it slide off my plate.

Lately, I've become enamored with Open Source as a concept and am wondering:
would you guys be interested in a joint-venture to build a Motion-Blur
compiler studio over this newsgroup? We could take this to the next level!

I'm also working on a program I've been calling ColdStitch which will, with
luck, be an Open Source replacement for SPatch/HamaPatch (but using DirectX
instead of OpenGL* and it will have a lot more features and the target goal
is to make it shrug off a Poser model like it ain't no thang). Part of the
development was to also have it import and export just about every 3D format
I can think-of... and, and I can't stress this enough, it would be Free
Software under the GNU license so that nobody can go and suddenly call it
"Shareware" and kill it.

If there's interest in this, this could be a lot of fun! Or, I'm fairly new
to this group -- is this already happening and can I get in on the action?

PS: Please don't judge my coding skills on that posting -- I wrote that as a
quick one-off to get the job done and I thought it might illustrate the
concept. I know you should never use global variables and should comment
code -- I write C code sometimes like I write PERL code and I didn't
originally plan on releasing that to the public. :-)


* Don't give me no guff about DirectX... I don't see SGI working it's
tail-off to make OpenGL better, but Microsoft is clamoring to do so because
of their gaming franchise, and Microsoft seems to be turning a new leaf
lately... along with the rest of the industry. .NET is wonderful thing.


Post a reply to this message

From: Warp
Subject: Re: movie within
Date: 28 Jan 2004 04:57:35
Message: <4017878f@news.povray.org>
Dan P <dan### [at] yahoocom> wrote:
> PS: Please don't judge my coding skills on that posting -- I wrote that as a
> quick one-off to get the job done and I thought it might illustrate the
> concept.

  IMHO quick coding is not an excuse to break every possible good coding
principle in the market... ;)

> I know you should never use global variables and should comment
> code

  Global variables were just one of the many problems in your code,
and comments aren't necessary if the code is otherwise very clear and
easy to read.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Tom Galvin
Subject: Re: movie within
Date: 28 Jan 2004 05:35:10
Message: <Xns947E38A2533E6tomatimporg@203.29.75.35>
"Dan P" <dan### [at] yahoocom> wrote in
news:40170c7c$1@news.povray.org: 

>  an Open Source replacement for SPatch/HamaPatch 
>

http://jPatch.sourceforge.net

Works nicely and is cross platform.


-- 
Tom
_________________________________
The Internet Movie Project
http://www.imp.org/


Post a reply to this message

From: Dan P
Subject: Re: movie within
Date: 28 Jan 2004 19:20:27
Message: <401851cb@news.povray.org>
"Tom Galvin" <tom### [at] imporg> wrote in message
news:Xns947E38A2533E6tomatimporg@203.29.75.35...
> "Dan P" <dan### [at] yahoocom> wrote in
> news:40170c7c$1@news.povray.org:
>
> >  an Open Source replacement for SPatch/HamaPatch
> >
>
> http://jPatch.sourceforge.net

Cool! Thanks!


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.