Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,138 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "engines/grim/debug.h"
#include "engines/grim/emi/costume/emianim_component.h"
#include "engines/grim/emi/costume/emiskel_component.h"
#include "engines/grim/resource.h"
#include "engines/grim/costume.h"
#include "engines/grim/emi/costumeemi.h"
#include "engines/grim/emi/modelemi.h"
#include "engines/grim/emi/skeleton.h"
#include "engines/grim/emi/animationemi.h"
namespace Grim {
EMIAnimComponent::EMIAnimComponent(Component *p, int parentID, const char *filename, Component *prevComponent, tag32 t) :
Component(p, parentID, filename, t), _animState(nullptr) {
}
EMIAnimComponent::~EMIAnimComponent() {
delete _animState;
}
void EMIAnimComponent::init() {
_visible = true;
_animState = new AnimationStateEmi(_name);
}
int EMIAnimComponent::update(uint time) {
EMISkelComponent *skel = ((EMICostume *)_cost)->_emiSkel;
if (skel) {
_animState->setSkeleton(skel->_obj);
_animState->update(time);
}
return 0;
}
void EMIAnimComponent::setKey(int f) {
switch (f) {
case 0: // Stop
_animState->stop();
break;
case 1: // Play
_animState->play();
break;
case 2: // Pause
_animState->setPaused(true);
break;
case 3: // Loop
_animState->setLooping(true);
_animState->play();
break;
case 4: // No loop
_animState->setLooping(false);
break;
case 5: // Fade in 1
_animState->fade(Animation::FadeIn, 1000);
break;
case 6: // Fade in 3/4
_animState->fade(Animation::FadeIn, 750);
break;
case 7: // Fade in 1/2
_animState->fade(Animation::FadeIn, 500);
break;
case 8: // Fade in 1/4
_animState->fade(Animation::FadeIn, 250);
break;
case 9: // Fade in 1/8
_animState->fade(Animation::FadeIn, 125);
break;
case 10: // Fade out 1
_animState->fade(Animation::FadeOut, 1000);
break;
case 11: // Fade out 3/4
_animState->fade(Animation::FadeOut, 750);
break;
case 12: // Fade out 1/2
_animState->fade(Animation::FadeOut, 500);
break;
case 13: // Fade out 1/4
_animState->fade(Animation::FadeOut, 250);
break;
case 14: // Fade out 1/8
_animState->fade(Animation::FadeOut, 125);
break;
default:
Debug::warning(Debug::Costumes, "Unknown key %d for component %s", f, _name.c_str());
break;
}
}
void EMIAnimComponent::reset() {
_visible = true;
_animState->stop();
}
void EMIAnimComponent::fade(Animation::FadeMode mode, int fadeLength) {
_animState->fade(mode, fadeLength);
}
void EMIAnimComponent::advance(uint msecs) {
_animState->advance(msecs);
}
void EMIAnimComponent::setPaused(bool paused) {
_animState->setPaused(paused);
}
void EMIAnimComponent::draw() {
}
void EMIAnimComponent::saveState(SaveGame *state) {
_animState->saveState(state);
}
void EMIAnimComponent::restoreState(SaveGame *state) {
_animState->restoreState(state);
}
} // end of namespace Grim

View File

@@ -0,0 +1,54 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef GRIM_EMI_ANIM_COMPONENT_H
#define GRIM_EMI_ANIM_COMPONENT_H
#include "engines/grim/costume/component.h"
// This is mostly stubbed for testing the animation loading at the moment.
namespace Grim {
class AnimationStateEmi;
class EMIAnimComponent : public Component {
public:
EMIAnimComponent(Component *parent, int parentID, const char *filename, Component *prevComponent, tag32 tag);
~EMIAnimComponent();
void init() override;
void setKey(int) override;
int update(uint time) override;
void reset() override ;
void fade(Animation::FadeMode mode, int fadeLength) override ;
void advance(uint msecs) override ;
void setPaused(bool paused) override;
void draw() override;
void saveState(SaveGame *state) override;
void restoreState(SaveGame *state) override;
private:
AnimationStateEmi *_animState;
};
} // end of namespace Grim
#endif

View File

