| 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: Stefan Lienard |
|---|
| 13 | co-programmer: ... |
|---|
| 14 | */ |
|---|
| 15 | |
|---|
| 16 | #include "mapped_water.h" |
|---|
| 17 | #include "util/loading/load_param.h" |
|---|
| 18 | #include "util/loading/factory.h" |
|---|
| 19 | #include "material.h" |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | CREATE_FACTORY(MappedWater, CL_MAPPED_WATER); |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | MappedWater::MappedWater(const TiXmlElement* root) |
|---|
| 26 | { |
|---|
| 27 | this->setClassID(CL_MAPPED_WATER, "MappedWater"); |
|---|
| 28 | this->toList(OM_ENVIRON); |
|---|
| 29 | |
|---|
| 30 | if (root != NULL) |
|---|
| 31 | this->loadParams(root); |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | MappedWater::~MappedWater() |
|---|
| 35 | { |
|---|
| 36 | |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | void MappedWater::loadParams(const TiXmlElement* root) |
|---|
| 40 | { |
|---|
| 41 | WorldEntity::loadParams(root); |
|---|
| 42 | |
|---|
| 43 | LoadParam(root, "waterHeight", this, MappedWater, setHeight); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | void MappedWater::draw() const |
|---|
| 48 | { |
|---|
| 49 | glPushMatrix(); |
|---|
| 50 | |
|---|
| 51 | /* |
|---|
| 52 | glTranslatef (this->getAbsCoor ().x, |
|---|
| 53 | this->getAbsCoor ().y, |
|---|
| 54 | this->getAbsCoor ().z); |
|---|
| 55 | */ |
|---|
| 56 | glTranslatef(0,this->waterHeight,0); |
|---|
| 57 | |
|---|
| 58 | //glEnable(GL_LIGHTING); |
|---|
| 59 | |
|---|
| 60 | Material mat; |
|---|
| 61 | mat.setDiffuseMap("pictures/ground.tga", GL_TEXTURE_2D, 0); |
|---|
| 62 | //mat.setDiffuseMap("pictures/sky-replace.jpg", GL_TEXTURE_2D, 1); |
|---|
| 63 | //mat.setTransparency(1.0); |
|---|
| 64 | //mat.setDiffuse(1.0, 0, .1); |
|---|
| 65 | mat.select(); |
|---|
| 66 | |
|---|
| 67 | glBegin(GL_QUADS); |
|---|
| 68 | glNormal3f(0,1,0); |
|---|
| 69 | glTexCoord2f(0,0); |
|---|
| 70 | //glMultiTexCoord2f(GL_TEXTURE1, 0,0); |
|---|
| 71 | glVertex3f(0,0,0); |
|---|
| 72 | glTexCoord2f(1,0); |
|---|
| 73 | //glMultiTexCoord2f(GL_TEXTURE1, 1,0); |
|---|
| 74 | glVertex3f(100,0,0); |
|---|
| 75 | glTexCoord2f(1,1); |
|---|
| 76 | //glMultiTexCoord2f(GL_TEXTURE1, 1,1); |
|---|
| 77 | glVertex3f(100,0,-100); |
|---|
| 78 | glTexCoord2f(0,1); |
|---|
| 79 | //glMultiTexCoord2f(GL_TEXTURE1, 0,1); |
|---|
| 80 | glVertex3f(0,0,-100); |
|---|
| 81 | glEnd(); |
|---|
| 82 | |
|---|
| 83 | glPopMatrix(); |
|---|
| 84 | } |
|---|
| 85 | |
|---|
| 86 | void MappedWater::tick(float dt) |
|---|
| 87 | { |
|---|
| 88 | |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | void MappedWater::setHeight(float height) |
|---|
| 92 | { |
|---|
| 93 | this->waterHeight = height; |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | void MappedWater::activateReflection() {} |
|---|
| 97 | void MappedWater::deactivateReflection() {} |
|---|
| 98 | |
|---|
| 99 | void MappedWater::activateRefraction() {} |
|---|
| 100 | void MappedWater::deactivateRefraction() {} |
|---|