POV-Ray : Newsgroups : povray.general : Duplicate ? Server Time
5 Aug 2024 10:17:01 EDT (-0400)
  Duplicate ? (Message 7 to 16 of 26)  
<<< Previous 6 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Thorsten Froehlich
Subject: Re: Duplicate ?
Date: 24 Nov 2002 14:07:25
Message: <3de1236d$1@news.povray.org>
In article <Xns### [at] 204213191226>, "Rafal 'Raf256' Maj"
<raf### [at] raf256com> wrote:

>> If this is happening to you, you are not using the mesh object
>> properly.
>> Follow Marc's suggestion and maybe you also should try to just explain
>> your problem and wait for an answer, not immediately turn it into a
>> redundant feature request...
>
> Ok, I did it. I know that it would be better to have one mesh istead union
> of 100 meshes, but as I explain - it's a problem due to transforms in each
> "sub-mesh"

No, create one mesh, i.e. #declare mymesh = mesh { ... }.  Then transform it
using object { mymesh translate ... rotate ... }.  In consequence you have
exactly one mesh in memory and can then transform it as necessary.  The mesh
data will not be copied.  Of course, the transform data needs to be stored
for each copy of the mesh (unless you don't transform it, of course).

That way your one million pieces of grass (meshes) will take somewhere
between 100 and 500 bytes per piece of grass (meshes).

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Duplicate ?
Date: 24 Nov 2002 14:07:49
Message: <3de12385$1@news.povray.org>
In article <chr### [at] netplexaussieorg> , 
Christopher James Huff <chr### [at] maccom>  wrote:

>> 2. add new syntax :
>>   duplicate { ... }
>> that will work in same way as
>>   object {... }
>> but will re-use memory
>
> There is no need for a new syntax, copy by reference can be done with
> the existing syntax. However, it would take a lot of work, don't expect
> it before the 4.0 rewrite.
>
> The best solution to your problem would be to just put multiple grass
> blades in a single mesh tile. This is the most efficient way to do mesh
> grass.

You forgot that meshes are already reference copied.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: (exacly) - Duplicate ?
Date: 24 Nov 2002 14:09:41
Message: <3de123f5$1@news.povray.org>
In article <Xns### [at] 204213191226>, "Rafal 'Raf256' Maj"
<raf### [at] raf256com> wrote:

> Macro PutGrass - generates single grass leaf (about 200-500 triangles).
> It works as :
> mesh {
>   // loop {
>     triangle { ... }
>   // }
>   translate ... rotate ... // ((-1-))
> }
>
>
> Macro PutGrassArea calls PutGrass in loop
>
> Later, we have
> #declare GrassBlock = union { // ((-2-))
>   PutGrassArea(0,0,10,10)
> }

This in no way shows what you are doing.  Do you create multiple
"GrassBlock"s?  Or do you copy them?  Just some rough scatch of your scene
will not allow anybody to determine what you are doing wrong, nor really
help you without having to guess most of the important facts.

    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Rafal 'Raf256' Maj
Subject: Re: Duplicate ?
Date: 24 Nov 2002 14:29:45
Message: <Xns92D0CFED285BAraf256com@204.213.191.226>
"Thorsten Froehlich" <tho### [at] trfde> wrote in 
news:3de12385$1@news.povray.org

> You forgot that meshes are already reference copied.

This future will be very usefull for other objects, i.e. I made trees 
basing mostly on cones. I'm planing to make a sity - there I would use 
mostly box'es (differences / intersecions / union's of them)

-- 
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M


Post a reply to this message

From: Rafal 'Raf256' Maj
Subject: Re: (exacly) - Duplicate ?
Date: 24 Nov 2002 14:35:13
Message: <Xns92D0D0DA175ADraf256com@204.213.191.226>
#macro PutGrassLeaf(grassPos, grassPrec, grassSeed)
[...]
#macro qua(aaa,bbb,ccc,ddd) 
  triangle { aaa, bbb, ccc }  
  triangle { aaa, ccc, ddd } 
#end
[...]
mesh {
  #local iii=0;  #while (iii<=cfgHeight)
  [...]
        qua(_a,_b,_bu,_au) qua(_b,_c,_cu,_bu) // front side
        qua(_c,_d,_du,_cu) qua(_d,_e,_eu,_du) // right side
  [...]
  #local iii=iii+1;  #end 
  scale [...] rotate [...] translate grassPos+<0,-2,0>
}
#end // end of PutGrassLeaf

#macro CoverWithGrass(fromX,fromZ,toX,toZ, prec, seed1)
  [...]
  #local r1=seed(seed1);
  #local ix=fromX;  #while (ix<=toX)
   #local iy=fromZ;  #while (iy<=toZ)
      PutGrassLeaf(  <ix,0,iy>*[...] )
      #declare StGrass= StGrass+1;
    #local iy=iy+1; #end
  #local ix=ix+1; #end
#end

#declare GrassBlocks = array[5]; // 5 types of grass block
#declare I=0; #while (I<5) // create 5 blocks, 10*10 leafs each
  #declare GrassBlocks[I] = 
  union {
    CoverWithGrass(0,0,10,10, 25, 12345)
    scale .025 [...]
  } 
#declare I=I+1; #end
                    

