POV-Ray : Newsgroups : povray.general : Debugging help : Debugging help Server Time
3 May 2024 00:02:41 EDT (-0400)
  Debugging help  
From: Anthony D  Baye
Date: 22 May 2017 03:15:01
Message: <web.59228e7d3389885cfd6b6fe10@news.povray.org>
Back working on my Seraglio project after a bit of a hiatus due to work and
other issues.

Been working on this all weekend.  It's beginning to take shape, but there's
something wrong with the math.

It works until (I think) the vector changes signs... the bricks start generating
perpendicular to the wall direction, rather than with it.

the code is supposed to build the wall brick-wise from isosurface blocks. It's a
bit overkill, but I'm horrible at texturing. And a bit obsessive when it comes
to detail.

If anyone can help me with this problem, I'd appreciate it.

#version 3.7;

#include "math.inc"
#include "functions.inc"
#include "rad_def.inc"
#include "kolors.inc"
#include "rand.inc"

#default {
    pigment { rgb <0.07,0.37,0.75> }
    finish { ambient 0 }
    }
#local FAST = 1;
#local FANCY = 2;
#local FANCIER = 3;
/* !- Global Switches -! */
#declare RAD = off      ;
#declare PHO = off      ;
#declare TEX = on       ;
#declare LGT = FAST     ;
/* --------------------- */

#if(RAD)
    #if(LGT = FANCIER)
        #declare Count_Max = 160000;
        #default {
            radiosity { importance 0.001 }
            }
//intersection {
    #else
        #declare Count_Max = 160;
        #default {
            radiosity { importance 1.0 }
            }
    #end
#end

global_settings {
#if(RAD)
     radiosity {
        pretrace_start 0.08
        pretrace_end   0.004
        count Count_Max

        nearest_count 8
        error_bound 0.15
        recursion_limit 2
        low_error_factor 0.5
        gray_threshold 0.2
        minimum_reuse 0.015
        brightness 1.0
        normal off

        adc_bailout 0.01/2
       }
#end

#if (PHO)
    photons {
        // count 20000
        spacing 1/1000
//        autostop 0.51
//        jitter 0.4
        }
#end
     assumed_gamma 1.0
     // max_trace_level 10
     }

light_source { <60.0, 120.0, -50.0> rgb 1 }

camera {
    ultra_wide_angle
    location <30.0, 75.0, -100.0>
//    location <0.0, 15.0, -25.0>
    up y
    right x*(image_width/image_height)
    look_at <0.0, 6.0, 25.0>
    }

#declare F_RoughBrick =
function {
     pattern {
          wrinkles
          turbulence <0.3, 0.1, 0.5>
    scale <1.0, 1.0, 0.125>
          }
     }
#declare F_GraniteFacing =
function {
     pattern {
          granite
          turbulence <0.3, 0.1, 0.5>
    scale 0.01
          }
     }

#declare F_Sandstone =
function {
     pattern {
          bozo
          turbulence 0.7
          ramp_wave
          rotate -90.0 * x
          }
     }

#macro Block(X, Y, Z)
#local pattern_seed = 15643544181;
#local _X = Rand_Normal(0.0, 1.0, RdmA)*2e5;
#local _Y = Rand_Normal(0.0, 1.0, RdmB)*2e5;
#local _Z = Rand_Normal(0.0, 1.0, RdmC)*2e5;

isosurface {
 function {
      f_rounded_box(x,y,z,0.0625,
           X-0.0078125*F_RoughBrick(x-_X,y-_Y,z-_Z),
           Y-0.0078125*F_RoughBrick(x-_X,y-_Y,z-_Z),
           Z/2-0.078125*F_RoughBrick(x-_X,y-_Y,z-_Z))
      }
 threshold 0
 max_gradient 2
 contained_by { box { <0.0, 0.0, -Z/2> <X, Y, Z/2> } }
 all_intersections
     // translate <0.5*L, 0.5*T, 0.0>
 }
#end

#macro Wall(START, END, HEIGHT, BSIZE, MWIDTH)

    #local wall_vec = vnormalize(END - START);
    #local wall_vec = <wall_vec.u, 0, wall_vec.v>;
    #local wall_dlength = vlength(END - START);
    #local wall_perp = vcross(wall_vec, y);
    #local wall_th  = degrees(acos(vdot(wall_vec,x)));
    #local remainder = 0;

