3d Animation Code

Published on February 2017 | Categories: Documents | Downloads: 35 | Comments: 0 | Views: 564
of 2
Download PDF   Embed   Report

Comments

Content

//subscribe if you find this code helpful! #include "DarkGDK.h" #include "SC_Collision.h" void collision(void); void DarkGDK ( void ) { dbSyncOn ( ); dbSyncRate ( 60 ); SC_Start( ); dbLoadObject("Assault Trooper.x",1); dbLoadImage("Image5.jpg",5); SC_SetupObject(1,2,2); dbPositionObject(1,-10,-10,-220); dbRotateObject(1,90,180,180); for( int i=10002; i <= 10040; i++ ) { dbMakeObjectPlain( i,3,3 ); dbTextureObject (i,5); dbSetObjectLight( i,0 ); dbHideObject( i ); } dbSetObjectSpeed(1,10000); dbPlayObject(1); dbLoopObject(1); while ( LoopGDK ( ) ) { SC_DrawObjectBounds(1); dbControlCameraUsingArrowKeys(0,2,2); dbYRotateCamera( dbCameraAngleY() + ( dbMouseMoveX()/10.0f ) ); dbXRotateCamera( dbCameraAngleX() + ( dbMouseMoveY()/10.0f ) ); collision( ); // update the screen SC_UpdateObject(1); dbSync ( ); } // return back to windows return; } void collision(void) { int collide=0; int counter = 10002; if ( dbMouseClick() == 1 ) { //get our collision vector float oldx = dbCameraPositionX(); float oldy = dbCameraPositionY(); float oldz = dbCameraPositionZ(); dbMoveCamera( 200 ); float x = dbCameraPositionX();

float y = dbCameraPositionY(); float z = dbCameraPositionZ(); dbMoveCamera( -200 ); collide = SC_RayCast( 0, oldx,oldy,oldz, x,y,z, 0 ); if ( collide > 0 ) { //get the collision point float newx = SC_GetStaticCollisionX(); float newy = SC_GetStaticCollisionY(); float newz = SC_GetStaticCollisionZ(); //get collision normal float normx = SC_GetCollisionNormalX(); float normy = SC_GetCollisionNormalY(); float normz = SC_GetCollisionNormalZ(); //position and point a marker in the right direc tion dbPositionObject( counter, newx + normx/10.0f, n ewy + normy/10.0f, newz + normz/10.0f ); dbPointObject( counter, newx + normx, newy + nor my, newz + normz ); dbShowObject( counter ); counter++; if ( counter > 10040 ) counter = 10002; } } }

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close