XML to LDR


Re: XML to LDR
#5
Hey Michael,

all predefined colors can be found in the source files, which are free available:
DataManagement.java Wrote:legoTop.setColor("11_Black",0,0,0);
legoTop.setColor("85_Dark_Bluish_Gray",73,88,101);
legoTop.setColor("86_Light_Bluish_Gray",161,171,178);
legoTop.setColor("99_Very_Light_Bluish_Gray",198,205,209);
legoTop.setColor("01_White",255,255,255);
legoTop.setColor("03_Yellow",255,214,0);
legoTop.setColor("33_Light_Yellow",255,233,143);
legoTop.setColor("69_Dark_Tan",144,144,105);
legoTop.setColor("02_Tan",214,191,145);
legoTop.setColor("88_Reddish_Brown",104,46,47);
legoTop.setColor("04_Orange",244,123,32);
legoTop.setColor("31_Medium_Orange",248,155,28);
legoTop.setColor("59_Dark_Red",247,4,55);
legoTop.setColor("05_Red",238,46,36);
legoTop.setColor("25_Salmon",246,150,124);
legoTop.setColor("26_Light_Salmon",250,188,174);
legoTop.setColor("47_Dark_Pink",205,127,181);
legoTop.setColor("23_Pink",247,179,204);
legoTop.setColor("89_Dark_Purple",70,42,135);
legoTop.setColor("24_Purple",127,63,152);
legoTop.setColor("93_Light_Purple",142,49,146);
legoTop.setColor("71_Magenta",171,29,137);
legoTop.setColor("63_Dark_Blue",0,54,96);
legoTop.setColor("07_Blue",0,87,164);
legoTop.setColor("42_Medium_Blue",94,174,224);
legoTop.setColor("62_Light_Blue",193,224,244);
legoTop.setColor("39_Dark_Turquoise",0,146,121);
legoTop.setColor("40_Light_Turquoise",0,179,176);
legoTop.setColor("41_Aqua",162,218,222);
legoTop.setColor("80_Dark_Green",0,65,37);
legoTop.setColor("06_Green",0,148,74);
legoTop.setColor("37_Medium_Green",151,211,184);
legoTop.setColor("38_Light_Green",186,225,209);
legoTop.setColor("34_Lime",181,206,47);
legoTop.setColor("76_Medium_Lime",193,216,55);
legoTop.setColor("35_Light_Lime",197,225,170);
But you can define colors yourself!

The xml-file contains the data "row by row top down and from the left to the right". The xml-file represents one huge matrix. If you only use LEGO plates 1x1 each entry (tag) in the matrix (the xml-file) would be filled. If you use bigger parts, only the upper left most matrix entry for each part is filled. All overlayed matrix entries will appear as an empty tag.

Here is a pseudo code to convert the xml-file to LDraw:
Code:
read xmlFile
foreach row in xmlFile
    x = 0 // each row starts at the left
    foreach unit in row
        if unit is not empty
            color = translateColor
            part = translateElement
            offest = calculateOffset(part) // the origin of the ldraw parts is not the upper left most stud
            write ldrFile "1 color x+offset y 0 1 0 0 0 1 0 0 0 1 part.dat"
        x += 20 // for each horizontal entry (unit) in the matrix, we have to shift right
    y += 8 // for each vertical entry (row) in the matrix, we have to go down

You would have to translate the given color and the given element. For this you can implement some kind of dictionary. But also parts can be defined by yourself! This means: if you work with the predefined colors and elements a conversion is possible. But once there is a userdefined element, an "always working" conversion would become impossible.

Currently I have not detected any difference between the xml-files for "LEGO in top view" and "LEGO in side view". Only some entries might give a hint (e.g. LEGO plate 4x4 would not appear in side view).

Rolf
Reply
« Next Oldest | Next Newest »



Messages In This Thread
XML to LDR - by Arthur Sigg - 2013-03-06, 17:21
Re: XML to LDR - by Tim Gould - 2013-03-06, 20:52
Re: XML to LDR - by Rolf Osterthun - 2013-03-07, 1:49
Re: XML to LDR - by Rolf Osterthun - 2013-03-09, 22:25
Re: XML to LDR - by Arthur Sigg - 2013-03-10, 1:33
Re: XML to LDR - by Rolf Osterthun - 2013-03-15, 14:52
Re: XML to LDR - by Michael Heidemann - 2013-03-15, 20:35
Re: XML to LDR - by Rolf Osterthun - 2013-03-17, 20:43
Re: XML to LDR - by Arthur Sigg - 2013-03-24, 20:23
Re: XML to LDR - by Rolf Osterthun - 2013-03-25, 10:11
Re: XML to LDR - by Michael Heidemann - 2013-03-07, 16:04
Re: XML to LDR - by Rolf Osterthun - 2013-03-07, 21:03
Re: XML to LDR - by Michael Heidemann - 2013-03-07, 22:23
Re: XML to LDR - by Arthur Sigg - 2013-03-07, 23:36
Re: XML to LDR - by Nina68 - 2013-12-30, 7:49
RE: XML to LDR - by Fernando Correia - 2017-12-24, 0:01

Forum Jump:


Users browsing this thread: 2 Guest(s)