| 1 | #include "3dUnit.h" | 
|---|
| 2 | /* Provides function for loading a 3ds file */ | 
|---|
| 3 | #include "3ds.h" | 
|---|
| 4 | /* Model structures that are needed to load in a .3DS file. */ | 
|---|
| 5 | #include "3dStructs.h" | 
|---|
| 6 |  | 
|---|
| 7 | /*########################### Showroom.cpp ########################### | 
|---|
| 8 | # This class generates a unit, and provides functions to load and display | 
|---|
| 9 | # the corresponding 3ds file. | 
|---|
| 10 | # $Author: Johannes Bader | 
|---|
| 11 | # $Revision: 1.0 | 
|---|
| 12 | # $Date: 5.5.04 | 
|---|
| 13 | ###################################################################### */ | 
|---|
| 14 |  | 
|---|
| 15 | C3dUnit::C3dUnit( char* name ) | 
|---|
| 16 | { | 
|---|
| 17 |     /* Creates a new 3d Object of type "name"  | 
|---|
| 18 |        "name" must have at most 8 characters */ | 
|---|
| 19 |      | 
|---|
| 20 |     if( strlen( name ) <= 8 ) { | 
|---|
| 21 |         strcpy( sName, name );         | 
|---|
| 22 |     } | 
|---|
| 23 |     else { | 
|---|
| 24 |         printf( "Name to long, >= 8 characters: %s!", name ); | 
|---|
| 25 |         strcpy( sName, "noname" ); | 
|---|
| 26 |     } | 
|---|
| 27 |     Init(); | 
|---|
| 28 | } | 
|---|
| 29 |  | 
|---|
| 30 | C3dUnit::C3dUnit( void ) | 
|---|
| 31 | { | 
|---|
| 32 |     /* No name specified */ | 
|---|
| 33 |     strcpy( sName, "test.3ds" ); | 
|---|
| 34 |     Init(); | 
|---|
| 35 | } | 
|---|
| 36 |  | 
|---|
| 37 | void C3dUnit::Init( void ) | 
|---|
| 38 | { | 
|---|
| 39 |    b3dModelLoaded = false; | 
|---|
| 40 | } | 
|---|
| 41 |  | 
|---|
| 42 | void C3dUnit::Import3ds( void ) | 
|---|
| 43 | { | 
|---|
| 44 |    /* Class to load the *.3ds file */ | 
|---|
| 45 |    CLoad3ds g_Load3ds; | 
|---|
| 46 |    /* Loads the file "name" and stores the data in CModel */ | 
|---|
| 47 |    b3dModelLoaded = g_Load3ds.Import3DS( &CModel, sName ); | 
|---|
| 48 | } | 
|---|
| 49 |  | 
|---|
| 50 | void C3dUnit::Draw( int mode ) | 
|---|
| 51 | { | 
|---|
| 52 |    /* Draws the Model. If none has been loaded, print an error */ | 
|---|
| 53 |    if( b3dModelLoaded ) CModel.Draw( mode ); | 
|---|
| 54 |    else printf( "No Model for Unit %s loaded!", sName );    | 
|---|
| 55 | } | 
|---|
| 56 |  | 
|---|
| 57 | void C3dUnit::PrintProperties( void ) | 
|---|
| 58 | { | 
|---|
| 59 |    /* This function displays the Properties of the Model */ | 
|---|
| 60 |    if( b3dModelLoaded ) | 
|---|
| 61 |       CModel.PrintProperties(); | 
|---|
| 62 |    else printf( "No Model for Unit %s loaded!", sName ); | 
|---|
| 63 | } | 
|---|
| 64 |  | 
|---|