//intersection {
    union {
    #local wall_aheight = 0.0;
    #while(wall_aheight < HEIGHT)
    #local wall_alength = 0.0;
        #while(wall_alength < wall_dlength)
            #local nbLength = (remainder > 0 ? remainder : min(BSIZE.x,
wall_dlength - wall_alength));
            #local remainder = 0;
            object { Block(nbLength, BSIZE.y, BSIZE.z) rotate -(wall_th)*y
translate <START.u, wall_aheight, START.v> + wall_alength*wall_vec }
        #local wall_alength = wall_alength + nbLength + MWIDTH;
        #end
    #local remainder = BSIZE.x - nbLength;
    #local wall_aheight = wall_aheight + BSIZE.y + MWIDTH;
    #end
        }
/*    prism {
        0, HEIGHT, 5
        START - BSIZE.z*0.5*<wall_perp.x, wall_perp.z>, END -
BSIZE.z*0.5*<wall_perp.x, wall_perp.z>,
        END + BSIZE.z*0.5*<wall_perp.x, wall_perp.z>, START +
BSIZE.z*0.5*<wall_perp.x, wall_perp.z>,
        START - BSIZE.z*0.5*<wall_perp.x, wall_perp.z>
        }
    }*/
#end

#macro hexTower(MINR, PROTR, HEIGHT, OFFSET)

#local minR = MINR;
#local majR = minR/cosd(30);
#local pR = PROTR;
#local Offset2 = OFFSET;

#declare tArray =
array[19] {
    majR*<cosd(0), sind(0)>,
    <majR*cosd(60) - pR*sind(60 + 150), majR*sind(60) + pR*cosd(60 + 150)>,
    <(majR + Offset2)*cosd(60) - pR*sind(60 + 150), (majR + Offset2)*sind(60) +
pR*cosd(60 + 150)>,
    (majR + Offset2)*<cosd(60), sind(60)>,
    <(majR + Offset2)*cosd(60) - pR*sind(60 + 30), (majR + Offset2)*sind(60) +
pR*cosd(60 + 30)>,
    <majR*cosd(60) - pR*sind(60 + 30), majR*sind(60) + pR*cosd(60 + 30)>
    majR*<cosd(120), sind(120)>,
    <majR*cosd(180) - pR*sind(180 + 150), majR*sind(180) + pR*cosd(180 + 150)>,
    <(majR + Offset2)*cosd(180) - pR*sind(180 + 150), (majR + Offset2)*sind(180)
+ pR*cosd(180 + 150)>,
    (majR + Offset2)*<cosd(180), sind(180)>,
    <(majR + Offset2)*cosd(180) - pR*sind(180 + 30), (majR + Offset2)*sind(180)
+ pR*cosd(180 + 30)>,
    <majR*cosd(180) - pR*sind(180 + 30), majR*sind(180) + pR*cosd(180 + 30)>
    majR*<cosd(240), sind(240)>,
    <majR*cosd(300) - pR*sind(300 + 150), majR*sind(300) + pR*cosd(300 + 150)>,
    <(majR + Offset2)*cosd(300) - pR*sind(300 + 150), (majR + Offset2)*sind(300)
+ pR*cosd(300 + 150)>,
    (majR + Offset2)*<cosd(300), sind(300)>,
    <(majR + Offset2)*cosd(300) - pR*sind(300 + 30), (majR + Offset2)*sind(300)
+ pR*cosd(300 + 30)>,
    <majR*cosd(300) - pR*sind(300 + 30), majR*sind(300) + pR*cosd(300 + 30)>,
    majR*<cosd(0), sind(0)>
    }

#for(c, 0, 17, 1)
    Wall(tArray[c], tArray[c + 1], 10.0, <2.25, 0.75, 1.25>, 0.375/12)
#end

#end

plane { y, 0 pigment { White } }

union { hexTower(35.0 + 2.25/cosd(30), 10.0 + 2.25/cosd(30), 10.0, 5.0) }
//Wall(<-15.0, 10.0>, <15.0, 25.0>, 10.0, <2.25, 0.75, 1.25>, 0.375/12)


Post a reply to this message

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