absence_thelab

diff src/demonpart.cpp @ 0:1cffe3409164

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 23 Oct 2014 01:46:07 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/demonpart.cpp	Thu Oct 23 01:46:07 2014 +0300
     1.3 @@ -0,0 +1,40 @@
     1.4 +#include "demonpart.h"
     1.5 +#include "nwt/widget.h"
     1.6 +#include "fmod.h"
     1.7 +
     1.8 +extern Widget *win;
     1.9 +extern FMUSIC_MODULE *mod;
    1.10 +
    1.11 +DemonPart::DemonPart(GraphicsContext *gc) {
    1.12 +	this->gc = gc;
    1.13 +
    1.14 +	//SceneLoader::SetNormalFileSaving(true);
    1.15 +	SceneLoader::SetDataPath("data/textures/");
    1.16 +	SceneLoader::LoadScene("data/geometry/demon.3ds", &scene);
    1.17 +
    1.18 +	curve = scene->GetCurve("Line01");
    1.19 +	curve->SetArcParametrization(true);
    1.20 +	cam = scene->GetCamera("Camera01");
    1.21 +	cam->SetCameraPath(curve, 0, 0, 1500);
    1.22 +}
    1.23 +
    1.24 +DemonPart::~DemonPart() {
    1.25 +	delete scene;
    1.26 +}
    1.27 +
    1.28 +void DemonPart::MainLoop() {
    1.29 +	dword msec = timer.GetMilliSec();
    1.30 +	float t = msec / 1000.0f;
    1.31 +
    1.32 +	FMUSIC_SetMasterVolume(mod, (1500 - msec) / 6);
    1.33 +
    1.34 +	gc->Clear(0);
    1.35 +	gc->ClearZBufferStencil(1.0f, 0);
    1.36 +
    1.37 +	if(t > 1.5f) {
    1.38 +		PostMessage(win, WM_CLOSE, 0, 0);
    1.39 +	}
    1.40 +
    1.41 +	cam->FollowPath(msec);
    1.42 +	scene->Render();
    1.43 +}
    1.44 \ No newline at end of file