POV-Ray : Newsgroups : povray.newusers : Attaching a vector to an object : Re: Attaching a vector to an object Server Time
28 Jul 2024 14:31:25 EDT (-0400)
  Re: Attaching a vector to an object  
From: Tim Attwood
Date: 19 Nov 2008 21:23:58
Message: <4924ca3e$1@news.povray.org>
"Bill" <mis### [at] gmailcom> wrote in message 
news:web.4922f5c93f11211224b378250@news.povray.org...
> Let me start by saying this was easier to do in POV3.1 than 3.6.1. And I 
> have no
> explanation as to why. So I am asking the POV Gurus for help.
>
> I have a set of programs that create pov files that I render for animation
> purposes.
> The setup is this.
> There are two aircrafts (World War I style).
> The view point is the cockpit of the snipe.
> Each plane will be twisting and turning and doing what fighter planes do. 
> :)
 ...
> More info. The HeadPos is the offset of the center of gravity for the 
> plane at
> where the pilot's head should be.
>
> Ok, here is the problem. In 3.1g I was able to define the location in the 
> camera
> then rotate and translate the camera to the same position as the snipe_pos
> vector. In 3.6.1 this doesnt work at all. :(

That is still the perfered method... maybe you have changed the center
points of your model?

> So, I have been trying all sorts of things to help get me to where I need 
> to be.
> This setup with vtransform is the closest I have gotten to date, but it 
> still
> doesnt work right.
>
> I would like the camera to be fixed to the snipe_pos+HeadPos when the 
> plane is
> rotated and transformed and still be able to specify look_at fok_pos.
>
> This way no matter how the plane banks and yanks the camera will always be 
> in
> the position of the pilot's head.
>
> Can anyone please help me kick this beast in the backside?

This is your code modified to follow the model. (w/o animation)

#include "colors.inc"
#include "textures.inc"
#include "transforms.inc"

global_settings {
   ambient_light rgb<2,2,2>
   //radiosity{}
}

// paths
#declare snipe_pos = <58.601052,1500.000000,100.000000>;
#declare snipe_rot = <0,0,12>;
#declare fok_pos = <59.034065,1500.000000,150.000000>;
#declare fok_rot = <0,60,20>;

// camera
camera {
   location  <0, 0, -1>
   direction z
   right     x*image_width/image_height
   look_at   <0, 0, 0>  // face camera forward
   translate <0,0.5,-1> // move camera to cockpit
   rotate fok_rot       // rotate camera with airplane
   translate fok_pos    // move camera to airplane
}

// textures
#declare sky_Tex = texture {
   pigment {
      bozo
      turbulence 0.92
      color_map {
         [0.00 rgb <0.2, 0.2, 1>*0.9]
         [0.50 rgb <0.2, 0.2, 1>*0.9]
         [0.70 rgb <1,1,1>]
         [0.85 rgb <0.25,0.25,0.25>]
         [1.0 rgb <0.5,0.5,0.5>]
      }
      scale <1,1,1.5>*2.5
      translate<1.0,0,-1>
   }
   finish {
      ambient 1
      diffuse 0
   }
};
#declare ground_Tex = texture {
   pigment{
      color rgb<0.35,0.65,0.0>*0.8
   }
   finish {
      ambient 0.1
      diffuse 0.8
   }
};

// objects
//#include "fok2.inc"
//#include "snipe.inc"
#declare aero = union { // model stand in
   cone {<0,0,-0.4>,0.1,<0,0,1>,0}
   box {<-1,-0.05,-0.25>,<1,0.05,0.25>}
};
#declare fok = object{aero pigment {Red}};
#declare snipe = object{aero pigment {Blue}};


// lights
light_source{<0,5000,0> rgb<2,2,2> }

// scene
plane { y, 1
   hollow
   texture {sky_Tex}
   scale 10000
}
plane { y, 0
   texture {ground_Tex}
}
fog {
   distance 300000
   color rgb <.5,.5,.5>
}

// MOBs
object {
   fok
   rotate fok_rot
   translate fok_pos
}

object {
   snipe
   rotate snipe_rot
   translate snipe_pos
}

Don't forget that you can use splines to describe the paths
of your airplanes. Using that method you can avoid having
to separately track the tilt angles. For example...

#declare snipe_path = spline {
   natural_spline
   -0.1, <0, 1500, 90>
    0.0, <0, 1500, 100>
    0.5, <27, 1450, 27>
    1.0, <100,  1400, 0>
    1.1, <110,  1400, 0>
};
camera {
   ...
   Spline_Trans(snipe_path, clock, y, 0.1, 0.5)
}
object {
   snipe
   Spline_Trans(snipe_path, clock, y, 0.1, 0.5)
}


Post a reply to this message

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