POV-Ray : Newsgroups : povray.programming : Parsing an object Server Time
28 Jul 2024 14:35:07 EDT (-0400)
  Parsing an object (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: Warp
Subject: Parsing an object
Date: 17 Jan 2001 09:17:21
Message: <3a65a971@news.povray.org>
Just noticed that my tesselation patch supports object identifiers but
not objects directly. That is, I can write:

tesselate { MyObject }

but I can't write, for example:

tesselate { object { MyObject scale 2 } }

  Although this alone seems irrelevant (because you could perfectly put the
transformations in the tesselate block instead of the object block), it's
more relevant when using the tesselation block inside meshes (because you
can tesselate the same object several times into the same mesh). For example
this way:

mesh
{ tesselate { object { MyObject translate y } }
  tesselate { object { MyObject rotate z*180 translate -y } }
}

  How should I parse that so that it would accept any form of an object and
not just object identifiers?

  I'm currently parsing it this way:

    EXPECT
      CASE (OBJECT_ID_TOKEN)
        Object = Token.Data;
      END_CASE

      ... (parsing of the other allowed keywords here) ...

      OTHERWISE
        UNGET
        EXIT
      END_CASE
    END_EXPECT


  How should I modify that?    

-- 
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

From: Ron Parker
Subject: Re: Parsing an object
Date: 17 Jan 2001 09:25:39
Message: <slrn96bar4.et0.ron.parker@fwi.com>
On 17 Jan 2001 09:17:21 -0500, Warp wrote:
>  How should I parse that so that it would accept any form of an object and
>not just object identifiers?

Call Parse_Object, which will return a pointer to an OBJECT or NULL if 
one wasn't found.  If you absolutely want the object to be able to appear
anywhere inside the curly braces, as it can in your code below, you will 
want to call Parse_Object between the UNGET and the EXIT in your OTHERWISE
clause.  However, I recommend calling Parse_Object before your EXPECT loop
and just requiring it to be the first thing inside the curly braces.

Also, since Parse_Object already recognizes OBJECT_ID_TOKENs as objects,
you can remove that CASE.

Remember to free up the object when you're done with it (even if it was
an object ID; Parse_Object makes a copy.)

>  I'm currently parsing it this way:
>
>    EXPECT
>      CASE (OBJECT_ID_TOKEN)
>        Object = Token.Data;
>      END_CASE
>
>      ... (parsing of the other allowed keywords here) ...
>
>      OTHERWISE
>        UNGET
>        EXIT
>      END_CASE
>    END_EXPECT
>
>
>  How should I modify that?    


-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Wlodzimierz ABX Skiba
Subject: Re: Parsing an object
Date: 17 Jan 2001 09:41:12
Message: <3a65af08@news.povray.org>
Warp wrote in message <3a65a971@news.povray.org>...
> tesselate { MyObject }


just like Ron Parker said : OBJECT *Parse_Object()

btw: is there automatic inheriting of parameters such like texture, no_shadow,
etc.?
I mean in tesselation patch.

ABX


Post a reply to this message

From: Chris Huff
Subject: Re: Parsing an object
Date: 17 Jan 2001 09:49:08
Message: <chrishuff-8D3D07.09501117012001@news.povray.org>
In article <3a65a971@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

>       CASE (OBJECT_ID_TOKEN)
>         Object = Token.Data;
>       END_CASE

I don't have the source code open right now, but if the object data 
sticks around past the parse stage, this will be a problem. You should 
probably use Parse_Object(), as Ron said...then just delete it when you 
aren't using it any more.

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: Warp
Subject: Re: Parsing an object
Date: 17 Jan 2001 10:07:50
Message: <3a65b545@news.povray.org>
Ron Parker <ron### [at] povrayorg> wrote:
: Call Parse_Object, which will return a pointer to an OBJECT or NULL if 
: one wasn't found.

  Ok, thanks. That's exactly it.

: Remember to free up the object when you're done with it (even if it was
: an object ID; Parse_Object makes a copy.)

  Hmm... How is it freed? Just POV_FREE(Object)?

-- 
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

From: Warp
Subject: Re: Parsing an object
Date: 17 Jan 2001 10:08:58
Message: <3a65b58a@news.povray.org>
Wlodzimierz ABX Skiba <abx### [at] abxartpl> wrote:
: btw: is there automatic inheriting of parameters such like texture, no_shadow,
: etc.?
: I mean in tesselation patch.

  The tesselation patch makes a Parse_Object_Mods((OBJECT*)tesselationMesh)
after creating the mesh.
  I don't know if that's what you mean.

-- 
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

From: Ron Parker
Subject: Re: Parsing an object
Date: 17 Jan 2001 10:20:34
Message: <slrn96be24.eus.ron.parker@fwi.com>
On 17 Jan 2001 10:07:50 -0500, Warp wrote:
>Ron Parker <ron### [at] povrayorg> wrote:
>: Remember to free up the object when you're done with it (even if it was
>: an object ID; Parse_Object makes a copy.)
>
>  Hmm... How is it freed? Just POV_FREE(Object)?

Destroy_Object.  See objects.c for parameters.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Warp
Subject: Re: Parsing an object
Date: 17 Jan 2001 10:30:28
Message: <3a65ba93@news.povray.org>
I have run into one problem. I get a:

error: Attempt to malloc zero size block (File: parse.c Line: 4385).

  This line is inside the Parse_Mesh() function and is the following:

  Object->Data->UVCoords = (UV_VECT *)POV_MALLOC(number_of_uvcoords*sizeof(UV_VECT),
"triangle mesh data");

  It unconditionally allocates space for uv-coordinates even if
number_of_uvcoords is 0 (as it is in my case where I only create triangles
with the tesselation function).

  Shouldn't it be enclosed in an if(number_of_uvcoords)?
  Will I break something if I add that condition?

  Why it doesn't crash with regular meshes (without uv-coordinates)?

-- 
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

From: Warp
Subject: Re: Parsing an object
Date: 17 Jan 2001 10:39:04
Message: <3a65bc97@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
:   Will I break something if I add that condition?

  Probably. I get a bus error, core dumped when I try to render a
tesselated mesh created this way (povray crashes when the rendering
process reaches the mesh).

  There's probably something with that uv-coord info that I don't take
into account. What is it?

-- 
char*i="b[7FK@`3NB6>B:b3O6>:B:b3O6><`3:;8:6f733:>::b?7B>:>^B>C73;S1";
main(_,c,m){for(m=32;c=*i++-49;c&m?puts(""):m)for(_=(
c/4)&7;putchar(m),_--?m:(_=(1<<(c&3))-1,(m^=3)&3););}    /*- Warp -*/


Post a reply to this message

From: Ron Parker
Subject: Re: Parsing an object
Date: 17 Jan 2001 10:41:50
Message: <slrn96bfa0.eus.ron.parker@fwi.com>
On 17 Jan 2001 10:30:28 -0500, Warp wrote:
>  Shouldn't it be enclosed in an if(number_of_uvcoords)?
>  Will I break something if I add that condition?

This sounds like a question for p.u.p.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

Goto Latest 10 Messages Next 3 Messages >>>

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