Fixed more invisible object and colormap issues, fix dillopede elevator music.
This commit is contained in:
parent
7fb143a7c9
commit
8e1925acf5
8 changed files with 95 additions and 61 deletions
90
costume.cpp
90
costume.cpp
|
@ -124,7 +124,6 @@ public:
|
|||
protected:
|
||||
std::string _filename;
|
||||
ResPtr<Model> _obj;
|
||||
ResPtr<CMap> _previousCmap;
|
||||
Model::HierNode *_hier;
|
||||
Matrix4 _matrix;
|
||||
};
|
||||
|
@ -216,7 +215,6 @@ ModelComponent::ModelComponent(Costume::Component *parent, int parentID, const c
|
|||
} else {
|
||||
_filename = filename;
|
||||
}
|
||||
_previousCmap = NULL;
|
||||
if (prevComponent != NULL) {
|
||||
MainModelComponent *mmc = dynamic_cast<MainModelComponent *>(prevComponent);
|
||||
|
||||
|
@ -231,13 +229,9 @@ void ModelComponent::init() {
|
|||
// constructor before
|
||||
if (_obj == NULL) {
|
||||
CMap *cmap = this->cmap();
|
||||
// If we still don't have the necessary colormap
|
||||
// then try the one from the previous costume
|
||||
if (cmap == NULL && _previousCmap != NULL)
|
||||
cmap = _previousCmap;
|
||||
|
||||
// Get the default colormap if we still haven't
|
||||
// found a valid colormap
|
||||
|
||||
// Get the default colormap if we haven't found
|
||||
// a valid colormap
|
||||
if (cmap == NULL) {
|
||||
if (debugLevel == DEBUG_MODEL || debugLevel == DEBUG_WARN || debugLevel == DEBUG_ALL)
|
||||
warning("No colormap specified for %s, using %s\n", _filename.c_str(), DEFAULT_COLORMAP);
|
||||
|
@ -246,7 +240,12 @@ void ModelComponent::init() {
|
|||
}
|
||||
_obj = g_resourceloader->loadModel(_filename.c_str(), *cmap);
|
||||
_hier = _obj->copyHierarchy();
|
||||
reset();
|
||||
// Use parent availablity to decide whether to default the
|
||||
// component to being visible
|
||||
if (_parent == NULL || !_parent->visible())
|
||||
setKey(1);
|
||||
else
|
||||
setKey(0);
|
||||
}
|
||||
|
||||
// If we're the child of a mesh component, put our nodes in the
|
||||
|
@ -262,32 +261,13 @@ void ModelComponent::init() {
|
|||
}
|
||||
|
||||
void ModelComponent::setKey(int val) {
|
||||
MainModelComponent *mmc;
|
||||
ModelComponent *moc;
|
||||
MeshComponent *mc;
|
||||
|
||||
_hier->_hierVisible = (val != 0);
|
||||
// If we're making a model component visible then assume
|
||||
// that the parent mesh object should also become visible
|
||||
if (_parent == NULL || val == 0)
|
||||
return;
|
||||
mc = dynamic_cast<MeshComponent *>(_parent);
|
||||
if (mc == NULL)
|
||||
return;
|
||||
mc->node()->_meshVisible = true;
|
||||
// Do the same thing with the parent of the mesh object
|
||||
// but DO NOT handle the parent if it's a MMDL
|
||||
if (mc->parent() == NULL)
|
||||
return;
|
||||
moc = dynamic_cast<ModelComponent *>(mc->parent());
|
||||
mmc = dynamic_cast<MainModelComponent *>(mc->parent());
|
||||
if (moc == NULL || mmc != NULL)
|
||||
return;
|
||||
moc->_hier->_hierVisible = true;
|
||||
_visible = (val != 0);
|
||||
_hier->_hierVisible = _visible;
|
||||
}
|
||||
|
||||
void ModelComponent::reset() {
|
||||
_hier->_hierVisible = false;
|
||||
_visible = false;
|
||||
_hier->_hierVisible = _visible;
|
||||
}
|
||||
|
||||
// Reset the hierarchy nodes for any keyframe animations (which
|
||||
|
@ -318,11 +298,29 @@ ModelComponent::~ModelComponent() {
|
|||
delete[] _hier;
|
||||
}
|
||||
|
||||
void translateObject(Model::HierNode *node, bool reset) {
|
||||
if (node->_parent != NULL)
|
||||
translateObject(node->_parent, reset);
|
||||
|
||||
if(reset)
|
||||
g_driver->translateViewpoint();
|
||||
else
|
||||
g_driver->translateViewpoint(node->_animPos / node->_totalWeight, node->_animPitch / node->_totalWeight, node->_animYaw / node->_totalWeight, node->_animRoll / node->_totalWeight);
|
||||
}
|
||||
|
||||
void ModelComponent::draw() {
|
||||
if (_parent == NULL)
|
||||
// Otherwise it was already drawn by
|
||||
// being included in the parent's hierarchy
|
||||
_hier->draw();
|
||||
// If the object was drawn by being a component
|
||||
// of it's parent then don't draw it
|
||||
if (_parent != NULL && _parent->visible())
|
||||
return;
|
||||
// Need to translate object to be in accordance
|
||||
// with the setup of the parent
|
||||
if (_hier->_parent != NULL)
|
||||
translateObject(_hier->_parent, false);
|
||||
_hier->draw();
|
||||
// Need to un-translate when done
|
||||
if (_hier->_parent != NULL)
|
||||
translateObject(_hier->_parent, true);
|
||||
}
|
||||
|
||||
MainModelComponent::MainModelComponent(Costume::Component *parent, int parentID, const char *filename, Costume::Component *prevComponent, tag32 tag) :
|
||||
|
@ -341,7 +339,8 @@ MainModelComponent::MainModelComponent(Costume::Component *parent, int parentID,
|
|||
|
||||
void MainModelComponent::init() {
|
||||
ModelComponent::init();
|
||||
_hier->_hierVisible = true;
|
||||
_visible = true;
|
||||
_hier->_hierVisible = _visible;
|
||||
}
|
||||
|
||||
void MainModelComponent::update() {
|
||||
|
@ -353,7 +352,8 @@ void MainModelComponent::update() {
|
|||
}
|
||||
|
||||
void MainModelComponent::reset() {
|
||||
_hier->_hierVisible = true;
|
||||
_visible = true;
|
||||
_hier->_hierVisible = _visible;
|
||||
}
|
||||
|
||||
MainModelComponent::~MainModelComponent() {
|
||||
|
@ -721,6 +721,8 @@ Costume::~Costume() {
|
|||
}
|
||||
|
||||
Costume::Component::Component(Component *parent, int parentID, tag32 tag) {
|
||||
_visible = -1;
|
||||
_previousCmap = NULL;
|
||||
_cmap = NULL;
|
||||
_cost = NULL;
|
||||
_parent = NULL;
|
||||
|
@ -738,8 +740,16 @@ void Costume::Component::setColormap(CMap *c) {
|
|||
mc->resetColormap();
|
||||
}
|
||||
|
||||
bool Costume::Component::visible() {
|
||||
if (_visible == -1 && _parent != NULL)
|
||||
return _parent->visible();
|
||||
return _visible;
|
||||
}
|
||||
|
||||
CMap *Costume::Component::cmap() {
|
||||
if (_cmap == NULL && _parent != NULL)
|
||||
if (_cmap == NULL && _previousCmap != NULL)
|
||||
return _previousCmap;
|
||||
else if (_cmap == NULL && _parent != NULL)
|
||||
return _parent->cmap();
|
||||
else if (_cmap == NULL && _parent == NULL && _cost != NULL)
|
||||
return _cost->_cmap;
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
tag32 tag() { return _tag; }
|
||||
CMap *cmap();
|
||||
void setColormap(CMap *c);
|
||||
bool visible();
|
||||
Component *parent() { return _parent; }
|
||||
virtual void setMatrix(Matrix4) { };
|
||||
virtual void init() { }
|
||||
|
@ -75,9 +76,9 @@ public:
|
|||
virtual ~Component() { }
|
||||
|
||||
protected:
|
||||
ResPtr<CMap> _cmap;
|
||||
ResPtr<CMap> _cmap, _previousCmap;
|
||||
tag32 _tag;
|
||||
int _parentID;
|
||||
int _parentID, _visible;
|
||||
Component *_parent, *_child, *_sibling;
|
||||
Matrix4 _matrix;
|
||||
Costume *_cost;
|
||||
|
|
3
driver.h
3
driver.h
|
@ -65,6 +65,9 @@ public:
|
|||
|
||||
virtual void set3DMode() = 0;
|
||||
|
||||
virtual void translateViewpoint(Vector3d pos, float pitch, float yaw, float roll) = 0;
|
||||
virtual void translateViewpoint() = 0;
|
||||
|
||||
virtual void drawHierachyNode(const Model::HierNode *node) = 0;
|
||||
virtual void drawModelFace(const Model::Face *face, float *vertices, float *vertNormals, float *textureVerts) = 0;
|
||||
|
||||
|
|
|
@ -146,16 +146,23 @@ void DriverGL::drawModelFace(const Model::Face *face, float *vertices, float *ve
|
|||
glDisable( GL_ALPHA_TEST );
|
||||
}
|
||||
|
||||
void DriverGL::translateViewpoint(Vector3d pos, float pitch, float yaw, float roll) {
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
||||
glTranslatef(pos.x(), pos.y(), pos.z());
|
||||
glRotatef(yaw, 0, 0, 1);
|
||||
glRotatef(pitch, 1, 0, 0);
|
||||
glRotatef(roll, 0, 1, 0);
|
||||
}
|
||||
|
||||
void DriverGL::translateViewpoint() {
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void DriverGL::drawHierachyNode(const Model::HierNode *node) {
|
||||
translateViewpoint(node->_animPos / node->_totalWeight, node->_animPitch / node->_totalWeight, node->_animYaw / node->_totalWeight, node->_animRoll / node->_totalWeight);
|
||||
if (node->_hierVisible) {
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glPushMatrix();
|
||||
|
||||
glTranslatef(node->_animPos.x() / node->_totalWeight, node->_animPos.y() / node->_totalWeight, node->_animPos.z() / node->_totalWeight);
|
||||
glRotatef(node->_animYaw / node->_totalWeight, 0, 0, 1);
|
||||
glRotatef(node->_animPitch / node->_totalWeight, 1, 0, 0);
|
||||
glRotatef(node->_animRoll / node->_totalWeight, 0, 1, 0);
|
||||
|
||||
if (node->_mesh != NULL && node->_meshVisible) {
|
||||
glPushMatrix();
|
||||
glTranslatef(node->_pivot.x(), node->_pivot.y(), node->_pivot.z());
|
||||
|
@ -168,8 +175,8 @@ void DriverGL::drawHierachyNode(const Model::HierNode *node) {
|
|||
node->_child->draw();
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
glPopMatrix();
|
||||
}
|
||||
translateViewpoint();
|
||||
|
||||
if (node->_sibling != NULL)
|
||||
node->_sibling->draw();
|
||||
|
|
|
@ -49,6 +49,9 @@ public:
|
|||
|
||||
void set3DMode();
|
||||
|
||||
void translateViewpoint(Vector3d pos, float pitch, float yaw, float roll);
|
||||
void translateViewpoint();
|
||||
|
||||
void drawHierachyNode(const Model::HierNode *node);
|
||||
void drawModelFace(const Model::Face *face, float *vertices, float *vertNormals, float *textureVerts);
|
||||
|
||||
|
|
|
@ -199,15 +199,22 @@ void DriverTinyGL::drawModelFace(const Model::Face *face, float *vertices, float
|
|||
tglEnd();
|
||||
}
|
||||
|
||||
void DriverTinyGL::translateViewpoint(Vector3d pos, float pitch, float yaw, float roll) {
|
||||
tglPushMatrix();
|
||||
|
||||
tglTranslatef(pos.x(), pos.y(), pos.z());
|
||||
tglRotatef(yaw, 0, 0, 1);
|
||||
tglRotatef(pitch, 1, 0, 0);
|
||||
tglRotatef(roll, 0, 1, 0);
|
||||
}
|
||||
|
||||
void DriverTinyGL::translateViewpoint() {
|
||||
tglPopMatrix();
|
||||
}
|
||||
|
||||
void DriverTinyGL::drawHierachyNode(const Model::HierNode *node) {
|
||||
translateViewpoint(node->_animPos / node->_totalWeight, node->_animPitch / node->_totalWeight, node->_animYaw / node->_totalWeight, node->_animRoll / node->_totalWeight);
|
||||
if (node->_hierVisible) {
|
||||
tglPushMatrix();
|
||||
|
||||
tglTranslatef(node->_animPos.x() / node->_totalWeight, node->_animPos.y() / node->_totalWeight, node->_animPos.z() / node->_totalWeight);
|
||||
tglRotatef(node->_animYaw / node->_totalWeight, 0, 0, 1);
|
||||
tglRotatef(node->_animPitch / node->_totalWeight, 1, 0, 0);
|
||||
tglRotatef(node->_animRoll / node->_totalWeight, 0, 1, 0);
|
||||
|
||||
if (node->_mesh != NULL && node->_meshVisible) {
|
||||
tglPushMatrix();
|
||||
tglTranslatef(node->_pivot.x(), node->_pivot.y(), node->_pivot.z());
|
||||
|
@ -220,8 +227,8 @@ void DriverTinyGL::drawHierachyNode(const Model::HierNode *node) {
|
|||
node->_child->draw();
|
||||
tglMatrixMode(TGL_MODELVIEW);
|
||||
}
|
||||
tglPopMatrix();
|
||||
}
|
||||
translateViewpoint();
|
||||
|
||||
if (node->_sibling != NULL)
|
||||
node->_sibling->draw();
|
||||
|
|
|
@ -50,6 +50,9 @@ public:
|
|||
|
||||
void set3DMode();
|
||||
|
||||
void translateViewpoint(Vector3d pos, float pitch, float yaw, float roll);
|
||||
void translateViewpoint();
|
||||
|
||||
void drawHierachyNode(const Model::HierNode *node);
|
||||
void drawModelFace(const Model::Face *face, float *vertices, float *vertNormals, float *textureVerts);
|
||||
|
||||
|
|
|
@ -120,8 +120,8 @@ ImuseTable grimStateMusicTable[] = {
|
|||
{3, 1165, 94, 4, 24, 20, 64, "1125 - Hector Steps Out.IMC"},
|
||||
{3, 1166, 94, 4, 24, 127, 10, "1125 - Hector Steps Out.IMC"},
|
||||
{3, 1167, 0, 0, 60, 127, 0, "1167 - Dillopede Elev.IMC"},
|
||||
{3, 1168, 0, 0, 60, 127, 0, "1168 - Dillopede Elev.IMC"},
|
||||
{3, 1169, 0, 0, 60, 127, 0, "1169 - Dillopede Elev.IMC"},
|
||||
{3, 1168, 0, 0, 60, 127, 0, "1167 - Dillopede Elev.IMC"},
|
||||
{3, 1169, 0, 0, 60, 127, 0, "1167 - Dillopede Elev.IMC"},
|
||||
{3, 1170, 0, 0, 24, 105, 0, "1170 - Extendo Bridge.IMC"},
|
||||
{3, 1171, 0, 0, 24, 105, 0, "1170 - Extendo Bridge.IMC"},
|
||||
{3, 1172, 0, 0, 24, 105, 0, "1170 - Extendo Bridge.IMC"},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue