POV-Ray : Newsgroups : povray.newusers : Rollercoaster type maths (not possible in povray?) : Re: Rollercoaster type maths (not possible in povray?) Server Time
29 Jul 2024 10:21:10 EDT (-0400)
  Re: Rollercoaster type maths (not possible in povray?)  
From: CdeathJd
Date: 7 Aug 2006 18:25:01
Message: <web.44d7bcddd4496aa8e2e0912a0@news.povray.org>
To all,

Cheers for all your help people, i finally got it working today, it was done
in a stange way indeed but i managed to make it work. Thanks to everyone for
their advice and for putting up with my defeatism, im a pessimist im afraid.
However doing a lot of research helped me get there in the end.

For reference, here is the file as it currently stands. Hopefully if others
run into similar problems this will help them out. Note that the file does
not depend on the CLOCK value in any way:

// Persistence of Vision Ray Tracer Scene Description File
// File: This.pov
// Vers: 3.6
// Desc: Roller Coaster Tycoons match
// Date: cant remember
// Auth: Cdeath, with a LOT of help from others!
//

#declare Powered_Launch=0;              // Powered Launch? 1=Yes 0=no, -
this means that a certain increase in velocity happens up to a frame
threshhold
#declare Powered_Launch_Add=0.02;       // velocity to add each frame
#declare Powered_Launch_Clock=0;        // Stop adding when CLOCK reaches
this value

#declare velocity=0.2;
#declare ynowvel=0;
#declare SPLINE_POINTS=215;
#declare SPLINE_POINTS=SPLINE_POINTS-1;


#macro Save_Velocity()
  #fopen IFV_File "InterFrameVelocity.inc" write
  #write ( IFV_File, "// This is a generated file which " )
  #write ( IFV_File, "can probably be deleted without too much harm.n" )
  #write ( IFV_File, concat(  "#declare ynowvel = ", str(ynowvel,0,3),";n"
))
  #write ( IFV_File, concat(  "#declare velocity = ", str(velocity,0,3),";n"
))

  #fclose IFV_File
#end

// VERY IMPORTANT!!!

//Save_Velocity()

//De-commenting the above line will reset the simulation, and create file
"InterFrameVelocity.Inc"
//Once this has done, and pov-ray starts to render, stop the render and
re-comment the line, other
//wise the camera wont go anywhere.



#version 3.6;

#include "math.inc"
#include "transforms.inc"
#include "colors.inc"
#include "InterFrameVelocity.inc"


global_settings {
  assumed_gamma 2.0
  max_trace_level 3
}


// ----------------------------------------


