POV-Ray : Newsgroups : povray.general : Generating SDL Server Time
18 Nov 2024 13:16:56 EST (-0500)
  Generating SDL (Message 1 to 10 of 18)  
Goto Latest 10 Messages Next 8 Messages >>>
From: pto
Subject: Generating SDL
Date: 15 Aug 2002 07:39:44
Message: <3D5B9300.9050709@cs.helsinki.fi>
I started making library to generate pov SDL with c++. The idea is to 
have API like this:

int main() {
	p_camera();begin();
		p_look_at(); p_vector(2,3,2);
		p_angle(); p_float(135);
	end();

	box(); begin();
		p_float(-1); p_float(9);
		p_pigment(); begin();
			p_rgb(.8);
		end();
		p_finish();begin();
			p_reflection(); p_float(.3);
		end();
	end();
}

which produces POV SDL like this:

camera { look_at <2,3,2> angle 135 } box { -1 9 pigment { rgb 0.8 } 
finish { reflection 0.3 } }

Large parts of this API can be generated directly from list of reserved 
words and only some parts need to be hand coded (vector, color etc.).

With this API one could implements his own routines and take advantage 
from full power of c++. Greatest problem I see is that error messages 
would be difficult to map into code.

void camera(vector a,vector b,float c)
{
	p_camera();p_begin();
		p_location();p_vector(a);
		p_look_at();p_vector(b);		
		p_angle();p_float(c);
	p_end();	
}

Here is what I have allready made
http://www.cs.helsinki.fi/u/ojamies/pov++/

I have just joined these groups so I don't know if someone has allready 
made this kind of system for POV (and I don't have patience to read few 
thousand mail headers). Does anyone have links?

pto
-- 
camera{look_at y+2angle 135} box{-1 9pigment{rgb.8} finish{reflection.3} 
no_image}#macro l(a) light_source{8*a rgb a/vlength(a)fade_power 2 
fade_distance 3}#end l(x)l(y)l(z)l(1-x)l(1-y)l(1-z)l(x+y+z) sphere{4 3 
finish{reflection 1}no_shadow}//pto


Post a reply to this message

From: Tom Melly
Subject: Re: Generating SDL
Date: 15 Aug 2002 08:26:48
Message: <3d5b9e08$1@news.povray.org>
"pto" <oja### [at] cshelsinkifi> wrote in message
news:3D5### [at] cshelsinkifi...
>

<snip>

Just out of curiosity, what would be the point of this? (I have a pretty good
idea, but seek clarification).


Post a reply to this message

From: Warp
Subject: Re: Generating SDL
Date: 15 Aug 2002 08:30:58
Message: <3d5b9f01@news.povray.org>
I can't but wonder how writing this:

> int main() {
> 	p_camera();begin();
> 		p_look_at(); p_vector(2,3,2);
> 		p_angle(); p_float(135);
> 	end();

> 	box(); begin();
> 		p_float(-1); p_float(9);
> 		p_pigment(); begin();
> 			p_rgb(.8);
> 		end();
> 		p_finish();begin();
> 			p_reflection(); p_float(.3);
> 		end();
> 	end();
> }

would be better than writing this:

> camera { look_at <2,3,2> angle 135 } box { -1 9 pigment { rgb 0.8 } 
> finish { reflection 0.3 } }

-- 
#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: Generating SDL
Date: 15 Aug 2002 09:16:16
Message: <Xns926B9AB4DF2B8raf256com@204.213.191.226>
pto <oja### [at] cshelsinkifi> wrote in news:3D5### [at] cshelsinkifi

> 
> I started making library to generate pov SDL with c++. The idea is to 

grr... that is my idea ! ;-)

and about point of this - making complicated images/animations that would 
be REALY hard to do via SDL only. Watch .b.i in inext few days :)

