POV-Ray : Newsgroups : povray.newusers : a simple surface : Re: a simple surface Server Time
30 Jul 2024 16:18:20 EDT (-0400)
  Re: a simple surface  
From: Phil Cook
Date: 25 Jun 2004 10:22:49
Message: <opr95l75vyefp2ch@news.povray.org>
And lo on Fri, 25 Jun 2004 12:28:03 +0100, Phil Cook  
<phi### [at] nospamdeckingdealscouk> did spake, saying:

> And lo on Thu, 24 Jun 2004 14:32:50 -0400, Ross  
> <rli### [at] everestkcnet> did spake, saying:
>
>> "Phil Cook" <phi### [at] nospamdeckingdealscouk> wrote in message
>> news:opr93snpswefp2ch@news.povray.org...
>>
>> :snip:
>>
>>>
>>> Uses boxes rather than points and might be slow with a *lot* of data  
>>> (this
>>> took 26 sec on my computer, 76800 objects) but I hope it helps.
>>>
>>> --
>>> Phil Cook
>>>
>>> --
>>> All thoughts and comments are my own unless otherwise stated and I am
>>> happy to be proven wrong.
>>
>>
>> couldn't you use a bicubic_patch object, assuming each line in the data  
>> file
>> is a point in 3d space?
>
> I wasn't keen on the fact that the control-point doesn't necessarily  
> represent the actual point co-ords and that as a bicubic patch it only  
> allows 16 vector points which means dividing the data file into 4x4  
> 'sets' <0,0,Y>,<4,0,Y> to <4,0,Y,>, <4,4,Y> etc. and then recreating the  
> patch with the correct data 'set' each time. Of course you have to  
> assume the data is divisible by 16 or pad it. I must admit with the code  
> here I assumed it was square, but that's easily changed.
>
> It seemed to fiddly to do with a bicubic patch, though of course if you  
> care to try I'd be interested in seeing your code :)

Just to prove it can be done though crudely and with no error-checking

//code

#fopen MyFile "superficie.dat" read
#while (defined(MyFile))
#read (MyFile,LastX, LastZ, DitchY)
#end

#declare LastX=LastX+1;
#declare LastZ=LastZ+1;

camera{
location <LastX/2,300,300>
look_at  <LastX/2,0,LastZ/2>
}

light_source{<LastX/2,50,LastZ/2> rgb 1 shadowless}

#declare MyArray= array[LastX][LastZ];

#fopen MyFile "superficie.dat" read
#while (defined(MyFile))
#read (MyFile,MyX, MyZ, MyY)
#declare MyArray[MyX][MyZ]=<MyX,MyY,MyZ>;
#end

#macro PatchDraw()
bicubic_patch{
type 0
flatness 0.01
u_steps 4
v_steps 4
MyArray[i][j],MyArray[i][j+1],MyArray[i][j+2],MyArray[i][j+3],

MyArray[i+1][j],MyArray[i+1][j+1],MyArray[i+1][j+2],MyArray[i+1][j+3],

MyArray[i+2][j],MyArray[i+2][j+1],MyArray[i+2][j+2],MyArray[i+2][j+3],

MyArray[i+3][j],MyArray[i+3][j+1],MyArray[i+3][j+2],MyArray[i+3][j+3]
pigment{green 1}
finish{ambient 0.3}
}
#end

#declare i=0;
#declare j=0;

#while(i<LastX)

#while(j<LastZ)
PatchDraw()
#declare j=j+4;
#end
#declare i=i+4;
#declare j=0;
#end
//end code

Though this takes about 50 odd seconds compared to 20 odd for the boxes.

To join them up change the last part to:

#while(i<LastX-3)

#while(j<LastZ-3)
PatchDraw()
#declare j=j+3;
#end
#declare i=i+3;
#declare j=0;
#end

Hmm this ran at 44sec

To use all the data then both X-3 and Z-3 need to be divisible by 4; with  
this data that means 0,0,Y to 322,242,Y

Certainly looks smoother :)

--
Phil Cook

-- 
All thoughts and comments are my own unless otherwise stated and I am  
happy to be proven wrong.


Post a reply to this message

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