POV-Ray : Newsgroups : povray.newusers : Problems declaring objects Server Time
26 Nov 2024 05:37:59 EST (-0500)
  Problems declaring objects (Message 1 to 10 of 14)  
Goto Latest 10 Messages Next 4 Messages >>>
From: Oleguer Vilella
Subject: Problems declaring objects
Date: 14 Sep 2004 16:30:41
Message: <414754f1@news.povray.org>
Why if I do this some objects move down?
The code is:

=============The camera==============
#include "colors.inc"
#include "shapes.inc"
#include "stones.inc"
#include "textures.inc"
#include "woods.inc"
#include "metals.inc"
#include "golds.inc"
#include "glass.inc"
#include "glass_old.inc"

global_settings { assumed_gamma 2 }
background { color White }
camera { location <-10, 8, -19> look_at <0, 5, 0> }
light_source { <0, 33, 0> color White spotlight point_at <0, 0, 0> radius 50
falloff 20 tightness 0  }
light_source { <0, 19, 0> color rgb <0.5, 0.5, 0.5> }
light_source { <40, 25, 0> color rgb <1, 1, 1>
spotlight
point_at <0, 5, 0>
radius 20
falloff 20  }
===================================
============The object================
//Inici del relotge.
//Per fer el marc.
#declare Reloj =
union {
  merge {
    box {<-5,0,-55>,<0,95,55>}
    cylinder{<-5,95,0>,<0,95,0>,55}
   texture { T_Wood15 } finish { specular .51 ambient 1 diffuse .96 }
  scale 0.1 no_shadow}
//Per fer l'esfera.
difference {
    cylinder{<-10,95,0>,<20,95,0>,40}
    cylinder{<-11,95,0>,< 6,95,0>,36}
    texture { T_Gold_1D } finish { specular 2 ambient 1 diffuse .07
reflection 0.1 phong 0.3 phong_size 30 }
    scale 0.1}
no_shadow
}
//Per fer els punts dels quarts.
#declare Puntos = union {
sphere { <0, 0, 0>, 0.1 pigment { color White } finish { ambient 1 }
translate <2.1, 9.7, -4> }
sphere { <0, 0, 0>, .1 pigment { color White } finish { ambient 1 }
translate <-5.4, 9.35, -4> }
sphere { <0, 0, 0>, .1 pigment { color White } finish { ambient 1 }
translate <-2.2, 12.6, -4> }
sphere { <0, 0, 0>, .1 pigment { color White } finish { ambient 1 }
translate <-2.2, 6, -4> }
no_shadow
}
//Agulles del relotge.
#declare Agulles = union {
box { <-1, 0, -3.5> <-0.8, .2, 3.5> pigment { color Black } finish { ambient
1 } translate <0, 9.5, -4> rotate <0, 0, 0> no_shadow }
box { <-1, 0, -1> <-0.8, .2, 0.5> pigment { color Black } finish { ambient
1 } translate <1.12, -0.5, -10> rotate <60, 30, 0> no_shadow }
}
//Cilindre que unix les agulles.
#declare Cilindre =
cylinder { <0, 0.9, -0.5> <0, 1, 1> 0.035 texture { T_Gold_1D } finish {
specular 2 ambient 1 diffuse .07 reflection 0.1 phong 0.3 phong_size 30 }
rotate y*25 rotate x*-2 translate <-3.18, 8.25, -6>
}
//Declarant les diverses parts.
#declare Todo_Reloj = union {
object { Reloj rotate y*115 translate <0, 0, 0> }
object { Puntos }
object { Agulles }
object { Cilindre }
}
//Declarant tot junt.
object { Todo_Reloj  no_shadow }
===================================
If I put this on the last line "object { Todo_Reloj scale 0.5 no_shadow }",
some objects change their position. Why??
Can anyone help me?

Thanks in advance,
Oleguer


Post a reply to this message