-- 
#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: Mr Art
Subject: Re: Generating SDL
Date: 15 Aug 2002 09:41:24
Message: <3D5BAF6D.9020900@chesapeake.net>
Warp wrote:
>   I can't but wonder how writing this:
> 
> 
>>int main() {
>>	p_camera();begin();
>>		p_look_at(); p_vector(2,3,2);
>>		p_angle(); p_float(135);
>>	end();
> 
> 
>>	box(); begin();
>>		p_float(-1); p_float(9);
>>		p_pigment(); begin();
>>			p_rgb(.8);
>>		end();
>>		p_finish();begin();
>>			p_reflection(); p_float(.3);
>>		end();
>>	end();
>>}
> 
> 
> would be better than writing this:
> 
> 
>>camera { look_at <2,3,2> angle 135 } box { -1 9 pigment { rgb 0.8 } 
>>finish { reflection 0.3 } }
> 
> 

It would seem to be that they are letting the computer do the writing.
Maybe they want to generate some data and let the program genetate
"snapshots" of what is going on that POV will then render...


Post a reply to this message

From: Christopher James Huff
Subject: Re: Generating SDL
Date: 15 Aug 2002 13:18:02
Message: <chrishuff-60B890.12045315082002@netplex.aussie.org>
Looks a little similar to OpenGL. Something like "begin(kCamera)" would 
be more compact and get rid of the repetitive "xxx(); begin();" pattern. 
You would of course put it in its own namespace to avoid name conflicts.

I don't really see the point of this approach though, it doesn't take 
advantage of any C++ features. The only advantage I see is that it could 
probably be mostly automatically generated. How about something more 
like:

begin("camera");
key("look_at"); vecval(2, 3, 2);
key("angle"); vecval(135);
end();

or:
//the constructor pushes the camera onto a stack of things being
//constructed
Camera cam1();
key("look_at"); vecval(2, 3, 2);
key("angle"); vecval(135);
Close();//Pops the camera off the construction stack

SetCamera(cam1);

I wouldn't like using either of these though, I personally would do 
something like:

Scene scene;

scene.SetCamera(PerspectiveCamera);
scene.GetCamera().SetLookAt(vec(2, 3, 2));
scene.GetCamera().SetAngle(135);

Material boxMat;
boxMat.SetPigment(SolidPigment(0.8));
boxMat.GetFinish().SetReflection(0.3);

scene.AddShape(Box(-1, 9, boxMat));

scene.OGLPreview();
outfile << scene;

This is similar to what I'm doing for the CSDL/Sapphire POV library, 
though things are a little different with a prototype-based OOL. 
Sapphire is slower than C++ because it is interpreted, but faster and 
more flexible than POV-Script. It will look more like:

delegate load POV: "povray.csdl";

function run() {
    .camera.SetLookAt(< 2, 3, 2>);
    .camera.SetAngle(135);
    
    //make() is a method of the POV-Ray library object that
    //clones a shape object and adds the clone to the scene,
    //and returns the clone.
    .make(.Box) {
        pta = -1;
        ptb = 9;
        material {
            clone pigment: SolidPigment {color = 0.8};
            finish.SetReflection(0.3);
        };
    };

    clone fout: stream;
    fout.open("outputfile.pov");
    fout.write(POV);
};

-- 
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: Christopher James Huff
Subject: Re: Generating SDL
Date: 15 Aug 2002 13:19:53
Message: <chrishuff-14E135.12064515082002@netplex.aussie.org>
The C++ version could be used in a C++ program that does things like 
particle and cloth simulation that are difficult to program and 
extremely slow to compute directly in POV.

-- 
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: Generating SDL
Date: 15 Aug 2002 14:22:47
Message: <3d5bf176@news.povray.org>
Christopher James Huff <chr### [at] maccom> wrote:
> The C++ version could be used in a C++ program that does things like 
> particle and cloth simulation that are difficult to program and 
> extremely slow to compute directly in POV.

  I don't see any reason for making it that complicated.

-- 
#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: Warp
Subject: Re: Generating SDL
Date: 15 Aug 2002 14:46:56
Message: <3d5bf720@news.povray.org>
It still looks kind of ugly.
  With the power or C++, you can get close to what POV-Ray SDL does. For
