PDA

View Full Version : GAME engine + non-polygonal 3d collision detection project



Georgy
05-02-2008, 04:22 PM
latest version here: http://www.igrodel.ru/tdg3d

This is the new release of Collision Detection engine. It is better than CDNR1 (released in 2006). Improved perfomance and less memory requirements, here it is: CDNR2ALPHA v2008-2-5: http://www.igrodel.ru/index.php?p=1202226872

http://www.igrodel.ru/upload/cdnr2alpha-2008-2-5-1.jpg http://www.igrodel.ru/upload/cdnr2alpha-2008-2-5-2.jpg

http://www.igrodel.ru/upload/cdnr2alpha-2008-2-5.7z (245kb)

waran
05-02-2008, 04:53 PM
I browsed your code a bit and here are my tips :D
Avoid so much divisions. Float divs are slow like hell.

Slow:

vx:=vx/vlen;
vy:=vy/vlen;
vz:=vz/vlen;
Damn lot faster:

vlen := 1/vlen;
vx:=vx*vlen;
vy:=vy*vlen;
vz:=vz*vlen;

Also check if you are using any sqrt() for your bounding circle/sphere
code - its unnecessary!

Maybe you can use further math-tricks to speed it up a lot.
To success!

Georgy
20-02-2008, 01:13 PM
small update: the same engine sources with old demo included
http://www.igrodel.ru/upload/myengine-2008-2-20.zip (771kb)

chronozphere
20-02-2008, 03:13 PM
Also check if you are using any sqrt() for your bounding circle/sphere
code - its unnecessary!

Hmmm... that makes me kinda curious. How can you do circle collision detection without using the square root :?

I thought the only way was to use pythagoras. Can you explain how your way works? :razz:

waran
20-02-2008, 03:19 PM
Pythagoras said: c¬? = a¬? + b¬?.
If you want to find out c, you need the root. But
that isn't exactly what you want to know...


type
circle = record
x, y, r: single;
end;

function collide(a, b: circle): boolean;
begin
result &#58;= sqr&#40;a.x-b.x&#41; + sqr&#40;a.y-b.y&#41; <= sqr&#40;a.r+b.r&#41;;
end;

Just quad the radii and compare :)

Georgy
22-02-2008, 12:58 PM
this code (mycollisiontrick.pas) runs only 1 time for each object in frame
it's better to optimise 2d code in collisioncircle/docollision array layered heightmap algorithm (mydepthcollision.pas) first.

chronozphere
22-02-2008, 04:35 PM
@waran: that's a neat trick...You dont need to know the actual length between the circle centers. why didn't i thought about this before. :razz:

Georgy
13-03-2008, 12:51 PM
New release with debug output:
http://www.igrodel.ru/tdg3d/tdg-4.jpg

http://www.igrodel.ru/tdg3d/tdg-3.jpg

http://www.igrodel.ru/tdg3d/tdg-2.jpg

http://www.igrodel.ru/tdg3d/tdg-1.jpg

http://www.igrodel.ru/tdg3d/tdg-2008-3-13.zip

Georgy
21-03-2008, 12:53 PM
v 2008/3/21
- new more powerful functions added
- added post-processing shader functions
- better GLSL shader support
- collision detection improvements
- fixed material management errors
- some changes in nft_export.py for Blender 2.45

Download:
http://www.igrodel.ru/tdg3d/tdg-2008-3-21.zip

Screenshots:
http://www.igrodel.ru/tdg3d/tdg-7.jpg

http://www.igrodel.ru/tdg3d/tdg-6.jpg

Georgy
05-04-2008, 12:43 PM
Added screen space ambient occlusion support:

http://www.igrodel.ru/tdg3d/tdg-8.jpg

v 2008/4/5
- added simple dynamic Ambient Occlusion example
- added cameraPosition flag to shader parser
- few bugs fixed

arthurprs
05-04-2008, 04:24 PM
looks good, you are developing only the engine or a game?

Georgy
06-04-2008, 02:15 AM
only the engine

I want develop game engine and better graphics engine. First make some tech demos and then maybe start some real game project.

Georgy
07-04-2008, 09:54 AM
v 2008/4/7
- added TBN support
- added parallax mapping example
- added temporary uvscalehack global variable
- fixed ssao shader

http://www.igrodel.ru/tdg3d/tdg-9.jpg

Georgy
13-07-2008, 04:35 AM
Depth Corrected Parallax Mapping shader for TDG3D:

&#91;VP test&#93;

varying vec3 lightVec;
varying vec3 eyeVec;
varying vec3 et;

varying vec3 V_M;
varying vec4 glVertex;
varying vec2 glTexCoord0;

//*> TBNtangent Tangent
attribute vec3 Tangent;

