Just did a quick test to create a lightmap on a texture and it turned out to be quite easy(image attached).
This is using the 'intersect object' command and memblocks to alter the image.
#include "DarkGDK.h"
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbMakeObjectBox(2, 25, 5, 25);
dbPositionObject(2, 0, 15, 0);
dbRotateObject(2, 0, 30, 0);
dbLoadImage("Images/Texture.jpg", 1);
dbMakeMemblockFromImage(1, 1);
int size = dbGetMemblockSize(1);
DWORD width = dbMemblockDword(1, 0);
DWORD height = dbMemblockDword(1, 4);
DWORD depth = dbMemblockDword(1, 8);
dbMakeMemblock(2, size);
dbWriteMemblockDword(2, 0, width);
dbWriteMemblockDword(2, 4, height);
dbWriteMemblockDword(2, 8, depth);
int x = 0;
int y = 0;
for(int i = 0; i < width * height; i++){
DWORD p = dbMemblockDword(1, (i * 4) + 12);
int r = dbRGBR(p);
int g = dbRGBG(p);
int b = dbRGBB(p);
float intersect = dbIntersectObject(2, x - 128, 100, 128 - y, x - 128, -100, 128 - y);
if(intersect){
int brightness = 100;
r -= brightness;
if(r < 0) r = 0;
g -= brightness;
if(g < 0) g = 0;
b -= brightness;
if(b < 0) b = 0;
}
dbWriteMemblockDword(2, (i * 4) + 12, dbRGB(r, g, b));
x++;
if(x == width){
x = 0;
y++;
}
}
dbMakeImageFromMemblock(2, 2);
dbSaveImage("Images/TextureAltered.jpg", 2);
dbMakeObjectPlain(1, 256, 256);
dbRotateObject(1, -90, 0, 0);
dbTextureObject(1, 2);
while ( LoopGDK ( ) )
{
// display some text on screen
dbText ( 0, 0, "Use the up and down arrow keys to move the camera" );
// move the camera forwards
if ( dbUpKey ( ) )
dbMoveCamera ( 1 );
// move the camera backwards
if ( dbDownKey ( ) )
dbMoveCamera ( -1 );
dbSync ( );
}
return;
}
If I create a tool for this I will share with all