digitalmars.D.learn - C++ code to D (multi dem 3d mesh)
- Joel (38/38) Oct 26 2020 ```
- Joel (33/83) Oct 27 2020 This is what I came up with:
- Imperatorn (2/8) Oct 27 2020 It's not really clear what your question is.
- Joel (4/13) Oct 27 2020 I'm trying to convert from C++ code to D code, see where I've put
- Imperatorn (9/23) Oct 27 2020 Ok, some steps have to be done manually.
- Joel (2/26) Oct 27 2020 Thanks, I've bookmarked this.
```
struct vec3d
{
float x, y, z;
}
struct triangle
{
vec3d[3] p;
}
struct mesh
{
triangle[] tris;
}
// This here
meshCube.tris = {
// SOUTH
{ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f },
// EAST
{ 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f },
{ 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f },
// NORTH
{ 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f },
{ 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f },
// WEST
{ 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f },
{ 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f },
// TOP
{ 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f },
{ 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f },
// BOTTOM
{ 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f },
{ 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f },
};
```
See:
https://youtu.be/ih20l3pJoeU
https://github.com/OneLoneCoder/videos/blob/master/OneLoneCoder_olcEngine3D_Part1.cpp
Oct 26 2020
On Monday, 26 October 2020 at 23:38:22 UTC, Joel wrote:
```
struct vec3d
{
float x, y, z;
}
struct triangle
{
vec3d[3] p;
}
struct mesh
{
triangle[] tris;
}
// This here
meshCube.tris = {
// SOUTH
{ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f
},
{ 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f
},
// EAST
{ 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f
},
{ 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f
},
// NORTH
{ 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f
},
{ 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f
},
// WEST
{ 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f
},
{ 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f
},
// TOP
{ 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f
},
{ 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f
},
// BOTTOM
{ 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f
},
{ 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f
},
};
```
See:
https://youtu.be/ih20l3pJoeU
https://github.com/OneLoneCoder/videos/blob/master/OneLoneCoder_olcEngine3D_Part1.cpp
This is what I came up with:
meshCube.tris =
// south
[triangle(vec3d(0f,0f,0f)), triangle(vec3d(0f,1f,0f)),
triangle(vec3d(1f,1f,0f)),
triangle(vec3d(0f,0f,0f)), triangle(vec3d(1f,1f,0f)),
triangle(vec3d(1f,0f,0f)),
// east
triangle(vec3d(1f,0f,0f)), triangle(vec3d(1f,1f,0f)),
triangle(vec3d(1f,1f,1f)),
triangle(vec3d(1f,0f,0f)), triangle(vec3d(1f,1f,1f)),
triangle(vec3d(1f,0f,1f)),
// north
triangle(vec3d(1f,0f,1f)), triangle(vec3d(1f,1f,1f)),
triangle(vec3d(0f,1f,1f)),
triangle(vec3d(1f,0f,1f)), triangle(vec3d(0f,1f,1f)),
triangle(vec3d(0f,0f,1f)),
// west
triangle(vec3d(0f,0f,1f)), triangle(vec3d(0f,1f,1f)),
triangle(vec3d(0f,1f,0f)),
triangle(vec3d(0f,0f,1f)), triangle(vec3d(0f,1f,0f)),
triangle(vec3d(0f,0f,0f)),
// top
triangle(vec3d(0f,1f,0f)), triangle(vec3d(0f,1f,1f)),
triangle(vec3d(1f,1f,1f)),
triangle(vec3d(0f,1f,0f)), triangle(vec3d(1f,1f,1f)),
triangle(vec3d(1f,1f,0f)),
// bottom
triangle(vec3d(1f,0f,1f)), triangle(vec3d(0f,0f,1f)),
triangle(vec3d(0f,0f,0f)),
triangle(vec3d(1f,0f,1f)), triangle(vec3d(0f,0f,0f)),
triangle(vec3d(1f,0f,0f))];
Oct 27 2020
On Monday, 26 October 2020 at 23:38:22 UTC, Joel wrote:
```
struct vec3d
{
float x, y, z;
}
[...]
It's not really clear what your question is.
Oct 27 2020
On Tuesday, 27 October 2020 at 07:17:46 UTC, Imperatorn wrote:On Monday, 26 October 2020 at 23:38:22 UTC, Joel wrote:I'm trying to convert from C++ code to D code, see where I've put '// This here' - with all the data. I found one way. I think I've thought of another way too.``` struct vec3d { float x, y, z; } [...]It's not really clear what your question is.
Oct 27 2020
On Tuesday, 27 October 2020 at 07:32:30 UTC, Joel wrote:On Tuesday, 27 October 2020 at 07:17:46 UTC, Imperatorn wrote:Ok, some steps have to be done manually. Just wanted to share some links that might be interesting when converting in the future: https://github.com/lhamot/CPP2D https://github.com/jacob-carlborg/dstep https://github.com/atilaneves/dpp http://www.swig.org/Doc4.0/D.html https://dlang.org/htod.htmlOn Monday, 26 October 2020 at 23:38:22 UTC, Joel wrote:I'm trying to convert from C++ code to D code, see where I've put '// This here' - with all the data. I found one way. I think I've thought of another way too.``` struct vec3d { float x, y, z; } [...]It's not really clear what your question is.
Oct 27 2020
On Tuesday, 27 October 2020 at 08:14:28 UTC, Imperatorn wrote:On Tuesday, 27 October 2020 at 07:32:30 UTC, Joel wrote:Thanks, I've bookmarked this.On Tuesday, 27 October 2020 at 07:17:46 UTC, Imperatorn wrote:Ok, some steps have to be done manually. Just wanted to share some links that might be interesting when converting in the future: https://github.com/lhamot/CPP2D https://github.com/jacob-carlborg/dstep https://github.com/atilaneves/dpp http://www.swig.org/Doc4.0/D.html https://dlang.org/htod.htmlOn Monday, 26 October 2020 at 23:38:22 UTC, Joel wrote:I'm trying to convert from C++ code to D code, see where I've put '// This here' - with all the data. I found one way. I think I've thought of another way too.``` struct vec3d { float x, y, z; } [...]It's not really clear what your question is.
Oct 27 2020









Joel <joelcnz gmail.com> 