POV-Ray : Newsgroups : povray.newusers : Olympic Flag Server Time
23 Dec 2024 15:06:28 EST (-0500)
  Olympic Flag (Message 1 to 10 of 16)  
Goto Latest 10 Messages Next 6 Messages >>>
From: sam kim
Subject: Olympic Flag
Date: 7 Feb 2009 14:40:00
Message: <web.498de26469c1735e7c859cee0@news.povray.org>
Hello,

I am trying to render an olympic flag by csg

with torus and an object that can be used for flag.

An example would be:

http://www.scotsindependent.org/2005/050826/olympic_flag.jpg

Which object should I use for flag, or should I throw away the csg

idea out the window and approach it differently?

Thank You


Post a reply to this message

From: Chris B
Subject: Re: Olympic Flag
Date: 7 Feb 2009 15:46:19
Message: <498df31b$1@news.povray.org>
"sam kim" <nomail@nomail> wrote in message 
news:web.498de26469c1735e7c859cee0@news.povray.org...
> Hello,
>
> I am trying to render an olympic flag by csg
> with torus and an object that can be used for flag.
> An example would be:
>
> http://www.scotsindependent.org/2005/050826/olympic_flag.jpg
>
> Which object should I use for flag, or should I throw away the csg
> idea out the window and approach it differently?
>

It depends how flag like you want to make it.

You can do a simplified (flat) version of this quite easily with CSG by 
positioning 5 torii of the appropriate colours, using a very thin box shape 
to cut a thin slice out of each and then a very slightly thinner white box 
to create the background flag (see the example below). It uses slightly 
different cutting surface thicknesses to avoid the surfaces of two 
overlapping circles being exactly coincident, in which case it wouldn't know 
which colour to choose.

If you need to get the circles to intersect correctly you'll need to slice 
it up a bit more.
You can add a normal clause to get it looking a bit wrinkly, but that won't 
look very convincing.

To get a proper wavy shape you can use these objects to define different 
layers of pigment that can be applied to a wavy mesh or mesh2 object in the 
shape of an authentic looking flag. This is a bit complicated for beginners, 
but would give you something you can subsequently animate if you need to.

Regards,
Chris B.

camera {location <4.5,2.5,-8> look_at <4.5,2.5,0>}
light_source {<-10,20,-25>, rgb 1}

intersection {
  torus {0.97,0.08 rotate -x*90 translate <2,3,0>}
  box {-0.000001*z,<9,5,0.010001>}
  pigment {rgb <0,0,0.2>} // Blue
}
intersection {
  torus {0.97,0.08 rotate -x*90 translate <4.5,3,0>}
  box {-0.000002*z,<9,5,0.010002>}
  pigment {rgb <0,0,0>} // Black
}
intersection {
  torus {0.97,0.08 rotate -x*90 translate <7,3,0>}
  box {-0.000003*z,<9,5,0.010003>}
  pigment {rgb <1,0,0>} // Red
}
intersection {
  torus {0.97,0.08 rotate -x*90 translate <3.25,2,0>}
  box {-0.000004*z,<9,5,0.010004>}
  pigment {rgb <0.8,0.68,0>} // Yellow
}
intersection {
  torus {0.97,0.08 rotate -x*90 translate <5.75,2,0>}
  box {-0.000005*z,<9,5,0.010005>}
  pigment {rgb <0,0.2,0>} // Green
}
box {0,<9,5,0.01>
  pigment {rgb 1}
}


Post a reply to this message

From: sam kim
Subject: Re: Olympic Flag
Date: 7 Feb 2009 16:20:00
Message: <web.498df9d6a703dd17c859cee0@news.povray.org>
Thank You for your prompt reply.

I understand the procedure for csg you just described.

How would I put the torus in a mesh object?

And how can i create a flag with mesh?

Wouldn't I need to use a modeller for that?

Thank You


Post a reply to this message

From: Chris B
Subject: Re: Olympic Flag
Date: 7 Feb 2009 17:46:43
Message: <498e0f53$1@news.povray.org>
"sam kim" <nomail@nomail> wrote in message 
news:web.498df9d6a703dd17c859cee0@news.povray.org...
>
> I understand the procedure for csg you just described.
> How would I put the torus in a mesh object?
> And how can i create a flag with mesh?
> Wouldn't I need to use a modeller for that?
>

You could use a modeller if you like, but the mesh2 definition isn't too 
hard to code by hand for simple shapes.
There are also some mesh2 generation macros that you might care to Google.

