POV-Ray : Newsgroups : povray.binaries.programming : My idea: Developers need tips! Help me, please! Server Time
21 Dec 2024 12:01:25 EST (-0500)
  My idea: Developers need tips! Help me, please! (Message 21 to 30 of 50)  
<<< Previous 10 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: clipka
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 13 Sep 2016 13:09:45
Message: <57d832d9$1@news.povray.org>
Am 13.09.2016 um 16:29 schrieb LanuHum:
> clipka <ano### [at] anonymousorg> wrote:
>> Am 12.09.2016 um 22:13 schrieb LanuHum:
>>> "LanuHum" <Lan### [at] yandexru> wrote:
>>>>
>>>> We will look for errors. :))))
>>>
>>> :(
>>> If I uncommented Py_Finalize(), application crash when the command Py_Finalize()
>>> run. If I do not use the import of bpy, the application lives
>>
>> Have you finished your other homework yet?
>>
> 
> No. To learn your lesson, I started from scratch. I started all over again.
> I wrote a single function.
> The function must import the module, clean it and write "Hello World".
...

> Where is the "Hello World"?

Take even another step back: Write a program that does _not_ try to run
Python at all, and instead just outputs "Hello World" to the standard
output stream.

How exactly are you running the program in the first place? What is this
"Konsole"? Why is it writing "Blender quit" when you're testing a
self-made program?

In MS Visual Studio, if I simply run a "Hello World" program by hitting
F5, I never see the output because the output window is closed as soon
as the program exits.

If you have a similar problem, make sure that your program reads a
character from standard input at the end, so that you need to press a
key before the window closes.


Post a reply to this message

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 13 Sep 2016 14:20:00
Message: <web.57d842a3397eea9f7a3e03fe0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> Am 13.09.2016 um 16:29 schrieb LanuHum:
> > clipka <ano### [at] anonymousorg> wrote:
> >> Am 12.09.2016 um 22:13 schrieb LanuHum:
> >>> "LanuHum" <Lan### [at] yandexru> wrote:
> >>>>
> >>>> We will look for errors. :))))
> >>>
> >>> :(
> >>> If I uncommented Py_Finalize(), application crash when the command Py_Finalize()
> >>> run. If I do not use the import of bpy, the application lives
> >>
> >> Have you finished your other homework yet?
> >>
> >
> > No. To learn your lesson, I started from scratch. I started all over again.
> > I wrote a single function.
> > The function must import the module, clean it and write "Hello World".
> ...
>
> > Where is the "Hello World"?
>
> Take even another step back: Write a program that does _not_ try to run
> Python at all, and instead just outputs "Hello World" to the standard
> output stream.
>
> How exactly are you running the program in the first place? What is this
> "Konsole"? Why is it writing "Blender quit" when you're testing a
> self-made program?
>
> In MS Visual Studio, if I simply run a "Hello World" program by hitting
> F5, I never see the output because the output window is closed as soon
> as the program exits.
>
> If you have a similar problem, make sure that your program reads a
> character from standard input at the end, so that you need to press a
> key before the window closes.

OK. My OS - Linux.
The first program for Windows is different from the first program for Linux.

For Windows:

#include <iostream>
#include <cstdlib> // for system

int main()
{
    std::cout << "Hello, world!" << std::endl;
    system("pause");
    return 0;
}

For Linux:

#include <iostream>

int main() {
    std::cout<<"Hello world!"<< std::endl;
    return 0;
}

cmd in Widows = konsole, console, terminal, gnome-terminal, lxterminal, xterm in
Linux.
My IDE - Geany, NOT MS Visual Studio! :)))
Compiling object file in IDE:
g++ -Wall -c "%f"
Make binary:
g++ -Wall -o "%e" "%f"
Run:
"./%e"

IDE automatically runs a program from the konsole.
konsole displays the result.
I can run the program manually.
After quit program the console does not close.

This is our first step:


Post a reply to this message


Attachments:
Download 'konsole(kde4).jpg' (37 KB)

Preview of image 'konsole(kde4).jpg'
konsole(kde4).jpg


 

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 13 Sep 2016 16:00:00
Message: <web.57d859ee397eea9f7a3e03fe0@news.povray.org>
clipka, I think I found an error!

#include <python3.3m/Python.h>
#include <iostream>

int main() {
    int len;
    Py_Initialize();
    PyRun_SimpleString("import sys");
    PyRun_SimpleString("sys.path.append(\".\")");
    PyRun_SimpleString("import bpy");

PyRun_SimpleString("bpy.ops.wm.open_mainfile(filepath='/home/leonid/workspace/blender/files_blend/test_so.blend')");
 //read blend-file
    PyObject *pyModuleName = PyUnicode_FromString("bpy");
    PyObject *pyModuleName1 = PyUnicode_FromString("bimport");
    PyObject *pyModule = PyImport_Import(pyModuleName); // import Blender module
    PyObject *pyModule1 = PyImport_Import(pyModuleName1);   // import my module
with parser functions
    PyObject *pyFunc = PyObject_GetAttrString(pyModule1,
"import_blender_scene");
    PyObject *pyArgs = PyTuple_New(1);
    PyTuple_SetItem(pyArgs, 0, pyModule);
    PyObject *pyLen = PyObject_CallObject(pyFunc, pyArgs);
    len = PyLong_AsLong(pyLen);
    std::cout<<len<<std::endl;  // Number of objects in scene (5)
    Py_Finalize();

    std::cout<<"Hello world!"<<std::endl;  //After py_finalize!!!!
    return 0;
}