#declare MySpline =
spline {
   natural_spline

-2, <-1.04587,-0.2,11.9543>,
-1, <-1.83027,-0.2,20.9201>,
0, <-2.61467,-0.2,29.8858>,
1, <-3.39907,-0.2,38.8516>,
2, <-4.18348,-0.2,47.8173>,
3, <-4.96788,-0.2,56.7831>,
4, <-5.75137,-0.492935,65.7384>,
5, <-6.51985,-2.23882,74.5222>,
6, <-7.24984,-5.50099,82.866>,
7, <-7.9188,-10.1788,90.5123>,
8, <-8.50608,-16.1277,97.2249>,
9, <-8.99354,-23.1641,102.797>,
10, <-9.36615,-31.0709,107.056>,
11, <-9.61977,-39.5802,109.954>,
12, <-9.88797,-48.0347,113.02>,
13, <-10.2199,-56.1862,116.814>,
14, <-10.6129,-63.9717,121.306>,
15, <-11.064,-71.3309,126.462>,
16, <-11.5697,-78.2069,132.242>,
17, <-12.1261,-84.5466,138.602>,
18, <-12.7289,-90.301,145.492>,
19, <-13.3735,-95.4254,152.859>,
20, <-14.0547,-99.8804,160.646>,
21, <-14.7675,-103.631,168.793>,
22, <-15.5062,-106.65,177.237>,
23, <-16.2652,-108.911,185.912>,
24, <-17.0385,-110.399,194.751>,
25, <-17.8203,-111.102,203.687>,
26, <-18.6044,-111.014,212.649>,
27, <-19.3848,-110.136,221.569>,
28, <-20.1555,-108.475,230.378>,
29, <-20.9104,-106.043,239.007>,
30, <-21.6676,-102.853,247.385>,
31, <-22.6483,-98.8524,255.383>,
32, <-23.8709,-94.0639,262.9>,
33, <-25.2839,-88.5351,269.854>,
34, <-26.8283,-82.322,276.174>,
35, <-28.4385,-75.4874,281.797>,
36, <-30.044,-68.1001,286.674>,
37, <-31.5708,-60.2348,290.765>,
38, <-33.3106,-52.3151,294.66>,
39, <-35.7494,-44.8479,299.044>,
40, <-38.9568,-37.904,303.778>,
41, <-42.9761,-31.5492,308.715>,
42, <-47.8225,-25.8437,313.701>,
43, <-53.4827,-20.8416,318.584>,
44, <-59.9155,-16.5903,323.215>,
45, <-67.0528,-13.1301,327.455>,
46, <-74.8025,-10.4938,331.181>,
47, <-83.0509,-8.7063,334.288>,
48, <-91.6674,-7.78466,336.695>,
49, <-100.508,-7.73755,338.344>,
50, <-109.422,-8.56543,339.208>,
51, <-118.254,-10.2605,339.285>,
52, <-126.853,-12.8066,338.602>,
53, <-135.26,-15.6802,337.182>,
54, <-143.536,-18.4732,335.021>,
55, <-151.614,-21.1856,332.133>,
56, <-159.43,-23.8169,328.537>,
57, <-166.921,-26.367,324.255>,
58, <-174.026,-28.8357,319.318>,
59, <-180.688,-31.2226,313.762>,
60, <-186.874,-33.4516,307.621>,
61, <-192.614,-35.2148,300.921>,
62, <-197.849,-36.4766,293.714>,
63, <-202.521,-37.2327,286.063>,
64, <-206.578,-37.4808,278.038>,
65, <-209.981,-37.2202,269.714>,
66, <-212.697,-36.4515,261.172>,
67, <-214.709,-35.1755,252.496>,
68, <-216.004,-33.2985,243.794>,
69, <-216.588,-30.7776,235.179>,
70, <-216.484,-27.6265,226.754>,
71, <-215.73,-23.8622,218.618>,
72, <-214.379,-19.5054,210.864>,
73, <-212.498,-14.5798,203.575>,
74, <-210.165,-9.11214,196.822>,
75, <-207.571,-3.69689,190.136>,
76, <-205.208,-0.014575,182.297>,
77, <-203.369,1.65415,173.671>,
78, <-202.233,1.21706,164.777>,
79, <-201.851,-1.30167,156.169>,
80, <-202.151,-5.76286,148.384>,
81, <-202.941,-11.92,141.897>,
82, <-203.937,-19.3871,136.999>,
83, <-204.931,-26.9988,132.302>,
84, <-205.892,-34.3841,127.25>,
85, <-206.805,-41.5275,121.854>,
86, <-207.655,-48.4142,116.123>,
87, <-208.427,-55.03,110.072>,
88, <-209.106,-61.3611,103.713>,
89, <-209.679,-67.3945,97.0602>,
90, <-210.121,-73.3661,90.3428>,
91, <-210.41,-79.7202,83.9775>,
92, <-210.559,-86.4431,77.998>,
93, <-210.584,-93.5109,72.4284>,
94, <-210.502,-100.898,67.2908>,
95, <-210.332,-108.579,62.6056>,
96, <-210.093,-116.526,58.3906>,
97, <-209.802,-124.695,54.6272>,
98, <-209.445,-132.916,50.9812>,
99, <-209.016,-141.148,47.369>,
100, <-208.517,-149.392,43.7919>,
101, <-207.949,-157.646,40.2514>,
102, <-207.314,-165.913,36.7487>,
103, <-206.613,-174.19,33.2852>,
104, <-205.846,-182.478,29.8622>,
105, <-204.958,-190.67,26.2467>,
106, <-203.865,-198.612,22.1603>,
107, <-202.553,-206.274,17.6261>,
108, <-201.008,-213.623,12.6691>,
109, <-199.22,-220.632,7.3168>,
110, <-197.178,-227.273,1.59809>,
111, <-194.876,-233.519,-4.45632>,
112, <-192.297,-239.307,-10.8436>,
113, <-189.37,-244.357,-17.6882>,
114, <-186.096,-248.572,-24.9295>,
115, <-182.499,-251.903,-32.4721>,
116, <-178.61,-254.31,-40.2178>,
117, <-174.465,-255.765,-48.0679>,
118, <-170.11,-256.252,-55.9239>,
119, <-165.596,-255.764,-63.6894>,
120, <-160.94,-254.828,-71.3344>,
121, <-156.131,-253.864,-78.8802>,
122, <-151.171,-252.871,-86.3237>,
123, <-146.061,-251.851,-93.6617>,
124, <-140.804,-250.803,-100.891>,
125, <-135.403,-249.726,-108.009>,
126, <-129.86,-248.622,-115.013>,
127, <-124.177,-247.489,-121.899>,
128, <-118.357,-246.329,-128.665>,
129, <-112.403,-245.14,-135.308>,
130, <-106.317,-243.923,-141.825>,
131, <-100.101,-242.679,-148.214>,
132, <-93.7597,-241.406,-154.472>,
133, <-87.2944,-240.105,-160.596>,
134, <-80.7086,-238.777,-166.585>,
135, <-74.005,-237.42,-172.434>,
136, <-67.1867,-236.036,-178.143>,
137, <-60.2566,-234.623,-183.709>,
138, <-53.2179,-233.183,-189.129>,
139, <-46.0736,-231.715,-194.402>,
140, <-38.827,-230.219,-199.525>,
141, <-31.4812,-228.695,-204.496>,
142, <-24.0395,-227.143,-209.314>,
143, <-16.5051,-225.563,-213.976>,
144, <-8.94393,-223.808,-218.529>,
145, <-1.44341,-221.693,-223.031>,
146, <5.98382,-219.223,-227.472>,
147, <13.3252,-216.402,-231.846>,
148, <20.5682,-213.235,-236.147>,
149, <27.7006,-209.726,-240.366>,
150, <34.7103,-205.881,-244.498>,
151, <41.5853,-201.708,-248.536>,
152, <48.3138,-197.212,-252.474>,
153, <54.8843,-192.402,-256.306>,
154, <61.2855,-187.286,-260.025>,
155, <67.5064,-181.871,-263.627>,
156, <73.5362,-176.168,-267.105>,
157, <79.3646,-170.185,-270.455>,
158, <84.9814,-163.932,-273.672>,
159, <90.3769,-157.421,-276.751>,
160, <95.5415,-150.661,-279.687>,
161, <100.466,-143.664,-282.477>,
162, <105.143,-136.443,-285.116>,
163, <109.562,-129.007,-287.601>,
164, <113.717,-121.371,-289.929>,
165, <117.6,-113.547,-292.096>,
166, <121.203,-105.548,-294.1>,
167, <124.522,-97.3876,-295.939>,
168, <127.656,-89.1278,-297.656>,
169, <130.806,-80.8662,-299.337>,
170, <133.974,-72.6047,-300.983>,
171, <137.16,-64.3431,-302.595>,
172, <140.363,-56.0816,-304.171>,
173, <143.584,-47.82,-305.712>,
174, <146.821,-39.5584,-307.217>,
175, <150.075,-31.2969,-308.687>,
176, <153.345,-23.0353,-310.121>,
177, <156.63,-14.7737,-311.518>,
178, <159.93,-6.51214,-312.88>,
179, <163.245,1.74943,-314.205>,
180, <166.575,10.011,-315.494>,
181, <169.918,18.2726,-316.746>,
182, <173.275,26.5341,-317.961>,
183, <176.646,34.7957,-319.139>,
184, <180.028,43.0573,-320.28>,
185, <183.424,51.3189,-321.384>,
186, <186.831,59.5804,-322.45>,
187, <190.25,67.842,-323.479>,
188, <193.68,76.1035,-324.47>,
189, <197.12,84.3651,-325.423>,
190, <200.571,92.6266,-326.339>,
191, <204.032,100.888,-327.216>,
192, <207.502,109.15,-328.056>,
193, <210.981,117.411,-328.857>,
194, <214.469,125.673,-329.62>,
195, <217.965,133.935,-330.344>,
196, <221.468,142.196,-331.03>,
197, <224.979,150.458,-331.677>,
198, <228.497,158.719,-332.286>,
199, <232.022,166.981,-332.856>,
200, <235.552,175.243,-333.387>,
201, <239.088,183.504,-333.88>,
202, <242.629,191.766,-334.333>,
203, <246.175,200.027,-334.748>,
204, <249.726,208.289,-335.123>,
205, <253.28,216.551,-335.46>,
206, <256.838,224.812,-335.757>,
207, <260.399,233.074,-336.015>,
208, <263.962,241.335,-336.234>,
209, <267.528,249.597,-336.414>,
210, <271.095,257.858,-336.555>,
211, <274.664,266.12,-336.656>,
212, <278.234,274.381,-336.718>,
213, <281.804,282.643,-336.741>,
214, <285.374,290.904,-336.724>,
215, <288.944,299.166,-336.669>,


}

