[Scummvm-cvs-logs] CVS: residual actor.cpp,1.22,1.23 costume.cpp,1.14,1.15 costume.h,1.7,1.8
Daniel Schepler
dschepler at users.sourceforge.net
Tue Mar 23 05:16:09 CET 2004
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16349
Modified Files:
actor.cpp costume.cpp costume.h
Log Message:
Implement animated textures.
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- actor.cpp 22 Mar 2004 12:46:38 -0000 1.22
+++ actor.cpp 23 Mar 2004 13:05:08 -0000 1.23
@@ -245,6 +245,10 @@
}
void Actor::draw() {
+ for (std::list<Costume *>::iterator i = costumeStack_.begin();
+ i != costumeStack_.end(); i++)
+ (*i)->setupTextures();
+
if (! costumeStack_.empty()) {
g_driver->startActorDraw(pos_, yaw_, pitch_, roll_);
costumeStack_.back()->draw();
Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/costume.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- costume.cpp 23 Mar 2004 10:38:02 -0000 1.14
+++ costume.cpp 23 Mar 2004 13:05:08 -0000 1.15
@@ -22,6 +22,7 @@
#include "engine.h"
#include "colormap.h"
#include "keyframe.h"
+#include "material.h"
#include "model.h"
#include "lua.h"
#include "sound.h"
@@ -62,6 +63,10 @@
// given by a playing chore
// update() -- gives the component a chance to update its internal
// state once every frame
+// setupTexture() -- sets up animated textures for the object. This
+// is a separate stage from update() since all the
+// costumes on screen need to get updated before any
+// drawing can start.
// draw() -- actually draws the component onto the screen
// reset() -- notifies the component that a chore controlling it
// has stopped
@@ -412,6 +417,50 @@
node_->update();
}
+class MaterialComponent : public Costume::Component {
+public:
+ MaterialComponent(Costume::Component *parent, int parentID,
+ const char *filename);
+ void init();
+ void setKey(int val);
+ void setupTexture();
+ void reset();
+ ~MaterialComponent() { }
+
+private:
+ ResPtr<Material> mat_;
+ std::string filename_;
+ int num_;
+};
+
+MaterialComponent::MaterialComponent(Costume::Component *parent, int parentID,
+ const char *filename) :
+ Costume::Component(parent, parentID), filename_(filename), num_(0) {
+ warning("Constructing MaterialComponent %s\n", filename);
+}
+
+void MaterialComponent::init() {
+ warning("MaterialComponent::init on %s\n", filename_.c_str());
+ // The parent model and thus all its textures should have been
+ // loaded by now, so passing an arbitrary colormap here
+ // shouldn't cause problems.
+ ResPtr<CMap> cmap =
+ ResourceLoader::instance()->loadColormap("item.cmp");
+ mat_ = ResourceLoader::instance()->loadMaterial(filename_.c_str(), *cmap);
+}
+
+void MaterialComponent::setKey(int val) {
+ num_ = val;
+}
+
+void MaterialComponent::setupTexture() {
+ mat_->setNumber(num_);
+}
+
+void MaterialComponent::reset() {
+ num_ = 0;
+}
+
class LuaVarComponent : public Costume::Component {
public:
LuaVarComponent(Costume::Component *parent, int parentID,
@@ -661,7 +710,8 @@
return new SoundComponent(parent, parentID, name);
else if (std::memcmp(tag, "bknd", 4) == 0)
return new BitmapComponent(parent, parentID, name);
-
+ else if (std::memcmp(tag, "mat ", 4) == 0)
+ return new MaterialComponent(parent, parentID, name);
warning("Unknown tag '%.4s', name '%s'\n", tag, name);
return NULL;
}
@@ -712,6 +762,12 @@
talkChores_[index-1] = chore;
}
+void Costume::setupTextures() {
+ for (int i = 0; i < numComponents_; i++)
+ if (components_[i] != NULL)
+ components_[i]->setupTexture();
+}
+
void Costume::draw() {
for (int i = 0; i < numComponents_; i++)
if (components_[i] != NULL)
Index: costume.h
===================================================================
RCS file: /cvsroot/scummvm/residual/costume.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- costume.h 24 Feb 2004 21:09:53 -0000 1.7
+++ costume.h 23 Mar 2004 13:05:08 -0000 1.8
@@ -48,6 +48,7 @@
void setHead( int joint1, int joint2, int joint3, float maxRoll, float maxPitch, float maxYaw );
void update();
+ void setupTextures();
void draw();
void setPosRotate( Vector3d pos_, float pitch_, float yaw_, float roll_ );
@@ -59,6 +60,7 @@
virtual void init() { }
virtual void setKey(int /* val */) { }
virtual void update() { }
+ virtual void setupTexture() { }
virtual void draw() { }
virtual void reset() { }
virtual ~Component() { }
More information about the Scummvm-git-logs
mailing list