| [4554] | 1 | /* |
|---|
| [4333] | 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 | |
|---|
| [4343] | 20 | #include "light.h" |
|---|
| [4333] | 21 | |
|---|
| [4343] | 22 | #include "objModel.h" |
|---|
| [6222] | 23 | #include "md2Model.h" |
|---|
| [4343] | 24 | #include "primitive_model.h" |
|---|
| 25 | #include <stdlib.h> |
|---|
| [4333] | 26 | |
|---|
| [4649] | 27 | #include "resource_manager.h" |
|---|
| [4343] | 28 | |
|---|
| 29 | Model* obj; |
|---|
| 30 | |
|---|
| 31 | void Framework::moduleInit(int argc, char** argv) |
|---|
| [4333] | 32 | { |
|---|
| [4649] | 33 | ResourceManager::getInstance()->addImageDir("./"); |
|---|
| 34 | |
|---|
| [4653] | 35 | for (int i = 0; i < argc; i++) |
|---|
| 36 | { |
|---|
| 37 | printf("%s\n", argv[i]); |
|---|
| 38 | } |
|---|
| 39 | ResourceManager::getInstance()->addImageDir(""); |
|---|
| 40 | |
|---|
| 41 | |
|---|
| [4343] | 42 | if (argc>=3) |
|---|
| [6222] | 43 | { |
|---|
| 44 | if( strstr(argv[1], ".obj") != NULL) |
|---|
| 45 | obj = new OBJModel (argv[1], atof(argv[2])); |
|---|
| 46 | else if( strstr(argv[1], ".md2") != NULL) |
|---|
| 47 | { |
|---|
| 48 | obj = new MD2Model(argv[1], argv[2]); |
|---|
| 49 | ((MD2Model*)obj)->tick(0.1f); |
|---|
| 50 | } |
|---|
| 51 | } |
|---|
| [4343] | 52 | else if (argc>=2) |
|---|
| [6222] | 53 | { |
|---|
| 54 | if( strstr(argv[1], ".obj") != NULL) |
|---|
| 55 | obj = new OBJModel(argv[1]); |
|---|
| 56 | else if( strstr(argv[1], ".md2") != NULL) { |
|---|
| 57 | obj = new MD2Model(argv[1], "fake_texture.bad"); |
|---|
| 58 | obj = new MD2Model(argv[1], argv[2]); |
|---|
| 59 | ((MD2Model*)obj)->tick(0.1f); |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| [4554] | 62 | else |
|---|
| [4492] | 63 | obj = new PrimitiveModel(PRIM_CYLINDER); |
|---|
| [4333] | 64 | |
|---|
| [4653] | 65 | ResourceManager::getInstance()->debug(); |
|---|
| 66 | |
|---|
| [4343] | 67 | LightManager* lightMan = LightManager::getInstance(); |
|---|
| 68 | lightMan->setAmbientColor(.1,.1,.1); |
|---|
| [4741] | 69 | (new Light())->setAbsCoor(5.0, 10.0, 40.0); |
|---|
| 70 | (new Light())->setAbsCoor(-10, -20, -100); |
|---|
| [4333] | 71 | } |
|---|
| 72 | |
|---|
| [4334] | 73 | void Framework::moduleEventHandler(SDL_Event* event) |
|---|
| 74 | { |
|---|
| 75 | switch (event->type) |
|---|
| 76 | { |
|---|
| 77 | case SDL_KEYDOWN: |
|---|
| 78 | switch (event->key.keysym.sym) |
|---|
| [4554] | 79 | { |
|---|
| 80 | case SDLK_i: |
|---|
| 81 | break; |
|---|
| 82 | } |
|---|
| [4334] | 83 | } |
|---|
| [4333] | 84 | } |
|---|
| 85 | |
|---|
| 86 | void Framework::moduleTick(float dt) |
|---|
| 87 | { |
|---|
| [4554] | 88 | |
|---|
| [4333] | 89 | } |
|---|
| 90 | |
|---|
| [4349] | 91 | void Framework::moduleDraw(void) const |
|---|
| [4334] | 92 | { |
|---|
| [4343] | 93 | obj->draw(); |
|---|
| 94 | |
|---|
| 95 | LightManager::getInstance()->draw(); |
|---|
| [4334] | 96 | } |
|---|
| [4333] | 97 | |
|---|
| [4334] | 98 | |
|---|
| [4333] | 99 | void Framework::moduleHelp(void) const |
|---|
| 100 | { |
|---|
| [4554] | 101 | |
|---|
| [4333] | 102 | } |
|---|