V
V
vova_bober2014-08-22 13:52:48
3D
vova_bober, 2014-08-22 13:52:48

How to decode 3D shapes in xml?

I converted a 3d figure from one design program to xml. Now we need to decipher it somehow. Tell me how this code is deciphered:
Cube 100 * 100 * 100mm:

<?xml version="1.0" encoding="windows-1251" ?>
<scene>
  <layer>
    <shape thickness="0.018">
      <matrix>
        0.000000000000003, 0.000000000000005, -5.555555555555510, -1.950000000000001, 
        0.000000000000000, -1.000000000000000, 0.000000000000000, -1.375000000000000, 
        -1.000000000000000, 0.000000000000000, 0.000000000000000, -1.875000000000000, 
        0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000
      </matrix>
      <segments>
        <line>0.025, 0.025</line>
        <line>0.025, 0.125</line>
        <line>0.125, 0.125</line>
        <line>0.125, 0.025</line>
      </segments>
    </shape>
  </layer>
</scene>

Cube 1*1*1mm
<?xml version="1.0" encoding="windows-1251" ?>
<scene>
  <layer>
    <shape thickness="0.018">
      <matrix>
        0.000000000000003, 0.000000000000005, -0.055555555555555, -1.999500000000000, 
        0.000000000000000, -1.000000000000000, 0.000000000000000, -1.498750000000000, 
        -1.000000000000000, 0.000000000000000, 0.000000000000000, -1.998750000000000, 
        0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000
      </matrix>
      <segments>
        <line>0.000, 0.000</line>
        <line>0.000, 0.001</line>
        <line>0.001, 0.001</line>
        <line>0.001, 0.000</line>
      </segments>
    </shape>
  </layer>
</scene>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SHVV, 2014-08-27
@SHVV

It's like extrusion.
That is, a 2D figure is drawn and extruded to the desired thickness.
In your case, a square is drawn by listing the 2D coordinates of its vertices (x, y):

<segments>
        <line>0.000, 0.000</line>
        <line>0.000, 0.001</line>
        <line>0.001, 0.001</line>
        <line>0.001, 0.000</line>
</segments>

And this square is given a thickness (height in 3D):
And in the end, all this is transformed by a transformation matrix:
<matrix>
        0.000000000000003, 0.000000000000005, -0.055555555555555, -1.999500000000000, 
        0.000000000000000, -1.000000000000000, 0.000000000000000, -1.498750000000000, 
        -1.000000000000000, 0.000000000000000, 0.000000000000000, -1.998750000000000, 
        0.000000000000000, 0.000000000000000, 0.000000000000000, 1.000000000000000
</matrix>

Here, if you look more closely, the right column is the shift, and diagonally - the scale of each of the axes. But in the general case, there can still be a twist.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question