POV-Ray : Newsgroups : povray.binaries.programming : My idea: Developers need tips! Help me, please! Server Time
26 Apr 2024 10:58:07 EDT (-0400)
  My idea: Developers need tips! Help me, please! (Message 31 to 40 of 50)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 15 Oct 2016 14:20:01
Message: <web.58027268397eea9f7a3e03fe0@news.povray.org>
"LanuHum" <Lan### [at] yandexru> wrote:

> A new attempt: the bootloader on a Cython.

It kills me. :) Sometime later :)


> 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, the light pointer is present.
> 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);}

I want to do this:

#include <map>
#include "core/scene/object.h"
#include "core/shape/mesh.h"

using namespace pov;

class BlenderScene{

    public:
        .....
        std::map<string,ObjectBase*>  shapes;
        .....
}

BlenderScene *bscene = new BlenderScene()
for (ulong i = 0; i < numberBlenderObjects; i++){
    if (type==0){
       Mesh *pMesh = new Mesh();
       ...// Building povray mesh from blender
       bscene->shapes.insert( pair<string,Mesh>(name,pMesh) );
}}

Next in the povray_run...
SceneData *scene = new SceneData();
If in .pov string:
 #declare Cube = mesh2{load_from_bscene}:

scene -> objects.push_back(bscene->shapes.find(name));

If the static mesh: will not restart.
If mesh use bone or other modifiers which move vertices:
  ob=bscene->shapes.find(name);
  bscene->shapes.erase (ob);
  Mesh *pMesh = new Mesh();
  ...// Building povray mesh from blender
  bscene->shapes.insert( pair<string,Mesh>(name,pMesh) );


Control of objects in the bscene is performed to parse...


Post a reply to this message

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 21 Oct 2016 12:30:00
Message: <web.580a419b397eea9f7a3e03fe0@news.povray.org>
Now I know how to create a mesh:

/********************************************************************************
*
*
*                                   BlenderMesh.h
*
*
*
********************************************************************************/
#ifndef BLENDERMESH_H
#define BLENDERMESH_H

#include <vector>
#include <string>
#include "Vector.h"

namespace povanim{

class BlenderMesh{
    public:
    std::vector<Vector3*>           vertex_vectors;  //Vector3 double
    std::vector<Vector3*>           normal_vectors;
    std::vector<Vector2*>           uv_vectors;
    std::vector<std::string>        texture_list;
    std::vector<Vector3UL*>         face_indices;  //Vector3 unsigned long
    std::vector<Vector3UL*>         face_textures;
    std::vector<Vector3UL*>         normal_indices;
    std::vector<Vector3UL*>         uv_indices;
                                    BlenderMesh();
                                    ~BlenderMesh();
    void                            addVertex(double x, double y, double z);
    void                            addNormal(double x, double y, double z);
    void                            addUV(double x, double y);
    void                            addTexture(std::string texture);
    void                            addFace(unsigned long x, unsigned long y,
unsigned long z);
    void                            addFaceTextures(unsigned long x, unsigned
long y, unsigned long z);
    void                            addNormalIndices(unsigned long x, unsigned
long y, unsigned long z);
    void                            addUVIndices(unsigned long x, unsigned long
y, unsigned long z);
};
}
#endif


To be continued.
:)


Post a reply to this message

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 30 Oct 2016 02:40:01
Message: <web.581594de397eea9f7a3e03fe0@news.povray.org>
"LanuHum" <Lan### [at] yandexru> wrote:

> To be continued.
> :)

Now we need to understand here:
povray-master/source/parser/parser.cpp:
6704:       CASE (OBJECT_ID_TOKEN)
            Object = Copy_Object(reinterpret_cast<ObjectPtr>(Token.Data));
            EXIT
            END_CASE

In .pov:
object{Human}

But Human no declare:
File '/tmp/Scene.pov' line 17: Parse Error: Expected 'object', undeclared
 identifier 'Human' found instead
Fatal error in parser: Cannot parse input.
Render failed

It needs to be fixed:
if (undeclared identifier){go to BlenderScene}

:)


Post a reply to this message

From: clipka
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 30 Oct 2016 04:26:34
Message: <5815aeba@news.povray.org>
Am 30.10.2016 um 07:36 schrieb LanuHum:

> Now we need to understand here:
> povray-master/source/parser/parser.cpp:
> 6704:       CASE (OBJECT_ID_TOKEN)
>             Object = Copy_Object(reinterpret_cast<ObjectPtr>(Token.Data));
>             EXIT
>             END_CASE
> 
> In .pov:
> object{Human}
> 
> But Human no declare:
> File '/tmp/Scene.pov' line 17: Parse Error: Expected 'object', undeclared
>  identifier 'Human' found instead
> Fatal error in parser: Cannot parse input.
> Render failed
> 
> It needs to be fixed:
> if (undeclared identifier){go to BlenderScene}

Note that in the POV-Ray parser, the job of identifying the type of a
variable is integrated into the tokenizer: The token type is only set to
OBJECT_ID_TOKEN if the variable is defined as a geometric object
(sphere, box, whatever).

For undeclared identifiers, the tokenizer sets the token type to
IDENTIFIER_TOKEN.


Post a reply to this message

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 30 Oct 2016 04:45:00
Message: <web.5815b226397eea9f7a3e03fe0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 30.10.2016 um 07:36 schrieb LanuHum:
>
> > Now we need to understand here:
> > povray-master/source/parser/parser.cpp:
> > 6704:       CASE (OBJECT_ID_TOKEN)
> >             Object = Copy_Object(reinterpret_cast<ObjectPtr>(Token.Data));
> >             EXIT
> >             END_CASE
> >
> > In .pov:
> > object{Human}
> >
> > But Human no declare:
> > File '/tmp/Scene.pov' line 17: Parse Error: Expected 'object', undeclared
> >  identifier 'Human' found instead
> > Fatal error in parser: Cannot parse input.
> > Render failed
> >
> > It needs to be fixed:
> > if (undeclared identifier){go to BlenderScene}
>
> Note that in the POV-Ray parser, the job of identifying the type of a
> variable is integrated into the tokenizer: The token type is only set to
> OBJECT_ID_TOKEN if the variable is defined as a geometric object
> (sphere, box, whatever).
>
> For undeclared identifiers, the tokenizer sets the token type to
> IDENTIFIER_TOKEN.

Thanks! I am trying to understand.


Post a reply to this message

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 30 Oct 2016 05:25:01
Message: <web.5815bb72397eea9f7a3e03fe0@news.povray.org>
"LanuHum" <Lan### [at] yandexru> wrote:
> Thanks! I am trying to understand.


I looked neither to! (I have not looked back!)
Will it work?

6775:   CASE (OBJECT_TOKEN)
            Parse_Begin ();
            Object = Parse_Object ();
            if (!Object)
                addBlenderObject(Token.Token_String);
            Object = Parse_Object ();
            if (!Object)
                Expectation_Error ("object");
            Object = Parse_Object_Mods (reinterpret_cast<ObjectPtr>(Object));
            EXIT
        END_CASE


Post a reply to this message

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 30 Oct 2016 05:30:00
Message: <web.5815bd4b397eea9f7a3e03fe0@news.povray.org>
"LanuHum" <Lan### [at] yandexru> wrote:
> "LanuHum" <Lan### [at] yandexru> wrote:
> > Thanks! I am trying to understand.
>
>
> I looked neither to! (I have not looked back!)
> Will it work?
>
> 6775:   CASE (OBJECT_TOKEN)
>             Parse_Begin ();
>             Object = Parse_Object ();
>             if (!Object)
>                 addBlenderObject(Token.Token_String);
>             Object = Parse_Object ();
>             if (!Object)
>                 Expectation_Error ("object");
>             Object = Parse_Object_Mods (reinterpret_cast<ObjectPtr>(Object));
>             EXIT
>         END_CASE

 6775:   CASE (OBJECT_TOKEN)
             Parse_Begin ();
             Object = Parse_Object ();
             if (!Object)
                 bool add = addBlenderObject(Token.Token_String);
             if (!add)
                 Expectation_Error ("object");
             Object = Parse_Object_Mods (reinterpret_cast<ObjectPtr>(Object));
             EXIT
         END_CASE