@@ -0,0 +1,140 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "engines/grim/emi/costume/emichore.h"
#include "engines/grim/emi/modelemi.h"
namespace Grim {
EMIChore::EMIChore(char name[32], int id, Costume *owner, int length, int numTracks) :
Chore(name, id, owner, length, numTracks), _mesh(nullptr), _skeleton(nullptr),
_fadeMode(Animation::None), _fade(1.f), _fadeLength(0), _startFade(1.0f) {
}
void EMIChore::addComponent(Component *component) {
if (component->isComponentType('m', 'e', 's', 'h')) {
_mesh = static_cast<EMIMeshComponent *>(component);
} else if (component->isComponentType('s', 'k', 'e', 'l')) {
_skeleton = static_cast<EMISkelComponent *>(component);
}
if (_mesh && _mesh->_obj && _skeleton) {
_mesh->_obj->setSkeleton(_skeleton->_obj);
}
}
void EMIChore::update(uint time) {
if (!_playing || _paused)
return;
if (_fadeMode != Animation::None) {
if (_fadeMode == Animation::FadeIn) {
_fade += (float)time * (1.0f - _startFade) / _fadeLength;
if (_fade >= 1.f) {
_fade = 1.f;
_fadeMode = Animation::None;
}
} else {
_fade -= (float)time * _startFade / _fadeLength;
if (_fade <= 0.f) {
_fade = 0.f;
stop(0);
return;
}
}
}
int newTime;
if (_currTime < 0)
newTime = 0; // For first time through
else
newTime = _currTime + time;
setKeys(_currTime, newTime);
if (_length >= 0 && newTime > _length) {
if (!_looping && _fadeMode != Animation::FadeOut) {
stop(0);
}
else {
do {
newTime -= _length;
setKeys(-1, newTime);
} while (newTime > _length);
}
}
_currTime = newTime;
}
void EMIChore::stop(uint msecs) {
if (msecs > 0) {
fade(Animation::FadeOut, msecs);
} else {
_playing = false;
_hasPlayed = false;
for (int i = 0; i < _numTracks; i++) {
Component *comp = getComponentForTrack(i);
if (comp)
comp->reset();
}
}
}
void EMIChore::fade(Animation::FadeMode mode, uint msecs) {
if (mode == Animation::None) {
_fade = 1.0f;
}
_startFade = _fade;
_fadeMode = mode;
_fadeLength = msecs;
for (int i = 0; i < _numTracks; i++) {
Component *comp = getComponentForTrack(i);
if (comp) {
comp->fade(mode, msecs);
}
}
}
void EMIChore::saveState(SaveGame *state) const {
Chore::saveState(state);
state->writeLESint32((int)_fadeMode);
state->writeFloat(_fade);
state->writeFloat(_startFade);
state->writeLESint32(_fadeLength);
}
void EMIChore::restoreState(SaveGame *state) {
Chore::restoreState(state);
if (state->saveMinorVersion() >= 10) {
_fadeMode = (Animation::FadeMode)state->readLESint32();
_fade = state->readFloat();
_startFade = state->readFloat();
_fadeLength = state->readLESint32();
} else {
if (_length == -1 && _playing)
_currTime = -1;
}
}
} // end of namespace Grim

View File

@@ -0,0 +1,60 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef GRIM_EMICHORE_H
#define GRIM_EMICHORE_H
#include "engines/grim/costume/chore.h"
#include "engines/grim/pool.h"
#include "engines/grim/emi/costume/emimesh_component.h"
#include "engines/grim/emi/costume/emiskel_component.h"
namespace Grim {
class EMIChore : public PoolObject<EMIChore>, public Chore {
public:
EMIChore(char name[32], int id, Costume *owner, int length, int numTracks);
static int32 getStaticTag() { return MKTAG('C', 'H', 'O', 'R'); }
void update(uint msecs) override;
void stop(uint msecs) override;
void addComponent(Component *component);
bool isWearChore() { return _mesh && _skeleton; }
void saveState(SaveGame *state) const override;
void restoreState(SaveGame *state) override;
EMIMeshComponent *getMesh() { return _mesh; }
EMISkelComponent *getSkeleton() { return _skeleton; }
private:
void fade(Animation::FadeMode mode, uint msecs) override;
Animation::FadeMode _fadeMode;
float _fade;
float _startFade;
int _fadeLength;
EMIMeshComponent *_mesh;
EMISkelComponent *_skeleton;
};
} // end of namespace Grim
#endif

View File

