Chris, I'm not sure if this is the only problem with your code, but does the following slightly amended version work better?
The important lines are the ones marked with
// amended by GG -- ****** --
i.e. I'm fairly sure you intended to store data for every vertex separately.
// added by GG (out of habit) plus change to Project Screen properties
set display mode desktop width(), desktop height(), 32, 1
sync on
sync rate 60
sync
//
`VertexColorData
`VertexColorData.dba
`======================
` Generating Data affects vertex diffuse on render?
DoNotGenerateData = 1
` Attempt to rewrite diffuse colours?
RewriteVertexData = 1
` Prepare scene
Color Backdrop 0x909090
Sync Rate 80
Sync On
` Open results file for writing
If File Exist(Dir EXE() + "\Results.xml")
Delete File "Results.xml"
Endif
Open To Write 1, Dir EXE() + "\Results.xml"
Write String 1, "<Results>"
` Load terrains with vertex colors and output to file
Dim VertexData(2,5,400) as dword // amended by GG -- ****** --
For i = 1 to 2
Load Object "BasicTerrain.x", i
Move Object Right i, (i+i-3) * Object Size(i) * 0.7
Load Effect "VertexColorTangent.fx", i, 0, DoNotGenerateData
If RewriteVertexData
numLimbs = get limb count(i)
For l = 0 to Get Limb Count(i)
If Limb Has Mesh(i,l)
Lock VertexData For Limb i, l, 2
vcount = Get VertexData Vertex Count()
For v = 0 to vcount - 1
VertexData(i,l,v) = Get VertexData Diffuse(v) // amended by GG -- ****** --
Set Cursor 0, 0
Print "Memorizing Vertex " + Str$(v) + " of " + Str$(vcount) + " for rewriting"
` If v Mod 10 = 0 Then Sync
Next v
Unlock VertexData
Exit
Endif
Next l
Endif
// added by GG to aid testing
repeat
text 20, 20, "Finished storing vertex data for "+str$(vcount)+" vertices"
text 20,50+20*l, " recorded data for "+str$(numlimbs)+" limbs"
sync
until spacekey()
//
Set Object Effect i, i
If i = 1
Set Effect Technique i, "ColorWithData" ` Technique with tangent usage
Endif
` Rewrite after generating data
If RewriteVertexData
For l = 0 to Get Limb Count(i)
If Limb Has Mesh(i,l)
Lock VertexData For Limb i, l, 2
vcount = Get VertexData Vertex Count()
For v = 0 to vcount - 1
Set VertexData Diffuse v, VertexData(i,l,v) // amended by GG -- ****** --
Set Cursor 0, 0
Print "Restoring Vertex " + Str$(v) + " of " + Str$(vcount)
` If v Mod 10 = 0 Then Sync
Next v
Unlock VertexData
Exit
Endif
Next l
Endif
For l = 0 to Get Limb Count(i)
If Limb Has Mesh(i,l)
Write String 1, Tab$() + "<Limb ID='" + Str$(l) + "' Object='" + Str$(i) + "' Name='" + Limb Name$(i,l) + "' >"
Lock VertexData For Limb i, l, 2
vcount = Get VertexData Vertex Count()
For v = 0 to vcount - 1
col = Get VertexData Diffuse(v)
r = RGBR(col)
g = RGBG(col)
b = RGBB(col)
Set Cursor 0, 0
Print "Writing Vertex " + Str$(v) + " of " + Str$(vcount) + " RGB: " + Str$(r) + "," + Str$(g) + "," + Str$(b)
If v Mod 5 = 0 Then Sync : wait 100
Write String 1, Tab$() + Tab$() + "<V ID='" + Str$(v) + "' RGB='" + Str$(r) + "," + Str$(g) + "," + Str$(b) + "' />"
Next v
Unlock VertexData
Write String 1, Tab$() + "</Limb>"
Exit
Endif
Next l
Next i
Write String 1, "</Results>"
Close File 1
Move Camera Up 30
Global v3Track : v3Track = New Vector3()
Do
Set Cursor 0, 0
BasicCameraMovement( c, 1.5, 2, 1, v3Track )
Sync
Loop
//==================================================
Function BasicCameraMovement( c, fSpeed#, fRotateSpeed#, fMouseInfluence#, v3Track )
If c < 0 Then ExitFunction
If Camera Exist(c) = 0 Then ExitFunction
If fMouseInfluence# <> 0
If v3Track > 0 And Vector Exist(v3Track)
//If BypassMouseZoom) = 0 Then Move Camera c, fMouseInfluence# * Clamp(MouseMoveZ(),-10,10) * fSpeed#
Move Camera Left c, Clamp(MouseMoveX(),-10,10) * fSpeed# * fMouseInfluence#
Position Camera CPX, CPY + Clamp(MouseMoveY(),-10,10) * fSpeed# * fMouseInfluence#, CPZ
Else
If ControlKey() + ShiftKey() = 0
YRotate Camera c, ( CAY + Clamp(MouseMoveX(),-10,10) * fRotateSpeed# * fMouseInfluence#)
XRotate Camera c, (CAX + Clamp(MouseMoveY(),-10,10) * fRotateSpeed# * fMouseInfluence#)
EndIf
Move Camera c, Clamp(MouseMoveY(),-10,10) * fSpeed# * fMouseInfluence#
Endif
Endif
Move Camera c, ( KeyState(KEY_W) - KeyState(KEY_S) ) * (fSpeed# + ((ControlKey() * fSpeed# * 9)) - ((ShiftKey() * fSpeed# * 0.75)) )
If Vector Exist(v3Track)
Move Camera Left c, KeyState(KEY_D) - KeyState(KEY_A) * fSpeed#
Move Camera Up c, KeyState(KEY_E) - KeyState(KEY_Q) * fSpeed#
Point Camera At Vector3 c, v3Track
Else
If fMouseInfluence# <> 0 And MouseClicked && 2
YRotate Camera c, CAY -((KeyState(KEY_A) * fRotateSpeed# ) + -KeyState(KEY_D) * fRotateSpeed#)
XRotate Camera c, CAX -( (KeyState(KEY_E) * fRotateSpeed#) + -KeyState(KEY_Q) * fRotateSpeed# )
`Print "Rotate mode"
Else
Move Camera Right c, (KeyState(KEY_D) * fSpeed# ) - (KeyState(KEY_A) * fSpeed#)
XRotate Camera c, CAX -( (KeyState(KEY_E) * fRotateSpeed#) + -KeyState(KEY_Q) * fRotateSpeed# )
`Print "Strafe mode"
Endif
Endif
Endfunction
#CONSTANT CPOS Camera Position X(), Camera Position Y(), Camera Position Z()
#CONSTANT CANG Camera Angle X(), Camera Angle Y(), Camera Angle Z()
#CONSTANT RCAM Rotate Camera
#CONSTANT PCAM Position Camera
#CONSTANT XRCAM XRotate Camera
#CONSTANT YRCAM YRotate Camera
#CONSTANT ZRCAM ZRotate Camera
#CONSTANT TCAML Turn Camera Left
#CONSTANT TCAMR Turn Camera Right
#CONSTANT MCAM Move Camera
#CONSTANT MCAML Move Camera Left
#CONSTANT MCAMR Move Camera Right
#CONSTANT MCAMU Move Camera Up
#CONSTANT MCAMD Move Camera Down
#CONSTANT CPX Camera Position X(c)
#CONSTANT CPY Camera Position Y(c)
#CONSTANT CPZ Camera Position Z(c)
#CONSTANT CAX Camera Angle X()
#CONSTANT CAY Camera Angle Y()
#CONSTANT CAZ Camera Angle Z()
#CONSTANT CANGX Camera Angle X(c)
#CONSTANT CANGY Camera Angle Y(c)
#CONSTANT CANGZ Camera Angle Z(c)
#CONSTANT CAM_POS_STRING Str$(Camera Position X()) + ", " + Str$(Camera Position Y()) + ", " + Str$(Camera Position Z())
#CONSTANT CAM_INT_POS_STRING Str$(Camera Position X(),0) + ", " + Str$(Camera Position Y(),0) + ", " + Str$(Camera Position Z(),0)
#CONSTANT SHIFT_KEY_FLAG 1
#CONSTANT CTRL_KEY_FLAG 2
#CONSTANT ALT_KEY_FLAG 4
//======================================================================
` Key codes
#constant Key_0 11
#constant Key_1 2
#constant Key_2 3
#constant Key_3 4
#constant Key_4 5
#constant Key_5 6
#constant Key_6 7
#constant Key_7 8
#constant Key_8 9
#constant Key_9 10
#constant Key_A 30
#constant Key_ABNT_C1 115
#constant Key_ABNT_C2 126
#constant Key_ADD 78
#constant Key_APOSTROPHE 40
#constant Key_APPS 221
#constant Key_AT 145
#constant Key_AX 150
#constant Key_B 48
#constant Key_BACK 14
#constant Key_BACKSLASH 43
#constant Key_BACKSPACE 14
#constant Key_C 46
#constant Key_CALCULATOR 161
#constant Key_CAPITAL 58
#constant Key_CAPSLOCK 58
#constant Key_CIRCUMFLEX 144
#constant Key_COLON 146
#constant Key_COMMA 51
#constant Key_CONVERT 121
#constant Key_D 32
#constant Key_DECIMAL 83
#constant Key_DELETE 211
#constant Key_DIVIDE 181
#constant Key_DOWN 208
#constant Key_DOWNARROW 208
#constant Key_E 18
#constant Key_END 207
#constant Key_ENTER 28
#constant Key_EQUALS 13
#constant Key_ESCAPE 1
#constant Key_F 33
#constant Key_F1 59
#constant Key_F2 60
#constant Key_F3 61
#constant Key_F4 62
#constant Key_F5 63
#constant Key_F6 64
#constant Key_F7 65
#constant Key_F8 66
#constant Key_F9 67
#constant Key_F10 68
#constant Key_F11 87
#constant Key_F12 88
#constant Key_F13 100
#constant Key_F14 101
#constant Key_F15 102
#constant Key_G 34
#constant Key_GRAVE 41
#constant Key_H 35
#constant Key_HOME 199
#constant Key_I 23
#constant Key_INSERT 210
#constant Key_J 36
#constant Key_K 37
#constant Key_KANA 112
#constant Key_KANJI 148
#constant Key_L 38
#constant Key_LALT 56
#constant Key_LBRACKET 26
#constant Key_LCONTROL 29
#constant Key_LEFT 203
#constant Key_LEFTARROW 203
#constant Key_LMENU 56
#constant Key_LSHIFT 42
#constant Key_LWIN 219
#constant Key_M 50
#constant Key_MAIL 236
#constant Key_MEDIASELECT 237
#constant Key_MEDIASTOP 164
#constant Key_MINUS 12
#constant Key_MULTIPLY 55
#constant Key_MUTE 160
#constant Key_MYCOMPUTER 235
#constant Key_N 49
#constant Key_NEXT 209
#constant Key_NEXTTRACK 153
#constant Key_NOCONVERT 123
#constant Key_NUMLOCK 69
#constant Key_NUMPAD0 82
#constant Key_NUMPAD1 79
#constant Key_NUMPAD2 80
#constant Key_NUMPAD3 81
#constant Key_NUMPAD4 75
#constant Key_NUMPAD5 76
#constant Key_NUMPAD6 77
#constant Key_NUMPAD7 71
#constant Key_NUMPAD8 72
#constant Key_NUMPAD9 73
#constant Key_NUMPADCOMMA 179
#constant Key_NUMPADENTER 156
#constant Key_NUMPADEQUALS 141
#constant Key_NUMPADMINUS 74
#constant Key_NUMPADPERIOD 83
#constant Key_NUMPADPLUS 78
#constant Key_NUMPADSLASH 181
#constant Key_NUMPADSTAR 55
#constant Key_O 24
#constant Key_OEM_102 86
#constant Key_P 25
#constant Key_PAUSE 197
#constant Key_PERIOD 52
#constant Key_PGDN 209
#constant Key_PGUP 201
#constant Key_PLAYPAUSE 162
#constant Key_POWER 222
#constant Key_PREVTRACK 144
#constant Key_PRIOR 201
#constant Key_Q 16
#constant Key_R 19
#constant Key_RALT 184
#constant Key_RBRACKET 27
#constant Key_RCONTROL 157
#constant Key_RETURN 28
#constant Key_RIGHT 205
#constant Key_RIGHTARROW 205
#constant Key_RMENU 184
#constant Key_RSHIFT 54
#constant Key_RWIN 220
#constant Key_S 31
#constant Key_SCROLL 70
#constant Key_SEMICOLON 39
#constant Key_SLASH 53
#constant Key_SLEEP 223
#constant Key_SPACE 57
#constant Key_SPACEBAR 57
#constant Key_STOP 149
#constant Key_SUBTRACT 74
#constant Key_SYSRQ 183
#constant Key_T 20
#constant Key_TAB 15
#constant Key_U 22
#constant Key_UNDERLINE 147
#constant Key_UNLABELED 151
#constant Key_UP 200
#constant Key_UPARROW 200
#constant Key_V 47
#constant Key_VOLUMEDOWN 174
#constant Key_VOLUMEUP 176
#constant Key_W 17
#constant Key_WAKE 227
#constant Key_WEBBACK 234
#constant Key_WEBFAVORITES 230
#constant Key_WEBFORWARD 233
#constant Key_WEBHOME 178
#constant Key_WEBREFRESH 231
#constant Key_WEBSEARCH 229
#constant Key_WEBSTOP 232
#constant Key_X 45
#constant Key_Y 21
#constant Key_YEN 125
#constant Key_Z 44
Oops, sorry Chris, forgot to warn you that I inserted a loop to break the code into sections, just press <spacekey> when the current set of calculations seem to be complete..
Code for loop:
// added by GG to aid testing
repeat
text 20, 20, "Finished storing vertex data for "+str$(vcount)+" vertices"
text 20,50+20*l, " recorded data for "+str$(numlimbs)+" limbs"
sync
until spacekey()
//