Konsole:

read blend: /home/leonid/workspace/blender/files_blend/test_so.blend
5
Hello world!
------------------
(program exited with code: 0)




Now I will try to create classes! Thank you. Your support has helped me.


Post a reply to this message

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 1 Oct 2016 14:35:01
Message: <web.57f000f3397eea9f7a3e03fe0@news.povray.org>
"LanuHum" <Lan### [at] yandexru> wrote:
> Now I will try to create classes! Thank you. Your support has helped me.

No, I will not understand your code. Very confusing.
What would be said Gerbert Shildt, if you saw your code?
Macros - evil. It is neither for you.

Where similar to this?

//Scene.h
#include <vector>
#include "Camera.h"
#include "Light.h"
#include "Object.h"
#include "Pigment.h"
#include "Normal.h"
#include "Finish.h"
#include "Texture.h"

using namespace std;

class Scene {
public:
    Camera              camera;
    vector<Light*>      lights;
    vector<Object*>     static_objects;
    vector<Object*>     animate_objects;
    vector<Pigment*>    pigments;
    vector<Normal*>     normals;
    vector<Finish*>     finishes;
    vector<Texture*>    textures;

                        Scene();
                        ~Scene();
};

In vain I try to.  :((((((((((((((


Post a reply to this message

From: clipka
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 2 Oct 2016 10:33:27
Message: <57f11ab7$1@news.povray.org>
Am 01.10.2016 um 20:31 schrieb LanuHum:

> No, I will not understand your code. Very confusing.
> What would be said Gerbert Shildt, if you saw your code?

(BTW, I suspect you mean Herbert Schildt. It seems that "Gerbert Shildt"
is a back-transcription of the name's transcription to Cyrillic script.)

> Macros - evil. It is neither for you.
> 
> Where similar to this?
> 
> //Scene.h
> #include <vector>
> #include "Camera.h"
> #include "Light.h"
> #include "Object.h"
> #include "Pigment.h"
> #include "Normal.h"
> #include "Finish.h"
> #include "Texture.h"
> 
> using namespace std;
> 
> class Scene {
> public:
>     Camera              camera;
>     vector<Light*>      lights;
>     vector<Object*>     static_objects;
>     vector<Object*>     animate_objects;
>     vector<Pigment*>    pigments;
>     vector<Normal*>     normals;
>     vector<Finish*>     finishes;
>     vector<Texture*>    textures;
> 
>                         Scene();
>                         ~Scene();
> };
> 
> In vain I try to.  :((((((((((((((

Didn't I tell you so?

POV-Ray originated 30 (!) years ago as a C project, and still contains
plenty of C-isms to this day.

As I've mentioned numerous times, efforts to clean up the code are in
progress but still far from completed.


That said, the thing you are looking for is the class `SceneData`
declared in `source/core/scene/scenedata.h`, and at that level it's not
/too/ far from what you're looking for -- with the notable exception
that POV-Ray does not manage textures, pigments etc. as indices into a
"library", but rather as direct references (i.e. pointers) to texture
objects. Also, `SceneData` contains a bit more stuff.


Post a reply to this message

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 2 Oct 2016 13:30:00
Message: <web.57f14303397eea9f7a3e03fe0@news.povray.org>
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);}


Post a reply to this message

From: clipka
Subject: Re: My idea: Developers need tips! Help me, please!
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

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 2 Oct 2016 16:05:00
Message: <web.57f16723397eea9f7a3e03fe0@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> 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...

:))))
Thank you.
My idea is only useful for animation. To speed up the data transfer very large.
Parents and children do not interest me.
Earlier you wrote me that well write:
sphere{}
sphere{}
sphere{}
than the cycle "for (i=0;i<3;i++)..."

I am most interested in triangles.
I will try to deal with the povray-master/source/core/shape/mesh.h


Post a reply to this message

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 4 Oct 2016 16:40:01
Message: <web.57f412da397eea9f7a3e03fe0@news.povray.org>
You can not give up on SDL.

Example scene.pov:

#version 3.7;

camera{...}

light_source{...}

#declare Home_tex = texture{...}

#declare Home = mesh { load_using_C++_library }

object { Home }


The code adds a new key: " load_using_C++_library "

Also add a new key code: "to_take_out_of_memory"

#declare Home = mesh { to_take_out_of_memory }

First frame:
#declare Home = mesh { load_using_C++_library }

Second frame:
#declare Home = mesh { to_take_out_of_memory } // if object static


for (uint frame = 1; frame < frame_end; frame++){
    string *filename = filenames[frame];
    parser::run(filename);
    render::run();
}


Post a reply to this message

From: LanuHum
Subject: Re: My idea: Developers need tips! Help me, please!
Date: 14 Oct 2016 14:30:00
Message: <web.5801237e397eea9f7a3e03fe0@news.povray.org>
Mesh: 3 145 728 tris
If I use the bootloader on a Python: Create an PyObject(Mesh) takes 28 seconds.
A new attempt: the bootloader on a Cython.
I have to get ready for an instance of the mesh.
I created a new repository:
https://github.com/Lanuhum/Povanim

I used your license, but FOX-TOOLKIT is licensed under GNU LESSER GENERAL PUBLIC
LICENSE Version 2.1.
I shoot? :)))


Now GUI looks like this:


Post a reply to this message


Attachments:
Download 'povray_animator.jpg' (29 KB)

Preview of image 'povray_animator.jpg'
povray_animator.jpg


 

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

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