From: Warp
Subject: Re: Problems declaring objects
Date: 14 Sep 2004 16:42:06
Message: <4147579e@news.povray.org>
Oleguer Vilella <ole### [at] infonegociocom> wrote:
> If I put this on the last line "object { Todo_Reloj scale 0.5 no_shadow }",
> some objects change their position. Why??

  Because you are scaling 'Todo_Reloj' to half size.
  Every size and distance inside 'Todo_Reloj' will be halved.

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Oleguer Vilella
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 04:13:56
Message: <4147f9c4$1@news.povray.org>
So, what if have to do? scale all the objects a part to make it slower? Is
it a good idea?

Regards,
Oleguer


news:4147579e@news.povray.org...
> Oleguer Vilella <ole### [at] infonegociocom> wrote:
> > If I put this on the last line "object { Todo_Reloj scale 0.5
no_shadow }",
> > some objects change their position. Why??
>
>   Because you are scaling 'Todo_Reloj' to half size.
>   Every size and distance inside 'Todo_Reloj' will be halved.
>
> -- 
> #macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb
x]
> [1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
> -1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// -
Warp -


Post a reply to this message

From: Tim Nikias
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 05:25:12
Message: <41480a78$1@news.povray.org>
Instead of placing everything in a union{} at the end and naming it
Todo_Reloj, why not place the different objects by themselves and only scale
what needs to be scaled? Something similiar to this:

object { Reloj rotate y*115 translate <0, 0, 0> no_shadow scale 0.5}
object { Puntos  no_shadow}
object { Agulles  no_shadow}
object { Cilindre  no_shadow}

That way, only Reloj will be scaled and the rest left untouched.
Or, leave the #declare Todo_Reloj = union{---} around all the objects, but
just scale the one needing to be scaled.

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Oleguer Vilella
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 05:53:12
Message: <41481108$1@news.povray.org>
If I do this:
===================================
object { Reloj rotate y*115 translate <0, 0, 0> scale 0.5 }
object { Puntos }
object { Agulles }
object { Cilindre }
==================================
I thinks that is your idea, I can not see the other object on the correct
place. If I do this:
====================================
object { Reloj rotate y*115 scale 0.5 }
object { Puntos scale 0.5 }
object { Agulles scale 0.5 }
object { Cilindre scale 0.5 }
=====================================
Some of the objects appear also moved.
I'm thinking....

Thanks,
Oleguer


mensaje news:41480a78$1@news.povray.org...
> Instead of placing everything in a union{} at the end and naming it
> Todo_Reloj, why not place the different objects by themselves and only
scale
> what needs to be scaled? Something similiar to this:
>
> object { Reloj rotate y*115 translate <0, 0, 0> no_shadow scale 0.5}
> object { Puntos  no_shadow}
> object { Agulles  no_shadow}
> object { Cilindre  no_shadow}
>
> That way, only Reloj will be scaled and the rest left untouched.
> Or, leave the #declare Todo_Reloj = union{---} around all the objects, but
> just scale the one needing to be scaled.
>
> Regards,
> Tim
>
> -- 
> "Tim Nikias v2.0"
> Homepage: <http://www.nolights.de>
>
>


Post a reply to this message

From: Tim Nikias
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 06:25:25
Message: <41481895@news.povray.org>
> If I do this:
> ===================================
> object { Reloj rotate y*115 translate <0, 0, 0> scale 0.5 }
> object { Puntos }
> object { Agulles }
> object { Cilindre }
> ==================================
> I thinks that is your idea, I can not see the other object on the correct
> place. If I do this:
> ====================================
> object { Reloj rotate y*115 scale 0.5 }
> object { Puntos scale 0.5 }
> object { Agulles scale 0.5 }
> object { Cilindre scale 0.5 }

Well, in your first example, you only scale Reloj, in your second example,
you scale all objects, which is just like you did before. Maybe you should
consult the Documentaion, Section 2.2.7 for some more information on
transformations.

The idea is simple: "translate" moves an object, "rotate" rotates an object
about the origin and the given axis', and "scale" scales/sizes an object in
relation to the origin (<0,0,0>). So, if an object is placed at <5,0,0> and
you scale it by .5, not only will the object's dimensions (e.g. its radius)
be sized down to half its original size, but the distance to the origin will
be sized down as well, thus placing the object at <2.5,0,0>.

Then, when you declare and union{} objects, they all get "glued" together,
so when you transform a union, all objects inside the union will get
transformed.

Now, if you want to scale an object's size, but not it's position, what do
you have to do? Let's say you've got a sphere at <5,0,0> and want to squish
it some along the x-axis, making it more disc-shaped. First, you'd have to
translate the sphere back to the origin, then you scale it, and then you
translate it back.

sphere{<5,0,0>,1
translate <-5,0,0>
scale <.25,1,1>
translate <5,0,0>
pigment{rgb 1}}

Now, for a sphere this is kinda pointless, as you could have placed it at
the origin from the beginning and thus save translating it back to the
origin:

sphere{<0,0,0>,1
scale <.25,1,1>
translate <5,0,0>
pigment{rgb 1}}

But that's the basic idea of how to transform objects. I don't know what
exactly you're after, but if you only want to scale certain parts of an
object, then only scale those, not the entire object.

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Tom Melly
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 06:26:31
Message: <414818d7$1@news.povray.org>
"Oleguer Vilella" <ole### [at] infonegociocom> wrote in message
news:41481108$1@news.povray.org...

> Some of the objects appear also moved.
> I'm thinking....

When you scale an object, the only point of the object that won't move is the
point that rests at <0,0,0> (assuming that you're scaling all axis).

To understand what is happening, try the following scene using different values
for myScale. Note that we divide the radius of the spheres by the value of
myScale. This means that the scale size doesn't affect the radius of the
spheres, only their positions.

camera {
  location  <0.0, 0.0, -10.0>
  look_at   <0.0, 0.0,  0.0>
}

light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <-30, 30, -30>
}

#declare myScale = 1;

sphere{
  0,0.25/myScale
  scale myScale
  pigment{rgb<1,0,0>}
}

sphere{
  1,0.25/myScale
  scale myScale
  pigment{rgb<0,1,0>}
}


Post a reply to this message

From: Oleguer Vilella
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 09:41:51
Message: <4148469f@news.povray.org>
Hello Tim,

I want to make all the object smaler. I understood your firts exemple and I
trayed it, but I don't understand your second exemple. You says:
=============
sphere{<0,0,0>,1
scale <.25,1,1>
translate <5,0,0>
pigment{rgb 1}}
=============
With the scale <.25, 1, 1>, how do you calculate the translate <5, 0, 0>?
If I put scale 5, how can I know the translate vector?

"for a sphere this is kinda pointless, as you could have placed it at the
origin from the beginning and thus save translating it back to the origin:"
Can you tray to explain me it again, please?

Thank you very much,
Oleguer



mensaje news:41481895@news.povray.org...
> > If I do this:
> > ===================================
> > object { Reloj rotate y*115 translate <0, 0, 0> scale 0.5 }
> > object { Puntos }
> > object { Agulles }
> > object { Cilindre }
> > ==================================
> > I thinks that is your idea, I can not see the other object on the
correct
> > place. If I do this:
> > ====================================
> > object { Reloj rotate y*115 scale 0.5 }
> > object { Puntos scale 0.5 }
> > object { Agulles scale 0.5 }
> > object { Cilindre scale 0.5 }
>
> Well, in your first example, you only scale Reloj, in your second example,
> you scale all objects, which is just like you did before. Maybe you should
> consult the Documentaion, Section 2.2.7 for some more information on
> transformations.
>
> The idea is simple: "translate" moves an object, "rotate" rotates an
object
> about the origin and the given axis', and "scale" scales/sizes an object
in
> relation to the origin (<0,0,0>). So, if an object is placed at <5,0,0>
and
> you scale it by .5, not only will the object's dimensions (e.g. its
radius)
> be sized down to half its original size, but the distance to the origin
will
> be sized down as well, thus placing the object at <2.5,0,0>.
>
> Then, when you declare and union{} objects, they all get "glued" together,
> so when you transform a union, all objects inside the union will get
> transformed.
>
> Now, if you want to scale an object's size, but not it's position, what do
> you have to do? Let's say you've got a sphere at <5,0,0> and want to
squish
> it some along the x-axis, making it more disc-shaped. First, you'd have to
> translate the sphere back to the origin, then you scale it, and then you
> translate it back.
>
> sphere{<5,0,0>,1
> translate <-5,0,0>
> scale <.25,1,1>
> translate <5,0,0>
> pigment{rgb 1}}
>
> Now, for a sphere this is kinda pointless, as you could have placed it at
> the origin from the beginning and thus save translating it back to the
> origin:
>
> sphere{<0,0,0>,1
> scale <.25,1,1>
> translate <5,0,0>
> pigment{rgb 1}}
>
> But that's the basic idea of how to transform objects. I don't know what
> exactly you're after, but if you only want to scale certain parts of an
> object, then only scale those, not the entire object.
>
> Regards,
> Tim
>
> -- 
> "Tim Nikias v2.0"
> Homepage: <http://www.nolights.de>
>
>