// FINAL MACRO - using grass blocks to cover a large area :
#macro CoverWithGrassBlocks(fromX,fromZ,toX,toZ)
  #local ix=fromX;  #while (ix<=toX)
    #local iz=fromZ;  #while (iz<=toZ)
      object {
        GrassBlocks[rand([...])*5] // select grass block #0..#4
        translate <ix,0,iz>
      }  
    #local iz=iz+GBSizeZ; #end
  #local ix=ix+GBSizeX; #end
#end

// FINAL OBJECT
union {  
  CoverWithGrassBlocks(-150,-150,+150,250)  
  texture { [...] } 
}  


-- 
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M


Post a reply to this message

From: Warp
Subject: Re: Duplicate ?
Date: 24 Nov 2002 14:48:55
Message: <3de12d27@news.povray.org>
As the other have already answered, you need to #declare the mesh as
an identifier and then create instances of this identifier. Like this:

#declare GrassPatch = mesh { ... }

object { GrassPatch translate ... }
object { GrassPatch translate ... }
object { GrassPatch translate ... }
...

  When you do it this way, the mesh data will be stored in memory only once,
independently of how many instances you make.

  I hope this clears all misunderstandings.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Rafal 'Raf256' Maj
Subject: Re: Duplicate ?
Date: 24 Nov 2002 15:06:03
Message: <Xns92D0D6128DEDEraf256com@204.213.191.226>
Warp <war### [at] tagpovrayorg> wrote in news:3de12d27@news.povray.org

> #declare GrassPatch = mesh { ... }

> object { GrassPatch translate ... }
> object { GrassPatch translate ... }
> object { GrassPatch translate ... }

unfourtunetly I need 1000*1000 object { GrassPatch }
so I wanted to create BigGrassPatch that is a union of 10*10 GrassPatch'es 
and then duplicate it 100*100 times, but in current yntax it seems 
impossible without hand transforming each grass pice (as described in post 
(exacly)...)




-- 
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M


Post a reply to this message

From: Rafal 'Raf256' Maj
Subject: Re: Duplicate ?
Date: 24 Nov 2002 15:11:49
Message: <Xns92D0D70F74507raf256com@204.213.191.226>
"Thorsten Froehlich" <tho### [at] trfde> wrote in
news:3de1236d$1@news.povray.org 

> it as necessary.  The mesh data will not be copied.  Of course, the
> transform data needs to be stored for each copy of the mesh (unless
> you don't transform it, of course). 
> That way your one million pieces of grass (meshes) will take somewhere
> between 100 and 500 bytes per piece of grass (meshes).

yes, and 500*1000,000 = 500 MB is my current memory usage (with is not bad 
when realizing that scene uses about 500,000,000 * 200 triangles).

But to save more mory I wanted do organize this meshes into super-meshes - 
clusters of about 10*10 (or 50*50) sub-meshes, only problem stoping me for 
doing this is that I need to transfor each sub-mesh before placing in big-
mesh, and I can't 

mesh { // big 
  mesh { triangle[...] rotate [...] // small
  mesh { triangle[...] rotate [...] // small
  rotate [...]
}



-- 
#macro g(U,V)(.4*abs(sin(9*sqrt(pow(x-U,2)+pow(y-V,2))))*pow(1-min(1,(sqrt(
pow(x-U,2)+pow(y-V,2))*.3)),2)+.9)#end#macro p(c)#if(c>1)#local l=mod(c,100
);g(2*div(l,10)-8,2*mod(l,10)-8)*p(div(c,100))#else 1#end#end light_source{
y 2}sphere{z*20 9pigment{function{p(26252423)*p(36455644)*p(66656463)}}}//M


Post a reply to this message

From: Christopher James Huff
Subject: Re: Duplicate ?
Date: 24 Nov 2002 15:41:53
Message: <chrishuff-0EDD32.15402424112002@netplex.aussie.org>
In article <3de12385$1@news.povray.org>,
 "Thorsten Froehlich" <tho### [at] trfde> wrote:

> You forgot that meshes are already reference copied.

No I didn't...that's exactly why I suggested he make tiles of multiple 
blades each. Where did I say they weren't copied by reference? If that 
were so, I would have suggested a single giant mesh.

-- 
Christopher James Huff <cja### [at] earthlinknet>
http://home.earthlink.net/~cjameshuff/
POV-Ray TAG: chr### [at] tagpovrayorg
http://tag.povray.org/


Post a reply to this message

From: Warp
Subject: Re: Duplicate ?
Date: 25 Nov 2002 03:13:59
Message: <3de1dbc6@news.povray.org>
Rafal 'Raf256' Maj <raf### [at] raf256com> wrote:
> unfourtunetly I need 1000*1000 object { GrassPatch }
> so I wanted to create BigGrassPatch that is a union of 10*10 GrassPatch'es 
> and then duplicate it 100*100 times, but in current yntax it seems 
> impossible without hand transforming each grass pice (as described in post 
> (exacly)...)

  Have you ever heard of #while-loops? They are handy, you know...


#declare GrassPatch = mesh { ... }

#declare Xpos = 0;
#while(Xpos < 100)
  #declare Zpos = 0;
  #while(Zpos < 100)
    object { GrassPatch translate <Xpos, 0, Zpos> }
    #declare Zpos = Zpos+1;
  #end
  #declare Xpos = Xpos+1;
#end

  Magically you get 100*100 instances of the mesh.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

<<< Previous 6 Messages Goto Latest 10 Messages Next 10 Messages >>>

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