@@ -0,0 +1,168 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "engines/grim/grim.h"
#include "engines/grim/emi/costume/emihead.h"
#include "engines/grim/emi/costumeemi.h"
#include "engines/grim/emi/skeleton.h"
namespace Grim {
EMIHead::EMIHead(EMICostume *costume) : _yawRange(80.0f), _minPitch(-30.0f), _maxPitch(30.0f) {
_cost = costume;
}
void EMIHead::setJoint(const char *joint, const Math::Vector3d &offset) {
_jointName = joint;
_offset = offset;
}
void EMIHead::setLimits(float yawRange, float maxPitch, float minPitch) {
_yawRange = yawRange;
_maxPitch = maxPitch;
_minPitch = minPitch;
}
void EMIHead::lookAt(bool entering, const Math::Vector3d &point, float rate, const Math::Matrix4 &matrix) {
if (!_cost->_emiSkel || !_cost->_emiSkel->_obj)
return;
if (_jointName.empty())
return;
Joint *joint = _cost->_emiSkel->_obj->getJointNamed(_jointName);
if (!joint)
return;
Math::Quaternion lookAtQuat; // Note: Identity if not looking at anything.
if (entering) {
Math::Matrix4 jointToWorld = _cost->getOwner()->getFinalMatrix() * joint->_finalMatrix;
Math::Vector3d jointWorldPos = jointToWorld.getPosition();
Math::Matrix4 worldToJoint = jointToWorld;
worldToJoint.invertAffineOrthonormal();
Math::Vector3d targetDir = (point + _offset) - jointWorldPos;
targetDir.normalize();
const Math::Vector3d worldUp(0, 1, 0);
Math::Vector3d frontDir = Math::Vector3d(worldToJoint(0, 1), worldToJoint(1, 1), worldToJoint(2, 1)); // Look straight ahead. (+Y)
Math::Vector3d modelFront(0, 0, 1);
Math::Vector3d modelUp(0, 1, 0);
modelFront = modelFront * joint->_absMatrix.getRotation();
modelUp = modelUp * joint->_absMatrix.getRotation();
// Generate a world-space look at matrix.
Math::Matrix4 lookAtTM;
lookAtTM.setToIdentity();
if (Math::Vector3d::dotProduct(targetDir, worldUp) >= 0.98f) // Avoid singularity if trying to look straight up.
lookAtTM.buildFromTargetDir(modelFront, targetDir, modelUp, -frontDir); // Instead of orienting head towards scene up, orient head towards character "back",
else if (Math::Vector3d::dotProduct(targetDir, worldUp) <= -0.98f) // Avoid singularity if trying to look straight down.
lookAtTM.buildFromTargetDir(modelFront, targetDir, modelUp, frontDir); // Instead of orienting head towards scene down, orient head towards character "front",
else
lookAtTM.buildFromTargetDir(modelFront, targetDir, modelUp, worldUp);
// Convert from world-space to joint-space.
lookAtTM = worldToJoint * lookAtTM;
// Apply angle limits.
Math::Angle p, y, r;
lookAtTM.getEuler(&y, &p, &r, Math::EO_ZXY);
y.clampDegrees(_yawRange);
p.clampDegrees(_minPitch, _maxPitch);
r.clampDegrees(30.0f);
lookAtTM.buildFromEuler(y, p, r, Math::EO_ZXY);
lookAtQuat.fromMatrix(lookAtTM.getRotation());
}
if (_headRot != lookAtQuat) {
Math::Quaternion diff = _headRot.inverse() * lookAtQuat;
diff.normalize();
float angle = 2 * acos(MIN(MAX(diff.w(), -1.0f), 1.0f));
if (diff.w() < 0.0f) {
angle = 2 * (float)M_PI - angle;
}
float turnAmount = g_grim->getPerSecond(rate * ((float)M_PI / 180.0f));
if (turnAmount < angle)
_headRot = _headRot.slerpQuat(lookAtQuat, turnAmount / angle);
else
_headRot = lookAtQuat;
}
if (_headRot != Math::Quaternion()) { // If not identity..
joint->_animMatrix = joint->_animMatrix * _headRot.toMatrix();
joint->_animQuat = joint->_animQuat * _headRot;
_cost->_emiSkel->_obj->commitAnim();
}
}
void EMIHead::saveState(SaveGame *state) const {
state->writeString(_jointName);
state->writeVector3d(_offset);
state->writeFloat(_headRot.x());
state->writeFloat(_headRot.y());
state->writeFloat(_headRot.z());
state->writeFloat(_headRot.w());
state->writeFloat(_yawRange);
state->writeFloat(_minPitch);
state->writeFloat(_maxPitch);
}
void EMIHead::restoreState(SaveGame *state) {
if (state->saveMinorVersion() >= 15) {
_jointName = state->readString();
_offset = state->readVector3d();
_headRot.x() = state->readFloat();
_headRot.y() = state->readFloat();
_headRot.z() = state->readFloat();
_headRot.w() = state->readFloat();
if (state->saveMinorVersion() >= 16) {
_yawRange = state->readFloat();
_minPitch = state->readFloat();
_maxPitch = state->readFloat();
}
} else {
state->readLESint32();
state->readLESint32();
state->readLESint32();
state->readFloat();
state->readFloat();
state->readFloat();
if (state->saveMinorVersion() < 2) {
state->readFloat();
state->readFloat();
} else {
for (int i = 0; i < 3; ++i) {
state->readFloat();
state->readFloat();
state->readFloat();
}
}
}
}
} // end of namespace Grim

