Quote: "Hi,
Thanks for sharing your tests, it's pretty neat!
I've made some changes which improve the performance:
Replace your main loop with this:"
Thanks to tparkin for the insight - I made some changes, and here is what I came up with
int totalObjects = 30;
dbMakeObjectSphere(1, 15);
dbColorObject (1, dbRGB(dbRND(255), dbRND(255), dbRND(255)));
dbPositionObject (1, 5, 0, 5);
dbSetObjectAmbient (1, 0);
dbMakeObjectSphere(2, 15);
dbColorObject (2, dbRGB(dbRND(255), dbRND(255), dbRND(255)));
dbPositionObject (2, 15, 5, 5);
dbSetObjectAmbient (2, 0);
for (int i = 3; i <= totalObjects; i++)
{
dbMakeObjectSphere (i, 3);
dbPositionObject (i, dbRND(20), 20, 5);
dbColorObject (i, dbRGB(dbRND(255), dbRND(255), dbRND(255)));
dbSetObjectAmbient (i, 0);
dbAutomaticObjectCollision (i, 1.5, 0);
}
dbPositionCamera ( 10, 10, -20 );
int i = 3;
while ( LoopGDK ( ) )
{
dbText( 0, 0, dbStr( dbScreenFPS( ) ) );
dbControlCameraUsingArrowKeys (0, 0.1, 0.1);
for( i = 3; i <= totalObjects; i++ ) {
if ( dbObjectInScreen (i) == 0){ dbPositionObject (i, dbRND(20), 20, 5);}
if ( dbObjectCollision (i, 0) != 0){dbYRotateObject(i, dbRND(1));dbPitchObjectDown(i, 1);}
dbMoveObjectDown (i, 0.3);
}
dbSync();
}
Notice that I have thrown in another sphere for greater effect.
The other thing that I came across was that using other objects, like a box, cube, cone, pyramid, plain, cylinder, or triangle, the visual appearance was not great at all.
Using the ShowObjectBounds function illustrates why the collision is not really working that well.
I removed the AutomaticObjectCollision from the first 2 Spheres - they are not going anywhere, so don't require the code, you will notice that if you do put it in, it moves the placement of the second object to ensure overlapping does not occur.
I added the SetObjectAmbient to each object as well, I don't know if that has an effect on the FPS at all.
And thanks to Pixel Perfect
why doesn't it work the way I want it to!