POV-Ray : Newsgroups : povray.binaries.animations : POVigma: I just can't get it right! : Re: POVigma: I just can't get it right! Server Time
20 Apr 2024 07:17:45 EDT (-0400)
  Re: POVigma: I just can't get it right!  
From: "Jörg \"Yadgar\" Bleimann"
Date: 30 Aug 2015 10:31:41
Message: <55e313cd@news.povray.org>
Hi(gh)!

On 30.08.2015 08:20, Le_Forgeron wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA256
>
> Le 29/08/2015 22:36, "Jörg \"Yadgar\" Bleimann" a écrit :
>> Hi(gh)!
>>
>> On 29.08.2015 19:30, Le_Forgeron wrote:
>>
>>> Rewrite the loop to avoid #break, using #else instead... might
>>> help.
>>
>> To be honest, I have no clue how to do this...
>>
>
> You should try harder, because, contrary to C and Java, in povray SDL,
> #break does not jump out of a block (or loop).
>
> #break is reserved to #switch, and jump to the next #end. Nothing
> less, nothing more. (and given the parser, it's not really a jump,
> just ignoring thinks until #end is found).
>
> so, your code is not doing what you think it should do.


And I already wondered why there is no #continue in POV-Ray...
 >
 > so, your code is not doing what you think it should do.

Instead, I now simply set cols and rows to LevelWidth and LevelLength 
respectively after a detected collision, so that the nested loops both 
come to an end...

...now the ball at least does not go through the wall anymore - but 
instead, it is reflected in a somewhat strange way off the eastern and 
southern bordering wall - see attachment!

This is not entirely absurd, as the border stones are beveled at the 
corners, unlike the Oxyd stones - but the bevel angle is 45°, and the 
ball hits always at angles which are not multiples of 45°, so it can not 
be reflected this way...

Then I combined this with an #else solution:

#declare rows=0; // check for collision with any stone
#while (rows < LevelLength)
   #declare cols=0;
   #while (cols < LevelWidth)
     // #warning concat("row: ", str(rows, 1, 0), ", col: ", str (cols, 
1, 0))
     #if (layer2_array[rows][cols] = 1 | layer3_array[rows][cols] >= 20)
       #declare xmin=cols-0.35;
       #declare xmax=cols+1+0.35;
       #declare zmin=rows-0.35;
       #declare zmax=rows+1+0.35;
       // horizontal obstacles
       #if (ballpos_next.x >= xmin & ballpos_next.x <= xmax & 
ballpos_next.z >= zmin & ballpos_next.z <= zmax & (ballpos.z < zmin | 
ballpos.z > zmax))
         #declare dir = 180-dir;
     #declare hit=1;
     #declare cols=LevelWidth;
     #declare rows=LevelLength; // loop is aborted
       #else
     #if (ballpos_next.x >= xmin & ballpos_next.x <= xmax & 
ballpos_next.z >= zmin & ballpos_next.z <= zmax & (ballpos.x < xmin | 
ballpos.x > xmax))
       #declare dir = -dir;
       #declare hit=1;
       #declare cols=LevelWidth;
       #declare rows=LevelLength; // loop is aborted
     #end
       #end
     #end
     #declare cols=cols+1;
   #end
   #declare rows=rows+1;
#end

...and it is the same like before!!! (see second attachment)

I hardly have words anymore for this... it's so frustrating... so 
endlessly frustrating... it only HURTS! Perhaps I should give up POV-Ray 
and programming in general completely and content myself with watching 
TV! Obviously my mind is too weak to tackle with the tasks of programming...

See you in some redneck trailer park!

Yadgar


Post a reply to this message


Attachments:
Download 'povigma_level0001_ballview_0-1_60c.mp4.mpg' (506 KB) Download 'povigma_level0001_ballview_0-1_60d.mp4.mpg' (501 KB)

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