POV-Ray : Newsgroups : povray.general : Pov 4.00 question Server Time
6 Aug 2024 23:26:36 EDT (-0400)
  Pov 4.00 question (Message 11 to 20 of 73)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: Alessandro Coppo
Subject: Re: Pov 4.00 question
Date: 30 Jan 2002 16:47:00
Message: <3c5869d4@news.povray.org>
What about something like this:

------------------------------------------------------------------------
BEGIN or REAL Java code
------------------------------------------------------------------------
package samples.basic; 
 
import jxl.num.linalg.DoubleVector3; 
import jxl.graphics.color.*; 
import jpovapi.base.*; 
import jpovapi.pigments.*; 
import jpovapi.normals.*; 
import jpovapi.finishes.*; 
import jpovapi.textures.*; 
import jpovapi.lights.*; 
import jpovapi.objects.*; 
import jpovapi.atmosphere.*; 
import jpovapi.renderers.*; 
 
public class test { 
    public static void main(String[] args) { 
        Scene scn = new Scene();                               
 
        PerspectiveCamera cam = new PerspectiveCamera(); 
        cam.setAngle(70); 
        cam.setAspectRatio(4. / 3.); 
        cam.setLocation(new DoubleVector3(0, 4, -3)); 
        cam.setLookAt(new DoubleVector3()); 
        scn.setCamera(cam); 
 
        scn.add(new PointLight(new DoubleVector3( 20, 20, 20), new 
ColorDef(1., 1., 1.))); 
        scn.add(new PointLight(new DoubleVector3(-20, 20, 20), new 
ColorDef(1., 1., 1.))); 
        
        Finish f  = new Finish(); 
        f.setDiffuse(.9); 
        f.setAmbient(new ColorDef(.1, .1, .1)); 
  
        Texture t0 = new Texture(new SolidPigment(new ColorDef(1., 0., 
0.)), null, f); 
        Texture t1 = new Texture(new SolidPigment(new ColorDef(0., 1., 
0.)), null, f); 
 
        Sphere s = new Sphere(); 
        s.setTexture(t0); 
        s.setCenter(new DoubleVector3(0, .5, 0)); 
        s.setRadius(1); 
        scn.add(s); 
         
        Plane p = new Plane(); 
        p.setTexture(t1); 
        p.setNormal(DoubleVector3.Y); 
        p.setDistance(0); 
        scn.add(p); 
 
        RenderOptions ro = new RenderOptions(); 
 
        POVRayGenerator.generate(scn, ro); 
    } 
}

--------------------------------------------------------------------------------
END OF JAVA CODE
--------------------------------------------------------------------------------

Well?

Bye!!!
        Alessandro Coppo
        a.c### [at] REMOVEiolit

P.S.:
        A red sphere on a green plane with two lights.... ;-)


Post a reply to this message

From: Daniel Matthews
Subject: Re: Pov 4.00 question
Date: 30 Jan 2002 16:51:12
Message: <5865125.alrnE6jSC6@3-e.net>
Tom Melly wrote:

> Just out of curiousity....
> 
> IIRC 4.0 will be OOP - does this just refer to the source, the scripting,
> or both?

There is nothing to stop the embedding of an existing OO language ( like 
Ruby ) into the POV GUI with POV libraries or bindings to some form of POV 
API. This meta scripting language could drive the GUI and external 
utilities as well as be embedded into the POV SDL files.

You could, with a complete library, use Ruby right now as an OO meta 
language for generating POV code.


Post a reply to this message

From: Warp
Subject: Re: Pov 4.00 question
Date: 30 Jan 2002 16:55:30
Message: <3c586bd2@news.povray.org>
Jan Walzer <jan### [at] lzernet> wrote:
: you mean, if it would something like the following, it wouldn't be OO ?

  Precisely. What you described is a typical modular language.
  Modular languages (eg. Modula 2) can have classes, member variables,
member functions, public and private parts, etc, but if they don't support
inheritance and dynamic binding, they are not OO.

  OO just happens to have been the hype the last 10-20 years and people call
almost anything "object-oriented". There was a joke in some OO forums that
if you want to sell your cat, you shouldn't praise how nice and clean etc
the cat is, but you should say that the cat is object-oriented.
  People have some misunderstandings about what is object-oriented and what
isn't. Most of the time you hear/read about people discussing
object-orientedness, they are actually speaking about modularity.
  It's of course true that modularity is a very essential part of OO
programming (OO is like modularity + some extra stuff).
  I'm sure that many of these people, if they saw a language like Modula 2,
they would call it an object-oriented language.

  As I said earlier, a modular language becomes object-oriented when it
implements at least the two requirements: Inheritance and dynamic binding
(mostly virtual functions). Some modular languages do even support some
kind of inheritance (I don't remember if some version of Modula does), but
they don't support the dynamic binding part.

-- 
#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: Christopher James Huff
Subject: Re: Pov 4.00 question
Date: 30 Jan 2002 16:55:43
Message: <chrishuff-293F40.16565430012002@netplex.aussie.org>
Hmm, I just couldn't resist converting this to CSDL (or at least, 
something that resembles what CSDL eventually will be):


object POV = load("povray.csdl");

object MySphere = POV.Sphere {center = <0,0,0>; radius = 5;};

object MyMaterial = POV.Material;
MyMaterial.texture.pigment.color = < 1, 1, 1>;