example, you could have a vector class which is almost as flexible as in
povray, like:

class Vec
{
 public:
    Vec();
    Vec(double);
    Vec(double, double, double);
    Vec(const Vec& rhs);

    Vec operator+(const Vec& rhs);
    Vec operator-(const Vec& rhs);
    Vec operator*(const Vec& rhs);
    // etc etc...
};


const Vec x(1,0,0);
const Vec y(0,1,0);
const Vec z(0,0,1);
double vlength(const Vec&);
// etc etc...

  For example the camera object could be defined as:

class Camera
{
 public:
    Camera(const Vec& location = -z, const Vec& look_at = 0);
    Vec location();
    void location(const Vec& loc);
    // etc etc...
};

  When the library is defined like that, you could create a scene like this:

Camera cam(Vec(1,2,3), 0);
// Could also be:
//   Camera cam(-z*20, y*2); // or Camera cam(10, Vec(1,2,3));
// or:
//   Camera cam;
//   cam.location(Vec(1,2,3)); // or cam.location(5);
//   cam.look_at(0); // or cam.look_at(Vec(2,3,4));
cam.angle(35);

Light l(Vec(4,5,6), 1);
// Could also be:
//   Light l(y*100, x+y);

Box obj1(-1, 1)
Sphere obj2(y, 1), obj3(x, .5);
Difference csg1;
csg1 << obj1 << obj2 << obj3;
csg1.texture(Texture(Pigment(RGB(.5,1,1))));

outfile << cam << l << csg1;

-- 
#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: Andrew Wilcox
Subject: Re: Generating SDL
Date: 15 Aug 2002 15:15:22
Message: <3d5bfdca$1@news.povray.org>
I have something similar in Java that I plan on releasing, I just haven't
had the time to clean it up.  I wanted objects to work with rather than a
scripting language.  It allows you to create things like tables that you can
query later, to ask how to place things on top of them.  There are tons of
uses.  Here's a snippet from some of my code.


  public static void main(String[] args) {
      SceneQuick scene = new SceneQuick();
      scene.setGroundPlane(false);
      scene.build();
      {
         Camera camera = new Camera("45");
         camera.setLocation(0, 2, -6);
         camera.setLookAt(0, 0, 0);
         camera.rotate(0,45,0);
         scene.addCamera(camera);
      }

      SurfaceFactory surfaces = D3PartFactory.getSurfaceFactory();

      D3Object obj = scene.add(new Xylophone());
      obj.rotate(0,30,0);
      //obj.translate(0,0.0,0);

      Camera camera = scene.getCamera(0);
      camera.setLocation(0, 4.5, -6.0);
      camera.setLookAt(0, 0, 0);
      camera.rotate(0,45,0);
      scene.add(new LightSource(LightSource.POINTLIGHT, new D3Vector(
30,1,-30), surfaces.colour(1,1,1)));
      scene.add(new LightSource(LightSource.POINTLIGHT, new
D3Vector(-30,1,-30), surfaces.colour(1,1,1)));
      try {
         scene.render(args);
      }
      catch(Throwable t) {
         t.printStackTrace();
      }
   }

--
#macro Q(A,E,W)box{-A/2,A/2pigment{rgb 9*W}translate E*A+W/1000}#end#macro
M(D,E)#local A=1/pow(3,D);#if(D<3)#local C=D+1;union{M(C,1)M(C,x+y)M(C,x+z)
M(C,y+z)M(C,x+y-z)M(C,x+z-y)M(C,y+z-x)M(C,x-y)M(C,z-x)M(C,y-z)M(C,y-x)M(C,
x-z)M(C,z-y)M(C,x-y-z)M(C,y-x-z)M(C,z-x-y)translate A*E}#else Q(A,E,x)Q(A,E
,y)Q(A,E,z)#end#end union{M(0,0)rotate<45,145,0>translate z*2}//Andrew


Post a reply to this message

Goto Latest 10 Messages Next 8 Messages >>>

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