POV-Ray : Newsgroups : povray.advanced-users : Object Oriented POV code Server Time
25 Nov 2024 01:32:26 EST (-0500)
  Object Oriented POV code (Message 1 to 10 of 179)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Tek
Subject: Object Oriented POV code
Date: 7 Feb 2004 18:45:01
Message: <4025787d@news.povray.org>
I've decided to have a go at creating a fairly complex scene file based on lots
of autonomous entities with simple ai and physics. So, I've been figuring out
tricks for writing pov scene code in an object-oriented manner.

i.e. there basically needs to be some way of defining classes (I won't do
inheritance), with member variables and functions. And some system of creating
and destroying these on the fly. Oh, and persistent variables.

Now, I think I've actually figured out a pretty decent way to do all this, just
using the SDL. I'm happy to give details but I don't want to clog up this
message with all that info.

But anyway, the reason I'm posting: I was just wondering has anyone done this
before? Either within the SDL, or as a modification to pov to support simple
data structures and function callbacks?

Oh, and do you think it should be oriented or orientated? ;)

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Christopher James Huff
Subject: Re: Object Oriented POV code
Date: 7 Feb 2004 23:23:37
Message: <cjameshuff-EF7F20.23235207022004@news.povray.org>
In article <4025787d@news.povray.org>, "Tek" <tek### [at] evilsuperbraincom> 
wrote:

> But anyway, the reason I'm posting: I was just wondering has anyone done this
> before? Either within the SDL, or as a modification to pov to support simple
> data structures and function callbacks?

Never actually done it, but I've considered doing something based on 
arrays...it'd be hellishly complex and inefficient. And it was limited 
to passive data structures, not really anything like objects.


> Oh, and do you think it should be oriented or orientated? ;)

Oriented. "Orientated" is a synonym, but sounds odd and I've never seen 
a "professional" source use that spelling in relation to object 
orientation. "Oriention" isn't a word though, so orientated is probably 
the original spelling.

-- 
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: Tek
Subject: Re: Object Oriented POV code
Date: 8 Feb 2004 03:02:50
Message: <4025ed2a$1@news.povray.org>
> Never actually done it, but I've considered doing something based on
> arrays...it'd be hellishly complex and inefficient. And it was limited
> to passive data structures, not really anything like objects.

Well that's kinda similar to what I'm thinking.

my theory is I interface to everything via macros. So if I want to get the
"position" member of an object that I have "pointer" to, this would actually
work by using indeces, not pointers, and having an array of positions. But I can
write the code via macros so it looks sorta like it's using structures!

The problem with this is that I need one set of arrays for each different class
of object/structure. And those arrays would need to be long enough to hold every
instance I would be likely to create. Still, that's not a big problem.

The other, much more cunning, trick is to be able to have functions (actually
macros) invoked differently for different objects. e.g. lets imagine I have lots
of classes that have the same basic structure, but different functions (e.g.
good guys and bad guys with different AI routines). The thing is I want to be
able to invoke different functions according to what class of object I'm
accessing *without needing a big switch statement handling all classes*.

My cunning trick is to store, as a parameter in the "structure", the name of the
macro I want to invoke for this object. e.g. "GoodGuyUpdate". Then I can save
this string out to a scratch file with a string of parameters (which will be the
same since this is just an implementation of a virtual function, if you want to
look at it like that). So we get a scratch file saying
"GoodGuyUpdate(myObject,deltaTime)" or something. Then just include that scratch
file to invoke it!

It's somewhat cumbersome, but it would certainly work.

In fact, I think I'm gonna start building this framework now :)

-- 
Tek
www.evilsuperbrain.com


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 8 Feb 2004 07:30:50
Message: <40262bfa$1@news.povray.org>
For anyone who's interested, I've just put the first building block of my
technique in p.b.s-f.

-- 
Tek
www.evilsuperbrain.com


"Tek" <tek### [at] evilsuperbraincom> wrote in message news:4025787d@news.povray.org...
> I've decided to have a go at creating a fairly complex scene file based on
lots
> of autonomous entities with simple ai and physics. So, I've been figuring out
> tricks for writing pov scene code in an object-oriented manner.
>
> i.e. there basically needs to be some way of defining classes (I won't do
> inheritance), with member variables and functions. And some system of creating
> and destroying these on the fly. Oh, and persistent variables.
>
> Now, I think I've actually figured out a pretty decent way to do all this,
just
> using the SDL. I'm happy to give details but I don't want to clog up this
> message with all that info.
>
> But anyway, the reason I'm posting: I was just wondering has anyone done this
> before? Either within the SDL, or as a modification to pov to support simple
> data structures and function callbacks?
>
> Oh, and do you think it should be oriented or orientated? ;)
>
> -- 
> Tek
> www.evilsuperbrain.com
>
>