Post a reply to this message

From: Tim Nikias
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 09:58:24
Message: <41484a80@news.povray.org>
> With the scale <.25, 1, 1>, how do you calculate the translate <5, 0, 0>?
> If I put scale 5, how can I know the translate vector?

That's actually pretty simple: first, Povray scales the object, afterwards
it translates it to <5,0,0>. Since the sphere is already located at the
origin, the position of the sphere won't change when scaling it. Thus, it
will be squashed a little, but still be positioned at <0,0,0>. So, if I want
to place the sphere at <5,0,0>, I just have to translate it there.

> "for a sphere this is kinda pointless, as you could have placed it at the
> origin from the beginning and thus save translating it back to the
origin:"
> Can you tray to explain me it again, please?

The same as above: positions of objects only change when they are not
centered at the origin, since scaling would not only scale the object, but
also its distance to the origin.
The sphere requires a center vector and a radius. If the center vector is
<0,0,0>, the sphere is sitting right on the origin, and scaling it will only
affect the size.

But, if you place the center of the sphere somewhere else, scaling would
also affect the position/center of the sphere. Hence, we need to move it to
the origin first, scale it, and move it back, if we want to retain its
position, but not its size.

Regards,
Tim

-- 
"Tim Nikias v2.0"
Homepage: <http://www.nolights.de>


