_declspec( dllexport ) int _stdcall GetCurFrame(float freq, int nFrames)
{
return (int)fmod(secs_passed * ((double)freq), ((double)nFrames));
}
_declspec( dllexport ) void _stdcall wSawtooth(WaveFunc &Wave, D3DCOLORVALUE *ARGB)
{
time = ((double)Wave.phase) + ((double)Wave.freq) * secs_passed;
time -= floor(time);
time = ((double)Wave.base) + ((double)Wave.amp) * time;
ARGB->a = (float)1;
ARGB->r = (float)time;
ARGB->g = (float)time;
ARGB->b = (float)time;
}
_declspec( dllexport ) void _stdcall InitTimer()
{
LARGE_INTEGER f;
QueryPerformanceFrequency(&f);
tic_sec_ratio=(double)f.QuadPart;
sec_tic_ratio=1.0f/tic_sec_ratio;
}
_declspec( dllexport ) void _stdcall StartTimer()
{
QueryPerformanceCounter(&start_tics);
tics_passed=0;
secs_passed=0;
}
_declspec( dllexport ) void _stdcall StopTimer()
{
QueryPerformanceCounter(&stop_tics);
tics_passed+=stop_tics.LowPart-start_tics.LowPart;
start_tics=stop_tics;
secs_passed=(double)tics_passed*sec_tic_ratio;
}
_declspec( dllexport ) double _stdcall GetSecs()
{
return secs_passed;
}
you will notice that I cast my variables very strictly, this is because I thought the problem would rely on internal rounding errors (but it doesn''t appears to...).
InitTimer and StartTimer are called before entering the main loop, at the end of the main loop I just call StopTimer.
When I encounter an face wich uses an RGBgen, I just use this call to change the emissive material property of my D3DMATERIAL:
wSawtooth Waves(rgbGenData(CurStage.rgbGen).waveInd), ObjMaterial.emissive
Waves(rgbGenData(CurStage.rgbGen).waveInd) holds the wave data (amplitude, freq, bla...)
After the wave is calculated, I just set the material and activate lighting, so that it will affect the object
D3Ddevice.SetMaterial ObjMaterial
D3Ddevice.SetRenderState D3DRS_LIGHTING, 1
Perhaps I should explain my problem an little bit more, but I really don''t know the source of my problem, I think it''s within the code I posted here (I at least hope so...).
Please help, I''m really lost
Q3BSP shaders: I'm going mad :(
I had some problems with Q3 BSP shader wave functions, it seems like they don''t run simoultan to the texture-change-animation, so I decided to directly copy some disel source into my C++ DLL (I''m using VB6, please don''t kill me ) and call it from my renderer, so I came up with this:
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement