puting 3D Data into a dll

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
PixelBender
Posts: 7
Joined: Thu Oct 20, 2016 8:30 am

puting 3D Data into a dll

Post by PixelBender »

Hi all,

I want to build a catalogue of the machines in my company.
The idea is an object oriented approach:

- The machines have a geometry (3D model)
- Abilities (methods)
- Data (sic)

It would be cool to have this all together in one file.

Since those machines should be loadable into let’s say a shop floor,
It would be a good thing to have them in separate Dlls.

One Dll per machine containing all the necessary things.

Is this possible?
Any ideas?

Greetings
Markus
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: puting 3D Data into a dll

Post by Mel »

I am not sure about what are you really after, but there is a way to include additional data into a DLL, in the same fashion as the built in font of irrlicht, and it can be changed on a per DLL basis, so it may be suitable for your needs, and it is to use the fileToHeader program that is included in the tools folder (it is not compiled, but it should be quick).

Word of advice though, the built-in data can't be larger than 65536 bytes long because it is a static segment of data which is not in the heap, but is a part of the DLL static data, which is small for very detailed models, unless you use some compression, but you can have several included.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: puting 3D Data into a dll

Post by Vectrotek »

Interesting question..

It's like Mel said, if your Geometric Data is small enough
you can get away with putting the "data" into a DLL file.

If you know how to programatically build i.e. Render an Object using the three
arrays shown below then it would be as simple as including a "Render" function
into the DLL along with the Arrays shown..

Now, you need some way of getting your geometric data into this "array" form..
There are many ways in which to do this.

My favourite is an old app called "Deep Exploration" which allows you to
export any 3D object as a "*.Cpp" file.
It has lots of options under export you can play with.
(the following example data and code comes from Deep Exploration)

Another method is to export from any competent 3D app (like Blender) to
any "ASCII based" 3D Format (obj, vrml, dae, etc) sothat you have the "human readable" information
available to paste into your code.
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: puting 3D Data into a dll

Post by Vectrotek »

Here are the arrays showing the elements of a 3D object:

Code: Select all

 
static u32 Object_001_Face Indices [80][6] = {
// Object #-1
    {24,2,21 ,0,0,0 }, {21,27,24 ,1,1,1 }, {11,4,37 ,0,0,0 }, {22,1,21 ,2,2,2 },
    {24,25,23 ,3,3,3 }, {9,35,27 ,3,3,3 }, {29,20,0 ,4,4,4 }, {10,1,36 ,2,2,2 },
    {22,29,0 ,2,2,2 }, {28,23,20 ,3,3,3 }, {6,3,5 ,5,5,5 }, {33,7,9 ,5,5,5 },
    {9,31,8 ,3,3,3 }, {26,36,1 ,2,2,2 }, {32,2,33 ,2,2,2 }, {33,10,32 ,2,2,2 },
    {27,35,25 ,3,3,3 }, {38,4,6 ,3,3,3 }, {20,26,0 ,5,5,5 }, {8,34,9 ,3,3,3 },
    {33,27,1 ,4,4,4 }, {10,8,32 ,6,6,6 }, {25,36,26 ,7,7,7 }, {37,42,11 ,5,5,5 },
    {42,12,39 ,2,2,2 }, {15,19,16 ,0,0,0 }, {40,41,38 ,3,3,3 }, {47,50,46 ,1,1,1 },
    {50,17,46 ,3,3,3 }, {10,35,34 ,0,0,0 }, {41,13,42 ,0,0,0 }, {29,8,28 ,1,1,1 },
    {14,16,44 ,5,5,5 }, {12,43,40 ,1,1,1 }, {5,11,39 ,2,2,2 }, {49,47,45 ,2,2,2 },
    {44,19,45 ,2,2,2 }, {14,47,46 ,4,4,4 }, {17,15,14 ,3,3,3 }, {12,6,5 ,4,4,4 },
    {48,51,49 ,0,0,0 }, {18,49,19 ,5,5,5 }, {24,7,2 ,0,0,0 }, {21,1,27 ,1,1,1 },
    {11,3,4 ,0,0,0 }, {22,26,1 ,2,2,2 }, {24,27,25 ,3,3,3 }, {9,34,35 ,3,3,3 },
    {29,28,20 ,4,4,4 }, {10,33,1 ,2,2,2 }, {22,30,29 ,2,2,2 }, {28,31,23 ,3,3,3 },
    {6,4,3 ,5,5,5 }, {33,2,7 ,5,5,5 }, {9,7,31 ,3,3,3 }, {32,30,2 ,2,2,2 },
    {38,37,4 ,3,3,3 }, {20,25,26 ,5,5,5 }, {33,9,27 ,4,4,4 }, {10,34,8 ,6,6,6 },
    {25,35,36 ,7,7,7 }, {37,41,42 ,5,5,5 }, {42,13,12 ,2,2,2 }, {15,18,19 ,0,0,0 },
    {40,43,41 ,3,3,3 }, {47,51,50 ,1,1,1 }, {50,48,17 ,3,3,3 }, {10,36,35 ,0,0,0 },
    {41,43,13 ,0,0,0 }, {29,32,8 ,1,1,1 }, {14,15,16 ,5,5,5 }, {12,13,43 ,1,1,1 },
    {5,3,11 ,2,2,2 }, {49,51,47 ,2,2,2 }, {44,16,19 ,2,2,2 }, {14,44,47 ,4,4,4 },
    {17,18,15 ,3,3,3 }, {12,40,6 ,4,4,4 }, {48,50,51 ,0,0,0 }, {18,48,49 ,5,5,5 }
};
static f32 Object_001_Vertices [52][3] = {
{0.5f,-0.5f,-0.5f},{2.5f,-0.5f,0.5f},{1.5f,-0.5f,2.5f},
{5.5f,-0.5f,-0.5f},{5.5f,0.5f,-0.5f},{4.5f,-0.5f,-0.5f},
{4.5f,0.5f,-0.5f},{1.5f,0.5f,2.5f},{2.5f,0.5f,3.5f},
{2.5f,0.5f,2.5f},{3.5f,-0.5f,2.5f},{5.5f,-0.5f,2.5f},
{4.5f,-0.5f,3.5f},{6.5f,-0.5f,3.5f},{7.5f,0.5f,-0.5f},
{8.5f,0.5f,-0.5f},{8.5f,-0.5f,-0.5f},{7.5f,0.5f,2.5f},
{8.5f,0.5f,2.5f},{8.5f,-0.5f,2.5f},{0.5f,0.5f,-0.5f},
{1.5f,-0.5f,0.5f},{1.5f,-0.5f,-0.5f},{1.5f,0.5f,-0.5f},
{1.5f,0.5f,0.5f},{2.5f,0.5f,-0.5f},{2.5f,-0.5f,-0.5f},
{2.5f,0.5f,0.5f},{0.5f,0.5f,3.5f},{0.5f,-0.5f,3.5f},
{1.5f,-0.5f,3.5f},{1.5f,0.5f,3.5f},{2.5f,-0.5f,3.5f},
{2.5f,-0.5f,2.5f},{3.5f,0.5f,2.5f},{3.5f,0.5f,0.5f},
{3.5f,-0.5f,0.5f},{5.5f,0.5f,2.5f},{4.5f,0.5f,2.5f},
{4.5f,-0.5f,2.5f},{4.5f,0.5f,3.5f},{6.5f,0.5f,2.5f},
{6.5f,-0.5f,2.5f},{6.5f,0.5f,3.5f},{7.5f,-0.5f,-0.5f},
{7.5f,-0.5f,2.5f},{7.5f,0.5f,3.5f},{7.5f,-0.5f,3.5f},
{9.5f,0.5f,2.5f},{9.5f,-0.5f,2.5f},{9.5f,0.5f,3.5f},
{9.5f,-0.5f,3.5f}
};
static f32 Object_001_Normals [8][3] = {
{1.0f,0.0f,0.0f},{0.0f,0.0f,1.0f},{0.0f,-1.0f,0.0f},
{0.0f,1.0f,0.0f},{-1.0f,0.0f,0.0f},{0.0f,0.0f,-1.0f},
{0.707107f,0.0f,0.707107f},{0.707107f,0.0f,-0.707107f}
};
 
 
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: puting 3D Data into a dll

Post by Vectrotek »

Now, you need to understand how these sets of data is interpreted by such a "Rendering Function"..

Here is an very simple Gl example of how you would go about rendering this "array" data:
(in Irrlicht it looks very much the same)

Once you understand how this function uses the data above to render the model,
you should have no problem using any kind of "HARD CODED" ASCII data to render objects.

Code: Select all

 
    glBegin (GL_TRIANGLES);
      for(int i=0;i<sizeof(Object_001_Face Indices)/sizeof(Object_001_Face Indices[0]);i++)
        {
        for(int j=0;j<3;j++)
         {
         int vi = Object_001_Face Indices[i][j];
         int ni = Object_001_Face Indices[i][j+3];
         glNormal3f (Object_001_Normals[ni][0],Object_001_Normals[ni][1],Object_001_Normals[ni][2]);
         glVertex3f (Object_001_Vertices[vi][0],Object_001_Vertices[vi][1],Object_001_Vertices[vi][2]);
        }
       }
    glEnd ();
 
Now if you can figure out "what" this model is then this was a usefull post.. :)

Good luck..
Vectrotek
Competition winner
Posts: 1087
Joined: Sat May 02, 2015 5:05 pm

Re: puting 3D Data into a dll

Post by Vectrotek »

Adding UV Coords for Image Mapping is just as simple.. :wink:
Post Reply