Post a reply to this message

From: ABX
Subject: Re: Object Oriented POV code
Date: 9 Feb 2004 03:15:38
Message: <vcge20l4jv2o4ikggniv4cf1hgmm5rrvbh@4ax.com>
On Sat, 7 Feb 2004 15:45:04 -0800, "Tek" <tek### [at] evilsuperbraincom> wrote:
> modification to pov to support simple
> data structures and function callbacks?

http://news.povray.org/povray.advanced-users/19907/

ABX


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 9 Feb 2004 04:19:47
Message: <402750b3$1@news.povray.org>
Ooh that's a nice technique! You mind if I borrow it? :)

-- 
Tek
www.evilsuperbrain.com

"ABX" <abx### [at] abxartpl> wrote in message
news:vcge20l4jv2o4ikggniv4cf1hgmm5rrvbh@4ax.com...
> On Sat, 7 Feb 2004 15:45:04 -0800, "Tek" <tek### [at] evilsuperbraincom> wrote:
> > modification to pov to support simple
> > data structures and function callbacks?
>
> http://news.povray.org/povray.advanced-users/19907/
>
> ABX


Post a reply to this message

From: JC (Exether)
Subject: Re: Object Oriented POV code
Date: 9 Feb 2004 18:14:03
Message: <4028143b$1@news.povray.org>
I had a try at doing some code for data aggregation, not dealing with 
functions. I wanted to do something general to construct, manipulate, 
save, load print and destroy any aggregation of data, but I stopped when 
I realized that I was not able to query the type of my data (hence no 
print or save).

Just in case it would give you any idea, I post my files on p-t-scene-files.

JC

Tek wrote:

> I've decided to have a go at creating a fairly complex scene file based on lots
> of autonomous entities with simple ai and physics. So, I've been figuring out
> tricks for writing pov scene code in an object-oriented manner.
> 
> i.e. there basically needs to be some way of defining classes (I won't do
> inheritance), with member variables and functions. And some system of creating
> and destroying these on the fly. Oh, and persistent variables.
> 
> Now, I think I've actually figured out a pretty decent way to do all this, just
> using the SDL. I'm happy to give details but I don't want to clog up this
> message with all that info.
> 
> But anyway, the reason I'm posting: I was just wondering has anyone done this
> before? Either within the SDL, or as a modification to pov to support simple
> data structures and function callbacks?
> 
> Oh, and do you think it should be oriented or orientated? ;)
>


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 10 Feb 2004 00:07:08
Message: <402866fc$1@news.povray.org>
Hmm... the array of arrays idea is interesting. In my system I never need to
query the type of data (it will only be accessed by code that knows what to
expect). It certainly has some potential.

Thanks!
-- 
Tek
www.evilsuperbrain.com

"JC (Exether)" <no### [at] spamfr> wrote in message news:4028143b$1@news.povray.org...
> I had a try at doing some code for data aggregation, not dealing with
> functions. I wanted to do something general to construct, manipulate,
> save, load print and destroy any aggregation of data, but I stopped when
> I realized that I was not able to query the type of my data (hence no
> print or save).
>
> Just in case it would give you any idea, I post my files on p-t-scene-files.
>
> JC
>
> Tek wrote:
>
> > I've decided to have a go at creating a fairly complex scene file based on
lots
> > of autonomous entities with simple ai and physics. So, I've been figuring
out
> > tricks for writing pov scene code in an object-oriented manner.
> >
> > i.e. there basically needs to be some way of defining classes (I won't do
> > inheritance), with member variables and functions. And some system of
creating
> > and destroying these on the fly. Oh, and persistent variables.
> >
> > Now, I think I've actually figured out a pretty decent way to do all this,
just
> > using the SDL. I'm happy to give details but I don't want to clog up this
> > message with all that info.
> >
> > But anyway, the reason I'm posting: I was just wondering has anyone done
this
> > before? Either within the SDL, or as a modification to pov to support simple
> > data structures and function callbacks?
> >
> > Oh, and do you think it should be oriented or orientated? ;)
> >


