POV-Ray : Newsgroups : povray.general : Generating SDL : Re: Generating SDL Server Time
5 Aug 2024 18:20:39 EDT (-0400)
  Re: Generating SDL  
From: Warp
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

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