Hmm okay, I was playing with this and first things first, I'll post the translated code for C++ and my game.
It will be a bit different because I'm looping through an 8x8 grid of terrains with the names
gv1(#,#)
mapName is a string that contains the filename of the map we're working with at the moment.
{
.....
for (int o=0; o<=7;o++)
{
for (int i=0; i<=7; i++)
{
dbHideAllSprites();
dbPasteSprite(loadScreen+50000,0,0);
dbText(xResolution*.4,yResolution*.7,"Terrain");
dbText(xResolution*.4,yResolution*.75,dbStr(i+1));
dbText(xResolution*.4,yResolution*.8,dbStr(o+1));
dbSync();
memset(mapName,0x0,sizeof(mapName));
strcat(mapName,"3D Maps/gv1(");
strcat(mapName,dbStr(i+1));
strcat(mapName,",");
strcat(mapName,dbStr(o+1));
strcat(mapName,").dbo");
dbLoadObject(mapName,GVTRAINING+i+(8*o));
convertTerrain(i,o,mapName);
}
}
}
void convertTerrain(int i, int o, char mapName[200])
{
int base = TedVA_ExtractBaseLayer(GVTRAINING+i+(8*o),165210,1681848);
memset(mapName,0x0,sizeof(mapName));
strcat(mapName,"DBO/gv1(");
strcat(mapName,dbStr(i+1));
strcat(mapName,",");
strcat(mapName,dbStr(o+1));
strcat(mapName,")_T.dbo");
dbSaveObject(mapName,GVTRAINING+i+(8*o));
memset(mapName,0x0,sizeof(mapName));
strcat(mapName,"DBO/gv1(");
strcat(mapName,dbStr(i+1));
strcat(mapName,",");
strcat(mapName,dbStr(o+1));
strcat(mapName,")_B.dbo");
dbSaveObject(mapName,base);
}
int TedVA_ExtractBaseLayer(int inObj,int freeMeshNum,int freeImgNum)
{
int count = 0;
int curobj = inObj+1;
char right[100];
char basetex[100];
_startloop:
for (int i = 1; i<=dbChecklistQuantity(); i++)
{
if ( strcmp(dbRight(dbChecklistString(i),10),"BASELAYER1")==0 )
{
if (strcmp(basetex,"")==0)
{
strcpy(basetex,dbLimbTextureName(inObj,i-1));
}
dbMakeObjectFromLimb(curobj,inObj,i-1);
dbPositionObject(curobj,dbLimbPositionX(inObj,i-1),dbLimbPositionY(inObj,i-1),dbLimbPositionZ(inObj,i-1));
count++;
curobj++;
dbRemoveLimb(inObj,i-1);
goto _startloop;
}
}
int outObj = inObj+count;
if (count == 1)
{
goto _end_conversion;
}
dbLoadImage(basetex,freeImgNum);
int limbcount = 1;
for (int i = inObj+1; i<= outObj-1; i++)
{
dbMakeMeshFromObject(freeMeshNum,i);
dbAddLimb(outObj,limbcount,freeMeshNum);
dbTextureLimb(outObj,limbcount,freeImgNum);
dbOffsetLimb(outObj,limbcount,dbObjectPositionX(i), dbObjectPositionY(i), dbObjectPositionZ(i));
dbDeleteMesh (freeMeshNum);
dbDeleteObject(i);
limbcount++;
}
_end_conversion:
dbSetObjectTransparency(inObj,2);
return(outObj);
}
I'd like to say it kind of works, but whether I load the Base terrains or the Texture layer terrains, I still end up with only the bottom gray stone layer instead of my grass. It might be working *slightly* because my stone has a slightly greeny colour (as can be proved in an in image editor), however it's like the grass layer is about 1% opacity, despite it being maxed out for alpha in T.ED when I exported the .x vertex alpha files.
Seems I'm still having quite a few issues here. It seems to *Work* but it's still not getting what I need, for completely unknown reasons.