Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

PrimitiveObjects.cpp

Go to the documentation of this file.
00001 
00002 /*
00003     TSGL - Teddy Space Game Library
00004     Copyright (C) 2002 Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: PrimitiveObjects.cpp,v 1.1 2002/01/08 20:47:05 tksuoran Exp $
00022 */
00023 
00024 
00025 #include "Teddy/SpaceGame/ObjectManager.h"
00026 #include "Teddy/Graphics/ImageFileTexture.h"
00027 #include "Teddy/Graphics/View.h"
00028 #include "Teddy/Imports/LWMesh.h"
00029 #include "Teddy/Materials/Material.h"
00030 #include "Teddy/Models/Box.h"
00031 #include "Teddy/Models/Cone.h"
00032 #include "Teddy/Models/ModelInstance.h"
00033 #include "Teddy/Models/Sphere.h"
00034 #include "Teddy/Models/Torus.h"
00035 #include "Teddy/Models/Tube.h"
00036 #include "Teddy/Models/Vertex.h"
00037 #include "Teddy/Scenes/Scene.h"
00038 #include "Teddy/SysSupport/FileScan.h"
00039 using namespace Teddy::Imports;
00040 using namespace Teddy::Models;
00041 using namespace Teddy::Scenes;
00042 
00043 
00044 namespace Teddy     {
00045 namespace SpaceGame {
00046 
00047 
00049 void ObjectManager::addPrimitives(){
00050     Material *m1 = new Material( "Test Material m1" );
00051     m1->setEmission( Color(0,0,0) );
00052     m1->setAmbient ( Color(0.3f,0.2f,0.1f) );
00053     m1->setDiffuse ( Color(0.3f,0.2f,0.1f) );
00054     m1->setSpecular( Color(0.4f,0.4f,0.8f) );
00055     m1->setBorder  ( Color(0,0,1) );
00056     m1->setMode    ( RENDER_MODE_FILL );
00057     m1->setLighting( RENDER_LIGHTING_SIMPLE );
00058     m1->setOptions (
00059         RENDER_OPTION_CULL_FACE_M  |
00060         RENDER_OPTION_DEPTH_TEST_M |
00061         RENDER_OPTION_AMBIENT_M    |
00062         RENDER_OPTION_DIFFUSE_M    |
00063         RENDER_OPTION_SPECULAR_M   |
00064         RENDER_OPTION_EMISSION_M   |
00065         RENDER_OPTION_SHINYNESS_M  |
00066         RENDER_OPTION_SMOOTH_M
00067     );
00068     m1->setShininess( 8.0f );
00069 
00070     //  Add Torus
00071     Torus         *torus    = new Torus( "Torus", 1000.0, 200.0, 5, 4 );
00072     ModelInstance *mi_torus = new ModelInstance( "Torus 1", torus );
00073     mi_torus->setPosition( 1000.0, 1000, 0 );
00074     mi_torus->setMaterial( &Material::RED );
00075     scene->addInstance( mi_torus );
00076 
00077     //  Add Tube
00078 /*  Tube          *tube    = new Tube( "Tube", 20.0, 5.0, 21, 24 );
00079     ModelInstance *mi_tube = new ModelInstance( "Tube", tube );
00080     mi_tube->setPosition( -30.0, 0.0, 0.0 );
00081     mi_tube->setMaterial( &Material::YELLOW );
00082     scene->addInstance( mi_tube );*/
00083 
00084     // Add Cone
00085 /*  Cone          *cone    = new Cone( "Cone", 10.0f, 3.0f, 10.0f, 17, 11 );
00086     ModelInstance *mi_cone = new ModelInstance( "Cone", cone );
00087     mi_cone->setPosition( 30.0, 0.0, -30.0  );
00088     mi_cone->setMaterial( m1 );
00089     scene->addInstance( mi_cone );*/
00090 
00091     // Add Sphere
00092 /*  Sphere        *sphere    = new Sphere( "Sphere", 10.0f, 17, 17 );
00093     ModelInstance *mi_sphere = new ModelInstance( "Sphere", sphere );
00094     mi_sphere->setPosition( -15.0, 0.0, -40.0 );
00095     mi_sphere->setMaterial( &Material::WHITE );
00096 //      mi_sphere->getMaterial()->setTexture( new SdlTexture( "mars.jpg" ), true );
00097     scene->addInstance( mi_sphere );*/
00098 
00099     // Add Box
00100     Box           *box    = new Box( "Box", 800, 400, 400, 8, 4, 4 );
00101     ModelInstance *mi_box = new ModelInstance( "Box", box );
00102     mi_box->setPosition( -1000, 1000, 0 );
00103     mi_box->setMaterial( &Material::CYAN );
00104     scene->addInstance( mi_box );
00105 //1 view->display();
00106 }
00107 
00108 
00109 };  //  namespace SpaceGame
00110 };  //  namespace Teddy
00111