POV-Ray : Newsgroups : povray.newusers : Attaching a vector to an object Server Time
28 Jul 2024 16:16:17 EDT (-0400)
  Attaching a vector to an object (Message 1 to 4 of 4)  
From: Bill
Subject: Attaching a vector to an object
Date: 18 Nov 2008 12:10:00
Message: <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. :)

Here is a sample scene.

#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,0>;
#include "colors.inc"
#include "textures.inc"
#include "transforms.inc"
global_settings { ambient_light rgb<2,2,2> radiosity{} }
light_source{<0,5000,0> rgb<2,2,2> }
plane{<0,1,0>,1 hollow 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} } scale 10000 }
plane { <0,1,0>, 0 texture{ pigment{color rgb<0.35,0.65,0.0>*0.8} finish
{ambient 0.1 diffuse 0.8} } }
fog{distance 300000 color rgb <.5,.5,.5>}
#include "fok2.inc"
#include "snipe.inc"
object{fok rotate fok_rot translate fok_pos finish { ambient 1 diffuse .4 } }
object{snipe rotate snipe_rot translate snipe_pos finish { ambient 1 diffuse .4
}}
#local HeadPos = <0,3,4.3>;
#local hp = vtransform(HeadPos,Rotate_Around_Trans(snipe_rot, <0,0,0>));
#declare Cam0 = camera { location HeadPos+snipe_pos direction <0, 0,  1> up
  <0, 1,  0> right   <-1.7777777778, 0,  0> look_at   fok_pos }
camera{Cam0}

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. :(

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?

Bill


Post a reply to this message

From: Tim Attwood
Subject: Re: Attaching a vector to an object
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

From: Bill
Subject: Re: Attaching a vector to an object
Date: 20 Nov 2008 11:55:00
Message: <web.49259567516e9f3c24b378250@news.povray.org>
Thanks Tim, but I actually nailed it this morning.
Here is the final pov for the snipe.

#declare snipe_pos = <58.601052,1500.000000,100.000000>;
#declare snipe_rot = <0,10,12>;
#declare fok_pos = <59.034065,1500.000000,150.000000>;
#declare fok_rot = <0,60,0>;
#include "colors.inc"
#include "textures.inc"
#include "transforms.inc"
global_settings { ambient_light rgb<2,2,2> radiosity{} }
light_source{<0,5000,0> rgb<2,2,2> }
plane{<0,1,0>,1 hollow 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} } scale 10000 }
plane { <0,1,0>, 0 texture{ pigment{color rgb<0.35,0.65,0.0>*0.8} finish
{ambient 0.1 diffuse 0.8} } }
fog{distance 300000 color rgb <.5,.5,.5>}
#include "fok2.inc"
#include "snipe.inc"
object{fok rotate fok_rot translate fok_pos finish { ambient 1 diffuse .4 } }
object{snipe rotate snipe_rot translate snipe_pos finish { ambient 1 diffuse .4
}}
#local HeadPos = <0,3,4.3>;
#local hp = vtransform(HeadPos,Rotate_Around_Trans(snipe_rot, <0,0,0>));
#local sky_r = vtransform(<0,1,0>,Rotate_Around_Trans(snipe_rot, <0,0,0>));
#local hp2 = hp+snipe_pos;
#declare Cam0 = camera {
location hp2
direction <0, 0,  1>
sky sky_r
up <0,1,0>
right <-1.7777777778, 0,  0>
look_at fok_pos
}
camera{Cam0}

For a quick view of the low quality image (temp holder for the image)
http://76.164.116.48:8080/fortim.png

It all had to do with moving the translate outside the camera and play with the
sky vector!

Bill


Post a reply to this message

From: SharkD
Subject: Re: Attaching a vector to an object
Date: 20 Nov 2008 20:15:00
Message: <web.49260b52516e9f3c5c688edf0@news.povray.org>
Sorry to take the thread off topic, but are there any flight sims that will
output such coordinates so that you can simply interpolate between them? IIRC,
Terragen had a similar option.

-Mike


Post a reply to this message

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