View File

@@ -0,0 +1,57 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef GRIM_EMIHEAD_H
#define GRIM_EMIHEAD_H
#include "math/vector3d.h"
#include "math/quat.h"
#include "engines/grim/costume/head.h"
namespace Grim {
class EMICostume;
class EMIHead : public BaseHead {
public:
EMIHead(EMICostume *costume);
void setJoint(const char *joint, const Math::Vector3d &offset);
void setLimits(float yawRange, float maxPitch, float minPitch);
void lookAt(bool entering, const Math::Vector3d &point, float rate, const Math::Matrix4 &matrix) override;
void loadJoints(ModelNode *nodes) override {}
void saveState(SaveGame *state) const override;
void restoreState(SaveGame *state) override;
private:
EMICostume *_cost;
Common::String _jointName;
Math::Vector3d _offset;
Math::Quaternion _headRot;
float _yawRange;
float _maxPitch;
float _minPitch;
};
} // end of namespace Grim
#endif

View File

@@ -0,0 +1,53 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "common/debug.h"
#include "engines/grim/debug.h"
#include "engines/grim/emi/costume/emiluacode_component.h"
namespace Grim {
EMILuaCodeComponent::EMILuaCodeComponent(Component *p, int parentID, const char *name, Component *prevComponent, tag32 t) : Component(p, parentID, name, t) {
}
EMILuaCodeComponent::~EMILuaCodeComponent() {
}
void EMILuaCodeComponent::init() {
}
int EMILuaCodeComponent::update(uint time) {
return 0;
}
void EMILuaCodeComponent::setKey(int val) {
Debug::debug(Debug::Lua, "LuaC component: executing code [%s]", _name.c_str());
lua_dostring(_name.c_str());
}
void EMILuaCodeComponent::reset() {
}
void EMILuaCodeComponent::draw() {
}
} // end of namespace Grim

View File

@@ -0,0 +1,44 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef GRIM_EMI_LUACODE_COMPONENT_H
#define GRIM_EMI_LUACODE_COMPONENT_H
#include "engines/grim/costume/component.h"
#include "engines/grim/lua/lua.h"
namespace Grim {
class EMILuaCodeComponent : public Component {
public:
EMILuaCodeComponent(Component *parent, int parentID, const char *name, Component *prevComponent, tag32 tag);
~EMILuaCodeComponent();
void init() override;
int update(uint time) override;
void reset() override;
void draw() override;
void setKey(int val) override;
private:
};
} // end of namespace Grim
#endif

View File

@@ -0,0 +1,55 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "common/debug.h"
#include "common/textconsole.h"
#include "engines/grim/debug.h"
#include "engines/grim/emi/costume/emiluavar_component.h"
namespace Grim {
EMILuaVarComponent::EMILuaVarComponent(Component *p, int parentID, const char *name, Component *prevComponent, tag32 t) : Component(p, parentID, name, t) {
}
EMILuaVarComponent::~EMILuaVarComponent() {
}
void EMILuaVarComponent::init() {
}
int EMILuaVarComponent::update(uint time) {
return 0;
}
void EMILuaVarComponent::setKey(int val) {
Debug::debug(Debug::Lua, "LuaV component: setting %s to %d", _name.c_str(), val);
lua_pushnumber(val);
lua_setglobal(_name.c_str());
}
void EMILuaVarComponent::reset() {
}
void EMILuaVarComponent::draw() {
}
} // end of namespace Grim

