Niels, I encountered the same problem as you, until I realised that the new vertex data was being stored onto a different limb (limb 0, instead of limb 1).
Here is updated code, showing loading/saving:
#include "DarkGDK.h"
int mapWidth = 100;
int mapHeight = 100;
int mapDepth = 100;
int mapSplit = 4;
int selectSize = 2;
int wireFrameMode = 0;
int pick;
float dist;
float camx;
float camy;
float camz;
float px;
float py;
float pz;
int vertCountStart;
int vertCountEnd;
float vertx;
float verty;
float vertz;
float keyTimer;
float timeWait = 0;
int objectLoaded = 0;
void DarkGDK(void)
{
dbSyncOn();
dbSyncRate(0);
dbSetDisplayModeAntialias(800,600,32,0,8,0);
dbSetWindowPosition((dbDesktopWidth() / 2) - (dbScreenWidth() / 2),(dbDesktopHeight() / 2) - (dbScreenHeight() / 2));
dbAutoCamOff();
dbLoadObject("vertManiPlain.x",1);
dbPositionObject(1,0,0,0);
dbSetObjectWireframe(1,wireFrameMode);
dbSetObjectEmissive(1,0xFFFFFF);
dbPositionCamera(0,150,-100);
dbPointCamera(0,0,0);
while ( LoopGDK ( ) )
{
pick = dbPickObject(dbMouseX(), dbMouseY(), 1, 2);
dist = dbGetPickDistance();
dbPickScreen(dbMouseX(), dbMouseY(), dist);
camx = dbCameraPositionX();
camy = dbCameraPositionY();
camz = dbCameraPositionZ();
px = dbGetPickVectorX() + camx;
py = dbGetPickVectorY()+ camy;
pz = dbGetPickVectorZ() + camz;
if (objectLoaded == 0)
{
dbLockVertexDataForLimb(1,1,1);
}
else
{
dbLockVertexDataForLimb(1,0,1);
}
vertCountStart = 0;
vertCountEnd = dbGetVertexDataVertexCount();
for (int i = vertCountStart; i < vertCountEnd; i++)
{
vertx = dbGetVertexDataPositionX(i);
verty = dbGetVertexDataPositionY(i);
vertz = dbGetVertexDataPositionZ(i);
if (vertx > px - selectSize && vertx < px + selectSize && verty > py - selectSize && verty < py + selectSize && vertz > pz - selectSize && vertz < pz + selectSize)
{
if (dbMouseClick() == 1)
{
verty = verty + 2;
}
if (dbMouseClick() == 2)
{
verty = verty - 2;
}
}
dbSetVertexDataPosition(i,vertx,verty,vertz);
}
dbUnlockVertexData();
dbText(0,0,dbStr(dbScreenFPS()));
dbText(0,10,"Press 1,2 & 3 for different detail levels");
dbText(0,20,"Press W For wireframe on/off");
dbText(0,30,"Press A/D to increase/decrease brush size");
dbText(0,40,"Use the left mouse button to raise vertices");
dbText(0,50,"Use the right mouse button to lower vertices");
dbText(0,60,"Press S to save the object.");
dbText(0,70,"Press L to load the object.");
if (dbKeyState(2))
{
dbDeleteObject(1);
dbLoadObject("vertManiPlain.x",1);
dbPositionObject(1,0,0,0);
dbSetObjectWireframe(1,wireFrameMode);
dbSetObjectEmissive(1,0xFFFFFF);
}
if (dbKeyState(3))
{
dbDeleteObject(1);
dbLoadObject("vertManiPlain2.x",1);
dbPositionObject(1,0,0,0);
dbSetObjectWireframe(1,wireFrameMode);
dbSetObjectEmissive(1,0xFFFFFF);
}
if (dbKeyState(4))
{
dbDeleteObject(1);
dbLoadObject("vertManiPlain3.x",1);
dbPositionObject(1,0,0,0);
dbSetObjectWireframe(1,wireFrameMode);
dbSetObjectEmissive(1,0xFFFFFF);
}
keyTimer = dbTimer();
if (timeWait + 100 < keyTimer)
{
if (dbKeyState(17))
{
if (wireFrameMode == 0)
{
wireFrameMode = 1;
dbSetObjectWireframe(1,1);
}
else
{
wireFrameMode = 0;
dbSetObjectWireframe(1,0);
}
}
if (dbKeyState(30))
{
selectSize = selectSize + 1;
}
if (dbKeyState(32))
{
selectSize = selectSize - 1;
}
if (dbKeyState(31))
{
if (dbFileExist("vertManiPlainUser.x") == 1)
{
dbDeleteFile("vertManiPlainUser.x");
}
dbMakeMeshFromObject(1,1);
dbSaveMesh("vertManiPlainUser.x",1);
}
if (dbKeyState(38))
{
if (dbObjectExist(1) == 1)
{
dbDeleteObject(1);
}
if (dbFileExist("vertManiPlainUser.x") == 1)
{
dbLoadObject("vertManiPlainUser.x",1);
dbPositionObject(1,0,0,0);
dbSetObjectWireframe(1,wireFrameMode);
dbSetObjectEmissive(1,0xFFFFFF);
objectLoaded = 1;
}
}
timeWait = keyTimer;
}
dbSync ( );
}
dbDeleteObject(1);
return;
}
Give that a go and get back to me if it helps with your problem!