diff options
Diffstat (limited to 'source/gameengine')
-rw-r--r-- | source/gameengine/BlenderRoutines/Makefile | 1 | ||||
-rw-r--r-- | source/gameengine/Converter/BL_BlenderDataConversion.cpp | 103 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/Makefile | 2 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/common/Makefile | 1 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/Makefile | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_CameraActuator.cpp | 15 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.cpp | 29 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_GameObject.h | 3 | ||||
-rw-r--r-- | source/gameengine/PyDoc/KX_GameObject.py | 10 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/Makefile | 2 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile | 1 |
11 files changed, 106 insertions, 63 deletions
diff --git a/source/gameengine/BlenderRoutines/Makefile b/source/gameengine/BlenderRoutines/Makefile index 2339b840679..64a17f44a84 100644 --- a/source/gameengine/BlenderRoutines/Makefile +++ b/source/gameengine/BlenderRoutines/Makefile @@ -65,6 +65,7 @@ CPPFLAGS += -I../Network CPPFLAGS += -I../Network/LoopBackNetwork CPPFLAGS += -I../Physics/common CPPFLAGS += -I../Physics/Sumo +CPPFLAGS += -I. ifeq ($(OS),windows) CPPFLAGS += -I../../blender diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 08e9e36c048..089af9a68e7 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -2176,70 +2176,71 @@ void BL_ConvertBlenderObjects(struct Main* maggie, { KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i); struct Object* blenderobject = converter->FindBlenderObject(gameobj); - int nummeshes = gameobj->GetMeshCount(); - RAS_MeshObject* meshobj = 0; - ListBase *conlist; - bConstraint *curcon; - conlist = get_active_constraints2(blenderobject); - if (conlist) { - for (curcon = (bConstraint *)conlist->first; curcon; curcon=(bConstraint *)curcon->next) { - if (curcon->type==CONSTRAINT_TYPE_RIGIDBODYJOINT){ - bRigidBodyJointConstraint *dat=(bRigidBodyJointConstraint *)curcon->data; - //if (dat->tar) - if (!dat->child){ - PHY_IPhysicsController* physctr2 = 0; - if (dat->tar) - { - KX_GameObject *gotar=getGameOb(dat->tar->id.name,sumolist); - if (gotar && gotar->GetPhysicsController()) - physctr2 = (PHY_IPhysicsController*) gotar->GetPhysicsController()->GetUserData(); - } + ListBase *conlist; + bConstraint *curcon; + conlist = get_active_constraints2(blenderobject); - if (gameobj->GetPhysicsController()) - { - float radsPerDeg = 6.283185307179586232f / 360.f; + if (conlist) { + for (curcon = (bConstraint *)conlist->first; curcon; curcon=(bConstraint *)curcon->next) { + if (curcon->type==CONSTRAINT_TYPE_RIGIDBODYJOINT){ + + bRigidBodyJointConstraint *dat=(bRigidBodyJointConstraint *)curcon->data; + + if (!dat->child){ + + PHY_IPhysicsController* physctr2 = 0; + + if (dat->tar) + { + KX_GameObject *gotar=getGameOb(dat->tar->id.name,sumolist); + if (gotar && gotar->GetPhysicsController()) + physctr2 = (PHY_IPhysicsController*) gotar->GetPhysicsController()->GetUserData(); + } - PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData(); - //we need to pass a full constraint frame, not just axis + if (gameobj->GetPhysicsController()) + { + float radsPerDeg = 6.283185307179586232f / 360.f; + + PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData(); + //we need to pass a full constraint frame, not just axis - //localConstraintFrameBasis - MT_Matrix3x3 localCFrame(MT_Vector3(radsPerDeg*dat->axX,radsPerDeg*dat->axY,radsPerDeg*dat->axZ)); - MT_Vector3 axis0 = localCFrame.getColumn(0); - MT_Vector3 axis1 = localCFrame.getColumn(1); - MT_Vector3 axis2 = localCFrame.getColumn(2); + //localConstraintFrameBasis + MT_Matrix3x3 localCFrame(MT_Vector3(radsPerDeg*dat->axX,radsPerDeg*dat->axY,radsPerDeg*dat->axZ)); + MT_Vector3 axis0 = localCFrame.getColumn(0); + MT_Vector3 axis1 = localCFrame.getColumn(1); + MT_Vector3 axis2 = localCFrame.getColumn(2); - int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX,(float)dat->pivY,(float)dat->pivZ, + int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX, + (float)dat->pivY,(float)dat->pivZ, (float)axis0.x(),(float)axis0.y(),(float)axis0.z(), (float)axis1.x(),(float)axis1.y(),(float)axis1.z(), - (float)axis2.x(),(float)axis2.y(),(float)axis2.z() - ); - if (constraintId) + (float)axis2.x(),(float)axis2.y(),(float)axis2.z()); + if (constraintId) + { + //if it is a generic 6DOF constraint, set all the limits accordingly + if (dat->type == PHY_GENERIC_6DOF_CONSTRAINT) { - //if it is a generic 6DOF constraint, set all the limits accordingly - if (dat->type == PHY_GENERIC_6DOF_CONSTRAINT) + int dof; + int dofbit=1; + for (dof=0;dof<6;dof++) { - int dof; - int dofbit=1; - for (dof=0;dof<6;dof++) + if (dat->flag & dofbit) { - if (dat->flag & dofbit) - { - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]); - } else - { - //minLimit > maxLimit means free(disabled limit) for this degree of freedom - kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1); - } - dofbit<<=1; + kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]); + } else + { + //minLimit > maxLimit means free(disabled limit) for this degree of freedom + kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1); } + dofbit<<=1; } } } - } - } - } - } - + } + } + } + } + } } templist->Release(); diff --git a/source/gameengine/GamePlayer/Makefile b/source/gameengine/GamePlayer/Makefile index 747a82fc333..c4f78f23117 100644 --- a/source/gameengine/GamePlayer/Makefile +++ b/source/gameengine/GamePlayer/Makefile @@ -34,7 +34,7 @@ SOURCEDIR = source/gameengine/GamePlayer DIR = $(OCGDIR)/gameengine/GamePlayer DIRS = common ghost -ifneq ($(NAN_NO_PLUGIN),true) +ifeq ($(WITH_BF_WEBPLUGIN),true) ifeq ($(OS),$(findstring $(OS), "freebsd irix windows")) ifneq ($(FREE_WINDOWS),true) DIRS += netscape diff --git a/source/gameengine/GamePlayer/common/Makefile b/source/gameengine/GamePlayer/common/Makefile index 254896e60e5..508dee18755 100644 --- a/source/gameengine/GamePlayer/common/Makefile +++ b/source/gameengine/GamePlayer/common/Makefile @@ -60,6 +60,7 @@ CPPFLAGS += -I../../../gameengine/Converter CPPFLAGS += -I../../../gameengine/Expressions CPPFLAGS += -I../../../gameengine/GameLogic CPPFLAGS += -I../../../gameengine/Converter +CPPFLAGS += -I../../../gameengine/BlenderRoutines CPPFLAGS += -I../../../gameengine/Ketsji CPPFLAGS += -I../../../gameengine/Ketsji/KXNetwork CPPFLAGS += -I../../../gameengine/Network diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile index 8a3d194cbd7..d5aae181396 100644 --- a/source/gameengine/GamePlayer/ghost/Makefile +++ b/source/gameengine/GamePlayer/ghost/Makefile @@ -69,6 +69,8 @@ CPPFLAGS += -I../../../blender/imbuf CPPFLAGS += -I../../../blender/makesdna CPPFLAGS += -I../../../blender/readblenfile +CPPFLAGS += -I../../../gameengine/BlenderRoutines + # kernel? GEN? stuff CPPFLAGS += -I../../../kernel/gen_system CPPFLAGS += -I../../../kernel/gen_messaging diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp index cb3180cb05e..27f4870de10 100644 --- a/source/gameengine/Ketsji/KX_CameraActuator.cpp +++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp @@ -155,14 +155,25 @@ static void Kx_VecUpMat3(float *vec, float mat[][3], short axis) mat[coz][0]= vec[0]; mat[coz][1]= vec[1]; mat[coz][2]= vec[2]; - Kx_Normalize((float *)mat[coz]); + if (Kx_Normalize((float *)mat[coz]) == 0.f) { + /* this is a very abnormal situation: the camera has reach the object center exactly + We will choose a completely arbitrary direction */ + mat[coz][0] = 1.0f; + mat[coz][1] = 0.0f; + mat[coz][2] = 0.0f; + } inp= mat[coz][2]; mat[coy][0]= - inp*mat[coz][0]; mat[coy][1]= - inp*mat[coz][1]; mat[coy][2]= 1.0 - inp*mat[coz][2]; - Kx_Normalize((float *)mat[coy]); + if (Kx_Normalize((float *)mat[coy]) == 0.f) { + /* the camera is vertical, chose the y axis arbitrary */ + mat[coy][0] = 0.f; + mat[coy][1] = 1.f; + mat[coy][2] = 0.f; + } Kx_Crossf(mat[cox], mat[coy], mat[coz]); diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index 4c6ba448ebf..fb636b23082 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -581,16 +581,27 @@ void KX_GameObject::SetObjectColor(const MT_Vector4& rgbavec) -MT_Vector3 KX_GameObject::GetLinearVelocity() +MT_Vector3 KX_GameObject::GetLinearVelocity(bool local) { MT_Vector3 velocity(0.0,0.0,0.0); - + MT_Matrix3x3 ori, locvel; + int i, j; if (m_pPhysicsController1) { velocity = m_pPhysicsController1->GetLinearVelocity(); + + if (local) + { + ori = GetSGNode()->GetWorldOrientation(); + + for(i=0; i < 3; i++) + for(j=0; j < 3; j++) + locvel[i][j]= velocity[i]*ori[i][j]; + for(i=0; i < 3; i++) + velocity[i] = locvel[0][i] + locvel[1][i] + locvel[2][i]; + } } - return velocity; - + return velocity; } @@ -948,7 +959,15 @@ PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* self, PyObject* kwds) { // only can get the velocity if we have a physics object connected to us... - return PyObjectFrom(GetLinearVelocity()); + int local = 0; + if (PyArg_ParseTuple(args,"|i",&local)) + { + return PyObjectFrom(GetLinearVelocity((local!=0))); + } + else + { + return NULL; + } } diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h index da0cd69e129..b83d63e26bf 100644 --- a/source/gameengine/Ketsji/KX_GameObject.h +++ b/source/gameengine/Ketsji/KX_GameObject.h @@ -252,8 +252,9 @@ public: /** * Return the linear velocity of the game object. */ - MT_Vector3 + MT_Vector3 GetLinearVelocity( + bool local=false ); /** diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py index 31c9993e194..8ef82b4943b 100644 --- a/source/gameengine/PyDoc/KX_GameObject.py +++ b/source/gameengine/PyDoc/KX_GameObject.py @@ -58,15 +58,16 @@ class KX_GameObject: @rtype: 3x3 rotation matrix @return: The game object's rotation matrix """ - def getLinearVelocity(): + def getLinearVelocity(local): """ Gets the game object's linear velocity. This method returns the game object's velocity through it's centre of mass, ie no angular velocity component. - cf getVelocity() - + @type local: boolean + @param local: - False: you get the "global" velocity ie: relative to world orientation. + - True: you get the "local" velocity ie: relative to object orientation. @rtype: list [vx, vy, vz] @return: the object's linear velocity. """ @@ -138,6 +139,9 @@ class KX_GameObject: def setParent(parent): """ Sets this object's parent. + + @type parent: L{KX_GameObject} + @param parent: new parent object. """ def removeParent(): """ diff --git a/source/gameengine/Rasterizer/Makefile b/source/gameengine/Rasterizer/Makefile index 9cde6069167..d544056e8ae 100644 --- a/source/gameengine/Rasterizer/Makefile +++ b/source/gameengine/Rasterizer/Makefile @@ -39,6 +39,8 @@ CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I../../kernel/gen_system +CPPFLAGS += -I../BlenderRoutines + ifeq ($(OS),darwin) CPPFLAGS += -fpascal-strings endif diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile index b0d79dcc897..1a88c51dc25 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile @@ -40,6 +40,7 @@ CPPFLAGS += -I$(OPENGL_HEADERS) CPPFLAGS += -I$(NAN_STRING)/include CPPFLAGS += -I$(NAN_MOTO)/include CPPFLAGS += -I../../../kernel/gen_system +CPPFLAGS += -I../../BlenderRoutines CPPFLAGS += -I.. ifeq ($(OS),darwin) CPPFLAGS += -fpascal-strings |