The example below creates a mesh2 using nested loops, which might be a bit 
scary if you've never done any programming.
The first section of the mesh2 definition loops 100 times horizontally and 
for each 'column' loops 100 times vertically to build a grid of points. I've 
kept the x and y coordinates uniformly spaced and varied the z coordinate 
using a horizontal sine wave. The sind function is in the standard include 
file "math.inc", hence the #include statement.

The second part of the mesh2 definition uses more nested loops to define how 
the points join together as triangles. There's one less square face per side 
than points (99 rather than 100). There are two triangular faces defined 
with each iteration of the loop. They are defined by referencing the indices 
of the points defined in the first part of the mesh2.

Each loop contains a little bit of logic to add a comma to all but the last 
line.

The texture MyTexture is built up of a sequence of textures (it's a layered 
texture). Everything but the first texture (plain White) has a transparent 
background (rgbt 1) so that the lower layers show through. The intersections 
of a torus and a thin box are stretched in the Z dimension so that we have a 
good depth of colour to make sure it doesn't turn white at the extremities 
of the waves.

As I mentioned, it's a bit more complicated than is usually attempted by 
newbies, so if any of that makes your head hurt just say and I'll try and 
explain it better. :-)

Regards,
Chris B.


camera {location <4.5,9,-8> look_at <4.5,2.5,0>}
light_source {<-10,20,-25>, rgb 1}

#include "math.inc"

// First declare a layered texture
#declare MyTexture =
  texture {pigment {rgb 1}}
  texture { pigment { object {
    intersection {
      torus {0.97,0.08 rotate -x*90 translate <2,3,0>}
      box {-0.000001*z,<9,5,0.010001>}
      scale <1,1,100000>
    }
    color rgbt 1
    color rgb <0,0,0.2> // Blue
  }}}
  texture { pigment { object {
    intersection {
      torus {0.97,0.08 rotate -x*90 translate <4.5,3,0>}
      box {-0.000002*z,<9,5,0.010002>}
      scale <1,1,100000>
    }
    color rgbt 1
    color rgb <0,0,0> // Black
  }}}
  texture { pigment { object {
    intersection {
      torus {0.97,0.08 rotate -x*90 translate <7,3,0>}
      box {-0.000003*z,<9,5,0.010003>}
      scale <1,1,100000>
    }
    color rgbt 1
    color rgb <1,0,0> // Red
  }}}
  texture { pigment { object {
    intersection {
      torus {0.97,0.08 rotate -x*90 translate <3.25,2,0>}
      box {-0.000004*z,<9,5,0.010004>}
      scale <1,1,100000>
    }
    color rgbt 1
    color rgb <0.8,0.68,0> // Yellow
  }}}
  texture { pigment { object {
    intersection {
      torus {0.97,0.08 rotate -x*90 translate <5.75,2,0>}
      box {-0.000005*z,<9,5,0.010005>}
      scale <1,1,100000>
    }
    color rgbt 1
    color rgb <0,0.2,0> // Green
  }}}


// Now draw the object and apply the texture to it
mesh2 {
  vertex_vectors {10000,
    #local I = 0;
    #while (I<100)
      #local J = 0;
      #while (J<100)
          <9*I/99,5*J/99,sind(I*20)*0.1>
          #if (J<99&I<99)
            ,
          #end
        #local J = J+1;
      #end

      #local I = I+1;
    #end
  }
  face_indices {
    99*99*2,
    #local I = 1;
    #while (I<100)
      #local J = 1;
      #while (J<100)
          <(I-1)*100+(J-1),(I)*100+(J-1),(I)*100+(J)>,
          <(I)*100+(J),(I-1)*100+(J),(I-1)*100+(J-1)>
          #if (J<99&I<99)
            ,
          #end
        #local J = J+1;
      #end

      #local I = I+1;
    #end
  }
  texture {MyTexture }
}


Post a reply to this message

From: sam kim
Subject: Re: Olympic Flag
Date: 7 Feb 2009 19:55:00
Message: <web.498e2c69a703dd17c859cee0@news.povray.org>
Thank You for your prompt reply.

It was a lot to swallow, I found something peculiar about using object

as pigment while trying to figure out what you did.

The default color values for the very last object-pigment is green,

