absence_thelab

annotate src/beginpart.cpp @ 1:4d5933c261c3

todo and .hgignore
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 23 Oct 2014 02:18:43 +0300
parents
children
rev   line source
nuclear@0 1 #include "beginpart.h"
nuclear@0 2
nuclear@0 3 BeginPart::BeginPart(GraphicsContext *gc) {
nuclear@0 4 this->gc = gc;
nuclear@0 5
nuclear@0 6 this->gc = gc;
nuclear@0 7
nuclear@0 8 SceneLoader::SetNormalFileSaving(true);
nuclear@0 9 SceneLoader::SetDataPath("data/textures/");
nuclear@0 10 SceneLoader::LoadScene("data/geometry/begin.3ds", &scene);
nuclear@0 11
nuclear@0 12 light = new DirLight(Vector3(0.0f, 0.0f, 1.0f));
nuclear@0 13 light->SetIntensity(1.5f);
nuclear@0 14 scene->AddLight(light);
nuclear@0 15
nuclear@0 16 // get stuff
nuclear@0 17 Logo1 = scene->GetObject("LogoT");
nuclear@0 18 scene->RemoveObject(Logo1);
nuclear@0 19
nuclear@0 20 Logo2 = scene->GetObject("LogoB");
nuclear@0 21 scene->RemoveObject(Logo2);
nuclear@0 22
nuclear@0 23 VolumeLogo = scene->GetObject("VolumeLogo");
nuclear@0 24 scene->RemoveObject(VolumeLogo);
nuclear@0 25
nuclear@0 26 Latin1 = scene->GetObject("Latin1");
nuclear@0 27 Latin2 = scene->GetObject("Latin2");
nuclear@0 28 Lines[0] = scene->GetObject("Lines1");
nuclear@0 29 Lines[1] = scene->GetObject("Lines2");
nuclear@0 30 TheLabText[0] = scene->GetObject("LabText1");
nuclear@0 31 TheLabText[1] = scene->GetObject("LabText2");
nuclear@0 32
nuclear@0 33 scene->RemoveObject(scene->GetObject("Plane01"));
nuclear@0 34
nuclear@0 35 gc->SetTextureTransformState(0, TexTransform2D);
nuclear@0 36 }
nuclear@0 37
nuclear@0 38 BeginPart::~BeginPart() {
nuclear@0 39 delete scene;
nuclear@0 40 }
nuclear@0 41
nuclear@0 42 #define psin(x) (sinf(x) / 2.0f + 0.5f)
nuclear@0 43 #define pcos(x) (cosf(x) / 2.0f + 0.5f)
nuclear@0 44
nuclear@0 45 void BeginPart::MainLoop() {
nuclear@0 46 dword msec = timer.GetMilliSec();
nuclear@0 47 float t = (float)msec / 1000.0f;
nuclear@0 48
nuclear@0 49 const float StartCycle = 2.5f;
nuclear@0 50 const float EndCycle = 5.0f;
nuclear@0 51 const float StartFade = 9.0f;
nuclear@0 52
nuclear@0 53
nuclear@0 54 Latin1->SetTextureMatrix(Matrix3x3(1,0,0, 0,1,0, 0,t/4,1));
nuclear@0 55 Latin2->SetTextureMatrix(Matrix3x3(1,0,0, 0,1,0, 0,t/2,1));
nuclear@0 56 Lines[0]->SetTextureMatrix(Matrix3x3(1,0,0, 0,1,0, t*2.0f,0,1));
nuclear@0 57 Lines[1]->SetTextureMatrix(Matrix3x3(1,0,0, 0,1,0, t/2.0f,0,1));
nuclear@0 58 TheLabText[0]->SetTextureMatrix(Matrix3x3(1,0,0, 0,1,0, t,0,1));
nuclear@0 59 TheLabText[1]->SetTextureMatrix(Matrix3x3(1,0,0, 0,1,0, t/3,0,1));
nuclear@0 60
nuclear@0 61 gc->Clear(0);
nuclear@0 62 gc->ClearZBufferStencil(1.0f, 0);
nuclear@0 63
nuclear@0 64 gc->SetZBuffering(false);
nuclear@0 65
nuclear@0 66 scene->Render();
nuclear@0 67
nuclear@0 68 gc->SetAlphaBlending(true);
nuclear@0 69 gc->SetTextureStageColor(0, TexBlendModulate, TexArgCurrent, TexArgTexture);
nuclear@0 70 gc->SetTextureStageAlpha(0, TexBlendModulate, TexArgCurrent, TexArgTexture);
nuclear@0 71 gc->SetBlendFunc(BLEND_ONE, BLEND_ONE);
nuclear@0 72
nuclear@0 73 Matrix3x3 TexMat;
nuclear@0 74
nuclear@0 75 // render shit
nuclear@0 76 Logo1->SetTranslation(0.0f, max(0.8f - t, 0) * 50.0f, 0.0f);
nuclear@0 77 Logo2->SetTranslation(0.0f, -max(0.8f - t, 0) * 50.0f, 0.0f);
nuclear@0 78
nuclear@0 79 if(t > StartCycle) {
nuclear@0 80 Logo1->material.Diffuse.r += (t-StartCycle) * 0.005f;
nuclear@0 81 Logo1->material.Diffuse.g -= (t-StartCycle) * 0.005f;
nuclear@0 82 Logo1->material.Diffuse.b -= (t-StartCycle) * 0.005f;
nuclear@0 83 if(Logo1->material.Diffuse.r > 0.5f) Logo1->material.Diffuse.r = 0.5f;
nuclear@0 84 if(Logo1->material.Diffuse.g < 0.0f) Logo1->material.Diffuse.g = 0.0f;
nuclear@0 85 if(Logo1->material.Diffuse.b < 0.0f) Logo1->material.Diffuse.b = 0.0f;
nuclear@0 86
nuclear@0 87 Logo2->material.Diffuse.r += (t-StartCycle) * 0.005f;
nuclear@0 88 Logo2->material.Diffuse.g -= (t-StartCycle) * 0.005f;
nuclear@0 89 Logo2->material.Diffuse.b -= (t-StartCycle) * 0.005f;
nuclear@0 90 if(Logo2->material.Diffuse.r > 0.5f) Logo2->material.Diffuse.r = 0.5f;
nuclear@0 91 if(Logo2->material.Diffuse.g < 0.0f) Logo2->material.Diffuse.g = 0.0f;
nuclear@0 92 if(Logo2->material.Diffuse.b < 0.0f) Logo2->material.Diffuse.b = 0.0f;
nuclear@0 93 }
nuclear@0 94
nuclear@0 95 gc->SetMaterial(Logo1->material);
nuclear@0 96 gc->SetTexture(0, Logo1->material.Maps[TextureMap]);
nuclear@0 97
nuclear@0 98 gc->SetWorldMatrix(Logo1->GetWorldTransform());
nuclear@0 99 Logo1->RenderBare();
nuclear@0 100
nuclear@0 101 gc->SetWorldMatrix(Logo2->GetWorldTransform());
nuclear@0 102 Logo2->RenderBare();
nuclear@0 103
nuclear@0 104 if(t > EndCycle) {
nuclear@0 105 Color color(Logo1->material.Diffuse.r, Logo1->material.Diffuse.g, Logo1->material.Diffuse.b);
nuclear@0 106 VolumeLogo->material.SetDiffuse(color);
nuclear@0 107 gc->SetTexture(0, VolumeLogo->material.Maps[TextureMap]);
nuclear@0 108
nuclear@0 109 float xoffs = sinf(t/2.0f) * 4.0f;
nuclear@0 110 float yoffs = sinf(t) * 1.5f;//-(t - 2.0f*EndCycle);
nuclear@0 111 for(int i=0; i<min(10, (int)((t-EndCycle)*30.0f)); i++) {
nuclear@0 112 Matrix4x4 mat;
nuclear@0 113 mat.SetTranslation(xoffs * ((float)i * 0.5f), yoffs * ((float)i * 0.5f), 0.0f);
nuclear@0 114
nuclear@0 115 float ScaleFactor = 1.0f + (float)i * 0.2f;
nuclear@0 116 Matrix4x4 ScaleMat;
nuclear@0 117 ScaleMat.SetScaling(ScaleFactor, ScaleFactor, ScaleFactor);
nuclear@0 118
nuclear@0 119 VolumeLogo->material.Diffuse.r -= 0.08f;
nuclear@0 120 VolumeLogo->material.Diffuse.g -= 0.08f;
nuclear@0 121 VolumeLogo->material.Diffuse.b -= 0.08f;
nuclear@0 122
nuclear@0 123 gc->SetWorldMatrix(VolumeLogo->GetWorldTransform() * mat * ScaleMat);
nuclear@0 124 VolumeLogo->RenderBare();
nuclear@0 125 }
nuclear@0 126 }
nuclear@0 127
nuclear@0 128 Material OrigMat = VolumeLogo->material;
nuclear@0 129 VolumeLogo->material = Material(0.0f, 0.0f, 0.0f, max((t - StartFade) / 2.0f, 0.0f));
nuclear@0 130 VolumeLogo->Render();
nuclear@0 131 VolumeLogo->material = OrigMat;
nuclear@0 132
nuclear@0 133 gc->SetZBuffering(true);
nuclear@0 134 gc->SetAlphaBlending(false);
nuclear@0 135 }