2003-01-26 19:04:46 -07:00
|
|
|
// nebula.cpp
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003, Chris Laurel <claurel@shatters.net>
|
|
|
|
//
|
|
|
|
// This program is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU General Public License
|
|
|
|
// as published by the Free Software Foundation; either version 2
|
|
|
|
// of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "celestia.h"
|
|
|
|
#include <celmath/mathlib.h>
|
|
|
|
#include <celutil/util.h>
|
|
|
|
#include <celutil/debug.h>
|
|
|
|
#include "astro.h"
|
|
|
|
#include "nebula.h"
|
|
|
|
#include "meshmanager.h"
|
|
|
|
#include "gl.h"
|
|
|
|
#include "vecgl.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
Nebula::Nebula() :
|
2004-02-17 02:58:52 -07:00
|
|
|
model(InvalidResource)
|
2003-01-26 19:04:46 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-02-17 02:58:52 -07:00
|
|
|
ResourceHandle Nebula::getModel() const
|
2003-01-26 19:04:46 -07:00
|
|
|
{
|
2004-02-17 02:58:52 -07:00
|
|
|
return model;
|
2003-01-26 19:04:46 -07:00
|
|
|
}
|
|
|
|
|
2004-02-17 02:58:52 -07:00
|
|
|
void Nebula::setModel(ResourceHandle _model)
|
2003-01-26 19:04:46 -07:00
|
|
|
{
|
2004-02-17 02:58:52 -07:00
|
|
|
model = _model;
|
2003-01-26 19:04:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-03-24 01:55:54 -07:00
|
|
|
bool Nebula::load(AssociativeArray* params, const string& resPath)
|
2003-01-26 19:04:46 -07:00
|
|
|
{
|
2004-02-17 02:58:52 -07:00
|
|
|
string model;
|
|
|
|
if (params->getString("Mesh", model))
|
2003-01-26 19:04:46 -07:00
|
|
|
{
|
2004-02-17 02:58:52 -07:00
|
|
|
ResourceHandle modelHandle =
|
|
|
|
GetModelManager()->getHandle(ModelInfo(model, resPath));
|
|
|
|
setModel(modelHandle);
|
2003-01-26 19:04:46 -07:00
|
|
|
}
|
|
|
|
|
2003-03-24 01:55:54 -07:00
|
|
|
return DeepSkyObject::load(params, resPath);
|
2003-01-26 19:04:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Nebula::render(const Vec3f& offset,
|
|
|
|
const Quatf& viewerOrientation,
|
|
|
|
float brightness,
|
|
|
|
float pixelSize)
|
|
|
|
{
|
2004-02-17 02:58:52 -07:00
|
|
|
Model* m = NULL;
|
|
|
|
if (model != InvalidResource)
|
|
|
|
m = GetModelManager()->find(model);
|
2003-01-26 19:04:46 -07:00
|
|
|
if (m == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
glDisable(GL_LIGHTING);
|
|
|
|
glEnable(GL_TEXTURE_2D);
|
|
|
|
glScalef(getRadius(), getRadius(), getRadius());
|
2003-02-26 01:12:53 -07:00
|
|
|
glRotate(getOrientation());
|
2003-01-26 19:04:46 -07:00
|
|
|
|
2004-02-17 02:58:52 -07:00
|
|
|
//m->render(Mesh::TexCoords0, 0);
|
|
|
|
m->render();
|
2003-01-26 19:04:46 -07:00
|
|
|
}
|