the rest of them being blue (unless transmit is used, then it's green).

pigment-object is an interesting type of csg it seems, where

the intersection of p-o and the object is kept (also the object is there)

while complement of the object does not show up.

It seems that two colors are needed for pigment-objects

first one for an in-between layer and the second for the pigment-object.

If only one color is given for a pigment-object, then the in-between layer
(everything else) takes on that color, and the pigment-object gets green.

If only one color is given for a pigment-object, then the in-between layer
(everything else) takes on blue, and the pigment-object gets green.

I am a soph. comp-sci major, so loop wasn't much of an issue, but

big thanks for explaining how this can be done with mesh

Thanks for great help, sam


Post a reply to this message

From: Chris B
Subject: Re: Olympic Flag
Date: 8 Feb 2009 05:27:22
Message: <498eb38a$1@news.povray.org>
"sam kim" <nomail@nomail> wrote in message 
news:web.498e2c69a703dd17c859cee0@news.povray.org...
> Thank You for your prompt reply.
>
> It was a lot to swallow, I found something peculiar about using object
> as pigment while trying to figure out what you did.
> The default color values for the very last object-pigment is green,
> the rest of them being blue (unless transmit is used, then it's green).

I don't think that's correct.
The first color specified is for anything outside the object, the second is 
for inside. The default for outside is blue and the default for inside 
green. If you only specify one color it's taken as the color for anything 
outside the object.

> pigment-object is an interesting type of csg it seems, where
> the intersection of p-o and the object is kept (also the object is there)
> while complement of the object does not show up.

It is something interesting and it's not something that's used very much. 
It's not a type of CSG though. Any object that has a well-defined inside and 
an outside (spheres, cylinders, planes etc.) can be used to define a pigment 
in this way. Objects are conventionally used as objects and have 
pigments/textures applied to them. The ability to use an object to create a 
pigment in this way is however something that occasionally turns out to be 
convenient.

The object isn't actually 'there' though. It is used to define a 3 
dimensional pigment. In this case the CSG objects themselves are never 
displayed in the scene, they are only used to create the pigment components 
of the layered texture that is displayed on the surface of the mesh2 object.

> It seems that two colors are needed for pigment-objects
> first one for an in-between layer and the second for the pigment-object.
> If only one color is given for a pigment-object, then the in-between layer
> (everything else) takes on that color, and the pigment-object gets green.
> If only one color is given for a pigment-object, then the in-between layer
> (everything else) takes on blue, and the pigment-object gets green.

It's really just that everything outside the 3D object is given the first 
color and that everything inside is given the second color.
The mesh2 object can be imagined as slicing through the 3D space containing 
the 3D texture. To determine which part of the layered texture to use it 
evaluates the top layer first and finds a slice of a torus, stretched in Z 
to form a hollow cylinder which it colors green. Because everything outside 
that is transparent it looks at the next layer on the texture etc. etc.

An alternative way to define this hollow cylinder shape would be to use the 
difference between two cylinders, one longer and thinner than the other. You 
could then avoid having to scale each CSG. Also, unlike the torus, cylinders 
can be defined in position, so you could do away with the need to rotate and 
translate the torus.

> I am a soph. comp-sci major, so loop wasn't much of an issue.

Ah ok. Good  :o)
Well you can probably see that the mesh2 definition can be tidied up by 
using variable definitions in place of literals. You can also use an 
elaborate collection of functions within the specification of the 3D 
coordinates in the first nested loop to distort the mesh in far more 
interesting and potentially flag-like ways.


Regards,
Chris B.


Post a reply to this message

From: Kenneth
Subject: Re: Olympic Flag
Date: 9 Feb 2009 03:35:01
Message: <web.498fe79fa703dd1f50167bc0@news.povray.org>
"sam kim" <nomail@nomail> wrote:

> I am trying to render an olympic flag by csg
> with torus and an object that can be used for flag.
>
> Which object should I use for flag, or should I throw away the csg
> idea out the window and approach it differently?

Recently, I made a waving flag for animating. It takes a different approach,
using a procedural height_field for the flag itself, then applying an
appropriate image_map to it. (In your case, you could render an image of your
finished flag graphic, then apply it.) The ripples in the flag come from
several bozo patterns, and 'fade in' from left to right (since one side of a
flag is attached to its flag pole, and doesn't wave there.) This is probably
more complex than what you asked for, but it produces a nice result. The code
contains some clock values for animating; just ignore those for rendering a
still image.

Typical flags have a width-to-height ratio of approximately 1.586:1, so I've
used that in the code. There *are* some problems when using pigments to
generate procedural height_fields, but I've left out most of those ugly
details, so that you won't get confused.

Ken W.
--------
#declare flag_function = // to make the undulating flag surface
function{
 pigment{ // a function evaluates its pigment on the X/Y plane.
   gradient x
   pigment_map{
   [0.0 color rgb .5] // .5 is a sort of 'bias' value here, forcing the flag to
                      // line up straight with X
   [0.85
    average
    pigment_map{
         [0.2
         bozo
         scale <595/944,1,1>
         scale 1.1*<.15,.5,1>
         color_map{
             [0.0 rgb 0]
             [1.0 rgb 1]
                  }
         translate 5.5*clock*x // for animating the pattern across the HF
         ]
         [1.0
         bozo
         scale <595/944,1,1>
         scale 1.1*<.35,.4,1>
         color_map{
            [0.0 rgb 0]
            [1.0 rgb 1]
                  }
         translate 2*y // just so it isn't the 'same' bozo pattern repeating.

         translate 5.5*clock*<1,1,0> // for animating the pattern across the
// HF. Because a function imposes a weird 'mirror image' of the pigment
// pattern it is made from, this direction vector--meant to be 45-deg.
// DOWNWARD--is instead made 45-deg. UPWARD.
         ]
        }
     ]
       }
   }
  }

height_field{
 function 944,595{ // actual pixel dimensions of my own image_map...ratio of
                   // 1.586 to 1
         flag_function(x,y,z).gray
                 }
      smooth
      double_illuminate

 texture{
   pigment{
   image_map{jpeg "my_flag_image.jpg" interpolate 2 once} // the once keyword
// is to keep extraneous pixels from showing up at the edges of flag.
   rotate -90*x
   scale <1,1,-1> // to reverse the image_map, due to
                  // HF function weirdness.
   }
  finish{
   ambient .3
   diffuse .8
        }

  normal{ // cloth weave
   average
   normal_map{
   [1.0 gradient x triangle_wave bump_size 1.2 scale .008]
   [1.0 gradient z triangle_wave bump_size 1.2 scale .016]
    }
   }
  }
 scale <944/595,1,1>
 rotate -90*x
 translate 5*y
 }


Post a reply to this message

From: Chris B
Subject: Re: Olympic Flag
Date: 9 Feb 2009 05:56:34
Message: <49900be2@news.povray.org>
"Kenneth" <kdw### [at] earthlinknet> wrote in message 
news:web.498fe79fa703dd1f50167bc0@news.povray.org...

> Recently, I made a waving flag for animating. It takes a different 
> approach,
> using a procedural height_field for the flag itself ...

Nice!

Prompted by Sam's question I've started building a few procedural flag 
textures that I plan to upload onto the POV-Ray Object Collection. Would you 
be ok with me incorporating an adaptation of your height_field flag code for 
that, distributed under a CC-LGPL license (authorising free reuse, 
modification and redistribution)?

Regards,
Chris B.


Post a reply to this message

From: sam kim
Subject: Re: Olympic Flag
Date: 9 Feb 2009 20:30:01
Message: <web.4990d776a703dd17c859cee0@news.povray.org>
Inside and outside I see..

Thank you for an alternative to Chris's method.

I am a "TA" for this introductory course on art and science.

The professor for this course wants to use Pov-Ray as a tool for

visualizing any scientic idea.

I learned the very basics of Povray here and there.

(The most extensive work I did was to create a flexible code

to generate a boron-nitride nanotube given any chiral vector.

http://deepspace9.sci.ccny.cuny.edu/JSR/artEntry.php?passVar=kim_01
)

I am teaching high school students (since the current professor

does not want to teach herself pov-ray because of her busy schedule)

based on my very limited knowledge.

I would like to explore the alternative method for creating flags, but

I want to venture out into different projects that involves CSG.

I told the students to use CSG to first model a castle or a tower,

showing them Gilles Trans' inspiring image, The Chess Game,

http://www.oyonale.com/image.php?code=204.

If I make substantial progress on this project, (I must do it to

set an example) I'll come back to this topic.

Thank You, Sam


Post a reply to this message

From: Chris B
Subject: Re: Olympic Flag
Date: 10 Feb 2009 10:46:54
Message: <4991a16e$1@news.povray.org>
"sam kim" <nomail@nomail> wrote in message 
news:web.4990d776a703dd17c859cee0@news.povray.org...
>
> I am teaching high school students ....
> I told the students to use CSG to first model a castle or a tower,
> showing them Gilles Trans' inspiring image, The Chess Game,
> http://www.oyonale.com/image.php?code=204.
>

Sounds quite ambitious for a first project, but I guess it's always good to 
aim high.

You might be interested in the wall generation macro at 
http://lib.povray.org/collection/blockwall/chrisb%201.1.1/blockwall.html in 
this context. It draws each individual block, so you probably wouldn't want 
to use it over very large areas or it might get a bit slow, but it may be 
handy for punctuating the scene with specific features. There's a predefined 
example with a tower containing a spiral staircase in with the source.

Regards,
Chris B.


Post a reply to this message

Goto Latest 10 Messages Next 6 Messages >>>

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