MySphere.SetCenter(<5,2,5>);
MySphere.SetMaterial(MyMaterial);

MyMaterial.texture.finish.ambient = 0;

object MyBox = POV.Box {
    material = MyMaterial {
        texture.finish {
            reflection = 0.7;
            ambient = 0.0;
            diffuse = 0.2
        };
    };
};
MyBox.SetCorners(<-1,-2,-3>,<1,2,3>);
MyBox.Translate(<-5,0,8>);


POV.AddShape(MyBox)
POV.AddShape(MySphere)
POV.AddShape(
    object POV.LightSource {location = y*20; color = < 1, 1, 1>;});

POV.camera {look_at = 0; location = y*5 + z*-10;};

POV.render()

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Warp
Subject: Re: Pov 4.00 question
Date: 30 Jan 2002 16:57:34
Message: <3c586c4e@news.povray.org>
Ron Parker <ron### [at] povrayorg> wrote:
: I assume you're referring to the claim that POV SDL is OO here.  The POV
: source, though written mostly in C, could be said to have both inheritance
: and dynamic binding.

  Yes, I was talking about the POV SDL.
  I know that the povray source code, even though written in C, uses pretty
much object-oriented features (of course it's a bit clumsy to do this in C,
as it has no direct support, but possible).

-- 
#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: Christopher James Huff
Subject: Re: Pov 4.00 question
Date: 30 Jan 2002 17:03:22
Message: <chrishuff-6A30AB.17043130012002@netplex.aussie.org>
In article <3c586bd2@news.povray.org>, Warp <war### [at] tagpovrayorg> 
wrote:

>   Modular languages (eg. Modula 2) can have classes, member variables,
> member functions, public and private parts, etc, but if they don't support
> inheritance and dynamic binding, they are not OO.

But Jan's example does use inheritance (the setCenter() and 
setMaterial() methods) and wasn't complex enough to show dynamic 
binding...


>   OO just happens to have been the hype the last 10-20 years and people call
> almost anything "object-oriented". There was a joke in some OO forums that
> if you want to sell your cat, you shouldn't praise how nice and clean etc
> the cat is, but you should say that the cat is object-oriented.

I've got some free kittens, they all demonstrate inheritance pretty 
obviously and are very dynamic...

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

From: Warp
Subject: Re: Pov 4.00 question
Date: 30 Jan 2002 17:07:29
Message: <3c586ea0@news.povray.org>
Christopher James Huff <chr### [at] maccom> wrote:
: But Jan's example does use inheritance (the setCenter() and 
: setMaterial() methods)

  Uh? Calling a member function is not inheritance.

-- 
#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: Warp
Subject: Re: Pov 4.00 question
Date: 30 Jan 2002 17:12:13
Message: <3c586fbc@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
: Christopher James Huff <chr### [at] maccom> wrote:
: : But Jan's example does use inheritance (the setCenter() and 
: : setMaterial() methods)

:   Uh? Calling a member function is not inheritance.

  I think it would come closer to OO if you could do something like:

class MySphere: specializes sphere
{
  virtual setCenter(Coords)
  {
    do_something_with(Coords);
  }
}

  Then you could have functions (or macros) which take 'sphere' type objects
and to which you could give wither true spheres or your MySphere and if
this function calls 'setCenter', the correct implementation will be called.

-- 
#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: Jan Walzer
Subject: Re: Pov 4.00 question
Date: 30 Jan 2002 17:24:06
Message: <3c587286$1@news.povray.org>
My Idea was, to have a constructor that resembles the "old" SDL ...
So with some minor wrappings, you could use old code and on the other
hand, can later modify it...

So pure Java was not the solution
(Except you put this constructor in as a String (Hey, thats the idea ...
I think, I can specify such a thing ... can I ?))

--
#macro J(N A)#local a=mod(N 3);#local W=<int(mod(A,4)*2)int(-A/4)9>*2;#if
(!mod(a 2))sphere{W,2,2pigment{color rgb<a*5A/2W.x/A*5>}}#if(a<1)sphere{W
+<2,0>2 2pigment{color rgb<a*10A 10>}}#end#end#if(N>3)J(int(N/3)A+1)#end#
end blob{J(29229171 0)threshold 1translate<-6 3>}/******Jan Walzer******/


Post a reply to this message

From: Christopher James Huff
Subject: Re: Pov 4.00 question
Date: 30 Jan 2002 17:28:01
Message: <chrishuff-B6B569.17291330012002@netplex.aussie.org>
In article <586### [at] 3-enet>, Daniel Matthews <dan### [at] 3-enet> 
wrote:

> There is nothing to stop the embedding of an existing OO language ( like 
> Ruby ) into the POV GUI with POV libraries or bindings to some form of POV 
> API. This meta scripting language could drive the GUI and external 
> utilities as well as be embedded into the POV SDL files.

Well, there is one thing: licensing. The current POV license is pretty 
restrictive (though for very good reasons).
Of course, you could just write a library in that other language that 
generates a scene and calls POV. That should be perfectly legal, as long 
as you don't hide the fact that your program/library is a separate piece 
of software using POV-Ray. That's what I am doing for the CSDL POV-Ray 
scene library, and I think Moray does it.

-- 
Christopher James Huff <chr### [at] maccom>
POV-Ray TAG e-mail: chr### [at] tagpovrayorg
TAG web site: http://tag.povray.org/


Post a reply to this message

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

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