[Scummvm-cvs-logs] CVS: residual actor.cpp,1.10,1.11 actor.h,1.5,1.6 lua.cpp,1.27,1.28 vector3d.h,1.1,1.2
Vincent Hamm
yazoo at users.sourceforge.net
Wed Aug 27 12:52:48 CEST 2003
Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1:/tmp/cvs-serv2673
Modified Files:
actor.cpp actor.h lua.cpp vector3d.h
Log Message:
added preliminary code for actorLookAt
Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- actor.cpp 24 Aug 2003 17:56:03 -0000 1.10
+++ actor.cpp 26 Aug 2003 00:25:22 -0000 1.11
@@ -29,7 +29,7 @@
Actor::Actor(const char *name) :
name_(name), talkColor_(255, 255, 255), pos_(0, 0, 0),
pitch_(0), yaw_(0), roll_(0), walkRate_(0), turnRate_(0),
- visible_(true), talkSound_(NULL), turning_(false), walking_(false)
+ visible_(true), talkSound_(NULL), turning_(false), walking_(false), walkChore_(-1)
{
Engine::instance()->registerActor(this);
}
@@ -202,6 +202,10 @@
}
else
pos_ += dir * walkAmt;
+ }
+
+ if (lookingMode_) {
+ float lookAtAmt = Engine::instance()->perSecond(lookAtRate_);
}
for (std::list<Costume *>::iterator i = costumeStack_.begin();
Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- actor.h 22 Aug 2003 12:28:33 -0000 1.5
+++ actor.h 26 Aug 2003 00:25:22 -0000 1.6
@@ -54,6 +54,7 @@
float turnRate() const { return turnRate_; }
void setWalkRate(float rate) { walkRate_ = rate; }
float walkRate() const { return walkRate_; }
+ void setLooking(bool lookingMode) { lookingMode_ = lookingMode; }
float angleTo(const Actor &a) const;
float yawTo(Vector3d p) const;
@@ -68,6 +69,8 @@
void shutUp();
bool talking();
+ void setWalkChore(int choreNumber) { walkChore_ = choreNumber; }
+
void pushCostume(const char *name);
void setCostume(const char *name);
void popCostume();
@@ -86,6 +89,20 @@
void update();
void draw();
+ bool isLookAtVectorZero() {
+ return lookAtVector_.isZero();
+ }
+ void setLookAtVectorZero() {
+ lookAtVector_.set( 0.f, 0.f, 0.f );
+ }
+ void setLookAtVector( Vector3d vector )
+ {
+ lookAtVector_ = vector;
+ }
+ void setLookAtRate( float rate ) {
+ lookAtRate_ = rate;
+ }
+
private:
std::string name_;
std::string setName_;
@@ -93,7 +110,9 @@
Vector3d pos_;
float pitch_, yaw_, roll_;
float walkRate_, turnRate_;
+
bool visible_;
+ bool lookingMode_;
ResPtr<Sound> talkSound_;
std::list<Costume *> costumeStack_;
@@ -104,6 +123,13 @@
// Variables for walking to a point
bool walking_;
Vector3d destPos_;
+
+ // chores
+ int walkChore_;
+
+ // lookAt
+ Vector3d lookAtVector_;
+ float lookAtRate_;
friend class Engine;
};
Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- lua.cpp 24 Aug 2003 17:56:03 -0000 1.27
+++ lua.cpp 26 Aug 2003 00:25:22 -0000 1.28
@@ -33,7 +33,27 @@
#include <cstdio>
#include <cmath>
-static int actor_tag, color_tag, sound_tag;
+static int actor_tag, color_tag, sound_tag, text_tag, vbuffer_tag;
+
+// Yaz: we'll need those later on, you'll see why....
+
+static inline bool isActor(int num) {
+ if(lua_tag(lua_getparam(num)) != actor_tag)
+ return false;
+ return true;
+}
+
+static inline bool isColor(int num) {
+ if(lua_tag(lua_getparam(num)) != color_tag)
+ return false;
+ return true;
+}
+
+static inline bool isSound(int num) {
+ if(lua_tag(lua_getparam(num)) != sound_tag)
+ return false;
+ return true;
+}
// Helper functions to ensure the arguments we get are what we expect
@@ -459,6 +479,69 @@
lua_pushnumber(result);
}
+static void ActorLookAt() {
+ Actor *act = check_actor(1);
+ lua_Object x = lua_getparam(2);
+ lua_Object y = lua_getparam(3);
+ lua_Object z = lua_getparam(4);
+ lua_Object rate = lua_getparam(5);
+
+ if(lua_isnumber(rate))
+ act->setLookAtRate( luaL_check_number(5) );
+
+ // Look at nothing
+ if( lua_isnil(x) )
+ {
+ if(act->isLookAtVectorZero()) // already looking at nothing
+ return;
+
+ act->setLookAtVectorZero();
+
+ if(lua_isnumber(y))
+ act->setLookAtRate( luaL_check_number(3) );
+
+ act->setLooking( true );
+ return;
+ }
+
+ // look at xyz
+ else if( lua_isnumber(x) )
+ {
+ Vector3d vector;
+ float fX;
+ float fY;
+ float fZ;
+
+ fX = luaL_check_number(2);
+
+ if( lua_isnumber(y) )
+ fY = luaL_check_number(3);
+ else
+ fY = 0.f;
+
+ if( lua_isnumber(z) )
+ fZ = luaL_check_number(4);
+ else
+ fZ = 0.f;
+
+ vector.set(fX,fY,fZ);
+
+ act->setLookAtVector( vector );
+ }
+ // look at another actor
+ else if(isActor(2))
+ {
+ Actor *lookedAct = check_actor(2);
+
+ act->setLookAtVector(lookedAct->pos());
+
+ if(lua_isnumber(y))
+ act->setLookAtRate(luaL_check_number(3));
+ }
+
+ act->setLooking( true );
+}
+
static void GetVisibleThings() {
lua_Object result = lua_createtable();
Actor *sel = Engine::instance()->selectedActor();
@@ -510,6 +593,11 @@
act->shutUp();
}
+static void HardwareAccelerated() {
+ // FIXME: Are we always in HW accelerated ?
+ lua_pushnumber( TRUE );
+}
+
// Sector functions
static void GetActorSector(void) {
Actor *act = check_actor(1);
@@ -883,7 +971,6 @@
static char *stubFuncs[] = {
"RestoreIMuse",
"SaveIMuse",
- "Is3DHardwareEnabled",
"SetActorInvClipNode",
"NukeResources",
"UnShrinkBoxes",
@@ -1001,7 +1088,6 @@
"GetCameraActor",
"GetActorLookRate",
"SetActorLookRate",
- "ActorLookAt",
"DriveActorTo",
"WalkActorVector",
"PutActorAtInterest",
@@ -1267,15 +1353,20 @@
{ "GetTextObjectDimensions", GetTextObjectDimensions },
{ "MakeTextObject", MakeTextObject },
{ "KillTextObject", KillTextObject },
- { "ShutUpActor", ShutUpActor }
+ { "ShutUpActor", ShutUpActor },
+ { "HardwareAccelerated", HardwareAccelerated },
+ { "ActorLookAt", ActorLookAt },
};
void register_lua() {
// Create various LUA tags
actor_tag = lua_newtag();
color_tag = lua_newtag();
- sound_tag = lua_newtag();
+ sound_tag = lua_newtag(); // Yaz: wasn't found in the original engine, maybe I messed it.
+ text_tag = lua_newtag();
+ vbuffer_tag = lua_newtag();
+ //Yaz: do we really need a garbage collector ?
// Register GC methods
lua_pushcfunction(gc_Color);
lua_settagmethod(color_tag, "gc");
Index: vector3d.h
===================================================================
RCS file: /cvsroot/scummvm/residual/vector3d.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- vector3d.h 15 Aug 2003 19:41:26 -0000 1.1
+++ vector3d.h 26 Aug 2003 00:25:22 -0000 1.2
@@ -72,6 +72,12 @@
float magnitude() const {
return std::sqrt(x() * x() + y() * y() + z() * z());
}
+
+ bool isZero() {
+ if(x() == 0.f && y() == 0.f && z() == 0.f)
+ return true;
+ return false;
+ }
};
inline float dot(const Vector3d& v1, const Vector3d& v2) {
More information about the Scummvm-git-logs
mailing list