Stats3D# ( type )
Parameters
|
type - which statistic to read 0: mesh triangles tested for collisions during the last UpdateWorld 1: peak terrain vertices rendered 2: peak terrain triangles rendered |
Description
|
Returns an internal engine statistic, for performance tuning. Type 0 counts how many mesh triangles the collision system had to test during the last UpdateWorld. It resets to zero at the start of every UpdateWorld, so it is a live per-update figure: park your player next to a huge polygon-soup level mesh and watch it jump. If collisions are eating your frame time, this number tells you whether the problem is entities colliding against far too many triangles. Types 1 and 2 report the peak number of vertices and triangles a terrain has rendered in a single frame - high-water marks that only ever rise, handy for checking what your TerrainDetail budget actually produces once the camera has toured the map. Other type values return 0. The return value is a float, so wrap it in Int() for tidy display, as the example does. See also: TrisRendered, UpdateWorld, Collisions, TerrainDetail, LoadTerrain. |
Example
; Stats3D Example ; --------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,64,25,5 RotateEntity camera,25,0,0 light=CreateLight() RotateEntity light,45,45,0 ; A terrain feeds the terrain statistics (types 1 and 2) terrain=LoadTerrain("media/Height_map.bmp") ScaleEntity terrain,0.5,20,0.5 TerrainDetail terrain,2000 ground_tex=LoadTexture("media/MossyGround.BMP") EntityTexture terrain,ground_tex ScaleTexture ground_tex,8,8 ; A mesh platform and a falling ball feed the collision statistic ; (type 0 counts mesh triangles tested by UpdateWorld) platform=CreateCube() ScaleEntity platform,4,0.5,4 PositionEntity platform,64,12,30 EntityType platform,2 ball=CreateSphere() PositionEntity ball,64,20,30 EntityType ball,1 ; Sphere-to-polygon collisions between the ball and the platform Collisions 1,2,2,2 While Not KeyDown(1) ; Space drops the ball onto the platform again If KeyHit(57) Then PositionEntity ball,64,20,30 ; Simple gravity for the ball TranslateEntity ball,0,-0.15,0 ; Arrow keys move the camera If KeyDown(200) Then MoveEntity camera,0,0,0.1 If KeyDown(208) Then MoveEntity camera,0,0,-0.1 If KeyDown(203) Then TurnEntity camera,0,1,0 If KeyDown(205) Then TurnEntity camera,0,-1,0 UpdateWorld RenderWorld Text 0,0,"Space: drop the ball Arrows: camera Esc: exit" Text 0,20,"Stats3D(0) collision triangles tested = "+Int(Stats3D(0)) Text 0,40,"Stats3D(1) peak terrain vertices = "+Int(Stats3D(1)) Text 0,60,"Stats3D(2) peak terrain triangles = "+Int(Stats3D(2)) Flip Wend End
Index