hi all , i have decided that before i'll jump into directX that for me is extremly hard to understand ,damn i dont even understand Win Api... i dont even know what a Dword is..
so , i have started cruising the Forums and converted some code maid by Van B, van ty so much.
here you can paint directly on a 3D object
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
void plot_memimage(int mem,int x,int y,int col,int res);
void update_memimage(int mem,int img);
void create_memimage(int mem,int img,int wid,int hig);
// the main entry point for the application is this function
void DarkGDK ( void )
{
dbSyncOn();
dbBackdropOn();
dbAutoCamOff();
dbSetCameraRange(0.5, 30000);
dbRandomize(dbTimer());
int colour_res=512;
int terrain_res;
float colour_res1;
float terrain_res1;
//` movement
float g_fSpeed = 0.05;
float g_fTurn = 0.3;
create_memimage(1,1,colour_res,colour_res);
for( int x=0;x <= colour_res;x++)
{
for( int y=0;y <= colour_res;y++)
{
plot_memimage(1,x,y,dbRnd(255),colour_res);
}
}
terrain_res=256*3;
colour_res1=colour_res;
terrain_res1=terrain_res;
dbMakeObjectPlain(1,terrain_res,terrain_res);
dbTextureObject( 1,1);
dbRotateObject (1,270,0,0);
dbPositionObject( 1,terrain_res/2.0,0,terrain_res/2.0);
update_memimage(1,1);
//` position the camera
dbPositionCamera(385,23,100);
DWORD col=dbRgb(255,255,255);
int cy = 0;
int lastmb = 0;
int mb = 0, mx = 0, my = 0;
float mv = 0.0f;
int pick = 0;
float CameraAngleY = 0;
float CameraAngleX = 0;
while ( LoopGDK ( ) )
{
lastmb = mb;
mb=dbMouseClick();
mx=dbMouseX();
my=dbMouseY();
mv = dbUpKey()-dbDownKey();
dbMoveCamera( g_fSpeed*mv);
if (mb==1)
{
pick=dbPickObject(mx,my,1,1);
if (pick>0)
{
float curx=dbCameraPositionX()+dbGetPickVectorX();
float curz=dbCameraPositionZ()+dbGetPickVectorZ();
float px=(curx/terrain_res)*colour_res;
float py=(curz/terrain_res)*colour_res;
plot_memimage(1,px,py,dbRgb(255,255,0),colour_res);
if (dbRnd(10)==1)update_memimage(1,1);
}
}
if (mb==0 && lastmb==1) update_memimage(1,1);
if (mb==2)
{
//if (lastmb != 2) dbMouseMoveX() + dbMouseMoveY();
//` store old camera angle
float OldCamAngleY = CameraAngleY;
float OldCamAngleX = CameraAngleX;
//` store new camera angle
CameraAngleY = dbWrapValue ( CameraAngleY + dbMouseMoveX ( ) * 0.4 );
CameraAngleX = dbWrapValue ( CameraAngleX + dbMouseMoveY ( ) * 0.4 );
dbRotateCamera(dbCurveAngle ( CameraAngleX, OldCamAngleX, 24 ),dbCurveAngle ( CameraAngleY, OldCamAngleY, 24 ),0);
}
// Camera Y Angle
cy =dbCameraPositionY();
if (cy<3.0 ) cy=3.0;
dbPositionCamera(dbCameraPositionX(),cy,dbCameraPositionZ());
// update the screen
dbSync ( );
}
// return back to windows
return;
}
void create_memimage(int mem,int img,int wid,int hig)
{
int size=(wid*hig*4)+12;
if (dbMemblockExist(mem)==1){dbDeleteMemblock( mem);}
dbMakeMemblock(mem,size);
dbWriteMemblockDword( mem,0,wid);
dbWriteMemblockDword( mem,4,hig);
dbWriteMemblockDword( mem,8,32);
if (dbImageExist(img)==1) dbDeleteImage( img);
dbMakeImageFromMemblock( img,mem);
}
void plot_memimage(int mem,int x,int y,int col,int res)
{
x=res-x;
if (dbMemblockExist(mem)==0)return;
if (x<0 || y<0) return;
if (x>=res || y>=res) return;
int pos=12+((x+(y*res))*4);
dbWriteMemblockByte( mem,pos+0,dbRgbB(col));
dbWriteMemblockByte( mem,pos+1,dbRgbG(col));
dbWriteMemblockByte( mem,pos+2,dbRgbR(col));
dbWriteMemblockByte( mem,pos+3,0);
}
void update_memimage(int mem,int img)
{
if (dbMemblockExist(mem)==0) return;
if (dbImageExist(img) == 1) dbDeleteImage(img);
dbMakeImageFromMemblock( img,mem);
if (img==1)dbTextureObject( 1,1);
}
and i already have the seamless texture working.