POV-Ray : Newsgroups : povray.binaries.programming : My idea: Developers need tips! Help me, please! : Re: My idea: Developers need tips! Help me, please! Server Time
19 May 2024 13:21:30 EDT (-0400)
  Re: My idea: Developers need tips! Help me, please!  
From: clipka
Date: 2 Oct 2016 15:10:43
Message: <57f15bb3$1@news.povray.org>
Am 02.10.2016 um 19:27 schrieb LanuHum:
> clipka <ano### [at] anonymousorg> wrote:
> 
>> That said, the thing you are looking for is the class `SceneData`
>> declared in `source/core/scene/scenedata.h`
> 
> All right. I watched this file.
> 
>         ~SceneData();
> 
>         /// list of all shape objects
>         vector<ObjectPtr> objects;
>         /// list of all global light sources
>         vector<LightSource *> lightSources;
>         /**
>          *  Create new scene specific data.
>          */
>         SceneData(GenericFunctionContextFactory* fcf);
> 
> A pointer to the object is absent,

I don't know what you mean by that. We have the `vector<ObjectPtr>
objects` there, nice and square.


> How to implement my.cpp?
> 
> SceneData::SceneData(){};
> 
> SceneData *scene = new SceneData();
> for (ulong i = 0; i < numberBlenderObjects; i++){
>     ObjectPtr *object = new ObjectPtr();
>     object = BlenderObjects[i];
>     scene -> objects.push_back(object);}

Uh... no, not exactly:

ObjectPtr is not a class type; it's a /pointer/ to a class type
(currently a plain C pointer, but might be made a `shared_ptr<>` some
time in the future). Also, the type it points to is actually an abstract
polymorphic base type, `ObjectBase`; the type you'll need to instantiate
depends on the primitive type you want; for example:

   Sphere *pSphere = new Sphere();
   pSphere->Center = Vector3d(BlenderObjects[i].Center);
   pSphere->Radius = BlenderObjects[i].Radius;
   scene->objects.push_back (pSphere);

or:

   Box *pBox = new Box();
   pBox->bounds[0] = Vector3d(BlenderObjects[i].BottomLeft);
   pBox->bounds[1] = Vector3d(BlenderObjects[i].TopRight);
   scene->objects.push_back (pBox);

or:

   Mesh *pMesh = new Mesh();
   // ...
   scene->objects.push_back (pMesh);

Note that much of the sanity-checking and precomputing of various stuff
is still implemented in the parser, rather than the primitive classes
where it would belong.

Also, in addition to the stuff the parser does while parsing the SDL
file, there are some additional steps required between the parsing and
the invocation of the render engine, such as propagating some
information between parent and child objects, setting up a bounding
hierarchy to speed up rendering, and other stuff like that.

Don't say I didn't warn you...


Post a reply to this message

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