POV-Ray : Newsgroups : povray.general : animated projectiles shot while moving : Re: animated projectiles shot while moving Server Time
9 Aug 2024 01:27:29 EDT (-0400)
  Re: animated projectiles shot while moving  
From: Chris Calef
Date: 1 Sep 2000 16:15:48
Message: <39B00E1F.A5183C3A@orcasinc.com>
Hi.  I'm new to this group, but I've been off in my own little cave working on
the problem of physics-based motion in povray for a little while now.  At the
moment I'm working on a "frog" that points in a random direction and leaps
according to a random vector, then slides and when it gets slow enough jumps
again.  Forgive me if I betray serious ignorance here, but in my
experimentation I haven't found any way to save persistent variables from one
frame to the next in povray without writing them out to a text file, so that's
what I'm doing.  (code snippet below)
It seems like "querying the host object" is sort of backwards... wouldn't you
create the projectile object and give it position and move vectors based on
the known muzzle position and angle?  If you don't know the muzzle position
and angle because the ship has moved and rotated, then you'd have to apply the
same transformations to the original muzzle coordinates that you applied to
the ship... does that make sense? (believe it or not, english actually is my
first language.)

#declare gravity_vector = <0,-8,0>;
#declare drag = 0.9;

#fopen FrogFile "frog.dat" read
#read (FrogFile,frog_position,frog_move,rot_y,rot_x)
#fclose FrogFile

#declare frog_move = (frog_move + gravity_vector) * drag;
#declare frog_position = frog_position + frog_move;

#fopen FrogFile "frog.dat" write
#write (FrogFile,frog_position,",",frog_move,",",rot_y,",",rot_x,",\n")
#fclose FrogFile

If anyone knows how I can save these variables without writing out to frog.dat
I'd be very happy!


"Greg M. Johnson" wrote:

> ryan constantine wrote:
>
> > by "query the host object" i mean it can find the end of the muzzle as
> > well as the direction it is pointing in order to know which drection to
> > shoot.  maybe the host (space ship) should set global variables
> > indicating where the muzzle tip is and the direction.  then the laser
> > would just use the globals.  what do you think?
>
> Still confused.
>
> EITHER
> ------------------------------------------------------------
>
> // LASER BEAM: SPEED OF LIGHT
>
> #declare laserhit=trace(Duck, LaserAim, LaserPosition, Norm);
>
> #if( Norm.x!=0&Norm.y!=0&Norm.z!=0)   //syntax may be a bit off
>          #declare DeadYet=1;
> #end
>
> ---------------------------------------------------
>
>  //        OR SHOOT A BUNCH OF BULLETS
>
> #declare Bulletposition=Bulletposition+0.1*Bulletveloc;
> #declare Bulletveloc=Bulletveloc-0.1*y;
>
> #if(DeadYet>0.5)
>     #declare TimeoDeath=TimeoDeath+1;
> #else
>     #if(vlength (DuckPostion-Bulletposition)<ContactDistance)  // ala Greg
>         #declare DeadYet=1;
>     #end
> #end


Post a reply to this message

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