Post a reply to this message

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 30 Oct 2016 06:20:01
Message: <web.5815c863397eea9f7a3e03fe0@news.povray.org>
"LanuHum" <Lan### [at] yandexru> wrote:
> "LanuHum" <Lan### [at] yandexru> wrote:
>
>  6775:   CASE (OBJECT_TOKEN)
>              Parse_Begin ();
>              Object = Parse_Object ();
>              if (!Object)
>                  bool add = addBlenderObject(Token.Token_String);
>              if (!add)
>                  Expectation_Error ("object");
>              Object = Parse_Object_Mods (reinterpret_cast<ObjectPtr>(Object));
>              EXIT
>          END_CASE


bool BlenderScene::addBlenderObject(std::string name){
    BlenderObject *bobject = objects.find(name) -> second;
    if (!bobject)
        return false
    switch (bobject -> type) {
        case 2: {
            Mesh *mesh = new Mesh();
            // reinterpret Blender mesh data to Povray mesh data
            // bla-bla-bla
        }
        case 1: { std::cout<<"Type: "<<"CSG"<<std::endl; break; } //del
        default: { std::cout<<"Type: "<<"BLOB"<<std::endl; } //del
    }
    return true
}


Post a reply to this message

From: clipka
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 30 Oct 2016 17:09:36
Message: <58166190$1@news.povray.org>
Am 30.10.2016 um 11:16 schrieb LanuHum:
> "LanuHum" <Lan### [at] yandexru> wrote:
>> "LanuHum" <Lan### [at] yandexru> wrote:
>>
>>  6775:   CASE (OBJECT_TOKEN)
>>              Parse_Begin ();
>>              Object = Parse_Object ();
>>              if (!Object)
>>                  bool add = addBlenderObject(Token.Token_String);
>>              if (!add)
>>                  Expectation_Error ("object");
>>              Object = Parse_Object_Mods (reinterpret_cast<ObjectPtr>(Object));
>>              EXIT
>>          END_CASE

No, you probably do /not/ want to do it this way.

Parse_Object may fail not only if an IDENTIFIER_TOKEN (a valid but
undeclared identifier) is used; it may also fail on virtually any other
token, e.g. a string literal, numeric literal, operator, a reserved
keyword that does not normally start a primitive, or even a string variable.

In case of a string literal, you'll get the raw string without the
surrounding double quotes.
If you want that to be supported, for the sake of consistency you should
also allow arbitrary string expressions -- but those would /not/ give
you the string in Token.Token_String; instead, that would just give you
the first token of that string expresison (e.g. "concat(Foo,Bar)" would
give you "concat).

My personal recommendation would be to add another keyword, e.g.
"blender_object", write completely separate code to parse that, and use
a string rather than an identifier to specify the Blender-internal name:

    #declare Foo = blender_object { "foo" }

The code would be something like:

    char *s;
    ...
    CASE(BLENDER_OBJECT_TOKEN)
        Parse_Begin();
        s = Parse_C_String();
        Object = addBlenderObject(std::string(s));
        POV_FREE(s);
        Parse_End();
    END_CASE


> bool BlenderScene::addBlenderObject(std::string name){
>     BlenderObject *bobject = objects.find(name) -> second;
>     if (!bobject)
>         return false
>     switch (bobject -> type) {
>         case 2: {
>             Mesh *mesh = new Mesh();
>             // reinterpret Blender mesh data to Povray mesh data
>             // bla-bla-bla
>         }
>         case 1: { std::cout<<"Type: "<<"CSG"<<std::endl; break; } //del
>         default: { std::cout<<"Type: "<<"BLOB"<<std::endl; } //del
>     }
>     return true
> }

You /somehow/ want to pass the mesh/blob object out of this function.


Post a reply to this message

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 31 Oct 2016 10:00:01
Message: <web.58174d25397eea9f7a3e03fe0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 30.10.2016 um 11:16 schrieb LanuHum:
>
> My personal recommendation would be to add another keyword, e.g.
> "blender_object", write completely separate code to parse that, and use
> a string rather than an identifier to specify the Blender-internal name:
>
>     #declare Foo = blender_object { "foo" }
>
> The code would be something like:
>
>     char *s;
>     ...
>     CASE(BLENDER_OBJECT_TOKEN)
>         Parse_Begin();
>         s = Parse_C_String();
>         Object = addBlenderObject(std::string(s));
>         POV_FREE(s);
>         Parse_End();
>     END_CASE
>
>


Thanks!


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.