| 1 | /* | 
|---|
| 2 | orxonox - the future of 3D-vertical-scrollers | 
|---|
| 3 |  | 
|---|
| 4 | Copyright (C) 2004 orx | 
|---|
| 5 |  | 
|---|
| 6 | This program is free software; you can redistribute it and/or modify | 
|---|
| 7 | it under the terms of the GNU General Public License as published by | 
|---|
| 8 | the Free Software Foundation; either version 2, or (at your option) | 
|---|
| 9 | any later version. | 
|---|
| 10 |  | 
|---|
| 11 | ### File Specific: | 
|---|
| 12 | main-programmer: Benjamin Grauer | 
|---|
| 13 | co-programmer: ... | 
|---|
| 14 |  | 
|---|
| 15 | this file extends the framework file, so it renders what i want. | 
|---|
| 16 | */ | 
|---|
| 17 |  | 
|---|
| 18 | #include "framework.h" | 
|---|
| 19 |  | 
|---|
| 20 | #include "light.h" | 
|---|
| 21 |  | 
|---|
| 22 | #include "texture_sequence.h" | 
|---|
| 23 | #include "material.h" | 
|---|
| 24 |  | 
|---|
| 25 | #include "objModel.h" | 
|---|
| 26 |  | 
|---|
| 27 | #include "primitive_model.h" | 
|---|
| 28 | #include <stdlib.h> | 
|---|
| 29 |  | 
|---|
| 30 | #include "resource_manager.h" | 
|---|
| 31 |  | 
|---|
| 32 | Model* obj; | 
|---|
| 33 | TextureSequence* seq; | 
|---|
| 34 | Texture* test; | 
|---|
| 35 | Material* testMat; | 
|---|
| 36 |  | 
|---|
| 37 | float counter = 0; | 
|---|
| 38 |  | 
|---|
| 39 |  | 
|---|
| 40 | void Framework::moduleInit(int argc, char** argv) | 
|---|
| 41 | { | 
|---|
| 42 | ResourceManager::getInstance()->addImageDir("./"); | 
|---|
| 43 |  | 
|---|
| 44 | testMat = new Material; | 
|---|
| 45 |  | 
|---|
| 46 | seq = new TextureSequence(); | 
|---|
| 47 | for (int i = 1; i < argc; i++) | 
|---|
| 48 | { | 
|---|
| 49 | seq->addFrame(argv[i]); | 
|---|
| 50 | printf("%s\n", argv[i]); | 
|---|
| 51 | } | 
|---|
| 52 | test = new Texture(argv[1]); | 
|---|
| 53 | testMat->setDiffuseMap(argv[1]); | 
|---|
| 54 |  | 
|---|
| 55 | ResourceManager::getInstance()->addImageDir(""); | 
|---|
| 56 |  | 
|---|
| 57 |  | 
|---|
| 58 | obj = new PrimitiveModel(PRIM_SPHERE, 10.0); | 
|---|
| 59 |  | 
|---|
| 60 | ResourceManager::getInstance()->debug(); | 
|---|
| 61 |  | 
|---|
| 62 | LightManager* lightMan = LightManager::getInstance(); | 
|---|
| 63 | lightMan->setAmbientColor(.1,.1,.1); | 
|---|
| 64 | (new Light())->setAbsCoor(5.0, 10.0, 40.0); | 
|---|
| 65 | (new Light())->setAbsCoor(-10, -20, -100); | 
|---|
| 66 | } | 
|---|
| 67 |  | 
|---|
| 68 | void Framework::moduleEventHandler(SDL_Event* event) | 
|---|
| 69 | { | 
|---|
| 70 | switch (event->type) | 
|---|
| 71 | { | 
|---|
| 72 | case SDL_KEYDOWN: | 
|---|
| 73 | switch (event->key.keysym.sym) | 
|---|
| 74 | { | 
|---|
| 75 | case SDLK_i: | 
|---|
| 76 | break; | 
|---|
| 77 | } | 
|---|
| 78 | } | 
|---|
| 79 | } | 
|---|
| 80 |  | 
|---|
| 81 | void Framework::moduleTick(float dt) | 
|---|
| 82 | { | 
|---|
| 83 | counter+=dt; | 
|---|
| 84 |  | 
|---|
| 85 | seq->gotoFrame((unsigned int)counter); | 
|---|
| 86 | if ((unsigned int)counter > seq->getFrameCount()) | 
|---|
| 87 | counter = 0; | 
|---|
| 88 | } | 
|---|
| 89 |  | 
|---|
| 90 | void Framework::moduleDraw(void) const | 
|---|
| 91 | { | 
|---|
| 92 | testMat->select(); | 
|---|
| 93 | glBindTexture(GL_TEXTURE_2D, seq->getTexture()); | 
|---|
| 94 | obj->draw(); | 
|---|
| 95 |  | 
|---|
| 96 | LightManager::getInstance()->draw(); | 
|---|
| 97 | } | 
|---|
| 98 |  | 
|---|
| 99 |  | 
|---|
| 100 | void Framework::moduleHelp(void) const | 
|---|
| 101 | { | 
|---|
| 102 |  | 
|---|
| 103 | } | 
|---|