//*> TBNnormal Normal
attribute vec3 Normal;

//*> TBNbinormal BiNormal
attribute vec3 BiNormal;


mat3 glNormalMatrixInverse&#40;void&#41;
&#123;
return mat3&#40; gl_ModelViewMatrix&#91;0&#93;&#91;0&#93;, gl_ModelViewMatrix&#91;1&#93;&#91;0&#93;, gl_ModelViewMatrix&#91;2&#93;&#91;0&#93;,
gl_ModelViewMatrix&#91;0&#93;&#91;1&#93;, gl_ModelViewMatrix&#91;1&#93;&#91;1&#93;, gl_ModelViewMatrix&#91;2&#93;&#91;1&#93;,
gl_ModelViewMatrix&#91;0&#93;&#91;2&#93;, gl_ModelViewMatrix&#91;1&#93;&#91;2&#93;, gl_ModelViewMatrix&#91;2&#93;&#91;2&#93; &#41;;
&#125;

void main&#40;void&#41;
&#123;

glTexCoord0 = gl_MultiTexCoord0.st;
glVertex = gl_Vertex;

V_M = normalize&#40;-glNormalMatrixInverse&#40;&#41; * gl_ModelViewMatrix&#91;3&#93;.xyz - glVertex.xyz&#41;;

gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

vec3 t = normalize&#40;gl_NormalMatrix * Tangent&#41;;
vec3 b = normalize&#40;gl_NormalMatrix * BiNormal&#41;;
vec3 n = normalize&#40;gl_NormalMatrix * Normal&#41;;

vec3 vVertex = vec3&#40;gl_ModelViewMatrix * gl_Vertex&#41;;

vec3 tmpVec = gl_LightSource&#91;0&#93;.position.xyz - vVertex;

lightVec.x = dot&#40;tmpVec, t&#41;;
lightVec.y = dot&#40;tmpVec, b&#41;;
lightVec.z = dot&#40;tmpVec, n&#41;;

tmpVec = -vVertex;
eyeVec.x = dot&#40;tmpVec, t&#41;;
eyeVec.y = dot&#40;tmpVec, b&#41;;
eyeVec.z = dot&#40;tmpVec, n&#41;;
&#125;



&#91;FP test&#93;


//*> sampler2D 0 colorMap
uniform sampler2D colorMap;

//*> sampler2D 1 heightMap
uniform sampler2D heightMap;

//*> sampler2D 2 normalMap
uniform sampler2D normalMap;


varying vec3 lightVec;
varying vec3 eyeVec;

varying vec3 V_M;
varying vec4 glVertex;
varying vec2 glTexCoord0;

const float howmuch = 1.5;
const float invRadius = 0.0005;

void main &#40;void&#41;
&#123;

float distSqr = dot&#40;lightVec, lightVec&#41;;
float att = clamp&#40;1.0 - invRadius * sqrt&#40;distSqr&#41;, 0.0, 1.0&#41;;
vec3 lVec = lightVec * inversesqrt&#40;distSqr&#41;;

vec3 vVec = normalize&#40;eyeVec&#41;;

float height = texture2D &#40; heightMap, glTexCoord0.xy &#41;.b;
float h = 0.03 * &#40;1.0-height&#41; - 0.015;

vec2 tex = glTexCoord0.xy - vVec.xy * h * howmuch / vVec.z;

vec4 base = texture2D&#40;colorMap, tex&#41;;

vec3 bump = normalize&#40; texture2D&#40;normalMap, tex&#41;.xyz * 2.0 - 1.0&#41;;

float diffuse = max&#40; dot&#40;lVec, bump&#41;, 0.0 &#41;;

vec4 vertex = glVertex + vec4&#40;2.0*height * V_M, 0.0&#41;;
vec4 p = gl_ModelViewProjectionMatrix * vertex;


gl_FragColor = vec4&#40; base.rgb*diffuse*att,1.0 &#41;;

gl_FragDepth = 0.5 * &#40;p.z / p.w + 1.0&#41;;

&#125;

This shader alters OpenGL depth buffer to make parallax effect more realistic. Enjoy!

JSoftware
13-07-2008, 02:48 PM
Screenshots?... :D

Firlefanz
14-07-2008, 06:44 AM
The downloads all don't work?

Is there a mesh to mesh collision function included? :wink:

Thanks,
firle

PS: Could download it now from the website. Interesting stuff. Too bad all the comments are in russian. :wink: And too bad it is OpenGL, but thanks anyway :)

Georgy
15-07-2008, 02:44 AM
Yes, functions included:

ObjectToLevelCollision(0,1, variablesElapsedTime);
ObjectToLevelCollision(2,1, variablesElapsedTime);

ObjectToObjectCollision(0,2);

0,2 - object1,object2
1 - level