|
GAME PROGRAMMING RESOURCES
<< BACK
|
|
|
USING 3IMPACT AS A DLL with FRAMEWORK PASCAL (FORMER TMT PASCAL) STEP-BY-STEP
NOTE: the package mentioned in this tutorial was designed especially for version 5.3.0.0 of the 3IMPACT engine, and was thoroughly tested until 6th of September 2007.
If you have any questions, bug-reports, suggestions, e-mail here.
Register
3IMPACT, download and install it.
Download the
Framework Pascal Package for 3IMPACT (13KB)
which contains 3IMPACT APIs ported and adapted by Varagus™ Technologies for Framework Pascal, and unzip the contained file _3IMPACT.PAS in your project's directory.
In your program or unit's interface section use the following line:
uses _3impact;
That's all! Enjoy it! ;)
NOTES
The Framework Pascal Package works only when 3IMPACT is used as a DLL.
The FLOAT type used in the original C/C++ sources corresponds to the Pascal SINGLE type, NOT to the REAL or DOUBLE types!!!
The package contains all the API delclarations until version 5.3.0.0 of 3IMPACT.
The package was brought to a mature state, overloaded operators are now availalble for all vector types. This means that from now on, you will be able to
compare / add / subtract / multiply / divide vectors using the standard pascal syntax used for standard predefined types.
The following operations are now allowed on vectors, using overloaded operators:
(+) addition (vector1 + vector2 | vector1 + float_number);
(+:=) addition and assignment (same, vector1 = result);
(-) subtraction (vector - vector | vector - float_number);
(-:=) subtraction and assignment (same, vector1 = result);
(*) multiplication (vector * float_number);
(*:=) multiplication and assignment (same, vector1 = result);
(/) division (vector / float_number);
(/:=) division and assignment (same, vector1 = result);
If you have any questions regarding the use of overloaded operators in Framework Pascal, send us an e-mail here.
Example: var v1, v2, v3 : D3DXVECTOR2; v3 := v1 / v2; --vector division by another vector; v1 /:= 2.12; --vector division by a number;
v1 := v1 * 3.2; --vector scaling by a number;
We have also added some macros for creating vectors and pointers to vectors, using direct vector contents as parameters.
The macros for creating vectors are:
_VE2(x,y) --D3DXVECTOR2 with coords=(x,y);
_VE3(x,y,z) --D3DXVECTOR3 with coords=(x,y,z);
_VE4(x,y,z,w) --D3DXVECTOR4 with coords=(x,y,z,w);
_QUAT(x,y,z,w) --D3DXQUATERNION with coords=(x,y,z,w);
_PLANE(a,b,c,d) --D3DXPLANE with coords=(a,b,c,d);
The following macros create pointers to vectors. There are 16 predefined reusable vectors for each vector type.
This ensures the code is clean, without memory leaks. These reusable vectors have indices from 0 to 15.
We encourage everyone to use these vectors as much as possible, because static pointers work much faster than dynamic pointers.
The mechanism is simple: the application creates a vector, stores it in the specified index, and returns a pointer to the specified vector.
_PVE2(index,x,y) --PD3DXVECTOR2 with coords=(x,y);
_PVE3(index,x,y,z) --PD3DXVECTOR3 with coords=(x,y,z);
_PVE4(index,x,y,z,w) --PD3DXVECTOR4 with coords=(x,y,z,w);
_PQUAT(index,x,y,z,w) --PD3DXQUATERNION with coords=(x,y,z,w);
_PPLANE(index,a,b,c,d) --PD3DXPLANE with coords=(a,b,c,d);
The vectors stored in the specified indexes remain there until they are overwritten. They are very useful for immediate operations. As mentioned above, they are reusable.
Example: vect1 := _VE3(1, 2, 3); --creates a D3DXVECTOR3 (x=1, y=2, z=3);
pvect1 := _PVE2(0, 1, 2); --creates a PD3DXVECTOR2;
pvect1^ +:= 3; --adds 3 to vector stored at index 0. The new values of the vector will be (x: 4; y: 5);
For extensions and tools for 3IMPACT visit Varagus™ Technologies' website.
|
|