// First-person-view camera
// Follows the same path as the first aircraft


#declare ynowvel=ynowvel+velocity;
#if (Powered_Launch=1)
    #if (clock<Powered_Launch_Clock)
        #declare velocity=velocity+Powered_Launch_Add;
    #end
#end
#declare VECT_HERE=MySpline(ynowvel).y;
#declare VECT_THERE=MySpline(ynowvel+velocity).y;

// Physical Velocity stuff
#if (VECT_HERE>VECT_THERE)
        #declare velocity=velocity+0.006;
#end
#if (VECT_HERE<VECT_THERE)
        #declare velocity=velocity-0.005;
#end

Save_Velocity()

   camera {
      location 0//<-150,-22.5, 140>
      //look_at z
      //look_at <-150,-32.5, 60>
      translate <0,0.4,0.4>
      Spline_Trans (MySpline, ynowvel, y, 0.85, 0.85)
      Save_Velocity()
      //translate <50, 42.5, -212>
      //Spline_Trans (MySpline, clock, y, 0.85, 0.85)

   angle 30
   }

  light_source {
  <0, 1, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  Spline_Trans (MySpline, ynowvel, y, 0.5, 0.5)

  fade_distance 5
  fade_power 1
}



//camera {
//  location  <140.0, 44.0, 185.0>
//  look_at   <140.0, -50.0, 220.0>
//}