Post a reply to this message

From: David Wallace
Subject: Re: Object Oriented POV code
Date: 10 Feb 2004 11:32:36
Message: <402907a4@news.povray.org>
"Tek" <tek### [at] evilsuperbraincom> wrote in message
news:4025787d@news.povray.org...
> I've decided to have a go at creating a fairly complex scene file based on
lots
> of autonomous entities with simple ai and physics. So, I've been figuring
out
> tricks for writing pov scene code in an object-oriented manner.
>
> i.e. there basically needs to be some way of defining classes (I won't do
> inheritance), with member variables and functions. And some system of
creating
> and destroying these on the fly. Oh, and persistent variables.
>
> Now, I think I've actually figured out a pretty decent way to do all this,
just
> using the SDL. I'm happy to give details but I don't want to clog up this
> message with all that info.
>
> But anyway, the reason I'm posting: I was just wondering has anyone done
this
> before? Either within the SDL, or as a modification to pov to support
simple
> data structures and function callbacks?
>
> Oh, and do you think it should be oriented or orientated? ;)
>
> -- 
> Tek
> www.evilsuperbrain.com
>
>
My principal "object" is the #include file.  Each object definition,
including macros, variables, etc. can be placed in this file.

If you want a macro to use the object, just use the filename as a string
parameter:

#macro ObUser(iFile, oFile)
    #include iFile
    #open oFile
    ...
    #write oFile, Data
    ...
    #close oFile
#end

I use this tactic frequently.  Macros that would otherwise use a large
number of parameters are greatly simplified by this method.  Macros,
functions, and primitives that might not otherwise be available as macro
parameters can be provided for this way.

#include files also carry one extra benefit: you can add descriptive
comments and variable names that make code reading easier

Try it some time.


Post a reply to this message

From: Tek
Subject: Re: Object Oriented POV code
Date: 11 Feb 2004 01:12:49
Message: <4029c7e1$1@news.povray.org>
Maybe I'm misunderstanding you, but how does having each object as an include
file help? Or do you mean have each class as an include file?

BTW, did you see the technique I posted in p.b.s-f? That sounds pretty similar
to what you're suggesting. It solves the problem of indirect function
invocation, but but I still haven't found a nice way of defining
structures/classes. Can your system do this?

Basically I want to be able to do things like this:

myMoveableObject = new Monkey; //Monkey is a class
...
myMoveableObject.move(deltaTime);
...
if ( myMoveableObject.position == invalid ) delete myMoveableObject;

-- 
Tek
www.evilsuperbrain.com


"David Wallace" <dar### [at] earthlinknet> wrote in message
news:402907a4@news.povray.org...
>
> "Tek" <tek### [at] evilsuperbraincom> wrote in message
> news:4025787d@news.povray.org...
> > I've decided to have a go at creating a fairly complex scene file based on
> lots
> > of autonomous entities with simple ai and physics. So, I've been figuring
> out
> > tricks for writing pov scene code in an object-oriented manner.
> >
> > i.e. there basically needs to be some way of defining classes (I won't do
> > inheritance), with member variables and functions. And some system of
> creating
> > and destroying these on the fly. Oh, and persistent variables.
> >
> > Now, I think I've actually figured out a pretty decent way to do all this,
> just
> > using the SDL. I'm happy to give details but I don't want to clog up this
> > message with all that info.
> >
> > But anyway, the reason I'm posting: I was just wondering has anyone done
> this
> > before? Either within the SDL, or as a modification to pov to support
> simple
> > data structures and function callbacks?
> >
> > Oh, and do you think it should be oriented or orientated? ;)
> >
> > -- 
> > Tek
> > www.evilsuperbrain.com
> >
> >
> My principal "object" is the #include file.  Each object definition,
> including macros, variables, etc. can be placed in this file.
>
> If you want a macro to use the object, just use the filename as a string
> parameter:
>
> #macro ObUser(iFile, oFile)
>     #include iFile
>     #open oFile
>     ...
>     #write oFile, Data
>     ...
>     #close oFile
> #end
>
> I use this tactic frequently.  Macros that would otherwise use a large
> number of parameters are greatly simplified by this method.  Macros,
> functions, and primitives that might not otherwise be available as macro
> parameters can be provided for this way.
>
> #include files also carry one extra benefit: you can add descriptive
> comments and variable names that make code reading easier
>
> Try it some time.
>
>
>


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

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