View File

@@ -0,0 +1,44 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef GRIM_EMI_LUAVAR_COMPONENT_H
#define GRIM_EMI_LUAVAR_COMPONENT_H
#include "engines/grim/lua/lua.h"
#include "engines/grim/costume/component.h"
namespace Grim {
class EMILuaVarComponent : public Component {
public:
EMILuaVarComponent(Component *parent, int parentID, const char *name, Component *prevComponent, tag32 tag);
~EMILuaVarComponent();
void init() override;
int update(uint time) override;
void reset() override;
void draw() override;
void setKey(int val) override;
private:
};
} // end of namespace Grim
#endif

View File

@@ -0,0 +1,99 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "engines/grim/emi/costume/emimesh_component.h"
#include "engines/grim/emi/modelemi.h"
#include "engines/grim/resource.h"
#include "engines/grim/costume.h"
namespace Grim {
EMIMeshComponent::EMIMeshComponent(Component *p, int parentID, const char *filename, Component *prevComponent, tag32 t, EMICostume *costume) :
Component(p, parentID, filename, t), _costume(costume), _obj(nullptr), _parentModel(nullptr), _hasComplained(false) {
_hierShared = false;
}
EMIMeshComponent::~EMIMeshComponent() {
if (_hierShared) {
_obj = nullptr; // Keep ~ModelComp from deleting it
//_animation = NULL;
} else {
delete _obj;
}
for (EMIMeshComponent *child : _children) {
child->_obj = nullptr;
//child->_hier = NULL;
child->_parentModel = nullptr;
}
if (_parentModel) {
_parentModel->_children.remove(this);
}
}
void EMIMeshComponent::init() {
_visible = true;
_obj = g_resourceloader->loadModelEMI(_name, _costume);
}
int EMIMeshComponent::update(uint time) {
return 0;
}
void EMIMeshComponent::reset() {
_visible = true;
}
void EMIMeshComponent::draw() {
// If the object was drawn by being a component
// of it's parent then don't draw it
if (_parent && _parent->isVisible())
return;
if (!_obj) {
if (!_hasComplained) {
warning("Tried to draw component we have no file for %s", _name.c_str());
_hasComplained = true;
}
return;
}
// Need to translate object to be in accordance
// with the setup of the parent
//translateObject(false);
_obj->draw();
// Need to un-translate when done
//translateObject(true);
}
void EMIMeshComponent::getBoundingBox(int *x1, int *y1, int *x2, int *y2) const {
// If the object was drawn by being a component
// of it's parent then don't draw it
if (_parent && _parent->isVisible())
return;
if (_obj)
_obj->getBoundingBox(x1, y1, x2, y2);
}
} // end of namespace Grim

View File

@@ -0,0 +1,53 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef GRIM_EMI_MESH_COMPONENT_H
#define GRIM_EMI_MESH_COMPONENT_H
#include "engines/grim/costume/component.h"
namespace Grim {
class EMICostume;
class EMIModel;
class EMIMeshComponent : public Component {
public:
EMIMeshComponent(Component *parent, int parentID, const char *filename, Component *prevComponent, tag32 tag, EMICostume *costume);
~EMIMeshComponent();
void init() override;
int update(uint time) override;
void reset() override;
void draw() override;
void getBoundingBox(int *x1, int *y1, int *x2, int *y2) const;
public:
EMICostume *_costume;
bool _hierShared;
Common::List<EMIMeshComponent*> _children;
EMIMeshComponent *_parentModel;
EMIModel *_obj;
bool _hasComplained; // Temporary fix for warning-spam.
};
} // end of namespace Grim
#endif

View File

@@ -0,0 +1,58 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "engines/grim/emi/costume/emiskel_component.h"
#include "engines/grim/resource.h"
#include "engines/grim/emi/modelemi.h"
#include "engines/grim/emi/skeleton.h"
#include "engines/grim/costume.h"
namespace Grim {
EMISkelComponent::EMISkelComponent(Component *p, int parentID, const char *filename, Component *prevComponent, tag32 t) : Component(p, parentID, filename, t), _obj(nullptr), _parentModel(nullptr), _hierShared(false) {
}
EMISkelComponent::~EMISkelComponent() {
delete _obj;
}
void EMISkelComponent::init() {
_visible = true;
_obj = g_resourceloader->loadSkeleton(_name);
}
void EMISkelComponent::animate() {
if (_obj)
_obj->animate();
}
int EMISkelComponent::update(uint time) {
return 0;
}
void EMISkelComponent::reset() {
_visible = true;
}
void EMISkelComponent::draw() {
}
} // end of namespace Grim