union {
   #declare C = 0;
   #declare Cmax= SPLINE_POINTS;
   #while (C<=Cmax)
      #declare Value1 = C/Cmax*SPLINE_POINTS;
      #declare Value2 = (C+1)/Cmax*SPLINE_POINTS;
      #declare Point1 = -0.5*y+MySpline(Value1);
      #declare Point2 = -0.5*y+MySpline(Value2);
      sphere {Point1, 0.2}
      cylinder {Point1, Point2, 0.16}
      #declare C = C+1;
   #end
   pigment {color rgb 0.5}
   finish {reflection 0.6 specular 2.5}
   //translate <50, 42.5, -230>

}

difference {
box {
  <-3000, -3000, -3000>  // one corner position <X1 Y1 Z1>
  < 3000,  3000,  3000>  // other corner position <X2 Y2 Z2>
}
union {
   #declare C = 0;
   #declare Cmax= SPLINE_POINTS;
   #while (C<=Cmax)
      #declare Value1 = C/Cmax*SPLINE_POINTS;
      #declare Value2 = (C+1)/Cmax*SPLINE_POINTS;
      #declare Point1 = -0.5*y+MySpline(Value1);
      #declare Point2 = -0.5*y+MySpline(Value2);
      //cylinder {Point1-0.1, Point2+0.1, 4.16}
      #declare C = C+1;
      box{ <-5,-5,-5> <5,5,5> translate Point1
         pigment {color rgb<1.0,0.7,0>} }
   //normal {dents 0.8 scale 0.45}}
   #end

   //finish {reflection 0.6 specular 2.5}
   //translate <50, 42.5, -230>

}}
// END OF FILE
I plan to add a "chain mechanism" as the rollercoaster doesn't roll
backwards at all. i Think i may be getting the hang of a lot of things now.

Does anyone have any advice on this issue, now that you've proved me wrong
reguarding the subject title?

For those that want a look at the finished product, a short movie clip (4MB)
can be downloaded here:
http://209.245.59.241/Gimme/66413073/1605450461/107060564/%7B5DA6D5F4-BCC8-4F91-B026-319609B6CD3A%7D/0.216928/2/Velocit
yTest.avi


Post a reply to this message

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