help with conversion

Just installed Ubuntu in a virtual box and saw a nice application to construct a planet!
A script for 2.49 may be exported!

I like to conert the resulting Blender info to 2.59 which is solved for most of it already

I have some problems with this part, the vertex colors of the planet … will not succeed
at this moment.

Here the 2.49 function to set colors and vertex colors …


def f(mesh,material,v0,v1,v2,c0,c1,c2):
    face=NMesh.Face()
    face.transp=NMesh.FaceTranspModes.ALPHA
    face.smooth=1
    face.mat=material
    face.v.append(mesh.verts[v0])
    face.v.append(mesh.verts[v1])
    face.v.append(mesh.verts[v2])
    face.col.append(NMesh.Col(c0[0],c0[1],c0[2],c0[3]))
    face.col.append(NMesh.Col(c1[0],c1[1],c1[2],c1[3]))
    face.col.append(NMesh.Col(c2[0],c2[1],c2[2],c2[3]))
    mesh.faces.append(face)

And a lot of data like this …
f(m,0,2685,676,2686,(19,245,0,255),(49,230,0,255),(26,241,0,255))

how to convert (19,245,0,255),(49,230,0,255),(26,241,0,255) the three colors in the data
for tri’s …
dividing by 255 does not do je job

white seems to be (255,255,255,255) (r g b a)

If I read a result from Bl 2.49 in Bl 2.59 and copy the vertexcolors from 2.49 verson to 2.59 version all is OK
See picture one.
and MY conversion result (using x/255.0)

my f is this


teller = -1
def f(mesh,material,v0,v1,v2,c0,c1,c2):
    global verts, faces, facematerial,teller
    teller += 1
    faces.append((v0,v1,v2))
    colors.append((c0[0]/255.,c0[1]/255.0,c0[2]/255.0))
    colors.append((c1[0]/255.0,c1[1]/255.0,c1[2]/255.0))
    colors.append((c2[0]/255.0,c2[1]/255.0,c2[2]/255.0))
    if teller % 1000 == 0:
        print(colors[-3],colors[-2],colors[-1])
    facematerial.append(material)

Attachments



Is it possible it is not RGB but instead Hue Saturation and Value (HSV) (although that does not make sense with your (255,255,255,255) = white example.

In your image, Blue rgb = (0,0,1) in 2.49 seems to go to white rgb = (1,1,1). or hsv = (X, 0, 1) ??

Hmm, I thaught for 2.49 people is clear what NMesh.Col(c0[0],c0[1],c0[2],c0[3] does ???
where the c0 etc are values between 0 and 255?
I think I have to give more info … (and first have to try to get the vertex color values in 2.49 )

I’m sorry my original post was very unclear.

Blue in the 2.49 image was converted to white in the 2.59 image through 2 functions: your division by 255 and an unknown color function. Suppose you passed an rgb tuple to a function expecting hsv input. Eg. rgb(blue) = (0,0,255) which your script turned into (0,0,1). hsv(0,0,1) yields white! That could explain the color transform. It could also just be total coincidence.

Ah, thanks, I will check … :wink:

Not found yet … I include a file with all information needed.

If you run F12 you see two planes, the left one is what it should look like,
the right one is wrong …
There are the following internal files:
newvisualizer to run and to see vertices and faces of objects in edit-mode
testboth.py to look and check what has been set …

Now the next two are the important ones my translation from an 2.49 script to an 2.59 script.
testplanet249.py (should be run in Bl 2.49 … save and gives in 2.59 the left picture)
testplanet259.py what I did , run it in Bl 2.59 gives the wrong picture (F12!) the right one)

I realize, that I did not ‘convert’ this command (because I do not know if it is possible
in 2.59 and is not yet found) : face.transp=NMesh.FaceTranspModes.ALPHA ???

Any help is much apreciated …

Attachments

testplanet249_3.blend (399 KB)

i tried this sample-blend-file about setting the vertex-colours.
Have you ever tried to use not the array-indizes of the color-data-part
and use the namings: b g h hsv r s v ??

next, some settings in the material are not the same (but this seems not to explain the difference in the color-settings)

and what was the link to the original data? Did i miss it? Are there any more notes about the kind of the data?

update:
did you already notice this link about the 2.49 way of using vertex-colors?
> http://www.blender3dclub.com/index.php?name=News&file=article&sid=54&theme=Printer

There is one first error found in the scripting sample:

the counting of the stored color-values is wrong.
It uses the counting (i) for the faces instead
of the 3-times-bigger value you increment in 3-steps.
Thus it is always using only values from the first part again
and only going up in the stored values by 1 (and not like wanted by 3).

other errors …? (such errors are hard to find, cause reading the code will automatically not notice such little usage of the wrong counter)

@test-dr.
The original made with Ubuntu planet program is testplanet249.py (in the .blend) made shorter than a whole planet (as a ball).

Your second post I have to understand … (indeed, there ‘must’ be some wrong interpretation of me …)

And a big thanks for trying to help!!!

I have the source of that planet program but the uses Qt or so things which I do not (yet) have available …

Your link to the vertexcolours of 2.49 is much apreciated, will look at it in a moment … thanks too for that.

ERROR found! Jippie!
The last lines of the 259 version should be


countcolor = -3
for i in range(len(colorlist)):
    obj.data.faces[i].material_index = facematerial[i]
    countcolor += 3
    colorlist[i].color1 = colors[countcolor]
    colorlist[i].color2 = colors[countcolor+1]
    colorlist[i].color3 = colors[countcolor+2]
    colorlist[i].color4 = (1,1,1)