topical media & game development
lib-game-darkgdk-samples-Animation-Showcase-Main.cpp / cpp
// Dark GDK - The Game Creators - www.thegamecreators.com
// include Dark GDK header file
include <DarkGDK.h>
// main entry point for program
void DarkGDK ( void )
{
// in this program we're going to show how to
// play videos on 3D obejcts
// declare some variables
float a = 0.0f;
int over = 0;
char* buts = " ";
// set up sync rate
dbSyncOn ( );
dbSyncRate ( 0 );
// switch to media directory
dbSetDir ( "media\\" );
// load our video and play it to an image
dbLoadAnimation ( "avi\\demo1.wmv" , 1 );
dbPlayAnimationToImage ( 1 , 1 , 0 , 0 , dbAnimationWidth ( 1 ) , dbAnimationHeight ( 1 ) );
dbLoopAnimation ( 1 );
// make a large cube and texture it with the image from the video
dbMakeObjectBox ( 1 , 350 , 350 , 1000 );
dbScaleObject ( 1 , 100 , 100 , -100 );
dbSetObject ( 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 );
dbTextureObject ( 1 , 1 );
// make a sphere and texture it with the image from the video
dbMakeObjectSphere ( 2 , 50 );
dbTextureObject ( 2 , 1 );
dbSetSphereMappingOn ( 2 , 1 );
// make some new cubes and again texture with video image
for ( int t = 0 ; t < 8 ; t++ )
{
dbMakeObjectCube ( 3 + t , 25 );
dbTextureObject ( 3 + t , 1 );
}
// main loop
while ( LoopGDK ( ) )
{
// quit on escape key
if ( dbEscapeKey ( ) )
return;
// scale our objects
a = dbWrapValue ( a - 4.0f );
dbScaleObject ( 2 , 100.0f + dbCos ( a ) * 25.0f , 100.0f + dbSin ( a ) * 25.0f , 100.0f );
// move our obbjects around the scene
for ( int t = 0 ; t < 8 ; t++ )
{
dbPositionObject (
3 + t ,
dbCos ( dbWrapValue ( a + ( t * 45 ) ) ) * 40 ,
dbSin ( dbWrapValue ( a + ( t * 45 ) ) ) * 30 ,
dbSin ( dbWrapValue ( a + ( t * 45 ) ) ) * 40
);
if ( t == 0 || t == 3 || t == 6 ) dbXRotateObject ( 3 + t , dbWrapValue ( dbObjectAngleX ( 3 + t ) + 2 ) );
if ( t == 1 || t == 4 || t == 7 ) dbYRotateObject ( 3 + t , dbWrapValue ( dbObjectAngleY ( 3 + t ) + 2 ) );
if ( t == 2 || t == 5 ) dbZRotateObject ( 3 + t , dbWrapValue ( dbObjectAngleZ ( 3 + t ) + 2 ) );
}
// position and point our camera
dbPositionCamera ( dbCos ( a ) * 10 , dbSin ( a ) * 10 , -100 );
dbPointCamera ( 0 , 0 , 0 , 0 );
// update the screen
dbSync ( );
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.