Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/levelloader/src/world_entities/environment.cc @ 4069

Last change on this file since 4069 was 3746, checked in by chris, 20 years ago

orxonox/branches/levelloader: Merged trunk into branch… still not working though…

File size: 2.8 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific
14   main-programmer: Patrick Boenzli
15   co-programmer:
16*/
17
18
19#include "environment.h"
20#include "stdincl.h"
21#include "world_entity.h"
22#include "vector.h"
23#include "objModel.h"
24
25using namespace std;
26
27
28CREATE_FACTORY(Environment);
29
30Environment::Environment () : WorldEntity()
31{
32  this->model = (Model*) ResourceManager::getInstance()->load("cube", RP_LEVEL);
33  //  this->model = new OBJModel("../data/models/fighter.obj");
34}
35
36Environment::Environment ( TiXmlElement* root)
37{
38        assert( root != NULL);
39       
40        char* temp;
41        const char* string = grabParameter( root, "name");
42
43        if( string == NULL)
44        {
45                PRINTF0("Environment is missing a proper 'name'\n");
46                string = "Unknown";
47                this->setName( string);
48        }
49        else
50        {
51                this->setName( string);
52        }
53       
54        this->model = NULL;
55        string = grabParameter( root, "model");
56        if( string != NULL)
57        this->model = (Model*) ResourceManager::getInstance()->load( string, RP_LEVEL);
58        else
59        {
60                PRINTF0("Environment is missing a proper 'model'\n");
61        this->model = (Model*) ResourceManager::getInstance()->load( "cube", RP_LEVEL);
62        }
63        if( this->model == NULL)
64        {
65                PRINTF0("Environment model '%s' could not be loaded\n", string);
66        }
67       
68        double buff[3];
69       
70        string = grabParameter( root, "position");
71        if( string != NULL && sscanf( string, "%lf,%lf,%lf", &(buff[0]), &(buff[1]), &(buff[2])) == 3)
72        {
73                Vector* es = new Vector( buff[0], buff[1], buff[2]);
74                this->setAbsCoor(es);
75                delete es;
76        }
77        else
78        {
79                PRINTF0("Environment is missing a proper 'position'\n");
80                Vector* es = new Vector();
81                this->setAbsCoor(es);
82                delete es;
83        }
84               
85        string = grabParameter( root, "orientation");
86        if( string != NULL && sscanf( string, "%lf,%lf,%lf", &(buff[0]), &(buff[1]), &(buff[2])) == 3)
87        {
88                Quaternion* qs = new Quaternion( buff[0], buff[1], buff[2]);
89                this->setAbsDir(qs);
90                delete qs;
91        }
92        else
93        {
94                PRINTF0("Environment is missing a proper 'orientation'\n");
95        Quaternion* qs = new Quaternion ();
96                this->setAbsDir(qs);
97                delete qs;
98        }
99}
100
101Environment::~Environment () 
102{
103
104}
105
106void Environment::tick (float time) {}
107
108void Environment::hit (WorldEntity* weapon, Vector* loc) {}
109
110void Environment::destroy () {}
111
112void Environment::collide (WorldEntity* other,  Uint32 ownhitflags, Uint32 otherhitflags) {}
113
114void Environment::draw () 
115{
116  glMatrixMode(GL_MODELVIEW);
117  glPushMatrix();
118  float matrix[4][4];
119 
120  glTranslatef (this->getAbsCoor ().x, this->getAbsCoor ().y, this->getAbsCoor ().z);
121  //rotate
122  this->getAbsDir().matrix (matrix);
123  glMultMatrixf((float*)matrix);
124 
125  this->model->draw();
126
127  glPopMatrix();
128}
129
Note: See TracBrowser for help on using the repository browser.