Post a reply to this message

From: Oleguer Vilella
Subject: Re: Problems declaring objects
Date: 15 Sep 2004 10:15:01
Message: <41484e65@news.povray.org>
Well, Tim, just a minute... I think that I'm doing it right now.


mensaje news:41484a80@news.povray.org...
> > With the scale <.25, 1, 1>, how do you calculate the translate <5, 0,
0>?
> > If I put scale 5, how can I know the translate vector?
>
> That's actually pretty simple: first, Povray scales the object, afterwards
> it translates it to <5,0,0>. Since the sphere is already located at the
> origin, the position of the sphere won't change when scaling it. Thus, it
> will be squashed a little, but still be positioned at <0,0,0>. So, if I
want
> to place the sphere at <5,0,0>, I just have to translate it there.
>
> > "for a sphere this is kinda pointless, as you could have placed it at
the
> > origin from the beginning and thus save translating it back to the
> origin:"
> > Can you tray to explain me it again, please?
>
> The same as above: positions of objects only change when they are not
> centered at the origin, since scaling would not only scale the object, but
> also its distance to the origin.
> The sphere requires a center vector and a radius. If the center vector is
> <0,0,0>, the sphere is sitting right on the origin, and scaling it will
only
> affect the size.
>
> But, if you place the center of the sphere somewhere else, scaling would
> also affect the position/center of the sphere. Hence, we need to move it
to
> the origin first, scale it, and move it back, if we want to retain its
> position, but not its size.
>
> Regards,
> Tim
>
> -- 
> "Tim Nikias v2.0"
> Homepage: <http://www.nolights.de>
>
>


Post a reply to this message

Goto Latest 10 Messages Next 4 Messages >>>

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