POV-Ray : Newsgroups : povray.text.scene-files : Megapov mechsim falling balls animation Server Time
26 Jun 2024 04:39:10 EDT (-0400)
  Megapov mechsim falling balls animation (Message 1 to 1 of 1)  
From: Thomas van der Veen
Subject: Megapov mechsim falling balls animation
Date: 31 Jan 2003 12:25:56
Message: <Xns9314B14F38E60veentukibmcom@204.213.191.226>
// Auth: Christoph Hormann/ Thomas van der Veen
// Requirements: IsoCSG library: http://www.tu-bs.de/~y0013390/pov/ic///
//
// as seen in http://news.povray.org/povray.binaries.animations/29982/
//
// I leave it to the reader to add some improvements ;)
//
// Render instructions:
// --------------------
//
// first render as still to generate simulation data:
//
// -w320 -h240
//
// then render as animation:
//
// -w320 -h240 +a0.3 -j +kff250

#version unofficial megapov 1.0;
#declare Radiosity = on;

#include "mechsim.inc"
#include "iso_csg.inc"

#declare BoxArray  = array[3]

#declare BoxArray[0] =  IC_Plane(y, 0.0)
#declare BoxArray[1] =  IC_Translate(IC_Rotate(IC_Box( <1.05, 1.05, 1>, 
< -1.05,-1.05,-1> ), <0,0,45>), <-1.75,2,0>)
#declare BoxArray[2] =  IC_Translate (IC_Rotate (IC_Box( <1.05, 1.05, 1>, 
< -1.05,-1.05,-1> ), <0,0,45>), <1.75,2,0>)

#declare fn_Env = IC_Merge_Array(BoxArray);  

global_settings 
{
    assumed_gamma 1.0

    #if (Radiosity = on )
        radiosity   
        {        
            pretrace_start 0.01
            pretrace_end   0.01
            count 400
            nearest_count 4
            error_bound 0.1        
            recursion_limit 1        
            low_error_factor 0.1
            gray_threshold 0.0        
            minimum_reuse 0.015        
            brightness 1.2
            adc_bailout 0.01/2        
        }
    #end        


    mechsim 
    {
        gravity <0, -9.81, 0 >
        method 1
        
        environment 
        {
            function { fn_Env(x, y, z) }
            stiffness 60000
            damping 10000
            friction 0.1, 1.001
            method 1
        }
        
        collision 
        {
            1, 0
            stiffness 60000
            damping 3000
        }
        
        #if (clock_on)
            step_count 1500
            time_step (1/30)/1500
        
            topology 
            {
                load_file "falling.dat"
        
            #if ( frame_number < 100 )
                #if (mod(frame_number, 16) = 15)
                    mass { < -1.25,5.5,0>, <0, 0, 0>, 0.1 density 5000 }
                #end
            #end
        
            save_file "falling.dat"
            }
        #else
            step_count 0
        
            topology 
            {
                mass { < -1.35,5.5,0>, <0, 0, 0>, 0.1 density 5000 }
                save_file "falling.dat"
            }
        #end
    }
}

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

camera 
{
    location <0, 5, -15.0>
    up y
    sky y
    look_at <0,2, 0>
    angle 30
}

#if (Radiosity = off )
    light_source 
    {
        <2000, 3000, -700>
        color rgb <1, 1, 1>
    }
#end    

sky_sphere
{
    pigment
    {
        gradient y 
        poly_wave 2 
        color_map
        {
            [0 rgb <0.7,0.8,1>*0.5]
            [0.75 rgb 1]
            [1 rgb 1]
        }
    translate -y*0.5 scale 2
    }
}


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

#declare T_Env = texture 
{
    pigment { rgb <0.7065,0.7065,0.7065>}
    finish { ambient 0.00 diffuse 1 specular 1 roughness 0.01 }
}


plane { y, 0 texture {pigment { color rgb .5} finish { ambient 0.00 
diffuse 1 }  }}

union 
{
    box { <1, 1, 1>, < -1,-1,-1> rotate 45*z translate <-1.75,2,0>  }
    box { <1, 1, 1>, < -1,-1,-1> rotate 45*z translate <1.75,2,0>  }

    box { <-5, -.1, .5>, < 5,10,1.2> }
    texture { T_Env }
}

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

MechSim_Show_All_Objects(-1, false, -1, "")


Post a reply to this message

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