SetOrthoCamera() by Dmitry K12th Nov 2004 13:10
|
---|
Summary Orthographic camera in DBPro Description Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com `******************************************************************************* `* Function SetOrthoCamera() * `* Created: 12/11/2004 * `* By: Dmitry K aka DMiTR0S dmitr0s@newmail.ru * `******************************************************************************* `******************************************************************************* `* Free License Agreement. * `* * `* The user/developer agrees to include a visible credit to "Dmitry Kuschev" * `* within your programs documentation and or web site. * `* * `* The user/developer agrees to NOT offer the this source code for Sale. * `* * `* Providing the user/Developer agrees in full to the previous Free * `* License Agreement clauses, the user/developer may use this source * `* code FREELY in all their products, commercial or otherwise. * `* * `******************************************************************************* CameraDll=1 Camera=0 For i=1 To 500 Make Object Cube i, Rnd(10) Position Object i, 500-Rnd(1000), 500-Rnd(1000), 500-Rnd(1000) Rotate Object i, Rnd(360), Rnd(360), Rnd(360) Next i SetOrthoCamera(CameraDll, Camera) Sync Rate 0 Sync On Do Control Camera Using ArrowKeys Camera, .1, .1 Text 10, 10, "Function SetOrthoCamera() by Dmitry Kuschev" Sync Loop Function SetOrthoCamera(CameraDll, Camera) Near#=1.0 Far#=3000.0 Width#=Screen Width()*1.0 Height#=Screen Height()*1.0 Load Dll "DBProCameraDebug.dll", CameraDll `Get pointer on internal structure of camera CID=Call Dll(1, "?GetInternalData@@YAPAXH@Z", Camera) `Get camera Projection matrix m00=CID : m01=CID+4 : m02=CID+8 : m03=CID+12 m10=CID+16 : m11=CID+20 : m12=CID+24 : m13=CID+28 m20=CID+32 : m21=CID+36 : m22=CID+40 : m23=CID+44 m30=CID+48 : m31=CID+52 : m32=CID+56 : m33=CID+60 `Replace camera Projection matrix with Ortho matrix *m00=2.0/Width# : *m01=0.0 : *m02=0.0 : *m03=0.0 *m10=0.0 : *m11=2.0/Height# : *m12=0.0 : *m13=0.0 *m20=0.0 : *m21=0.0 : *m22=1.0/(Far#-Near#) : *m23=0.0 *m30=0.0 : *m31=0.0 : *m32=1.0*Near#/(Near#-Far#) : *m33=1.0 EndFunction |