[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [15611] trunk/blender/source/gameengine/ Ketsji/KX_Scene.cpp: BGE patch: use the Blender convention to duplicate groups in the BGE so that the objects will be created with the location and orientation as in Blender .

Benoit Bolsee benoit.bolsee at online.be
Thu Jul 17 17:33:27 CEST 2008


Revision: 15611
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15611
Author:   ben2610
Date:     2008-07-17 17:33:27 +0200 (Thu, 17 Jul 2008)

Log Message:
-----------
BGE patch: use the Blender convention to duplicate groups in the BGE so that the objects will be created with the location and orientation as in Blender. Note that the BGE handles scaling in a parent tree differently than Blender. To avoid discrepencies between the 3D view and the BGE, use only isotropic scaling on all your objects except the leaf objects (i.e. without children) that can have anisotropic scaling

Modified Paths:
--------------
    trunk/blender/source/gameengine/Ketsji/KX_Scene.cpp

Modified: trunk/blender/source/gameengine/Ketsji/KX_Scene.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_Scene.cpp	2008-07-17 12:29:42 UTC (rev 15610)
+++ trunk/blender/source/gameengine/Ketsji/KX_Scene.cpp	2008-07-17 15:33:27 UTC (rev 15611)
@@ -672,19 +672,22 @@
 		}
 		// don't replicate logic now: we assume that the objects in the group can have
 		// logic relationship, even outside parent relationship
+		// In order to match 3D view, the position of groupobj is used as a 
+		// transformation matrix instead of the new position. This means that 
+		// the group reference point is 0,0,0
 
-		MT_Point3 newpos = groupobj->NodeGetWorldPosition();
-		replica->NodeSetLocalPosition(newpos);
-
-		MT_Matrix3x3 newori = groupobj->NodeGetWorldOrientation();
-		replica->NodeSetLocalOrientation(newori);
-	
 		// get the rootnode's scale
-		MT_Vector3 newscale = groupobj->GetSGNode()->GetRootSGParent()->GetLocalScale();
-
+		MT_Vector3 newscale = groupobj->NodeGetWorldScaling();
 		// set the replica's relative scale with the rootnode's scale
 		replica->NodeSetRelativeScale(newscale);
 
+		MT_Matrix3x3 newori = groupobj->NodeGetWorldOrientation() * gameobj->NodeGetWorldOrientation();
+		replica->NodeSetLocalOrientation(newori);
+
+		MT_Point3 newpos = groupobj->NodeGetWorldPosition() + 
+			newscale*(groupobj->NodeGetWorldOrientation() * gameobj->NodeGetWorldPosition());
+		replica->NodeSetLocalPosition(newpos);
+
 		if (replica->GetPhysicsController())
 		{
 			replica->GetPhysicsController()->setPosition(newpos);





More information about the Bf-blender-cvs mailing list