| 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 | #include "media_container.h" |
|---|
| 32 | |
|---|
| 33 | Model* obj; |
|---|
| 34 | TextureSequence* seq; |
|---|
| 35 | Texture* test; |
|---|
| 36 | Material* testMat; |
|---|
| 37 | MediaContainer* movie; |
|---|
| 38 | |
|---|
| 39 | float counter = 0; |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | void Framework::moduleInit(int argc, char** argv) |
|---|
| 43 | { |
|---|
| 44 | if( argc <= 1) |
|---|
| 45 | { |
|---|
| 46 | printf("Wrong arguments try following notations:\n"); |
|---|
| 47 | printf("./multitex [mediaFile]\n"); |
|---|
| 48 | exit(0); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | movie = new MediaContainer(argv[1]); |
|---|
| 52 | |
|---|
| 53 | // print information about the media file |
|---|
| 54 | movie->printMediaInformation(); |
|---|
| 55 | |
|---|
| 56 | ResourceManager::getInstance()->addImageDir("./"); |
|---|
| 57 | |
|---|
| 58 | testMat = new Material; |
|---|
| 59 | |
|---|
| 60 | seq = new TextureSequence(); |
|---|
| 61 | |
|---|
| 62 | // get each fram individually |
|---|
| 63 | //while(seq->addFrame(movie->getNextFrame()) != NULL); |
|---|
| 64 | // get a list of frames |
|---|
| 65 | seq->addFrameList(movie->getFrameList()); |
|---|
| 66 | |
|---|
| 67 | test = new Texture(); |
|---|
| 68 | testMat->setDiffuseMap("maps/radialTransparency.png"); |
|---|
| 69 | |
|---|
| 70 | ResourceManager::getInstance()->addImageDir(""); |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | obj = new PrimitiveModel(PRIM_PLANE, 10.0); |
|---|
| 74 | |
|---|
| 75 | ResourceManager::getInstance()->debug(); |
|---|
| 76 | |
|---|
| 77 | LightManager* lightMan = LightManager::getInstance(); |
|---|
| 78 | lightMan->setAmbientColor(.1,.1,.1); |
|---|
| 79 | (new Light())->setAbsCoor(5.0, 10.0, 40.0); |
|---|
| 80 | (new Light())->setAbsCoor(-10, -20, -100); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | void Framework::moduleEventHandler(SDL_Event* event) |
|---|
| 84 | { |
|---|
| 85 | switch (event->type) |
|---|
| 86 | { |
|---|
| 87 | case SDL_KEYDOWN: |
|---|
| 88 | switch (event->key.keysym.sym) |
|---|
| 89 | { |
|---|
| 90 | case SDLK_1: |
|---|
| 91 | obj = new PrimitiveModel(PRIM_CUBE, 10.0); |
|---|
| 92 | break; |
|---|
| 93 | case SDLK_2: |
|---|
| 94 | obj = new PrimitiveModel(PRIM_SPHERE, 10.0); |
|---|
| 95 | break; |
|---|
| 96 | case SDLK_3: |
|---|
| 97 | obj = new PrimitiveModel(PRIM_PLANE, 10.0); |
|---|
| 98 | break; |
|---|
| 99 | } |
|---|
| 100 | } |
|---|
| 101 | } |
|---|
| 102 | |
|---|
| 103 | void Framework::moduleTick(float dt) |
|---|
| 104 | { |
|---|
| 105 | counter += 0.2; |
|---|
| 106 | |
|---|
| 107 | seq->gotoFrame((unsigned int)counter); |
|---|
| 108 | |
|---|
| 109 | if ((unsigned int)counter > seq->getFrameCount()) |
|---|
| 110 | counter = 0; |
|---|
| 111 | |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | void Framework::moduleDraw(void) const |
|---|
| 115 | { |
|---|
| 116 | testMat->select(); |
|---|
| 117 | glBindTexture(GL_TEXTURE_2D, seq->getTexture()); |
|---|
| 118 | obj->draw(); |
|---|
| 119 | |
|---|
| 120 | LightManager::getInstance()->draw(); |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | void Framework::moduleHelp(void) const |
|---|
| 125 | { |
|---|
| 126 | |
|---|
| 127 | } |
|---|