Hi!
I try to make a flashlight with the Ultimate Shader Pack (26 - FlashLight [Evolved]), and it doesn't work!
I retranscribed the code in DarkGDK:
#include "DarkGDK.h"
float Brightness=0.0;
bool Light=0;
bool NoPress=0;
int vec = 0;
int mat = 0;
float cr=0;
float cf=0;
float ncr=0;
float ncf=0;
float cx=0;
float cy=0;
float ncx=0;
float ncy=0;
float angX=0;
float angY=0;
float angZ=0;
void DarkGDK(void)
{
dbSetDir ( "Media" );
vec = dbMakeVector4(1);
vec = dbMakeVector3(2);
mat = dbMakeMatrix4(3);
mat = dbMakeMatrix4(4);
mat = dbMakeMatrix4(5);
mat = dbMakeMatrix4(6);
dbSyncOn();
dbSyncRate(0);
dbHideMouse();
dbBackdropOff();
dbAutoCamOff();
dbPositionCamera(0,50,-150);
dbSetCameraFOV(80);
dbLoadEffect("Null.fx",1,0);
dbLoadObject("Test.x",1);
dbSetObjectEffect(1,1);
dbSetObjectLight(1,0);
dbLoadImage("SpotLight2.dds",1,2);
dbLoadEffect("FlashLight.fx",2,0);
dbLoadObject("Test_lm.x",2);
dbSetObjectEffect(2,2);
dbTextureObject(2,1,1);
dbSetObjectLight(2,0);
dbGhostObjectOn(2,1);
dbSetObjectNormals(2);
dbSync();
while (LoopGDK())
{
cr=0;
cf=0;
if (dbRightKey()==1 || dbKeyState(32)==1) cr=-5;
if (dbLeftKey()==1 || dbKeyState(30)==1) cr=5;
if (dbUpKey()==1 || dbKeyState(17)==1) cf=5;
if (dbDownKey()==1 || dbKeyState(31)==1) cf=-5;
ncr=dbCurveValue(cr,ncr,5);
ncf=dbCurveValue(cf,ncf,5);
cx=cx+dbMouseMoveY()*0.2;
cy=cy+dbMouseMoveX()*0.2;
if (cx>80) cx=80;
if (cx<-80) cx=-80;
ncx=dbCurveAngle(cx,ncx,2);
ncy=dbCurveAngle(cy,ncy,2);
dbMoveCamera(ncf);
dbRotateCamera(0,dbWrapValue(ncy-90),0);
dbMoveCamera(ncr);
dbRotateCamera(0,dbWrapValue(ncy+90),0);
dbRotateCamera(ncx,ncy,0);
if (dbKeyState(33)==1 && NoPress==0 && Light==0)
{
Light=1;
NoPress=1;
}
if (dbKeyState(33)==1 && NoPress==0 && Light==1)
{
Light=0;
NoPress=1;
}
if (Light==0) Brightness=Brightness-0.1;
if (Light==1) Brightness=Brightness+0.1;
if (Brightness>1.0) Brightness=1.0;
if (Brightness<0.0) Brightness=0.0;
dbSetEffectConstantFloat(2,"BrightNess",Brightness);
if (dbKeyState(33)==0) NoPress=0;
dbSetVector4(1,dbCameraPositionX(),dbCameraPositionY(),dbCameraPositionZ(),0);
dbSetEffectConstantVector(2,"LightPosition",1);
angX=dbCurveAngle(dbCameraAngleX(),angX,4);
angY=dbCurveAngle(dbCameraAngleY(),angY,4);
dbSetVector3(2,1,0,0);
dbBuildRotationAxisMatrix4(3,2,(angX)/57.3);
dbSetVector3(2,0,1,0);
dbBuildRotationAxisMatrix4(4,2,(angY)/57.3);
dbSetVector3(2,0,0,1);
dbBuildRotationAxisMatrix4(5,2,(angZ)/57.3);
dbMultiplyMatrix4(6, 3, 4);
dbMultiplyMatrix4(6, 6, 5);
dbSetEffectConstantMatrix(2,"LightAngle",6);
dbSync();
}
return;
}
And, errors are in this lines:
dbSetEffectConstantFloat(2,"BrightNess",Brightness);
.......
dbSetEffectConstantVector(2,"LightPosition",1);
.......
dbSetEffectConstantMatrix(2,"LightAngle",6);
(I'm new with DarkGDK)
Thanks !
*=*=* MageNoir *=*=*
www.k-corps.com