View File

@@ -0,0 +1,51 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef GRIM_EMI_SKEL_COMPONENT_H
#define GRIM_EMI_SKEL_COMPONENT_H
#include "engines/grim/costume/component.h"
// This is mostly stubbed for testing the skeletonloading at the moment.
namespace Grim {
class Skeleton;
class EMISkelComponent : public Component {
public:
EMISkelComponent(Component *parent, int parentID, const char *filename, Component *prevComponent, tag32 tag);
~EMISkelComponent();
void init() override;
void animate() override;
int update(uint time) override;
void reset() override;
void draw() override;
public:
bool _hierShared;
Component *_parentModel;
Skeleton *_obj;
};
} // end of namespace Grim
#endif

View File

@@ -0,0 +1,55 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "engines/grim/emi/costume/emisprite_component.h"
#include "engines/grim/emi/costumeemi.h"
#include "engines/grim/resource.h"
#include "engines/grim/costume.h"
#include "engines/grim/sprite.h"
namespace Grim {
EMISpriteComponent::EMISpriteComponent(Component *p, int parentID, const char *filename, Component *prevComponent, tag32 t) : Component(p, parentID, filename, t), _sprite(nullptr) {
}
EMISpriteComponent::~EMISpriteComponent() {
delete _sprite;
}
void EMISpriteComponent::init() {
EMICostume *c = static_cast<EMICostume *>(_cost);
_sprite = g_resourceloader->loadSprite(_name, c);
}
int EMISpriteComponent::update(uint time) {
return 0;
}
void EMISpriteComponent::reset() {
}
void EMISpriteComponent::draw() {
if (_sprite) {
_sprite->draw();
}
}
} // end of namespace Grim

View File

@@ -0,0 +1,46 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef GRIM_EMI_SPRITE_COMPONENT_H
#define GRIM_EMI_SPRITE_COMPONENT_H
#include "engines/grim/costume/component.h"
namespace Grim {
class Sprite;
class EMISpriteComponent : public Component {
public:
EMISpriteComponent(Component *parent, int parentID, const char *filename, Component *prevComponent, tag32 tag);
~EMISpriteComponent();
void init() override;
int update(uint time) override;
void reset() override;
void draw() override;
public:
Sprite *_sprite;
};
} // end of namespace Grim
#endif

View File

@@ -0,0 +1,59 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "engines/grim/costume.h"
#include "engines/grim/debug.h"
#include "engines/grim/material.h"
#include "engines/grim/savegame.h"
#include "engines/grim/emi/costumeemi.h"
#include "engines/grim/emi/modelemi.h"
#include "engines/grim/emi/costume/emimesh_component.h"
#include "engines/grim/emi/costume/emitexi_component.h"
namespace Grim {
EMITexiComponent::EMITexiComponent(Component *parent, int parentID, const char *filename, Component *prevComponent, tag32 tag) : Component(parent, parentID, filename, tag) {
}
EMITexiComponent::~EMITexiComponent() {
}
void EMITexiComponent::init() {
EMICostume *c = static_cast<EMICostume *>(_cost);
_mat = c->findMaterial(_name);
}
int EMITexiComponent::update(uint time) {
return 0;
}
void EMITexiComponent::setKey(int k) {
if (_mat && _mat->getNumTextures() > k)
_mat->setActiveTexture(k);
}
void EMITexiComponent::reset() {
}
void EMITexiComponent::draw() {
}
} // end of namespace Grim

View File

@@ -0,0 +1,49 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef GRIM_EMI_TEXI_COMPONENT_H
#define GRIM_EMI_TEXI_COMPONENT_H
#include "engines/grim/costume/component.h"
#include "engines/grim/material.h"
#include "engines/grim/resource.h"
#include "engines/grim/model.h"
namespace Grim {
class EMITexiComponent : public Component {
public:
EMITexiComponent(Component *parent, int parentID, const char *filename, Component *prevComponent, tag32 tag);
~EMITexiComponent();
void init() override;
int update(uint time) override;
void reset() override;
void draw() override;
void setKey(int k) override;
private:
Material *_mat;
};
} // end of namespace Grim
#endif