If you want to change the colour of individual vertices, you can do that either through memblocks, or by using the vertexdata commands (faster). Note that the original colour of the vertex is lost if you do it this way.
First of all, you need to check that the model you loaded is using the correct
frikkin' vertex format (FVF). You can look at that any time by reading the memblock header of it's mesh:
rem load our object
load object "bla.x" , 1
make mesh from object 1 , 1
make memblock from mesh 1 , 1
rem read header data
FVF = memblock dword( 1 , 0 )
VertSize = memblock dword( 1 , 4 )
VertCount = memblock dword( 1 , 8 )
rem clean up
delete mesh 1
delete memblock 1
rem main loop
do
rem print data to screen
set cursor 0 , 0
print "FVF format: ";FVF
print "Vertex Size (in bytes): ";VertSize
print "Vertex Count: ";VertCount
rem refresh screen
sync
rem end of main loop
loop
(Just for the record, it's actually "Flexible Vertex Format").
Assuming you ran the above code with your model, you're most likely going to get an FVF of 274 and vertex size of 32 bytes. What does this all mean? Well, here's an extract from the help files:
#constant FVF_XYZ 0x002
#constant FVF_XYZRHW 0x004
#constant FVF_XYZB1 0x006
#constant FVF_XYZB2 0x008
#constant FVF_XYZB3 0x00a
#constant FVF_XYZB4 0x00c
#constant FVF_XYZB5 0x00e
#constant FVF_NORMAL 0x010
#constant FVF_PSIZE 0x020
#constant FVF_DIFFUSE 0x040
#constant FVF_SPECULAR 0x080
#constant FVF_TEX0 0x000
#constant FVF_TEX1 0x100
#constant FVF_TEX2 0x200
#constant FVF_TEX3 0x300
#constant FVF_TEX4 0x400
#constant FVF_TEX5 0x500
#constant FVF_TEX6 0x600
#constant FVF_TEX7 0x700
#constant FVF_TEX8 0x800
MyFVF as dword
MyFVF = FVF_XYZ || FVF_NORMAL || FVF_TEX1
You'll see that using FVF_XYZ, FVF_NORMAL, FVF_TEX1, so 0x002 + 0x010 + 0x100 = 0x112 =
274. In order to be able to edit the diffuse of each vertex, we need to add the diffuse value to the FVF. So:
MyFVF = FVF_XYZ || FVF_NORMAL || FVF_DIFFUSE || FVF_TEX1
0x002 + 0x010 + 0x040 + 0x100 = 0x152 =
338.
Alright, now in order to be able to do that with the model, we need to convert it's FVF to 338:
rem load the object
load object "bla.x" , 1
rem convert FVF to 338
convert object fvf 1 , 338
rem read header data
make mesh from object 1 , 1
make memblock from mesh 1 , 1
FVF = memblock dword( 1 , 0 )
VertSize = memblock dword( 1 , 4 )
VertCount = memblock dword( 1 , 8 )
rem clean up
delete mesh 1
delete memblock 1
rem main loop
do
rem print data to screen
set cursor 0 , 0
print "FVF format: ";FVF
print "Vertex Size (in bytes): ";VertSize
print "Vertex Count: ";VertCount
rem refresh screen
sync
rem end of main loop
loop
Assuming you ran the code, you will now get an FVF of 338 and a vertex size of 36 bytes.
After doing that, you can freely change the diffuse values of every single vertex using the vertexdata commands:
rem I want vertex 2 to be red!
lock vertexdata for limb 1 , 0
set vertexdata diffuse 2 , 0xFFFF0000
unlock vertexdata
Also, here's a really cool feature that almost no one is aware of.

Did you know that you can set individual vertices to be transparent by changing the alpha channel? It requires an additional command for it to work though.
rem additional command so the object can be transparent
set object transparency 1 , 2
rem make vertex 2 transparent (0x50)
lock vertexdata for limb 1 , 0
set vertexdata diffuse 2 , 0x50FF0000
unlock vertexdata
Another thing to note is that the command
set object diffuse only works if the object accepts ambient light. Try using
set object light 1 , 0 and then
set object diffuse, you'll see that nothing will change. This is actually not the case when you edit the individual vertices.
TheComet