2011-02-23 10:52:22 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/*
  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								 *  $ Id $ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-16 22:40:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  * * * * *  BEGIN  GPL  LICENSE  BLOCK  * * * * * 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  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  2 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-16 22:40:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  of  the  License ,  or  ( at  your  option )  any  later  version . 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  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 ,  write  to  the  Free  Software  Foundation , 
							 
						 
					
						
							
								
									
										
										
										
											2010-02-12 13:34:04 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  Inc . ,  51  Franklin  Street ,  Fifth  Floor ,  Boston ,  MA  02110 - 1301 ,  USA . 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  The  Original  Code  is  Copyright  ( C )  2001 - 2002  by  NaN  Holding  BV . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  All  rights  reserved . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  The  Original  Code  is :  all  of  this  file . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Contributor ( s ) :  none  yet . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-16 22:40:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  * * * * *  END  GPL  LICENSE  BLOCK  * * * * * 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								 *  Game  object  wrapper 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-02-25 13:35:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/** \file gameengine/Ketsji/KX_GameObject.cpp
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *   \ ingroup  ketsji 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2005-11-28 06:51:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# if defined(_WIN64) 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								typedef  unsigned  __int64  uint_ptr ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# else 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								typedef  unsigned  long  uint_ptr ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-09-15 16:13:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# if defined(WIN32) && !defined(FREE_WINDOWS) 
  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// This warning tells us about truncation of __long__ stl-generated names.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// It can occasionally cause DevStudio to have internal compiler warnings.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# pragma warning( disable : 4786 )      
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# define KX_INERTIA_INFINITE 10000 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "RAS_IPolygonMaterial.h" 
  
						 
					
						
							
								
									
										
										
										
											2006-01-06 03:46:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "KX_BlenderMaterial.h" 
  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  "KX_GameObject.h" 
  
						 
					
						
							
								
									
										
										
										
											2009-05-24 23:43:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "KX_Camera.h"   // only for their ::Type
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "KX_Light.h"    // only for their ::Type
  
						 
					
						
							
								
									
										
											 
										
											
												Patch:[#25163] BGE support for Blender Font objects - unicode support
Problem/Bug:
------------
There were no way to have proper unicode characters (e.g. Japanese) in Blender Game Engine. Now we can :)
You can see a sample here: http://blog.mikepan.com/multi-language-support-in-blender/
Functionality Explanation:
--------------------------
This patch converts the Blender Font Objects to a new BGE type: KX_FontObject
This object inherits KX_GameObject.cpp and has the following properties:
- text (the text of the object)
- size (taken from the Blender object, usually is 1.0)
- resolution (1.0 by default, maybe not really needed, but at least for debugging/the time being it's nice to have) 
The way we deal with linked objects is different than Blender. In Blender the text and size are a property of the Text databock. Therefore linked objects necessarily share the same text (and size, although the size of the object datablock affects that too). In BGE they are stored and accessed per object. Without that it would be problematic to have addObject adding texts that don't share the same data.
Known problems/limitations/ToDo:
--------------------------------
1) support for packed font and the <builtin>
2) figure why some fonts are displayed in a different size in 3DView/BGE (BLF)
3) investigate some glitches I see some times
4) support for multiline
5) support for more Blender Font Object options (text aligment, text boxes, ...)
[1] Diego (bdiego) evantually will help on that. For the time being we are using the "default" (ui) font to replace the <builtin>.
[2] but not all of them. I need to cross check who is calculating the size/dpi in/correctly - Blender or BLF. (e.g. fonts that work well - MS Gothic)
[3] I think this may be related to the resolution we are drawing the font
[4] It can't/will not be handled inside BFL. So the way I see it is to implement a mini text library/api that works as a middlelayer between the drawing step and BLF. 
    So instead of:
      BLF_draw(fontid, (char *)text, strlen(text));
    We would do:
      MAGIC_ROUTINE_IM_NOT_BLF_draw(fontir, (char *)text, styleflag, width, height);
[5] don't hold your breath ... but if someone wants to have fun in the holidays the (4) and (5) are part of the same problem.
Code Explanation:
-----------------
The patch should be simple to read. They are three may parts:
1) BL_BlenderDataConversion.cpp:: converts the OB_FONT object into a KX_FontObject.cpp and store it in the KX_Scene->m_fonts
2) KetsjiEngine.cpp::RenderFonts:: loop through the texts and call their internal drawing routine.
3) KX_FontObject.cpp::
  a) constructor: load the font of the object, and store other values.
  b) DrawText: calculate the aspect for the given size (sounds hacky but this is how blf works) and call the render routine in RenderTools
4) KX_BlenderGL.cpp (called from rendertools) ::BL_print_game_line:: Draws the text. Using the BLF API
*) In order to handle visibility of the object added with AddObject I'm adding to the m_scene.m_fonts list only the Fonts in a visible layer - unlike Cameras and Lamps where all the objects are added.
Acknowledgements:
----------------
Thanks Benoit for the review and adjustment suggestions.
Thanks Diego for the BFL expertise, patches and support (Latin community ftw)
Thanks my boss for letting me do part of this patch during work time. Good thing we are starting a project in a partnership with a Japanese Foundation and eventual will need unicode in BGE :) for more details on that - www.nereusprogram.org - let's call it the main sponsor of this "bug feature" ;)
											 
										 
										
											2010-12-16 10:25:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "KX_FontObject.h"    // only for their ::Type
  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  "RAS_MeshObject.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "KX_MeshProxy.h" 
  
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "KX_PolyProxy.h" 
  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <stdio.h>   // printf
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "SG_Controller.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "KX_IPhysicsController.h" 
  
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "PHY_IGraphicController.h" 
  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  "SG_Node.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "SG_Controller.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "KX_ClientObjectInfo.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "RAS_BucketManager.h" 
  
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "KX_RayCast.h" 
  
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "KX_PythonInit.h" 
  
						 
					
						
							
								
									
										
										
										
											2004-05-26 12:06:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "KX_PyMath.h" 
  
						 
					
						
							
								
									
										
										
										
											2009-05-10 01:48:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "KX_PythonSeq.h" 
  
						 
					
						
							
								
									
										
										
										
											2009-07-25 22:57:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "KX_ConvertPhysicsObject.h" 
  
						 
					
						
							
								
									
										
										
										
											2008-07-19 07:45:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "SCA_IActuator.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "SCA_ISensor.h" 
  
						 
					
						
							
								
									
										
										
										
											2009-04-05 08:48:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "SCA_IController.h" 
  
						 
					
						
							
								
									
										
										
										
											2009-04-08 16:57:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "NG_NetworkScene.h"   //Needed for sendMessage()
  
						 
					
						
							
								
									
										
										
										
											2004-05-26 12:06:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "BL_ActionManager.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-06 14:13:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "PyObjectPlus.h"   /* python stuff */ 
  
						 
					
						
							
								
									
										
										
										
											2008-09-06 02:46:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								// This file defines relationships between parents and children
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// in the game engine.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  "KX_SG_NodeRelationships.h" 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-11-10 20:43:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  "BLI_math.h" 
  
						 
					
						
							
								
									
										
										
										
											2009-10-20 15:51:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-05 14:01:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  MT_Point3  dummy_point =  MT_Point3 ( 0.0 ,  0.0 ,  0.0 ) ;  
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  MT_Vector3  dummy_scaling  =  MT_Vector3 ( 1.0 ,  1.0 ,  1.0 ) ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  MT_Matrix3x3  dummy_orientation  =  MT_Matrix3x3 ( 	1.0 ,  0.0 ,  0.0 ,  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																						0.0 ,  1.0 ,  0.0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																						0.0 ,  0.0 ,  1.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-05 14:01:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								KX_GameObject : : KX_GameObject (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									void *  sgReplicationInfo , 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-28 11:22:26 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SG_Callbacks  callbacks ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									:  SCA_IObject ( ) , 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									m_bDyna ( false ) , 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-30 19:58:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_layer ( 0 ) , 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-29 15:48:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_pBlenderObject ( NULL ) , 
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_pBlenderGroupObject ( NULL ) , 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									m_bSuspendDynamics ( false ) , 
							 
						 
					
						
							
								
									
										
										
										
											2004-03-22 22:02:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_bUseObjectColor ( false ) , 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-25 14:37:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_bIsNegativeScaling ( false ) , 
							 
						 
					
						
							
								
									
										
										
										
											2004-03-22 22:02:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_bVisible ( true ) , 
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_bCulled ( true ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-13 20:08:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_bOccluder ( false ) , 
							 
						 
					
						
							
								
									
										
											 
										
											
												Patch: [ #2439 ] Makes objects react properly to deformations after a mesh replacement call.
from brian hayward (bthayward)
Detailed description:
 Currently, when an armature deformed object's mesh is replaced by the ReplaceMesh actuator, the new mesh fails to deform to the armature's movement.
 My patch fixes this by properly replacing the deform controller along with the mesh (when appropriete).
 For instance, if one had an animated character using any of the standard deformation techniques (armature, ipo, RVK, or AVK), that character's mesh would currently be prevented from changing mid-game. It could be replaced, but the new mesh would lack the controller which tells it how to deform. If one wanted to dynamiclly add a hat on top of the character's head, it would require storing a secondary prebuilt character (mesh, armature, logic, ect...) on another layer FOR EACH HAT the character could possibly wear, then swapping out the whole character when the hat change was desired. So if you had 4 possible hat/character combos, you would have 4 character meshes, 4 armatures, 4 sets of logic, and so on. I find this lack of flexibility to be unresonable.
 With my patch, one could accomplish the same thing mearly by making one version of the character in the main layer, and adding an invisible object atop the character's head (which is parented to the head bone). Then whenever it becomes desirable, one can replace the invisible object's mesh with the desirable hat's mesh, then make it visible. With my patch, the hat object would then continue to deform to the character's head regardless of which hat was currently being worn.
 *note 1*
 for armature/mesh deformations, the new mesh must have properly assigned vertex groups which match one or more of the bones of the target armature before the replaceMesh call is made. Otherwise the vertices won't react to the armature because they won't know how. (not sure if vertices can be scripted to change groups after the game has started)
 *note 2*
 The added processing time involved with replacing the object's deform controller is negligible.
											 
										 
										
											2005-04-18 11:44:21 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_pPhysicsController1 ( NULL ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_pGraphicController ( NULL ) , 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_xray ( false ) , 
							 
						 
					
						
							
								
									
										
											 
										
											
												Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====
Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.
* According to the GLEW website it works on Windows, Linux, Mac OS X,
  FreeBSD, Irix, and Solaris. There might still be platform specific
  issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
  regardless of the glext.h on the platform where compilation happens.
Game Engine
===========
Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.
The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.
For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.
* The game engine now also uses GLEW for extensions, replacing the
  custom opengl extensions code that was there. Removes a lot of
  #ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
  work around a specific bug and only disabled multitexturing anyway.
  It might also have caused a slowdown since it was retrieving the
  environment variable for every vertex in immediate mode (bug #13680).
* Refactored the code to allow drawing skinned meshes with vertex
  arrays too, removing some specific immediate mode drawing functions
  for this that only did extra normal calculation. Now it always splits
  vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
  required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
  attributes for vertex arrays. These were not being enabled/disabled
  correct according to the opengl spec, leading to crashes. Also tangent
  attributes used an immediate mode call for vertex arrays, which can't
  work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
  deform weights, now uses same trick as regular meshes.
											 
										 
										
											2008-06-17 10:27:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_pHitObject ( NULL ) , 
							 
						 
					
						
							
								
									
										
										
										
											2011-07-29 21:58:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_actionManager ( NULL ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_isDeformable ( false ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-10-31 04:11:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef WITH_PYTHON 
  
						 
					
						
							
								
									
										
										
										
											2009-09-29 21:42:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									,  m_attr_dict ( NULL ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_ignore_activity_culling  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-04-11 02:50:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_pClient_info  =  new  KX_ClientObjectInfo ( this ,  KX_ClientObjectInfo : : ACTOR ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									m_pSGNode  =  new  SG_Node ( this , sgReplicationInfo , callbacks ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// define the relationship between this node and it's parent.
 
							 
						 
					
						
							
								
									
										
										
										
											2004-05-26 12:06:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									KX_NormalParentRelation  *  parent_relation  =  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										KX_NormalParentRelation : : New ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_pSGNode - > SetParentRelation ( parent_relation ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								KX_GameObject : : ~ KX_GameObject ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									RemoveMeshes ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// is this delete somewhere ?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//if (m_sumoObj)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//	delete m_sumoObj;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									delete  m_pClient_info ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//if (m_pSGNode)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//	delete m_pSGNode;
 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-09 21:51:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_pSGNode ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// must go through controllers and make sure they will not use us anymore
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// This is important for KX_BulletPhysicsControllers that unregister themselves
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// from the object when they are deleted.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SGControllerList : : iterator  contit ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SGControllerList &  controllers  =  m_pSGNode - > GetSGControllerList ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  ( contit  =  controllers . begin ( ) ; contit ! = controllers . end ( ) ; + + contit ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											( * contit ) - > ClearObject ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_pSGNode - > SetSGClientObject ( NULL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-09-29 07:51:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										/* m_pSGNode is freed in KX_Scene::RemoveNodeDestructObject */ 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-09 21:51:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_pGraphicController ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										delete  m_pGraphicController ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_actionManager ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										delete  m_actionManager ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2010-10-31 04:11:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef WITH_PYTHON 
  
						 
					
						
							
								
									
										
										
										
											2009-04-17 20:06:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_attr_dict )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-04-20 02:56:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyDict_Clear ( m_attr_dict ) ;  /* incase of circular refs or other weird cases */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-27 04:01:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										/* Py_CLEAR: Py_DECREF's and NULL's */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Py_CLEAR ( m_attr_dict ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2010-10-31 04:11:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif  // WITH_PYTHON
  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-13 20:08:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								KX_GameObject *  KX_GameObject : : GetClientObject ( KX_ClientObjectInfo *  info )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! info ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  info - > m_gameobject ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								CValue *  KX_GameObject : : 	Calc ( VALUE_OPERATOR  op ,  CValue  * val )   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								CValue *  KX_GameObject : : CalcFinal ( VALUE_DATA_TYPE  dtype ,  VALUE_OPERATOR  op ,  CValue  * val )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  STR_String  &  KX_GameObject : : GetText ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  m_text ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 06:41:01 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								double  KX_GameObject : : GetNumber ( )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-05-10 20:53:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								STR_String &  KX_GameObject : : GetName ( )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  m_name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-05-10 20:53:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : SetName ( const  char  * name )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_name  =  name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ; 								// Set the name of the value
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								KX_IPhysicsController *  KX_GameObject : : GetPhysicsController ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  m_pPhysicsController1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								KX_GameObject *  KX_GameObject : : GetParent ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  result  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SG_Node *  node  =  m_pSGNode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									while  ( node  & &  ! result ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										node  =  node - > GetSGParent ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( node ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											result  =  ( KX_GameObject * ) node - > GetSGClientObject ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( result ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										result - > AddRef ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  result ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: user control to compound shape and setParent.
Compound shape control
======================
1) GUI control
It is now possible to control which child shape is added to 
a parent compound shape in the Physics buttons. The "Compound"
shape button becomes "Add to parent" on child objects and
determines whether the child shape is to be added to the top
parent compound shape when the game is stated.
Notes: * "Compound" is only available to top parent objects
         (objects without parent).
       * Nesting of compound shape is not possible: a child
         object with "Add to parent" button set will be added
         to the top parent compound shape, regardless of its
         position in the parent-child hierarchy and even if its
         immediate parent doesn't have the "Add to parent" button set.
2) runtime control
It is now possible to control the compound shape at runtime:
The SetParent actuator has a new "Compound" button that indicates
whether the object shape should be added to the compound shape
of the parent object, provided the parent has a compound shape
of course. If not, the object retain it's individual state
while parented.
Similarly, the KX_GameObject.setParent() python function has
a new compound parameter.
Notes: * When an object is dynamically added to a compound 
         shape, it looses temporarily all its physics capability
         to the benefit of the parent: it cannot register collisions
         and the characteristics of its shape are lost (ghost, sensor,
         dynamic, etc.). 
       * Nested compound shape is not supported: if the object
         being parented is already a compound shape, it is not
         added to the compound parent (as if the Compound option 
         was not set in the actuator or the setParent function).
       * To ensure compatibility with old blend files, the Blender
         subversion is changed to 2.48.5 and the old blend files
         are automatically converted to match the old behavior: 
         all children of a Compound object will have the "Add to
         parent" button set automatically.
Child ghost control
===================
It is now possible to control if an object should becomes ghost
or solid when parented. This is only applicable if the object
is not added to the parent compound shape (see above).
A new "Ghost" button is available on the SetParent actuator to 
that effect. Similarly the KX_GameObject.setParent() python function
has a new compound parameter.
Notes: * This option is not applicable to sensor objects: they stay
         ghost all the time.
       * Make sure the child object does not enter in collision with
         the parent shape when the Ghost option if off and the parent is
         dynamic: the collision creates a reaction force but the parent
         cannot escape the child, so the force builds up and produces
         eratic movements.
       * The collision capability of an ordinary object (dynamic or static)
         is limited when it is parented: it becomes automatically static
         and can only detect dynamic and sensor objects.
       * A sensor object retain its full collision capability when parented:
         it can detect static and dynamic object.
Python control
==============
KX_GameObject.setParent(parent,compound,ghost):
	Sets this object's parent. 
	Control the shape status with the optional compound and ghost parameters:
	compound=1: the object shape should be added to the parent compound shape (default)
	compound=0: the object should keep its individual shape. 
	In that case you can control if it should be ghost or not:
	ghost=1 if the object should be made ghost while parented (default)
	ghost=0 if the object should be solid while parented 
	Note: if the object type is sensor, it stays ghost regardless of ghost parameter
		
	parent: KX_GameObject reference or string (object name w/o OB prefix)
											 
										 
										
											2009-05-21 13:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : SetParent ( KX_Scene  * scene ,  KX_GameObject *  obj ,  bool  addToCompound ,  bool  ghost )  
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-10-16 23:33:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// check on valid node in case a python controller holds a reference to a deleted object
 
							 
						 
					
						
							
								
									
										
										
										
											2010-03-25 21:43:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( obj  & &  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GetSGNode ( )  & & 			// object is not zombi
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										obj - > GetSGNode ( )  & & 		// object is not zombi
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GetSGNode ( ) - > GetSGParent ( )  ! =  obj - > GetSGNode ( )  & & 	// not already parented to same object
 
							 
						 
					
						
							
								
									
										
										
										
											2010-03-31 22:49:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										! GetSGNode ( ) - > IsAncessor ( obj - > GetSGNode ( ) )  & &  		// no parenting loop
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										this  ! =  obj ) 										// not the object itself
 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Make sure the objects have some scale
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Vector3  scale1  =  NodeGetWorldScaling ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Vector3  scale2  =  obj - > NodeGetWorldScaling ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( fabs ( scale2 [ 0 ] )  <  FLT_EPSILON  | |  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											fabs ( scale2 [ 1 ] )  <  FLT_EPSILON  | |  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											fabs ( scale2 [ 2 ] )  <  FLT_EPSILON  | |  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											fabs ( scale1 [ 0 ] )  <  FLT_EPSILON  | |  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											fabs ( scale1 [ 1 ] )  <  FLT_EPSILON  | |  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											fabs ( scale1 [ 2 ] )  <  FLT_EPSILON )  {  return ;  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Remove us from our old parent and set our new parent
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										RemoveParent ( scene ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										obj - > GetSGNode ( ) - > AddChild ( GetSGNode ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-07-20 15:40:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( m_pPhysicsController1 )  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: user control to compound shape and setParent.
Compound shape control
======================
1) GUI control
It is now possible to control which child shape is added to 
a parent compound shape in the Physics buttons. The "Compound"
shape button becomes "Add to parent" on child objects and
determines whether the child shape is to be added to the top
parent compound shape when the game is stated.
Notes: * "Compound" is only available to top parent objects
         (objects without parent).
       * Nesting of compound shape is not possible: a child
         object with "Add to parent" button set will be added
         to the top parent compound shape, regardless of its
         position in the parent-child hierarchy and even if its
         immediate parent doesn't have the "Add to parent" button set.
2) runtime control
It is now possible to control the compound shape at runtime:
The SetParent actuator has a new "Compound" button that indicates
whether the object shape should be added to the compound shape
of the parent object, provided the parent has a compound shape
of course. If not, the object retain it's individual state
while parented.
Similarly, the KX_GameObject.setParent() python function has
a new compound parameter.
Notes: * When an object is dynamically added to a compound 
         shape, it looses temporarily all its physics capability
         to the benefit of the parent: it cannot register collisions
         and the characteristics of its shape are lost (ghost, sensor,
         dynamic, etc.). 
       * Nested compound shape is not supported: if the object
         being parented is already a compound shape, it is not
         added to the compound parent (as if the Compound option 
         was not set in the actuator or the setParent function).
       * To ensure compatibility with old blend files, the Blender
         subversion is changed to 2.48.5 and the old blend files
         are automatically converted to match the old behavior: 
         all children of a Compound object will have the "Add to
         parent" button set automatically.
Child ghost control
===================
It is now possible to control if an object should becomes ghost
or solid when parented. This is only applicable if the object
is not added to the parent compound shape (see above).
A new "Ghost" button is available on the SetParent actuator to 
that effect. Similarly the KX_GameObject.setParent() python function
has a new compound parameter.
Notes: * This option is not applicable to sensor objects: they stay
         ghost all the time.
       * Make sure the child object does not enter in collision with
         the parent shape when the Ghost option if off and the parent is
         dynamic: the collision creates a reaction force but the parent
         cannot escape the child, so the force builds up and produces
         eratic movements.
       * The collision capability of an ordinary object (dynamic or static)
         is limited when it is parented: it becomes automatically static
         and can only detect dynamic and sensor objects.
       * A sensor object retain its full collision capability when parented:
         it can detect static and dynamic object.
Python control
==============
KX_GameObject.setParent(parent,compound,ghost):
	Sets this object's parent. 
	Control the shape status with the optional compound and ghost parameters:
	compound=1: the object shape should be added to the parent compound shape (default)
	compound=0: the object should keep its individual shape. 
	In that case you can control if it should be ghost or not:
	ghost=1 if the object should be made ghost while parented (default)
	ghost=0 if the object should be solid while parented 
	Note: if the object type is sensor, it stays ghost regardless of ghost parameter
		
	parent: KX_GameObject reference or string (object name w/o OB prefix)
											 
										 
										
											2009-05-21 13:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											m_pPhysicsController1 - > SuspendDynamics ( ghost ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-20 15:40:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Set us to our new scale, position, and orientation
 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-09 22:40:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										scale2 [ 0 ]  =  1.0 / scale2 [ 0 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										scale2 [ 1 ]  =  1.0 / scale2 [ 1 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										scale2 [ 2 ]  =  1.0 / scale2 [ 2 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										scale1  =  scale1  *  scale2 ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										MT_Matrix3x3  invori  =  obj - > NodeGetWorldOrientation ( ) . inverse ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-09 22:40:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										MT_Vector3  newpos  =  invori * ( NodeGetWorldPosition ( ) - obj - > NodeGetWorldPosition ( ) ) * scale2 ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										NodeSetLocalScale ( scale1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										NodeSetLocalPosition ( MT_Point3 ( newpos [ 0 ] , newpos [ 1 ] , newpos [ 2 ] ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-02 17:22:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										NodeSetLocalOrientation ( invori * NodeGetWorldOrientation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										NodeUpdateGS ( 0.f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// object will now be a child, it must be removed from the parent list
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CListValue *  rootlist  =  scene - > GetRootParentList ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( rootlist - > RemoveValue ( this ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// the object was in parent list, decrement ref count as it's now removed
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Release ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-01-13 22:59:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// if the new parent is a compound object, add this object shape to the compound shape.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// step 0: verify this object has physical controller
 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: user control to compound shape and setParent.
Compound shape control
======================
1) GUI control
It is now possible to control which child shape is added to 
a parent compound shape in the Physics buttons. The "Compound"
shape button becomes "Add to parent" on child objects and
determines whether the child shape is to be added to the top
parent compound shape when the game is stated.
Notes: * "Compound" is only available to top parent objects
         (objects without parent).
       * Nesting of compound shape is not possible: a child
         object with "Add to parent" button set will be added
         to the top parent compound shape, regardless of its
         position in the parent-child hierarchy and even if its
         immediate parent doesn't have the "Add to parent" button set.
2) runtime control
It is now possible to control the compound shape at runtime:
The SetParent actuator has a new "Compound" button that indicates
whether the object shape should be added to the compound shape
of the parent object, provided the parent has a compound shape
of course. If not, the object retain it's individual state
while parented.
Similarly, the KX_GameObject.setParent() python function has
a new compound parameter.
Notes: * When an object is dynamically added to a compound 
         shape, it looses temporarily all its physics capability
         to the benefit of the parent: it cannot register collisions
         and the characteristics of its shape are lost (ghost, sensor,
         dynamic, etc.). 
       * Nested compound shape is not supported: if the object
         being parented is already a compound shape, it is not
         added to the compound parent (as if the Compound option 
         was not set in the actuator or the setParent function).
       * To ensure compatibility with old blend files, the Blender
         subversion is changed to 2.48.5 and the old blend files
         are automatically converted to match the old behavior: 
         all children of a Compound object will have the "Add to
         parent" button set automatically.
Child ghost control
===================
It is now possible to control if an object should becomes ghost
or solid when parented. This is only applicable if the object
is not added to the parent compound shape (see above).
A new "Ghost" button is available on the SetParent actuator to 
that effect. Similarly the KX_GameObject.setParent() python function
has a new compound parameter.
Notes: * This option is not applicable to sensor objects: they stay
         ghost all the time.
       * Make sure the child object does not enter in collision with
         the parent shape when the Ghost option if off and the parent is
         dynamic: the collision creates a reaction force but the parent
         cannot escape the child, so the force builds up and produces
         eratic movements.
       * The collision capability of an ordinary object (dynamic or static)
         is limited when it is parented: it becomes automatically static
         and can only detect dynamic and sensor objects.
       * A sensor object retain its full collision capability when parented:
         it can detect static and dynamic object.
Python control
==============
KX_GameObject.setParent(parent,compound,ghost):
	Sets this object's parent. 
	Control the shape status with the optional compound and ghost parameters:
	compound=1: the object shape should be added to the parent compound shape (default)
	compound=0: the object should keep its individual shape. 
	In that case you can control if it should be ghost or not:
	ghost=1 if the object should be made ghost while parented (default)
	ghost=0 if the object should be solid while parented 
	Note: if the object type is sensor, it stays ghost regardless of ghost parameter
		
	parent: KX_GameObject reference or string (object name w/o OB prefix)
											 
										 
										
											2009-05-21 13:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( m_pPhysicsController1  & &  addToCompound ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-01-13 22:59:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// step 1: find the top parent (not necessarily obj)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											KX_GameObject *  rootobj  =  ( KX_GameObject * ) obj - > GetSGNode ( ) - > GetRootSGParent ( ) - > GetSGClientObject ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// step 2: verify it has a physical controller and compound shape
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( rootobj  ! =  NULL  & &  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												rootobj - > m_pPhysicsController1  ! =  NULL  & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												rootobj - > m_pPhysicsController1 - > IsCompound ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												rootobj - > m_pPhysicsController1 - > AddCompoundChild ( m_pPhysicsController1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// graphically, the object hasn't change place, no need to update m_pGraphicController
 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : RemoveParent ( KX_Scene  * scene )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-10-16 23:33:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// check on valid node in case a python controller holds a reference to a deleted object
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( GetSGNode ( )  & &  GetSGNode ( ) - > GetSGParent ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2009-01-13 22:59:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// get the root object to remove us from compound object if needed
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										KX_GameObject *  rootobj  =  ( KX_GameObject * ) GetSGNode ( ) - > GetRootSGParent ( ) - > GetSGClientObject ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Set us to the right spot 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GetSGNode ( ) - > SetLocalScale ( GetSGNode ( ) - > GetWorldScaling ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GetSGNode ( ) - > SetLocalOrientation ( GetSGNode ( ) - > GetWorldOrientation ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GetSGNode ( ) - > SetLocalPosition ( GetSGNode ( ) - > GetWorldPosition ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Remove us from our parent
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GetSGNode ( ) - > DisconnectFromParent ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										NodeUpdateGS ( 0.f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// the object is now a root object, add it to the parentlist
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CListValue *  rootlist  =  scene - > GetRootParentList ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( ! rootlist - > SearchValue ( this ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// object was not in root list, add it now and increment ref count
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											rootlist - > Add ( AddRef ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-18 14:40:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( m_pPhysicsController1 )  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
										
										
											2009-01-13 22:59:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// in case this controller was added as a child shape to the parent
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( rootobj  ! =  NULL  & &  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												rootobj - > m_pPhysicsController1  ! =  NULL  & & 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												rootobj - > m_pPhysicsController1 - > IsCompound ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												rootobj - > m_pPhysicsController1 - > RemoveCompoundChild ( m_pPhysicsController1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-18 14:40:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											m_pPhysicsController1 - > RestoreDynamics ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-07-09 19:59:32 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( m_pPhysicsController1 - > IsDyna ( )  & &  ( rootobj  ! =  NULL  & &  rootobj - > m_pPhysicsController1 ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-21 19:38:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												// dynamic object should remember the velocity they had while being parented
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												MT_Point3  childPoint  =  GetSGNode ( ) - > GetWorldPosition ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												MT_Point3  rootPoint  =  rootobj - > GetSGNode ( ) - > GetWorldPosition ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												MT_Point3  relPoint ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												relPoint  =  ( childPoint - rootPoint ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												MT_Vector3  linVel  =  rootobj - > m_pPhysicsController1 - > GetVelocity ( relPoint ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												MT_Vector3  angVel  =  rootobj - > m_pPhysicsController1 - > GetAngularVelocity ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												m_pPhysicsController1 - > SetLinearVelocity ( linVel ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												m_pPhysicsController1 - > SetAngularVelocity ( angVel ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-18 14:40:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// graphically, the object hasn't change place, no need to update m_pGraphicController
 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-06-11 00:22:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								BL_ActionManager *  KX_GameObject : : GetActionManager ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// We only want to create an action manager if we need it
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! m_actionManager ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_actionManager  =  new  BL_ActionManager ( this ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  m_actionManager ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-06-29 01:53:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  KX_GameObject : : PlayAction ( const  char *  name ,  
						 
					
						
							
								
									
										
										
										
											2011-06-01 05:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																float  start , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																float  end , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																short  layer , 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-23 22:12:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																short  priority , 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-01 05:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																float  blendin , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																short  play_mode , 
							 
						 
					
						
							
								
									
										
										
										
											2011-07-03 01:59:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																float  layer_weight , 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-16 01:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																short  ipo_flags , 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-01 05:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
																float  playback_speed ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2011-07-03 01:59:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  GetActionManager ( ) - > PlayAction ( name ,  start ,  end ,  layer ,  priority ,  blendin ,  play_mode ,  layer_weight ,  ipo_flags ,  playback_speed ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-01 05:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : StopAction ( short  layer )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2011-06-11 00:22:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									GetActionManager ( ) - > StopAction ( layer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-01 05:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bool  KX_GameObject : : IsActionDone ( short  layer )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2011-06-11 00:22:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  GetActionManager ( ) - > IsActionDone ( layer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-01 05:46:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : UpdateActionManager ( float  curtime )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2011-06-11 00:22:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									GetActionManager ( ) - > Update ( curtime ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-06-01 07:42:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								float  KX_GameObject : : GetActionFrame ( short  layer )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2011-06-11 00:22:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  GetActionManager ( ) - > GetActionFrame ( layer ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-01 07:42:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : SetActionFrame ( short  layer ,  float  frame )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2011-06-11 00:22:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									GetActionManager ( ) - > SetActionFrame ( layer ,  frame ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-01 07:42:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-07-05 05:22:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bAction  * KX_GameObject : : GetCurrentAction ( short  layer )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  GetActionManager ( ) - > GetCurrentAction ( layer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-22 12:16:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : ProcessReplica ( )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-22 14:42:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SCA_IObject : : ProcessReplica ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-04-22 12:16:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_pPhysicsController1  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_pGraphicController  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_pSGNode  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_pClient_info  =  new  KX_ClientObjectInfo ( * m_pClient_info ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_pClient_info - > m_gameobject  =  this ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-11 00:22:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_actionManager ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_actionManager  =  new  BL_ActionManager ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-22 12:16:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_state  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-09-29 21:42:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-10-31 04:11:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef WITH_PYTHON 
  
						 
					
						
							
								
									
										
										
										
											2009-04-17 20:06:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( m_attr_dict ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-22 12:16:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										m_attr_dict =  PyDict_Copy ( m_attr_dict ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-09-29 21:42:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: new sensor object to generalize Near and Radar sensor, static-static collision capbility.
A new type of "Sensor" physics object is available in the GE for advanced
collision management. It's called Sensor for its similarities with the
physics objects that underlie the Near and Radar sensors.
Like the Near and Radar object it is:
- static and ghost
- invisible by default
- always active to ensure correct collision detection
- capable of detecting both static and dynamic objects
- ignoring collision with their parent
- capable of broadphase filtering based on:
  * Actor option: the collisioning object must have the Actor flag set to be detected
  * property/material: as specified in the collision sensors attached to it
  Broadphase filtering is important for performance reason: the collision points
  will be computed only for the objects that pass the broahphase filter.
- automatically removed from the simulation when no collision sensor is active on it
Unlike the Near and Radar object it can:
- take any shape, including triangle mesh
- be made visible for debugging (just use the Visible actuator)
- have multiple collision sensors using it
Other than that, the sensor objects are ordinary objects. You can move them
freely or parent them. When parented to a dynamic object, they can provide
advanced collision control to this object.
The type of collision capability depends on the shape:
- box, sphere, cylinder, cone, convex hull provide volume detection.
- triangle mesh provides surface detection but you can give some volume
  to the suface by increasing the margin in the Advanced Settings panel.
  The margin applies on both sides of the surface.
Performance tip:
- Sensor objects perform better than Near and Radar: they do less synchronizations
  because of the Scenegraph optimizations and they can have multiple collision sensors
  on them (with different property filtering for example).
- Always prefer simple shape (box, sphere) to complex shape whenever possible.
- Always use broadphase filtering (avoid collision sensor with empty propery/material)
- Use collision sensor only when you need them. When no collision sensor is active
  on the sensor object, it is removed from the simulation and consume no CPU.
Known limitations:
- When running Blender in debug mode, you will see one warning line of the console:
  "warning btCollisionDispatcher::needsCollision: static-static collision!"
  In release mode this message is not printed.
- Collision margin has no effect on sphere, cone and cylinder shape.
Other performance improvements:
- Remove unnecessary interpolation for Near and Radar objects and by extension
  sensor objects.
- Use direct matrix copy instead of quaternion to synchronize orientation.
Other bug fix:
- Fix Near/Radar position error on newly activated objects. This was causing
  several detection problems in YoFrankie
- Fix margin not passed correctly to gImpact shape.
- Disable force/velocity actions on static objects 
											 
										 
										
											2009-05-17 12:51:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  void  setGraphicController_recursive ( SG_Node *  node )  
						 
					
						
							
								
									
										
										
										
											2009-05-01 19:02:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NodeList &  children  =  node - > GetSGChildren ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( NodeList : : iterator  childit  =  children . begin ( ) ; ! ( childit = = children . end ( ) ) ; + + childit ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SG_Node *  childnode  =  ( * childit ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										KX_GameObject  * clientgameobj  =  static_cast < KX_GameObject * > (  ( * childit ) - > GetSGClientObject ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( clientgameobj  ! =  NULL )  // This is a GameObject
 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: new sensor object to generalize Near and Radar sensor, static-static collision capbility.
A new type of "Sensor" physics object is available in the GE for advanced
collision management. It's called Sensor for its similarities with the
physics objects that underlie the Near and Radar sensors.
Like the Near and Radar object it is:
- static and ghost
- invisible by default
- always active to ensure correct collision detection
- capable of detecting both static and dynamic objects
- ignoring collision with their parent
- capable of broadphase filtering based on:
  * Actor option: the collisioning object must have the Actor flag set to be detected
  * property/material: as specified in the collision sensors attached to it
  Broadphase filtering is important for performance reason: the collision points
  will be computed only for the objects that pass the broahphase filter.
- automatically removed from the simulation when no collision sensor is active on it
Unlike the Near and Radar object it can:
- take any shape, including triangle mesh
- be made visible for debugging (just use the Visible actuator)
- have multiple collision sensors using it
Other than that, the sensor objects are ordinary objects. You can move them
freely or parent them. When parented to a dynamic object, they can provide
advanced collision control to this object.
The type of collision capability depends on the shape:
- box, sphere, cylinder, cone, convex hull provide volume detection.
- triangle mesh provides surface detection but you can give some volume
  to the suface by increasing the margin in the Advanced Settings panel.
  The margin applies on both sides of the surface.
Performance tip:
- Sensor objects perform better than Near and Radar: they do less synchronizations
  because of the Scenegraph optimizations and they can have multiple collision sensors
  on them (with different property filtering for example).
- Always prefer simple shape (box, sphere) to complex shape whenever possible.
- Always use broadphase filtering (avoid collision sensor with empty propery/material)
- Use collision sensor only when you need them. When no collision sensor is active
  on the sensor object, it is removed from the simulation and consume no CPU.
Known limitations:
- When running Blender in debug mode, you will see one warning line of the console:
  "warning btCollisionDispatcher::needsCollision: static-static collision!"
  In release mode this message is not printed.
- Collision margin has no effect on sphere, cone and cylinder shape.
Other performance improvements:
- Remove unnecessary interpolation for Near and Radar objects and by extension
  sensor objects.
- Use direct matrix copy instead of quaternion to synchronize orientation.
Other bug fix:
- Fix Near/Radar position error on newly activated objects. This was causing
  several detection problems in YoFrankie
- Fix margin not passed correctly to gImpact shape.
- Disable force/velocity actions on static objects 
											 
										 
										
											2009-05-17 12:51:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											clientgameobj - > ActivateGraphicController ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-01 19:02:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// if the childobj is NULL then this may be an inverse parent link
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// so a non recursive search should still look down this node.
 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: new sensor object to generalize Near and Radar sensor, static-static collision capbility.
A new type of "Sensor" physics object is available in the GE for advanced
collision management. It's called Sensor for its similarities with the
physics objects that underlie the Near and Radar sensors.
Like the Near and Radar object it is:
- static and ghost
- invisible by default
- always active to ensure correct collision detection
- capable of detecting both static and dynamic objects
- ignoring collision with their parent
- capable of broadphase filtering based on:
  * Actor option: the collisioning object must have the Actor flag set to be detected
  * property/material: as specified in the collision sensors attached to it
  Broadphase filtering is important for performance reason: the collision points
  will be computed only for the objects that pass the broahphase filter.
- automatically removed from the simulation when no collision sensor is active on it
Unlike the Near and Radar object it can:
- take any shape, including triangle mesh
- be made visible for debugging (just use the Visible actuator)
- have multiple collision sensors using it
Other than that, the sensor objects are ordinary objects. You can move them
freely or parent them. When parented to a dynamic object, they can provide
advanced collision control to this object.
The type of collision capability depends on the shape:
- box, sphere, cylinder, cone, convex hull provide volume detection.
- triangle mesh provides surface detection but you can give some volume
  to the suface by increasing the margin in the Advanced Settings panel.
  The margin applies on both sides of the surface.
Performance tip:
- Sensor objects perform better than Near and Radar: they do less synchronizations
  because of the Scenegraph optimizations and they can have multiple collision sensors
  on them (with different property filtering for example).
- Always prefer simple shape (box, sphere) to complex shape whenever possible.
- Always use broadphase filtering (avoid collision sensor with empty propery/material)
- Use collision sensor only when you need them. When no collision sensor is active
  on the sensor object, it is removed from the simulation and consume no CPU.
Known limitations:
- When running Blender in debug mode, you will see one warning line of the console:
  "warning btCollisionDispatcher::needsCollision: static-static collision!"
  In release mode this message is not printed.
- Collision margin has no effect on sphere, cone and cylinder shape.
Other performance improvements:
- Remove unnecessary interpolation for Near and Radar objects and by extension
  sensor objects.
- Use direct matrix copy instead of quaternion to synchronize orientation.
Other bug fix:
- Fix Near/Radar position error on newly activated objects. This was causing
  several detection problems in YoFrankie
- Fix margin not passed correctly to gImpact shape.
- Disable force/velocity actions on static objects 
											 
										 
										
											2009-05-17 12:51:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										setGraphicController_recursive ( childnode ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-01 19:02:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: new sensor object to generalize Near and Radar sensor, static-static collision capbility.
A new type of "Sensor" physics object is available in the GE for advanced
collision management. It's called Sensor for its similarities with the
physics objects that underlie the Near and Radar sensors.
Like the Near and Radar object it is:
- static and ghost
- invisible by default
- always active to ensure correct collision detection
- capable of detecting both static and dynamic objects
- ignoring collision with their parent
- capable of broadphase filtering based on:
  * Actor option: the collisioning object must have the Actor flag set to be detected
  * property/material: as specified in the collision sensors attached to it
  Broadphase filtering is important for performance reason: the collision points
  will be computed only for the objects that pass the broahphase filter.
- automatically removed from the simulation when no collision sensor is active on it
Unlike the Near and Radar object it can:
- take any shape, including triangle mesh
- be made visible for debugging (just use the Visible actuator)
- have multiple collision sensors using it
Other than that, the sensor objects are ordinary objects. You can move them
freely or parent them. When parented to a dynamic object, they can provide
advanced collision control to this object.
The type of collision capability depends on the shape:
- box, sphere, cylinder, cone, convex hull provide volume detection.
- triangle mesh provides surface detection but you can give some volume
  to the suface by increasing the margin in the Advanced Settings panel.
  The margin applies on both sides of the surface.
Performance tip:
- Sensor objects perform better than Near and Radar: they do less synchronizations
  because of the Scenegraph optimizations and they can have multiple collision sensors
  on them (with different property filtering for example).
- Always prefer simple shape (box, sphere) to complex shape whenever possible.
- Always use broadphase filtering (avoid collision sensor with empty propery/material)
- Use collision sensor only when you need them. When no collision sensor is active
  on the sensor object, it is removed from the simulation and consume no CPU.
Known limitations:
- When running Blender in debug mode, you will see one warning line of the console:
  "warning btCollisionDispatcher::needsCollision: static-static collision!"
  In release mode this message is not printed.
- Collision margin has no effect on sphere, cone and cylinder shape.
Other performance improvements:
- Remove unnecessary interpolation for Near and Radar objects and by extension
  sensor objects.
- Use direct matrix copy instead of quaternion to synchronize orientation.
Other bug fix:
- Fix Near/Radar position error on newly activated objects. This was causing
  several detection problems in YoFrankie
- Fix margin not passed correctly to gImpact shape.
- Disable force/velocity actions on static objects 
											 
										 
										
											2009-05-17 12:51:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : ActivateGraphicController ( bool  recurse )  
						 
					
						
							
								
									
										
										
										
											2009-05-01 19:02:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pGraphicController ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: new sensor object to generalize Near and Radar sensor, static-static collision capbility.
A new type of "Sensor" physics object is available in the GE for advanced
collision management. It's called Sensor for its similarities with the
physics objects that underlie the Near and Radar sensors.
Like the Near and Radar object it is:
- static and ghost
- invisible by default
- always active to ensure correct collision detection
- capable of detecting both static and dynamic objects
- ignoring collision with their parent
- capable of broadphase filtering based on:
  * Actor option: the collisioning object must have the Actor flag set to be detected
  * property/material: as specified in the collision sensors attached to it
  Broadphase filtering is important for performance reason: the collision points
  will be computed only for the objects that pass the broahphase filter.
- automatically removed from the simulation when no collision sensor is active on it
Unlike the Near and Radar object it can:
- take any shape, including triangle mesh
- be made visible for debugging (just use the Visible actuator)
- have multiple collision sensors using it
Other than that, the sensor objects are ordinary objects. You can move them
freely or parent them. When parented to a dynamic object, they can provide
advanced collision control to this object.
The type of collision capability depends on the shape:
- box, sphere, cylinder, cone, convex hull provide volume detection.
- triangle mesh provides surface detection but you can give some volume
  to the suface by increasing the margin in the Advanced Settings panel.
  The margin applies on both sides of the surface.
Performance tip:
- Sensor objects perform better than Near and Radar: they do less synchronizations
  because of the Scenegraph optimizations and they can have multiple collision sensors
  on them (with different property filtering for example).
- Always prefer simple shape (box, sphere) to complex shape whenever possible.
- Always use broadphase filtering (avoid collision sensor with empty propery/material)
- Use collision sensor only when you need them. When no collision sensor is active
  on the sensor object, it is removed from the simulation and consume no CPU.
Known limitations:
- When running Blender in debug mode, you will see one warning line of the console:
  "warning btCollisionDispatcher::needsCollision: static-static collision!"
  In release mode this message is not printed.
- Collision margin has no effect on sphere, cone and cylinder shape.
Other performance improvements:
- Remove unnecessary interpolation for Near and Radar objects and by extension
  sensor objects.
- Use direct matrix copy instead of quaternion to synchronize orientation.
Other bug fix:
- Fix Near/Radar position error on newly activated objects. This was causing
  several detection problems in YoFrankie
- Fix margin not passed correctly to gImpact shape.
- Disable force/velocity actions on static objects 
											 
										 
										
											2009-05-17 12:51:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										m_pGraphicController - > Activate ( m_bVisible ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-01 19:02:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( recurse ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: new sensor object to generalize Near and Radar sensor, static-static collision capbility.
A new type of "Sensor" physics object is available in the GE for advanced
collision management. It's called Sensor for its similarities with the
physics objects that underlie the Near and Radar sensors.
Like the Near and Radar object it is:
- static and ghost
- invisible by default
- always active to ensure correct collision detection
- capable of detecting both static and dynamic objects
- ignoring collision with their parent
- capable of broadphase filtering based on:
  * Actor option: the collisioning object must have the Actor flag set to be detected
  * property/material: as specified in the collision sensors attached to it
  Broadphase filtering is important for performance reason: the collision points
  will be computed only for the objects that pass the broahphase filter.
- automatically removed from the simulation when no collision sensor is active on it
Unlike the Near and Radar object it can:
- take any shape, including triangle mesh
- be made visible for debugging (just use the Visible actuator)
- have multiple collision sensors using it
Other than that, the sensor objects are ordinary objects. You can move them
freely or parent them. When parented to a dynamic object, they can provide
advanced collision control to this object.
The type of collision capability depends on the shape:
- box, sphere, cylinder, cone, convex hull provide volume detection.
- triangle mesh provides surface detection but you can give some volume
  to the suface by increasing the margin in the Advanced Settings panel.
  The margin applies on both sides of the surface.
Performance tip:
- Sensor objects perform better than Near and Radar: they do less synchronizations
  because of the Scenegraph optimizations and they can have multiple collision sensors
  on them (with different property filtering for example).
- Always prefer simple shape (box, sphere) to complex shape whenever possible.
- Always use broadphase filtering (avoid collision sensor with empty propery/material)
- Use collision sensor only when you need them. When no collision sensor is active
  on the sensor object, it is removed from the simulation and consume no CPU.
Known limitations:
- When running Blender in debug mode, you will see one warning line of the console:
  "warning btCollisionDispatcher::needsCollision: static-static collision!"
  In release mode this message is not printed.
- Collision margin has no effect on sphere, cone and cylinder shape.
Other performance improvements:
- Remove unnecessary interpolation for Near and Radar objects and by extension
  sensor objects.
- Use direct matrix copy instead of quaternion to synchronize orientation.
Other bug fix:
- Fix Near/Radar position error on newly activated objects. This was causing
  several detection problems in YoFrankie
- Fix margin not passed correctly to gImpact shape.
- Disable force/velocity actions on static objects 
											 
										 
										
											2009-05-17 12:51:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										setGraphicController_recursive ( GetSGNode ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-01 19:02:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								CValue *  KX_GameObject : : GetReplica ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  replica  =  new  KX_GameObject ( * this ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									// this will copy properties and so on...
 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-22 12:16:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									replica - > ProcessReplica ( ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  replica ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : ApplyForce ( const  MT_Vector3 &  force , bool  local )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_pPhysicsController1 - > ApplyForce ( force , local ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : ApplyTorque ( const  MT_Vector3 &  torque , bool  local )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_pPhysicsController1 - > ApplyTorque ( torque , local ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : ApplyMovement ( const  MT_Vector3 &  dloc , bool  local )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( GetSGNode ( ) )  
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( m_pPhysicsController1 )  // (IsDynamic())
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											m_pPhysicsController1 - > RelativeTranslate ( dloc , local ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GetSGNode ( ) - > RelativeTranslate ( dloc , GetSGNode ( ) - > GetSGParent ( ) , local ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : ApplyRotation ( const  MT_Vector3 &  drot , bool  local )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Matrix3x3  rotmat ( drot ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( GetSGNode ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GetSGNode ( ) - > RelativeRotate ( rotmat , local ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-11 21:19:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( m_pPhysicsController1 )  {  // (IsDynamic())
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											m_pPhysicsController1 - > RelativeRotate ( rotmat , local ) ;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-11 21:19:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/**
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								GetOpenGL  Matrix ,  returns  an  OpenGL  ' compatible '  matrix  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								*/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								double * 	KX_GameObject : : GetOpenGLMatrix ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// todo: optimize and only update if necessary
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									double *  fl  =  m_OpenGL_4x4Matrix . getPointer ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( GetSGNode ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Transform  trans ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										trans . setOrigin ( GetSGNode ( ) - > GetWorldPosition ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										trans . setBasis ( GetSGNode ( ) - > GetWorldOrientation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										MT_Vector3  scaling  =  GetSGNode ( ) - > GetWorldScaling ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_bIsNegativeScaling  =  ( ( scaling [ 0 ]  <  0.0 )  ^  ( scaling [ 1 ]  <  0.0 )  ^  ( scaling [ 2 ]  <  0.0 ) )  ?  true  :  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										trans . scale ( scaling [ 0 ] ,  scaling [ 1 ] ,  scaling [ 2 ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										trans . getValue ( fl ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE performance, 3rd round: culling and rasterizer.
This commit extend the technique of dynamic linked list to the mesh
slots so as to eliminate dumb scan or map lookup. It provides massive 
performance improvement in the culling and in the rasterizer when 
the majority of objects are static.
Other improvements:
- Compute the opengl matrix only for objects that are visible.
- Simplify hash function for GEN_HasedPtr
- Scan light list instead of general object list to render shadows
- Remove redundant opengl calls to set specularity, shinyness and diffuse
  between each mesh slots.
- Cache GPU material to avoid frequent call to GPU_material_from_blender
- Only set once the fixed elements of mesh slot
- Use more inline function
The following table shows the performance increase between 2.48, 1st round
and this round of improvement. The test was done with a scene containing 
40000 objects, of which 1000 are in the view frustrum approximately. The
object are simple textured cube to make sure the GPU is not the bottleneck.
As some of the rasterizer processing time has moved under culling, I present
the sum of scenegraph(includes culling)+rasterizer time
Scenegraph+rasterizer(ms)       2.48      1st round       3rd round
All objects static,            323.0           86.0             7.2
all visible, 1000 in 
the view frustrum
All objects static,            219.0           49.7             N/A(*)
all invisible.
All objects moving,            323.0          105.6            34.7
all visible, 1000 in 
the view frustrum
Scene destruction              40min          40min              4s
(*) : this time is not representative because the frame rate was at 60fps.
      In that case, the GPU holds down the GE by frame sync. By design, the
      overhead of the rasterizer is 0 when the the objects are invisible. 
This table shows a global speed up between 9x and 45x compared to 2.48a
for scenegraph, culling and rasterizer overhead. The speed up goes much
higher when objects are invisible.
An additional 2-4x speed up is possible in the scenegraph by upgrading
the Moto library to use Eigen2 BLAS library instead of C++ classes but
the scenegraph is already so fast that it is not a priority right now.
Next speed up in logic: many things to do there...
											 
										 
										
											2009-05-07 09:13:01 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										GetSGNode ( ) - > ClearDirty ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  fl ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-09-24 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : UpdateBlenderObjectMatrix ( Object *  blendobj )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! blendobj ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										blendobj  =  m_pBlenderObject ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( blendobj )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  MT_Matrix3x3 &  rot  =  NodeGetWorldOrientation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  MT_Vector3 &  scale  =  NodeGetWorldScaling ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										const  MT_Vector3 &  pos  =  NodeGetWorldPosition ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										rot . getValue ( blendobj - > obmat [ 0 ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										pos . getValue ( blendobj - > obmat [ 3 ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-11-10 20:43:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										mul_v3_fl ( blendobj - > obmat [ 0 ] ,  scale [ 0 ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										mul_v3_fl ( blendobj - > obmat [ 1 ] ,  scale [ 1 ] ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										mul_v3_fl ( blendobj - > obmat [ 2 ] ,  scale [ 2 ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-09-24 21:22:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : AddMeshUser ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( size_t  i = 0 ; i < m_meshes . size ( ) ; i + + ) 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE performance, 3rd round: culling and rasterizer.
This commit extend the technique of dynamic linked list to the mesh
slots so as to eliminate dumb scan or map lookup. It provides massive 
performance improvement in the culling and in the rasterizer when 
the majority of objects are static.
Other improvements:
- Compute the opengl matrix only for objects that are visible.
- Simplify hash function for GEN_HasedPtr
- Scan light list instead of general object list to render shadows
- Remove redundant opengl calls to set specularity, shinyness and diffuse
  between each mesh slots.
- Cache GPU material to avoid frequent call to GPU_material_from_blender
- Only set once the fixed elements of mesh slot
- Use more inline function
The following table shows the performance increase between 2.48, 1st round
and this round of improvement. The test was done with a scene containing 
40000 objects, of which 1000 are in the view frustrum approximately. The
object are simple textured cube to make sure the GPU is not the bottleneck.
As some of the rasterizer processing time has moved under culling, I present
the sum of scenegraph(includes culling)+rasterizer time
Scenegraph+rasterizer(ms)       2.48      1st round       3rd round
All objects static,            323.0           86.0             7.2
all visible, 1000 in 
the view frustrum
All objects static,            219.0           49.7             N/A(*)
all invisible.
All objects moving,            323.0          105.6            34.7
all visible, 1000 in 
the view frustrum
Scene destruction              40min          40min              4s
(*) : this time is not representative because the frame rate was at 60fps.
      In that case, the GPU holds down the GE by frame sync. By design, the
      overhead of the rasterizer is 0 when the the objects are invisible. 
This table shows a global speed up between 9x and 45x compared to 2.48a
for scenegraph, culling and rasterizer overhead. The speed up goes much
higher when objects are invisible.
An additional 2-4x speed up is possible in the scenegraph by upgrading
the Moto library to use Eigen2 BLAS library instead of C++ classes but
the scenegraph is already so fast that it is not a priority right now.
Next speed up in logic: many things to do there...
											 
										 
										
											2009-05-07 09:13:01 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-29 13:37:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										m_meshes [ i ] - > AddMeshUser ( this ,  & m_meshSlots ,  GetDeformer ( ) ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE performance, 3rd round: culling and rasterizer.
This commit extend the technique of dynamic linked list to the mesh
slots so as to eliminate dumb scan or map lookup. It provides massive 
performance improvement in the culling and in the rasterizer when 
the majority of objects are static.
Other improvements:
- Compute the opengl matrix only for objects that are visible.
- Simplify hash function for GEN_HasedPtr
- Scan light list instead of general object list to render shadows
- Remove redundant opengl calls to set specularity, shinyness and diffuse
  between each mesh slots.
- Cache GPU material to avoid frequent call to GPU_material_from_blender
- Only set once the fixed elements of mesh slot
- Use more inline function
The following table shows the performance increase between 2.48, 1st round
and this round of improvement. The test was done with a scene containing 
40000 objects, of which 1000 are in the view frustrum approximately. The
object are simple textured cube to make sure the GPU is not the bottleneck.
As some of the rasterizer processing time has moved under culling, I present
the sum of scenegraph(includes culling)+rasterizer time
Scenegraph+rasterizer(ms)       2.48      1st round       3rd round
All objects static,            323.0           86.0             7.2
all visible, 1000 in 
the view frustrum
All objects static,            219.0           49.7             N/A(*)
all invisible.
All objects moving,            323.0          105.6            34.7
all visible, 1000 in 
the view frustrum
Scene destruction              40min          40min              4s
(*) : this time is not representative because the frame rate was at 60fps.
      In that case, the GPU holds down the GE by frame sync. By design, the
      overhead of the rasterizer is 0 when the the objects are invisible. 
This table shows a global speed up between 9x and 45x compared to 2.48a
for scenegraph, culling and rasterizer overhead. The speed up goes much
higher when objects are invisible.
An additional 2-4x speed up is possible in the scenegraph by upgrading
the Moto library to use Eigen2 BLAS library instead of C++ classes but
the scenegraph is already so fast that it is not a priority right now.
Next speed up in logic: many things to do there...
											 
										 
										
											2009-05-07 09:13:01 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// set the part of the mesh slot that never change
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									double *  fl  =  GetOpenGLMatrixPtr ( ) - > getPointer ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SG_QList : : iterator < RAS_MeshSlot >  mit ( m_meshSlots ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-08-19 10:26:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								//	RAS_MeshSlot* ms;
  
						 
					
						
							
								
									
										
											 
										
											
												BGE performance, 3rd round: culling and rasterizer.
This commit extend the technique of dynamic linked list to the mesh
slots so as to eliminate dumb scan or map lookup. It provides massive 
performance improvement in the culling and in the rasterizer when 
the majority of objects are static.
Other improvements:
- Compute the opengl matrix only for objects that are visible.
- Simplify hash function for GEN_HasedPtr
- Scan light list instead of general object list to render shadows
- Remove redundant opengl calls to set specularity, shinyness and diffuse
  between each mesh slots.
- Cache GPU material to avoid frequent call to GPU_material_from_blender
- Only set once the fixed elements of mesh slot
- Use more inline function
The following table shows the performance increase between 2.48, 1st round
and this round of improvement. The test was done with a scene containing 
40000 objects, of which 1000 are in the view frustrum approximately. The
object are simple textured cube to make sure the GPU is not the bottleneck.
As some of the rasterizer processing time has moved under culling, I present
the sum of scenegraph(includes culling)+rasterizer time
Scenegraph+rasterizer(ms)       2.48      1st round       3rd round
All objects static,            323.0           86.0             7.2
all visible, 1000 in 
the view frustrum
All objects static,            219.0           49.7             N/A(*)
all invisible.
All objects moving,            323.0          105.6            34.7
all visible, 1000 in 
the view frustrum
Scene destruction              40min          40min              4s
(*) : this time is not representative because the frame rate was at 60fps.
      In that case, the GPU holds down the GE by frame sync. By design, the
      overhead of the rasterizer is 0 when the the objects are invisible. 
This table shows a global speed up between 9x and 45x compared to 2.48a
for scenegraph, culling and rasterizer overhead. The speed up goes much
higher when objects are invisible.
An additional 2-4x speed up is possible in the scenegraph by upgrading
the Moto library to use Eigen2 BLAS library instead of C++ classes but
the scenegraph is already so fast that it is not a priority right now.
Next speed up in logic: many things to do there...
											 
										 
										
											2009-05-07 09:13:01 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for ( mit . begin ( ) ;  ! mit . end ( ) ;  + + mit ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										( * mit ) - > m_OpenGLMatrix  =  fl ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-05 16:22:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									UpdateBuckets ( false ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-05 16:22:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  void  UpdateBuckets_recursive ( SG_Node *  node )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NodeList &  children  =  node - > GetSGChildren ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( NodeList : : iterator  childit  =  children . begin ( ) ; ! ( childit = = children . end ( ) ) ; + + childit ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SG_Node *  childnode  =  ( * childit ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										KX_GameObject  * clientgameobj  =  static_cast < KX_GameObject * > (  ( * childit ) - > GetSGClientObject ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( clientgameobj  ! =  NULL )  // This is a GameObject
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											clientgameobj - > UpdateBuckets ( 0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// if the childobj is NULL then this may be an inverse parent link
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// so a non recursive search should still look down this node.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										UpdateBuckets_recursive ( childnode ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : UpdateBuckets (  bool  recursive  )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( GetSGNode ( ) )  { 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE performance, 3rd round: culling and rasterizer.
This commit extend the technique of dynamic linked list to the mesh
slots so as to eliminate dumb scan or map lookup. It provides massive 
performance improvement in the culling and in the rasterizer when 
the majority of objects are static.
Other improvements:
- Compute the opengl matrix only for objects that are visible.
- Simplify hash function for GEN_HasedPtr
- Scan light list instead of general object list to render shadows
- Remove redundant opengl calls to set specularity, shinyness and diffuse
  between each mesh slots.
- Cache GPU material to avoid frequent call to GPU_material_from_blender
- Only set once the fixed elements of mesh slot
- Use more inline function
The following table shows the performance increase between 2.48, 1st round
and this round of improvement. The test was done with a scene containing 
40000 objects, of which 1000 are in the view frustrum approximately. The
object are simple textured cube to make sure the GPU is not the bottleneck.
As some of the rasterizer processing time has moved under culling, I present
the sum of scenegraph(includes culling)+rasterizer time
Scenegraph+rasterizer(ms)       2.48      1st round       3rd round
All objects static,            323.0           86.0             7.2
all visible, 1000 in 
the view frustrum
All objects static,            219.0           49.7             N/A(*)
all invisible.
All objects moving,            323.0          105.6            34.7
all visible, 1000 in 
the view frustrum
Scene destruction              40min          40min              4s
(*) : this time is not representative because the frame rate was at 60fps.
      In that case, the GPU holds down the GE by frame sync. By design, the
      overhead of the rasterizer is 0 when the the objects are invisible. 
This table shows a global speed up between 9x and 45x compared to 2.48a
for scenegraph, culling and rasterizer overhead. The speed up goes much
higher when objects are invisible.
An additional 2-4x speed up is possible in the scenegraph by upgrading
the Moto library to use Eigen2 BLAS library instead of C++ classes but
the scenegraph is already so fast that it is not a priority right now.
Next speed up in logic: many things to do there...
											 
										 
										
											2009-05-07 09:13:01 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										RAS_MeshSlot  * ms ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( GetSGNode ( ) - > IsDirty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											GetOpenGLMatrix ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-10 20:53:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE performance, 3rd round: culling and rasterizer.
This commit extend the technique of dynamic linked list to the mesh
slots so as to eliminate dumb scan or map lookup. It provides massive 
performance improvement in the culling and in the rasterizer when 
the majority of objects are static.
Other improvements:
- Compute the opengl matrix only for objects that are visible.
- Simplify hash function for GEN_HasedPtr
- Scan light list instead of general object list to render shadows
- Remove redundant opengl calls to set specularity, shinyness and diffuse
  between each mesh slots.
- Cache GPU material to avoid frequent call to GPU_material_from_blender
- Only set once the fixed elements of mesh slot
- Use more inline function
The following table shows the performance increase between 2.48, 1st round
and this round of improvement. The test was done with a scene containing 
40000 objects, of which 1000 are in the view frustrum approximately. The
object are simple textured cube to make sure the GPU is not the bottleneck.
As some of the rasterizer processing time has moved under culling, I present
the sum of scenegraph(includes culling)+rasterizer time
Scenegraph+rasterizer(ms)       2.48      1st round       3rd round
All objects static,            323.0           86.0             7.2
all visible, 1000 in 
the view frustrum
All objects static,            219.0           49.7             N/A(*)
all invisible.
All objects moving,            323.0          105.6            34.7
all visible, 1000 in 
the view frustrum
Scene destruction              40min          40min              4s
(*) : this time is not representative because the frame rate was at 60fps.
      In that case, the GPU holds down the GE by frame sync. By design, the
      overhead of the rasterizer is 0 when the the objects are invisible. 
This table shows a global speed up between 9x and 45x compared to 2.48a
for scenegraph, culling and rasterizer overhead. The speed up goes much
higher when objects are invisible.
An additional 2-4x speed up is possible in the scenegraph by upgrading
the Moto library to use Eigen2 BLAS library instead of C++ classes but
the scenegraph is already so fast that it is not a priority right now.
Next speed up in logic: many things to do there...
											 
										 
										
											2009-05-07 09:13:01 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										SG_QList : : iterator < RAS_MeshSlot >  mit ( m_meshSlots ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for ( mit . begin ( ) ;  ! mit . end ( ) ;  + + mit ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ms  =  * mit ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ms - > m_bObjectColor  =  m_bUseObjectColor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ms - > m_RGBAcolor  =  m_objectColor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ms - > m_bVisible  =  m_bVisible ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ms - > m_bCulled  =  m_bCulled  | |  ! m_bVisible ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( ! ms - > m_bCulled )  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												ms - > m_bucket - > ActivateMesh ( ms ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											/* split if necessary */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# ifdef USE_SPLIT 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ms - > Split ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-05 16:22:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( recursive )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											UpdateBuckets_recursive ( GetSGNode ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-05 16:22:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : RemoveMeshes ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2004-03-22 22:02:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( size_t  i = 0 ; i < m_meshes . size ( ) ; i + + ) 
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										m_meshes [ i ] - > RemoveFromBuckets ( this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//note: meshes can be shared, and are deleted by KX_BlenderSceneConverter
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_meshes . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : UpdateTransform ( )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-27 16:44:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// HACK: saves function call for dynamic object, they are handled differently
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1  & &  ! m_pPhysicsController1 - > IsDyna ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Note that for Bullet, this does not even update the transform of static object
 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// but merely sets there collision flag to "kinematic" because the synchronization is 
 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-27 16:44:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// done during physics simulation
 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										m_pPhysicsController1 - > SetSumoTransform ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_pGraphicController ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// update the culling tree
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_pGraphicController - > SetGraphicTransform ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2004-05-26 12:06:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : UpdateTransformFunc ( SG_IObject *  node ,  void *  gameobj ,  void *  scene )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									( ( KX_GameObject * ) gameobj ) - > UpdateTransform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: new sensor object to generalize Near and Radar sensor, static-static collision capbility.
A new type of "Sensor" physics object is available in the GE for advanced
collision management. It's called Sensor for its similarities with the
physics objects that underlie the Near and Radar sensors.
Like the Near and Radar object it is:
- static and ghost
- invisible by default
- always active to ensure correct collision detection
- capable of detecting both static and dynamic objects
- ignoring collision with their parent
- capable of broadphase filtering based on:
  * Actor option: the collisioning object must have the Actor flag set to be detected
  * property/material: as specified in the collision sensors attached to it
  Broadphase filtering is important for performance reason: the collision points
  will be computed only for the objects that pass the broahphase filter.
- automatically removed from the simulation when no collision sensor is active on it
Unlike the Near and Radar object it can:
- take any shape, including triangle mesh
- be made visible for debugging (just use the Visible actuator)
- have multiple collision sensors using it
Other than that, the sensor objects are ordinary objects. You can move them
freely or parent them. When parented to a dynamic object, they can provide
advanced collision control to this object.
The type of collision capability depends on the shape:
- box, sphere, cylinder, cone, convex hull provide volume detection.
- triangle mesh provides surface detection but you can give some volume
  to the suface by increasing the margin in the Advanced Settings panel.
  The margin applies on both sides of the surface.
Performance tip:
- Sensor objects perform better than Near and Radar: they do less synchronizations
  because of the Scenegraph optimizations and they can have multiple collision sensors
  on them (with different property filtering for example).
- Always prefer simple shape (box, sphere) to complex shape whenever possible.
- Always use broadphase filtering (avoid collision sensor with empty propery/material)
- Use collision sensor only when you need them. When no collision sensor is active
  on the sensor object, it is removed from the simulation and consume no CPU.
Known limitations:
- When running Blender in debug mode, you will see one warning line of the console:
  "warning btCollisionDispatcher::needsCollision: static-static collision!"
  In release mode this message is not printed.
- Collision margin has no effect on sphere, cone and cylinder shape.
Other performance improvements:
- Remove unnecessary interpolation for Near and Radar objects and by extension
  sensor objects.
- Use direct matrix copy instead of quaternion to synchronize orientation.
Other bug fix:
- Fix Near/Radar position error on newly activated objects. This was causing
  several detection problems in YoFrankie
- Fix margin not passed correctly to gImpact shape.
- Disable force/velocity actions on static objects 
											 
										 
										
											2009-05-17 12:51:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : SynchronizeTransform ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// only used for sensor object, do full synchronization as bullet doesn't do it
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_pPhysicsController1 - > SetTransform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pGraphicController ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_pGraphicController - > SetGraphicTransform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : SynchronizeTransformFunc ( SG_IObject *  node ,  void *  gameobj ,  void *  scene )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									( ( KX_GameObject * ) gameobj ) - > SynchronizeTransform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : SetDebugColor ( unsigned  int  bgra )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2004-03-22 22:02:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  ( size_t  i = 0 ; i < m_meshes . size ( ) ; i + + ) 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										m_meshes [ i ] - > DebugColor ( bgra ) ; 	
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : ResetDebugColor ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SetDebugColor ( 0xff000000 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system.
New Add mode for Ipo actuator
=============================
A new Add button, mutually exclusive with Force button, is available in
the Ipo actuator. When selected, it activates the Add mode that consists
in adding the Ipo curve to the current object situation in world
coordinates, or parent coordinates if the object has a parent. Scale Ipo
curves are multiplied instead of added to the object current scale.
If the local flag is selected, the Ipo curve is added (multiplied) in 
the object's local coordinates. 
Delta Ipo curves are handled identically to normal Ipo curve and there 
is no need to work with Delta Ipo curves provided that you make sure 
that the Ipo curve starts from origin. Origin means location 0 for 
Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for 
Scale Ipo curve.
The "current object situation" means the object's location, rotation 
and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo 
actuators, this means at the start of each loop. This initial state is
used as a base during the execution of the Ipo Curve but when the Ipo 
curve is restarted (later or immediately in case of Loop mode), the  
object current situation at that time is used as the new base.
For reference, here is the exact operation of the Add mode for each
type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale
and orientation matrix at the start of the curve; iLoc, iRot, iScale,
iMat: Ipo curve loc/rot/scale and orientation matrix resulting from
the rotation).
Location
  Local=false: newLoc = oLoc+iLoc
  Local=true : newLoc = oLoc+oScale*(oMat*iLoc)
Rotation
  Local=false: newMat = iMat*oMat
  Local=true : newMat = oMat*iMat
Scale
  Local=false: newScale = oScale*iScale
  Local=true : newScale = oScale*iScale
Add+Local mode is very useful to have dynamic object executing complex
movement relative to their current location/orientation. Of cource, 
dynamics should be disabled during the execution of the curve.
Several corrections in state system
===================================
- Object initial state is taken into account when adding object
  dynamically
- Fix bug with link count when adding object dynamically
- Fix false on-off detection for Actuator sensor when actuator is
  trigged on negative event.
- Fix Parent actuator false activation on negative event
- Loop Ipo curve not restarting at correct frame when start frame is
  different from one.
											 
										 
										
											2008-07-08 12:18:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : InitIPO ( bool  ipo_as_force ,  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															bool  ipo_add , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															bool  ipo_local ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SGControllerList : : iterator  it  =  GetSGNode ( ) - > GetSGControllerList ( ) . begin ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									while  ( it  ! =  GetSGNode ( ) - > GetSGControllerList ( ) . end ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										( * it ) - > SetOption ( SG_Controller : : SG_CONTR_IPO_RESET ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										( * it ) - > SetOption ( SG_Controller : : SG_CONTR_IPO_IPO_AS_FORCE ,  ipo_as_force ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										( * it ) - > SetOption ( SG_Controller : : SG_CONTR_IPO_IPO_ADD ,  ipo_add ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										( * it ) - > SetOption ( SG_Controller : : SG_CONTR_IPO_LOCAL ,  ipo_local ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										it + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}   
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : UpdateIPO ( float  curframetime ,  
						 
					
						
							
								
									
										
											 
										
											
												BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system.
New Add mode for Ipo actuator
=============================
A new Add button, mutually exclusive with Force button, is available in
the Ipo actuator. When selected, it activates the Add mode that consists
in adding the Ipo curve to the current object situation in world
coordinates, or parent coordinates if the object has a parent. Scale Ipo
curves are multiplied instead of added to the object current scale.
If the local flag is selected, the Ipo curve is added (multiplied) in 
the object's local coordinates. 
Delta Ipo curves are handled identically to normal Ipo curve and there 
is no need to work with Delta Ipo curves provided that you make sure 
that the Ipo curve starts from origin. Origin means location 0 for 
Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for 
Scale Ipo curve.
The "current object situation" means the object's location, rotation 
and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo 
actuators, this means at the start of each loop. This initial state is
used as a base during the execution of the Ipo Curve but when the Ipo 
curve is restarted (later or immediately in case of Loop mode), the  
object current situation at that time is used as the new base.
For reference, here is the exact operation of the Add mode for each
type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale
and orientation matrix at the start of the curve; iLoc, iRot, iScale,
iMat: Ipo curve loc/rot/scale and orientation matrix resulting from
the rotation).
Location
  Local=false: newLoc = oLoc+iLoc
  Local=true : newLoc = oLoc+oScale*(oMat*iLoc)
Rotation
  Local=false: newMat = iMat*oMat
  Local=true : newMat = oMat*iMat
Scale
  Local=false: newScale = oScale*iScale
  Local=true : newScale = oScale*iScale
Add+Local mode is very useful to have dynamic object executing complex
movement relative to their current location/orientation. Of cource, 
dynamics should be disabled during the execution of the curve.
Several corrections in state system
===================================
- Object initial state is taken into account when adding object
  dynamically
- Fix bug with link count when adding object dynamically
- Fix false on-off detection for Actuator sensor when actuator is
  trigged on negative event.
- Fix Parent actuator false activation on negative event
- Loop Ipo curve not restarting at correct frame when start frame is
  different from one.
											 
										 
										
											2008-07-08 12:18:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
															  bool  recurse )  
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
											 
										
											
												BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system.
New Add mode for Ipo actuator
=============================
A new Add button, mutually exclusive with Force button, is available in
the Ipo actuator. When selected, it activates the Add mode that consists
in adding the Ipo curve to the current object situation in world
coordinates, or parent coordinates if the object has a parent. Scale Ipo
curves are multiplied instead of added to the object current scale.
If the local flag is selected, the Ipo curve is added (multiplied) in 
the object's local coordinates. 
Delta Ipo curves are handled identically to normal Ipo curve and there 
is no need to work with Delta Ipo curves provided that you make sure 
that the Ipo curve starts from origin. Origin means location 0 for 
Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for 
Scale Ipo curve.
The "current object situation" means the object's location, rotation 
and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo 
actuators, this means at the start of each loop. This initial state is
used as a base during the execution of the Ipo Curve but when the Ipo 
curve is restarted (later or immediately in case of Loop mode), the  
object current situation at that time is used as the new base.
For reference, here is the exact operation of the Add mode for each
type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale
and orientation matrix at the start of the curve; iLoc, iRot, iScale,
iMat: Ipo curve loc/rot/scale and orientation matrix resulting from
the rotation).
Location
  Local=false: newLoc = oLoc+iLoc
  Local=true : newLoc = oLoc+oScale*(oMat*iLoc)
Rotation
  Local=false: newMat = iMat*oMat
  Local=true : newMat = oMat*iMat
Scale
  Local=false: newScale = oScale*iScale
  Local=true : newScale = oScale*iScale
Add+Local mode is very useful to have dynamic object executing complex
movement relative to their current location/orientation. Of cource, 
dynamics should be disabled during the execution of the curve.
Several corrections in state system
===================================
- Object initial state is taken into account when adding object
  dynamically
- Fix bug with link count when adding object dynamically
- Fix false on-off detection for Actuator sensor when actuator is
  trigged on negative event.
- Fix Parent actuator false activation on negative event
- Loop Ipo curve not restarting at correct frame when start frame is
  different from one.
											 
										 
										
											2008-07-08 12:18:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// just the 'normal' update procedure.
 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									GetSGNode ( ) - > SetSimulatedTime ( curframetime , recurse ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									GetSGNode ( ) - > UpdateWorldData ( curframetime ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									UpdateTransform ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-01-06 03:46:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// IPO update
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								KX_GameObject : : UpdateMaterialData (  
						 
					
						
							
								
									
										
										
										
											2008-07-25 13:45:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										dword  matname_hash , 
							 
						 
					
						
							
								
									
										
										
										
											2006-01-06 03:46:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										MT_Vector4  rgba , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Vector3  specrgb , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Scalar  hard , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Scalar  spec , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Scalar  ref , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Scalar  emit , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Scalar  alpha 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  mesh  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ( ( unsigned  int ) mesh  <  m_meshes . size ( ) )  & &  mesh  > =  0 )  { 
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										list < RAS_MeshMaterial > : : iterator  mit  =  m_meshes [ mesh ] - > GetFirstMaterial ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-01-06 03:46:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										for ( ;  mit  ! =  m_meshes [ mesh ] - > GetLastMaterial ( ) ;  + + mit ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											RAS_IPolyMaterial *  poly  =  mit - > m_bucket - > GetPolyMaterial ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if ( poly - > GetFlag ( )  &  RAS_BLENDERMAT  ) 
							 
						 
					
						
							
								
									
										
										
										
											2006-01-06 03:46:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												KX_BlenderMaterial  * m  =   static_cast < KX_BlenderMaterial * > ( poly ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-25 13:45:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												
							 
						 
					
						
							
								
									
										
										
										
											2009-02-21 12:43:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  ( matname_hash  = =  0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-25 13:45:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													m - > UpdateIPO ( rgba ,  specrgb , hard , spec , ref , emit ,  alpha ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													// if mesh has only one material attached to it then use original hack with no need to edit vertices (better performance)
 
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													SetObjectColor ( rgba ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-25 13:45:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													if  ( matname_hash  = =  poly - > GetMaterialNameHash ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														m - > UpdateIPO ( rgba ,  specrgb , hard , spec , ref , emit ,  alpha ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														m_meshes [ mesh ] - > SetVertexColor ( poly , rgba ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														// no break here, because one blender material can be split into several game engine materials
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														// (e.g. one uvsphere material is split into one material at poles with ras_mode TRIANGLE and one material for the body
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														// if here was a break then would miss some vertices if material was split
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2006-01-06 03:46:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								bool  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								KX_GameObject : : GetVisible (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									void 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  m_bVisible ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-05 16:22:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  void  setVisible_recursive ( SG_Node *  node ,  bool  v )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NodeList &  children  =  node - > GetSGChildren ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( NodeList : : iterator  childit  =  children . begin ( ) ; ! ( childit = = children . end ( ) ) ; + + childit ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SG_Node *  childnode  =  ( * childit ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										KX_GameObject  * clientgameobj  =  static_cast < KX_GameObject * > (  ( * childit ) - > GetSGClientObject ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( clientgameobj  ! =  NULL )  // This is a GameObject
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											clientgameobj - > SetVisible ( v ,  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// if the childobj is NULL then this may be an inverse parent link
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// so a non recursive search should still look down this node.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										setVisible_recursive ( childnode ,  v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								void  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								KX_GameObject : : SetVisible (  
						 
					
						
							
								
									
										
										
										
											2008-09-05 16:22:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bool  v , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bool  recursive 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( GetSGNode ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_bVisible  =  v ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-01 20:34:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( m_pGraphicController ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											m_pGraphicController - > Activate ( m_bVisible ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( recursive ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											setVisible_recursive ( GetSGNode ( ) ,  v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-13 20:08:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  void  setOccluder_recursive ( SG_Node *  node ,  bool  v )  
						 
					
						
							
								
									
										
										
										
											2008-04-30 19:58:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-13 20:08:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									NodeList &  children  =  node - > GetSGChildren ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( NodeList : : iterator  childit  =  children . begin ( ) ; ! ( childit = = children . end ( ) ) ; + + childit ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SG_Node *  childnode  =  ( * childit ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										KX_GameObject  * clientgameobj  =  static_cast < KX_GameObject * > (  ( * childit ) - > GetSGClientObject ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( clientgameobj  ! =  NULL )  // This is a GameObject
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											clientgameobj - > SetOccluder ( v ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// if the childobj is NULL then this may be an inverse parent link
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// so a non recursive search should still look down this node.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										setOccluder_recursive ( childnode ,  v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-30 19:58:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  
						 
					
						
							
								
									
										
										
										
											2009-04-13 20:08:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								KX_GameObject : : SetOccluder (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bool  v , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bool  recursive 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-30 19:58:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( GetSGNode ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_bOccluder  =  v ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( recursive ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											setOccluder_recursive ( GetSGNode ( ) ,  v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-30 19:58:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								KX_GameObject : : SetLayer (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  l 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_layer  =  l ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								int  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								KX_GameObject : : GetLayer (  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									void 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
											 
										
											
												
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
  menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
  gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
  storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
  An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
  needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
  be at the origin.
											 
										 
										
											2008-09-04 20:51:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  m_layer ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : addLinearVelocity ( const  MT_Vector3 &  lin_vel , bool  local )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-09-17 21:47:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 )  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Vector3  lv  =  local  ?  NodeGetWorldOrientation ( )  *  lin_vel  :  lin_vel ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_pPhysicsController1 - > SetLinearVelocity ( lv  +  m_pPhysicsController1 - > GetLinearVelocity ( ) ,  0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : setLinearVelocity ( const  MT_Vector3 &  lin_vel , bool  local )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_pPhysicsController1 - > SetLinearVelocity ( lin_vel , local ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : setAngularVelocity ( const  MT_Vector3 &  ang_vel , bool  local )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_pPhysicsController1 - > SetAngularVelocity ( ang_vel , local ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-12-09 04:13:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2004-04-08 11:34:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : ResolveCombinedVelocities (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  MT_Vector3  &  lin_vel , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  MT_Vector3  &  ang_vel , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bool  lin_vel_local , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									bool  ang_vel_local 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								) {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-03-25 10:33:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Vector3  lv  =  lin_vel_local  ?  NodeGetWorldOrientation ( )  *  lin_vel  :  lin_vel ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Vector3  av  =  ang_vel_local  ?  NodeGetWorldOrientation ( )  *  ang_vel  :  ang_vel ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-04-08 11:34:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										m_pPhysicsController1 - > resolveCombinedVelocities ( 
							 
						 
					
						
							
								
									
										
										
										
											2005-03-25 10:33:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											lv . x ( ) , lv . y ( ) , lv . z ( ) , av . x ( ) , av . y ( ) , av . z ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-04-08 11:34:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : SetObjectColor ( const  MT_Vector4 &  rgbavec )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_bUseObjectColor  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_objectColor  =  rgbavec ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-01-16 23:53:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  MT_Vector4 &  KX_GameObject : : GetObjectColor ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  m_objectColor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												added a factor argument for aligning to vector, this isn't correct since it does linear interpolation of the vector and renormalizes.
(can be improved to rotate correctly but for our  use ist ok for now, would also be useful to have an argument to clamp the maximum rotation angle to get a constant rotation speed),
This will used to make franky upright when falling from an angle, to track to a surface when hanging onto a ledge and setting the glide pitch.
Without this rotation is instant and jerky.
currently this is done with Mathutils which isnt available in Blender Player.
def do_rotate_up(own):
	own.alignAxisToVect([0,0,1], 2, 0.1)
replaces...
def do_rotate_up(own):
	up_nor = Vector(0,0,1)
	own_mat = Matrix(*own.getOrientation()).transpose()
	own_up = up_nor * own_mat
	ang = AngleBetweenVecs(own_up, up_nor)
	if ang > 0.005:
		# Set orientation
		cross = CrossVecs(own_up, up_nor)
		new_mat = own_mat * RotationMatrix(ang*0.1, 3, 'r', cross)
		own.setOrientation(new_mat.transpose())
M    source/gameengine/Ketsji/KX_GameObject.cpp
M    source/gameengine/Ketsji/KX_GameObject.h
											 
										 
										
											2008-07-09 09:21:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : AlignAxisToVect ( const  MT_Vector3 &  dir ,  int  axis ,  float  fac )  
						 
					
						
							
								
									
										
										
										
											2008-06-02 17:31:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Matrix3x3  orimat ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Vector3  vect , ori , z , x , y ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Scalar  len ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-10-16 23:33:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// check on valid node in case a python controller holds a reference to a deleted object
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! GetSGNode ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-06-02 17:31:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									vect  =  dir ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									len  =  vect . length ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( MT_fuzzyZero ( len ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										cout  < <  " alignAxisToVect() Error: Null vector! \n " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
											 
										
											
												added a factor argument for aligning to vector, this isn't correct since it does linear interpolation of the vector and renormalizes.
(can be improved to rotate correctly but for our  use ist ok for now, would also be useful to have an argument to clamp the maximum rotation angle to get a constant rotation speed),
This will used to make franky upright when falling from an angle, to track to a surface when hanging onto a ledge and setting the glide pitch.
Without this rotation is instant and jerky.
currently this is done with Mathutils which isnt available in Blender Player.
def do_rotate_up(own):
	own.alignAxisToVect([0,0,1], 2, 0.1)
replaces...
def do_rotate_up(own):
	up_nor = Vector(0,0,1)
	own_mat = Matrix(*own.getOrientation()).transpose()
	own_up = up_nor * own_mat
	ang = AngleBetweenVecs(own_up, up_nor)
	if ang > 0.005:
		# Set orientation
		cross = CrossVecs(own_up, up_nor)
		new_mat = own_mat * RotationMatrix(ang*0.1, 3, 'r', cross)
		own.setOrientation(new_mat.transpose())
M    source/gameengine/Ketsji/KX_GameObject.cpp
M    source/gameengine/Ketsji/KX_GameObject.h
											 
										 
										
											2008-07-09 09:21:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( fac < = 0.0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2008-06-02 17:31:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// normalize
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									vect  / =  len ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									orimat  =  GetSGNode ( ) - > GetWorldOrientation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									switch  ( axis ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 	
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  0 :  //x axis
 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-25 06:43:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											ori . setValue ( orimat [ 0 ] [ 2 ] ,  orimat [ 1 ] [ 2 ] ,  orimat [ 2 ] [ 2 ] ) ;  //pivot axis
 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-20 10:41:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( MT_abs ( vect . dot ( ori ) )  >  1.0 - 3.0 * MT_EPSILON )  //is the vector parallel to the pivot?
 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-25 06:43:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												ori . setValue ( orimat [ 0 ] [ 1 ] ,  orimat [ 1 ] [ 1 ] ,  orimat [ 2 ] [ 1 ] ) ;  //change the pivot!
 
							 
						 
					
						
							
								
									
										
											 
										
											
												added a factor argument for aligning to vector, this isn't correct since it does linear interpolation of the vector and renormalizes.
(can be improved to rotate correctly but for our  use ist ok for now, would also be useful to have an argument to clamp the maximum rotation angle to get a constant rotation speed),
This will used to make franky upright when falling from an angle, to track to a surface when hanging onto a ledge and setting the glide pitch.
Without this rotation is instant and jerky.
currently this is done with Mathutils which isnt available in Blender Player.
def do_rotate_up(own):
	own.alignAxisToVect([0,0,1], 2, 0.1)
replaces...
def do_rotate_up(own):
	up_nor = Vector(0,0,1)
	own_mat = Matrix(*own.getOrientation()).transpose()
	own_up = up_nor * own_mat
	ang = AngleBetweenVecs(own_up, up_nor)
	if ang > 0.005:
		# Set orientation
		cross = CrossVecs(own_up, up_nor)
		new_mat = own_mat * RotationMatrix(ang*0.1, 3, 'r', cross)
		own.setOrientation(new_mat.transpose())
M    source/gameengine/Ketsji/KX_GameObject.cpp
M    source/gameengine/Ketsji/KX_GameObject.h
											 
										 
										
											2008-07-09 09:21:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( fac  = =  1.0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												x  =  vect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												x  =  ( vect  *  fac )  +  ( ( orimat  *  MT_Vector3 ( 1.0 ,  0.0 ,  0.0 ) )  *  ( 1 - fac ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												len  =  x . length ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( MT_fuzzyZero ( len ) )  x  =  vect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												else  x  / =  len ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-02 17:31:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											y  =  ori . cross ( x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											z  =  x . cross ( y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  1 :  //y axis
 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-25 06:43:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											ori . setValue ( orimat [ 0 ] [ 0 ] ,  orimat [ 1 ] [ 0 ] ,  orimat [ 2 ] [ 0 ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-02 17:31:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( MT_abs ( vect . dot ( ori ) )  >  1.0 - 3.0 * MT_EPSILON ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-25 06:43:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												ori . setValue ( orimat [ 0 ] [ 2 ] ,  orimat [ 1 ] [ 2 ] ,  orimat [ 2 ] [ 2 ] ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												added a factor argument for aligning to vector, this isn't correct since it does linear interpolation of the vector and renormalizes.
(can be improved to rotate correctly but for our  use ist ok for now, would also be useful to have an argument to clamp the maximum rotation angle to get a constant rotation speed),
This will used to make franky upright when falling from an angle, to track to a surface when hanging onto a ledge and setting the glide pitch.
Without this rotation is instant and jerky.
currently this is done with Mathutils which isnt available in Blender Player.
def do_rotate_up(own):
	own.alignAxisToVect([0,0,1], 2, 0.1)
replaces...
def do_rotate_up(own):
	up_nor = Vector(0,0,1)
	own_mat = Matrix(*own.getOrientation()).transpose()
	own_up = up_nor * own_mat
	ang = AngleBetweenVecs(own_up, up_nor)
	if ang > 0.005:
		# Set orientation
		cross = CrossVecs(own_up, up_nor)
		new_mat = own_mat * RotationMatrix(ang*0.1, 3, 'r', cross)
		own.setOrientation(new_mat.transpose())
M    source/gameengine/Ketsji/KX_GameObject.cpp
M    source/gameengine/Ketsji/KX_GameObject.h
											 
										 
										
											2008-07-09 09:21:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( fac  = =  1.0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												y  =  vect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												y  =  ( vect  *  fac )  +  ( ( orimat  *  MT_Vector3 ( 0.0 ,  1.0 ,  0.0 ) )  *  ( 1 - fac ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												len  =  y . length ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( MT_fuzzyZero ( len ) )  y  =  vect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												else  y  / =  len ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-02 17:31:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											z  =  ori . cross ( y ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											x  =  y . cross ( z ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  2 :  //z axis
 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-25 06:43:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											ori . setValue ( orimat [ 0 ] [ 1 ] ,  orimat [ 1 ] [ 1 ] ,  orimat [ 2 ] [ 1 ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-02 17:31:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( MT_abs ( vect . dot ( ori ) )  >  1.0 - 3.0 * MT_EPSILON ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-25 06:43:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												ori . setValue ( orimat [ 0 ] [ 0 ] ,  orimat [ 1 ] [ 0 ] ,  orimat [ 2 ] [ 0 ] ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												added a factor argument for aligning to vector, this isn't correct since it does linear interpolation of the vector and renormalizes.
(can be improved to rotate correctly but for our  use ist ok for now, would also be useful to have an argument to clamp the maximum rotation angle to get a constant rotation speed),
This will used to make franky upright when falling from an angle, to track to a surface when hanging onto a ledge and setting the glide pitch.
Without this rotation is instant and jerky.
currently this is done with Mathutils which isnt available in Blender Player.
def do_rotate_up(own):
	own.alignAxisToVect([0,0,1], 2, 0.1)
replaces...
def do_rotate_up(own):
	up_nor = Vector(0,0,1)
	own_mat = Matrix(*own.getOrientation()).transpose()
	own_up = up_nor * own_mat
	ang = AngleBetweenVecs(own_up, up_nor)
	if ang > 0.005:
		# Set orientation
		cross = CrossVecs(own_up, up_nor)
		new_mat = own_mat * RotationMatrix(ang*0.1, 3, 'r', cross)
		own.setOrientation(new_mat.transpose())
M    source/gameengine/Ketsji/KX_GameObject.cpp
M    source/gameengine/Ketsji/KX_GameObject.h
											 
										 
										
											2008-07-09 09:21:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( fac  = =  1.0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												z  =  vect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												z  =  ( vect  *  fac )  +  ( ( orimat  *  MT_Vector3 ( 0.0 ,  0.0 ,  1.0 ) )  *  ( 1 - fac ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												len  =  z . length ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( MT_fuzzyZero ( len ) )  z  =  vect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												else  z  / =  len ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-02 17:31:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											x  =  ori . cross ( z ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											y  =  z . cross ( x ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										default :  //wrong input?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											cout  < <  " alignAxisToVect(): Wrong axis ' "  < <  axis  < < " ' \n " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									x . normalize ( ) ;  //normalize the vectors
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									y . normalize ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									z . normalize ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-25 06:43:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									orimat . setValue ( 	x [ 0 ] , y [ 0 ] , z [ 0 ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														x [ 1 ] , y [ 1 ] , z [ 1 ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														x [ 2 ] , y [ 2 ] , z [ 2 ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-02 17:31:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( GetSGNode ( ) - > GetSGParent ( )  ! =  NULL ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// the object is a child, adapt its local orientation so that 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// the global orientation is aligned as we want.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Matrix3x3  invori  =  GetSGNode ( ) - > GetSGParent ( ) - > GetWorldOrientation ( ) . inverse ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										NodeSetLocalOrientation ( invori * orimat ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										NodeSetLocalOrientation ( orimat ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
  Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an 
event at the start of the game or when entering a state or at 
object creation. The event will be positive or negative 
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed 
with force. The control if of type "PID" (Propotional, Integral, 
Derivate): the force is automatically adapted to achieve the 
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style: 
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision 
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world 
       coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
       coordinates of LinV). No limitation means that the force
       will grow as large as necessary to achieve the target 
       speed along that axis. Set a max value to limit the 
       accelaration along an axis (slow start) and set a min
       value (negative) to limit the brake force.
P:     Proportional coefficient of servo controller, don't set
       directly unless you know what you're doing.
I:     Integral coefficient of servo controller. Use low value
       (<0.1) for slow reaction (sliding), high values (>0.5)
       for hard control. The P coefficient will be automatically
       set to 60 times the I coefficient (a reasonable value).
D:     Derivate coefficient. Leave to 0 unless you know what
       you're doing. High values create instability. 
Notes: - This actuator works perfectly in zero friction 
         environment: the PID controller will simulate friction
         by applying force as needed.
       - This actuator is compatible with simple Drot motion
         actuator but not with LinV and Dloc motion.
       - (0,0,0) is a valid target speed.
       - All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp:  Time constant (in nb of frames) of distance and 
       orientation control.
Dist:  Select to enable distance control and set target 
       distance. The object will be position at the given
       distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be 
       detected.
N    : Select to enable orientation control. The actuator will
       change the orientation and the location of the object 
       so that it is parallel to the surface at the vertical
       of the point of contact of the ray.  
M/P  : Select to enable material detection. Default is property
       detection.
Property/Material: name of property/material that the target of
       ray must have to be detected. If not set, property/
       material filter is disabled and any collisioning object
       within range will be detected.
PER  : Select to enable persistent operation. Normally the 
       actuator disables itself automatically if the ray does
       not reach a valid target. 
time : Maximum activation time of actuator. 
       0 : unlimited.
       >0: number of frames before automatic deactivation.  
rotDamp: Time constant (in nb of frame) of orientation control.
       0 : use Damp parameter.
       >0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
         does not change the position and orientation of the
         object; it works as a ray sensor.
       - The ray has no "X-ray" capability: if the first object
         hit does not have the required property/material, it
         returns no hit and the actuator disables itself unless
         PER option is enabled.
       - This actuator changes the position and orientation but
         not the speed of the object. This has an important 
         implication in a gravity environment: the gravity will
         cause the speed to increase although the object seems
         to stay still (it is repositioned at each frame).
         The gravity must be compensated in one way or another.
         the new servo control motion actuator is the simplest 
         way: set the target speed along the ray axis to 0
         and the servo control will automatically compensate 
         the gravity.
       - This actuator changes the orientation of the object 
         and will conflict with Drot motion unless it is 
         placed BEFORE the Drot motion actuator (the order of 
         actuator is important)
       - All parameters are accessible through Python.
Orientation constraint 
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction. 
time : Maximum activation time of actuator. 
       0 : unlimited.
       >0: number of frames before automatic deactivation.  
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
       - This actuator changes the orientation of the object
         and will conflict with Drot motion unless it is placed
         BEFORE the Drot motion actuator (the order of 
         actuator is important).
       - This actuator doesn't change the location and speed. 
         It is compatible with gravity.
       - All parameters are accessible through Python.
Actuator sensor 
===============
This sensor detects the activation and deactivation of actuators 
of the same object. The sensor generates a positive pulse when 
the corresponding sensor is activated and a negative pulse when 
it is deactivated (the contrary if the Inv option is selected). 
This is mostly useful to chain actions and to detect the loss of 
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
         want to detect the On-Off transition of an actuator 
         after it has been activated at least once, unselect the
         Lvl and Inv options and use a NAND controller.
       - Some actuators deactivates themselves immediately after 
         being activated. The sensor detects this situation as 
         an On-Off transition.
       - The actuator name can be set through Python.
											 
										 
										
											2008-07-04 08:14:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								MT_Scalar  KX_GameObject : : GetMass ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  m_pPhysicsController1 - > GetMass ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  0.0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-08 16:25:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								MT_Vector3  KX_GameObject : : GetLocalInertia ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Vector3  local_inertia ( 0.0 , 0.0 , 0.0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										local_inertia  =  m_pPhysicsController1 - > GetLocalInertia ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  local_inertia ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-05-06 20:55:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								MT_Vector3  KX_GameObject : : GetLinearVelocity ( bool  local )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-06-18 21:22:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									MT_Vector3  velocity ( 0.0 , 0.0 , 0.0 ) ,  locvel ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Matrix3x3  ori ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										velocity  =  m_pPhysicsController1 - > GetLinearVelocity ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-06 20:55:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( local ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ori  =  GetSGNode ( ) - > GetWorldOrientation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											
							 
						 
					
						
							
								
									
										
										
										
											2008-06-18 21:22:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											locvel  =  velocity  *  ori ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  locvel ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-06 20:55:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-06 20:55:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  velocity ; 	
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-06-24 19:37:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								MT_Vector3  KX_GameObject : : GetAngularVelocity ( bool  local )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Vector3  velocity ( 0.0 , 0.0 , 0.0 ) ,  locvel ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Matrix3x3  ori ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										velocity  =  m_pPhysicsController1 - > GetAngularVelocity ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( local ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ori  =  GetSGNode ( ) - > GetWorldOrientation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											locvel  =  velocity  *  ori ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  locvel ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  velocity ; 	
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-10-01 07:55:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								MT_Vector3  KX_GameObject : : GetVelocity ( const  MT_Point3 &  point )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  m_pPhysicsController1 - > GetVelocity ( point ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  MT_Vector3 ( 0.0 , 0.0 , 0.0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// scenegraph node stuff
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : NodeSetLocalPosition ( const  MT_Point3 &  trans )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-10-16 23:33:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// check on valid node in case a python controller holds a reference to a deleted object
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! GetSGNode ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1  & &  ! GetSGNode ( ) - > GetSGParent ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-20 15:40:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// don't update physic controller if the object is a child:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// 1) the transformation will not be right
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// 2) in this case, the physic controller is necessarily a static object
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										//    that is updated from the normal kinematic synchronization
 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										m_pPhysicsController1 - > setPosition ( trans ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-10-16 23:33:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									GetSGNode ( ) - > SetLocalPosition ( trans ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : NodeSetLocalOrientation ( const  MT_Matrix3x3 &  rot )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-10-16 23:33:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// check on valid node in case a python controller holds a reference to a deleted object
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! GetSGNode ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1  & &  ! GetSGNode ( ) - > GetSGParent ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-20 15:40:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// see note above
 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-21 12:37:27 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										m_pPhysicsController1 - > setOrientation ( rot ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-16 23:33:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									GetSGNode ( ) - > SetLocalOrientation ( rot ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : NodeSetGlobalOrientation ( const  MT_Matrix3x3 &  rot )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// check on valid node in case a python controller holds a reference to a deleted object
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! GetSGNode ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( GetSGNode ( ) - > GetSGParent ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GetSGNode ( ) - > SetLocalOrientation ( GetSGNode ( ) - > GetSGParent ( ) - > GetWorldOrientation ( ) . inverse ( ) * rot ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else 
							 
						 
					
						
							
								
									
										
										
										
											2010-12-08 06:59:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										NodeSetLocalOrientation ( rot ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : NodeSetLocalScale ( const  MT_Vector3 &  scale )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-10-16 23:33:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// check on valid node in case a python controller holds a reference to a deleted object
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! GetSGNode ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1  & &  ! GetSGNode ( ) - > GetSGParent ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-20 15:40:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// see note above
 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										m_pPhysicsController1 - > setScaling ( scale ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-16 23:33:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									GetSGNode ( ) - > SetLocalScale ( scale ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : NodeSetRelativeScale ( const  MT_Vector3 &  scale )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2006-12-25 04:11:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( GetSGNode ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-20 22:19:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2006-12-25 04:11:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										GetSGNode ( ) - > RelativeScale ( scale ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-09-20 22:19:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( m_pPhysicsController1  & &  ( ! GetSGNode ( ) - > GetSGParent ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// see note above
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// we can use the local scale: it's the same thing for a root object 
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// and the world scale is not yet updated
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											MT_Vector3  newscale  =  GetSGNode ( ) - > GetLocalScale ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											m_pPhysicsController1 - > setScaling ( newscale ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
  Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an 
event at the start of the game or when entering a state or at 
object creation. The event will be positive or negative 
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed 
with force. The control if of type "PID" (Propotional, Integral, 
Derivate): the force is automatically adapted to achieve the 
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style: 
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision 
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world 
       coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
       coordinates of LinV). No limitation means that the force
       will grow as large as necessary to achieve the target 
       speed along that axis. Set a max value to limit the 
       accelaration along an axis (slow start) and set a min
       value (negative) to limit the brake force.
P:     Proportional coefficient of servo controller, don't set
       directly unless you know what you're doing.
I:     Integral coefficient of servo controller. Use low value
       (<0.1) for slow reaction (sliding), high values (>0.5)
       for hard control. The P coefficient will be automatically
       set to 60 times the I coefficient (a reasonable value).
D:     Derivate coefficient. Leave to 0 unless you know what
       you're doing. High values create instability. 
Notes: - This actuator works perfectly in zero friction 
         environment: the PID controller will simulate friction
         by applying force as needed.
       - This actuator is compatible with simple Drot motion
         actuator but not with LinV and Dloc motion.
       - (0,0,0) is a valid target speed.
       - All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp:  Time constant (in nb of frames) of distance and 
       orientation control.
Dist:  Select to enable distance control and set target 
       distance. The object will be position at the given
       distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be 
       detected.
N    : Select to enable orientation control. The actuator will
       change the orientation and the location of the object 
       so that it is parallel to the surface at the vertical
       of the point of contact of the ray.  
M/P  : Select to enable material detection. Default is property
       detection.
Property/Material: name of property/material that the target of
       ray must have to be detected. If not set, property/
       material filter is disabled and any collisioning object
       within range will be detected.
PER  : Select to enable persistent operation. Normally the 
       actuator disables itself automatically if the ray does
       not reach a valid target. 
time : Maximum activation time of actuator. 
       0 : unlimited.
       >0: number of frames before automatic deactivation.  
rotDamp: Time constant (in nb of frame) of orientation control.
       0 : use Damp parameter.
       >0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
         does not change the position and orientation of the
         object; it works as a ray sensor.
       - The ray has no "X-ray" capability: if the first object
         hit does not have the required property/material, it
         returns no hit and the actuator disables itself unless
         PER option is enabled.
       - This actuator changes the position and orientation but
         not the speed of the object. This has an important 
         implication in a gravity environment: the gravity will
         cause the speed to increase although the object seems
         to stay still (it is repositioned at each frame).
         The gravity must be compensated in one way or another.
         the new servo control motion actuator is the simplest 
         way: set the target speed along the ray axis to 0
         and the servo control will automatically compensate 
         the gravity.
       - This actuator changes the orientation of the object 
         and will conflict with Drot motion unless it is 
         placed BEFORE the Drot motion actuator (the order of 
         actuator is important)
       - All parameters are accessible through Python.
Orientation constraint 
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction. 
time : Maximum activation time of actuator. 
       0 : unlimited.
       >0: number of frames before automatic deactivation.  
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
       - This actuator changes the orientation of the object
         and will conflict with Drot motion unless it is placed
         BEFORE the Drot motion actuator (the order of 
         actuator is important).
       - This actuator doesn't change the location and speed. 
         It is compatible with gravity.
       - All parameters are accessible through Python.
Actuator sensor 
===============
This sensor detects the activation and deactivation of actuators 
of the same object. The sensor generates a positive pulse when 
the corresponding sensor is activated and a negative pulse when 
it is deactivated (the contrary if the Inv option is selected). 
This is mostly useful to chain actions and to detect the loss of 
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
         want to detect the On-Off transition of an actuator 
         after it has been activated at least once, unselect the
         Lvl and Inv options and use a NAND controller.
       - Some actuators deactivates themselves immediately after 
         being activated. The sensor detects this situation as 
         an On-Off transition.
       - The actuator name can be set through Python.
											 
										 
										
											2008-07-04 08:14:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : NodeSetWorldPosition ( const  MT_Point3 &  trans )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! GetSGNode ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SG_Node *  parent  =  GetSGNode ( ) - > GetSGParent ( ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
  Servo control motion).
- No PyDoc at present, will be added soon.
Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an 
event at the start of the game or when entering a state or at 
object creation. The event will be positive or negative 
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.
Servo control motion
====================
A new variant of the motion actuator allows to control speed 
with force. The control if of type "PID" (Propotional, Integral, 
Derivate): the force is automatically adapted to achieve the 
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style: 
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision 
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world 
       coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
       coordinates of LinV). No limitation means that the force
       will grow as large as necessary to achieve the target 
       speed along that axis. Set a max value to limit the 
       accelaration along an axis (slow start) and set a min
       value (negative) to limit the brake force.
P:     Proportional coefficient of servo controller, don't set
       directly unless you know what you're doing.
I:     Integral coefficient of servo controller. Use low value
       (<0.1) for slow reaction (sliding), high values (>0.5)
       for hard control. The P coefficient will be automatically
       set to 60 times the I coefficient (a reasonable value).
D:     Derivate coefficient. Leave to 0 unless you know what
       you're doing. High values create instability. 
Notes: - This actuator works perfectly in zero friction 
         environment: the PID controller will simulate friction
         by applying force as needed.
       - This actuator is compatible with simple Drot motion
         actuator but not with LinV and Dloc motion.
       - (0,0,0) is a valid target speed.
       - All parameters are accessible through Python.
Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp:  Time constant (in nb of frames) of distance and 
       orientation control.
Dist:  Select to enable distance control and set target 
       distance. The object will be position at the given
       distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be 
       detected.
N    : Select to enable orientation control. The actuator will
       change the orientation and the location of the object 
       so that it is parallel to the surface at the vertical
       of the point of contact of the ray.  
M/P  : Select to enable material detection. Default is property
       detection.
Property/Material: name of property/material that the target of
       ray must have to be detected. If not set, property/
       material filter is disabled and any collisioning object
       within range will be detected.
PER  : Select to enable persistent operation. Normally the 
       actuator disables itself automatically if the ray does
       not reach a valid target. 
time : Maximum activation time of actuator. 
       0 : unlimited.
       >0: number of frames before automatic deactivation.  
rotDamp: Time constant (in nb of frame) of orientation control.
       0 : use Damp parameter.
       >0: use a different time constant for orientation.
Notes: - If neither N nor Dist options are set, the actuator
         does not change the position and orientation of the
         object; it works as a ray sensor.
       - The ray has no "X-ray" capability: if the first object
         hit does not have the required property/material, it
         returns no hit and the actuator disables itself unless
         PER option is enabled.
       - This actuator changes the position and orientation but
         not the speed of the object. This has an important 
         implication in a gravity environment: the gravity will
         cause the speed to increase although the object seems
         to stay still (it is repositioned at each frame).
         The gravity must be compensated in one way or another.
         the new servo control motion actuator is the simplest 
         way: set the target speed along the ray axis to 0
         and the servo control will automatically compensate 
         the gravity.
       - This actuator changes the orientation of the object 
         and will conflict with Drot motion unless it is 
         placed BEFORE the Drot motion actuator (the order of 
         actuator is important)
       - All parameters are accessible through Python.
Orientation constraint 
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction. 
time : Maximum activation time of actuator. 
       0 : unlimited.
       >0: number of frames before automatic deactivation.  
Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
       - This actuator changes the orientation of the object
         and will conflict with Drot motion unless it is placed
         BEFORE the Drot motion actuator (the order of 
         actuator is important).
       - This actuator doesn't change the location and speed. 
         It is compatible with gravity.
       - All parameters are accessible through Python.
Actuator sensor 
===============
This sensor detects the activation and deactivation of actuators 
of the same object. The sensor generates a positive pulse when 
the corresponding sensor is activated and a negative pulse when 
it is deactivated (the contrary if the Inv option is selected). 
This is mostly useful to chain actions and to detect the loss of 
contact of the distance motion actuator.
Notes: - Actuators are disabled at the start of the game; if you
         want to detect the On-Off transition of an actuator 
         after it has been activated at least once, unselect the
         Lvl and Inv options and use a NAND controller.
       - Some actuators deactivates themselves immediately after 
         being activated. The sensor detects this situation as 
         an On-Off transition.
       - The actuator name can be set through Python.
											 
										 
										
											2008-07-04 08:14:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( parent  ! =  NULL ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Make sure the objects have some scale
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Vector3  scale  =  parent - > GetWorldScaling ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( fabs ( scale [ 0 ] )  <  FLT_EPSILON  | |  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											fabs ( scale [ 1 ] )  <  FLT_EPSILON  | |  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											fabs ( scale [ 2 ] )  <  FLT_EPSILON ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return ;  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										scale [ 0 ]  =  1.0 / scale [ 0 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										scale [ 1 ]  =  1.0 / scale [ 1 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										scale [ 2 ]  =  1.0 / scale [ 2 ] ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Matrix3x3  invori  =  parent - > GetWorldOrientation ( ) . inverse ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Vector3  newpos  =  invori * ( trans - parent - > GetWorldPosition ( ) ) * scale ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										NodeSetLocalPosition ( MT_Point3 ( newpos [ 0 ] , newpos [ 1 ] , newpos [ 2 ] ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										NodeSetLocalPosition ( trans ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : NodeUpdateGS ( double  time )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2006-12-25 04:11:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( GetSGNode ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GetSGNode ( ) - > UpdateWorldData ( time ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  MT_Matrix3x3 &  KX_GameObject : : NodeGetWorldOrientation ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-10-16 23:33:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// check on valid node in case a python controller holds a reference to a deleted object
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! GetSGNode ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  dummy_orientation ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  GetSGNode ( ) - > GetWorldOrientation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  MT_Matrix3x3 &  KX_GameObject : : NodeGetLocalOrientation ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// check on valid node in case a python controller holds a reference to a deleted object
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! GetSGNode ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  dummy_orientation ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  GetSGNode ( ) - > GetLocalOrientation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								const  MT_Vector3 &  KX_GameObject : : NodeGetWorldScaling ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-10-16 23:33:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// check on valid node in case a python controller holds a reference to a deleted object
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! GetSGNode ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  dummy_scaling ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-16 23:33:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									return  GetSGNode ( ) - > GetWorldScaling ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  MT_Vector3 &  KX_GameObject : : NodeGetLocalScaling ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// check on valid node in case a python controller holds a reference to a deleted object
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! GetSGNode ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  dummy_scaling ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  GetSGNode ( ) - > GetLocalScale ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2009-04-05 14:01:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								const  MT_Point3 &  KX_GameObject : : NodeGetWorldPosition ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-10-16 23:33:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// check on valid node in case a python controller holds a reference to a deleted object
 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-25 06:43:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( GetSGNode ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  GetSGNode ( ) - > GetWorldPosition ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-03 02:16:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  dummy_point ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								const  MT_Point3 &  KX_GameObject : : NodeGetLocalPosition ( )  const  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// check on valid node in case a python controller holds a reference to a deleted object
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( GetSGNode ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  GetSGNode ( ) - > GetLocalPosition ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  dummy_point ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/* Suspend/ resume: for the dynamic behaviour, there is a simple
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  method .  For  the  residual  motion ,  there  is  not .  I  wonder  what  the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  correct  solution  is  for  Sumo .  Remove  from  the  motion - update  tree ? 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  So  far ,  only  switch  the  physics  and  logic . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject : : Resume ( void )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_suspended )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SCA_IObject : : Resume ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-05 14:01:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if ( GetPhysicsController ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											GetPhysicsController ( ) - > RestoreDynamics ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_suspended  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-07-18 14:40:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : Suspend ( )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ( ! m_ignore_activity_culling )  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										& &  ( ! m_suspended ) )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SCA_IObject : : Suspend ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-05 14:01:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if ( GetPhysicsController ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											GetPhysicsController ( ) - > SuspendDynamics ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										m_suspended  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  void  walk_children ( SG_Node *  node ,  CListValue *  list ,  bool  recursive )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! node ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NodeList &  children  =  node - > GetSGChildren ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( NodeList : : iterator  childit  =  children . begin ( ) ; ! ( childit = = children . end ( ) ) ; + + childit ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SG_Node *  childnode  =  ( * childit ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CValue *  childobj  =  ( CValue * ) childnode - > GetSGClientObject ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( childobj  ! =  NULL )  // This is a GameObject
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// add to the list
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											list - > Add ( childobj - > AddRef ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// if the childobj is NULL then this may be an inverse parent link
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// so a non recursive search should still look down this node.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( recursive  | |  childobj = = NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											walk_children ( childnode ,  list ,  recursive ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								CListValue *  KX_GameObject : : GetChildren ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CListValue *  list  =  new  CListValue ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									walk_children ( GetSGNode ( ) ,  list ,  0 ) ;  /* GetSGNode() is always valid or it would have raised an exception before this */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  list ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								CListValue *  KX_GameObject : : GetChildrenRecursive ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CListValue *  list  =  new  CListValue ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									walk_children ( GetSGNode ( ) ,  list ,  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  list ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-09-29 21:42:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/* ---------------------------------------------------------------------
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Some  stuff  taken  from  the  header 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-06 20:18:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  KX_GameObject : : Relink ( CTR_Map < CTR_HashedPtr ,  void * >  * map_parameter )  
						 
					
						
							
								
									
										
										
										
											2009-09-29 21:42:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// we will relink the sensors and actuators that use object references
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// if the object is part of the replicated hierarchy, use the new
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// object reference instead
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SCA_SensorList &  sensorlist  =  GetSensors ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SCA_SensorList : : iterator  sit ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( sit = sensorlist . begin ( ) ;  sit  ! =  sensorlist . end ( ) ;  sit + + ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										( * sit ) - > Relink ( map_parameter ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SCA_ActuatorList &  actuatorlist  =  GetActuators ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SCA_ActuatorList : : iterator  ait ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  ( ait = actuatorlist . begin ( ) ;  ait  ! =  actuatorlist . end ( ) ;  ait + + ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										( * ait ) - > Relink ( map_parameter ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef USE_MATHUTILS 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* These require an SGNode */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# define MATHUTILS_VEC_CB_POS_LOCAL 1 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# define MATHUTILS_VEC_CB_POS_GLOBAL 2 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# define MATHUTILS_VEC_CB_SCALE_LOCAL 3 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# define MATHUTILS_VEC_CB_SCALE_GLOBAL 4 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# define MATHUTILS_VEC_CB_INERTIA_LOCAL 5 
  
						 
					
						
							
								
									
										
										
										
											2010-01-16 23:53:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# define MATHUTILS_VEC_CB_OBJECT_COLOR 6 
  
						 
					
						
							
								
									
										
										
										
											2010-02-12 03:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# define MATHUTILS_VEC_CB_LINVEL_LOCAL 7 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# define MATHUTILS_VEC_CB_LINVEL_GLOBAL 8 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# define MATHUTILS_VEC_CB_ANGVEL_LOCAL 9 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# define MATHUTILS_VEC_CB_ANGVEL_GLOBAL 10 
  
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  int  mathutils_kxgameob_vector_cb_index =  - 1 ;  /* index for our callbacks */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-04-26 21:04:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  int  mathutils_kxgameob_generic_check ( BaseMathObject  * bmo )  
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2010-04-26 21:04:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > BGE_PROXY_REF ( bmo - > cb_user ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( self = = NULL ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  int  mathutils_kxgameob_vector_get ( BaseMathObject  * bmo ,  int  subtype )  
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2010-04-26 21:04:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > BGE_PROXY_REF ( bmo - > cb_user ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( self = = NULL ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-12-06 08:29:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# define PHYS_ERR(attr) PyErr_SetString(PyExc_AttributeError, "KX_GameObject." attr ", is missing a physics controller") 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									switch ( subtype )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_POS_LOCAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeGetLocalPosition ( ) . getValue ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_POS_GLOBAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeGetWorldPosition ( ) . getValue ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_SCALE_LOCAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeGetLocalScaling ( ) . getValue ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_SCALE_GLOBAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeGetWorldScaling ( ) . getValue ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_INERTIA_LOCAL : 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if ( ! self - > GetPhysicsController ( ) )  return  PHYS_ERR ( " localInertia " ) ,  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > GetPhysicsController ( ) - > GetLocalInertia ( ) . getValue ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-16 23:53:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_OBJECT_COLOR : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > GetObjectColor ( ) . getValue ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-16 23:53:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-02-12 03:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_LINVEL_LOCAL : 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if ( ! self - > GetPhysicsController ( ) )  return  PHYS_ERR ( " localLinearVelocity " ) ,  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > GetLinearVelocity ( true ) . getValue ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-02-12 03:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_LINVEL_GLOBAL : 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if ( ! self - > GetPhysicsController ( ) )  return  PHYS_ERR ( " worldLinearVelocity " ) ,  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > GetLinearVelocity ( false ) . getValue ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-02-12 03:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_ANGVEL_LOCAL : 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if ( ! self - > GetPhysicsController ( ) )  return  PHYS_ERR ( " localLinearVelocity " ) ,  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > GetAngularVelocity ( true ) . getValue ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-02-12 03:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_ANGVEL_GLOBAL : 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if ( ! self - > GetPhysicsController ( ) )  return  PHYS_ERR ( " worldLinearVelocity " ) ,  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > GetAngularVelocity ( false ) . getValue ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-02-12 03:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2010-12-06 08:29:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# undef PHYS_ERR 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  int  mathutils_kxgameob_vector_set ( BaseMathObject  * bmo ,  int  subtype )  
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2010-04-26 21:04:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > BGE_PROXY_REF ( bmo - > cb_user ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( self = = NULL ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									switch ( subtype )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_POS_LOCAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeSetLocalPosition ( MT_Point3 ( bmo - > data ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeUpdateGS ( 0.f ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_POS_GLOBAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeSetWorldPosition ( MT_Point3 ( bmo - > data ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeUpdateGS ( 0.f ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_SCALE_LOCAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeSetLocalScale ( MT_Point3 ( bmo - > data ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeUpdateGS ( 0.f ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_SCALE_GLOBAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-06-14 01:41:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyErr_SetString ( PyExc_AttributeError ,  " KX_GameObject.worldScale is read-only " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_INERTIA_LOCAL : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											/* read only */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-16 23:53:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_OBJECT_COLOR : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > SetObjectColor ( MT_Vector4 ( bmo - > data ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-16 23:53:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-02-12 03:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_LINVEL_LOCAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > setLinearVelocity ( MT_Point3 ( bmo - > data ) , true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-02-12 03:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_LINVEL_GLOBAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > setLinearVelocity ( MT_Point3 ( bmo - > data ) , false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-02-12 03:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_ANGVEL_LOCAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > setAngularVelocity ( MT_Point3 ( bmo - > data ) , true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-02-12 03:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_VEC_CB_ANGVEL_GLOBAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > setAngularVelocity ( MT_Point3 ( bmo - > data ) , false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-02-12 03:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  int  mathutils_kxgameob_vector_get_index ( BaseMathObject  * bmo ,  int  subtype ,  int  index )  
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/* lazy, avoid repeteing the case statement */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-03 08:01:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( mathutils_kxgameob_vector_get ( bmo ,  subtype )  = =  - 1 ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  int  mathutils_kxgameob_vector_set_index ( BaseMathObject  * bmo ,  int  subtype ,  int  index )  
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									float  f =  bmo - > data [ index ] ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/* lazy, avoid repeteing the case statement */ 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-03 08:01:11 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( mathutils_kxgameob_vector_get ( bmo ,  subtype )  = =  - 1 ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									bmo - > data [ index ] =  f ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-06-14 01:41:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  mathutils_kxgameob_vector_set ( bmo ,  subtype ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Mathutils_Callback  mathutils_kxgameob_vector_cb  =  {  
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									mathutils_kxgameob_generic_check , 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									mathutils_kxgameob_vector_get , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									mathutils_kxgameob_vector_set , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									mathutils_kxgameob_vector_get_index , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									mathutils_kxgameob_vector_set_index 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/* Matrix */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# define MATHUTILS_MAT_CB_ORI_LOCAL 1 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# define MATHUTILS_MAT_CB_ORI_GLOBAL 2 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  int  mathutils_kxgameob_matrix_cb_index =  - 1 ;  /* index for our callbacks */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  int  mathutils_kxgameob_matrix_get ( BaseMathObject  * bmo ,  int  subtype )  
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2010-04-26 21:04:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > BGE_PROXY_REF ( bmo - > cb_user ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( self = = NULL ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									switch ( subtype )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_MAT_CB_ORI_LOCAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeGetLocalOrientation ( ) . getValue3x3 ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_MAT_CB_ORI_GLOBAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeGetWorldOrientation ( ) . getValue3x3 ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  int  mathutils_kxgameob_matrix_set ( BaseMathObject  * bmo ,  int  subtype )  
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2010-04-26 21:04:42 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > BGE_PROXY_REF ( bmo - > cb_user ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( self = = NULL ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Matrix3x3  mat3x3 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									switch ( subtype )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_MAT_CB_ORI_LOCAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											mat3x3 . setValue3x3 ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeSetLocalOrientation ( mat3x3 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											self - > NodeUpdateGS ( 0.f ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										case  MATHUTILS_MAT_CB_ORI_GLOBAL : 
							 
						 
					
						
							
								
									
										
										
										
											2010-04-27 19:21:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											mat3x3 . setValue3x3 ( bmo - > data ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											self - > NodeSetLocalOrientation ( mat3x3 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											self - > NodeUpdateGS ( 0.f ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2011-02-28 18:42:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Mathutils_Callback  mathutils_kxgameob_matrix_cb  =  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									mathutils_kxgameob_generic_check , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									mathutils_kxgameob_matrix_get , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									mathutils_kxgameob_matrix_set , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NULL , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NULL 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  KX_GameObject_Mathutils_Callback_Init ( void )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// register mathutils callbacks, ok to run more then once.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									mathutils_kxgameob_vector_cb_index =  Mathutils_RegisterCallback ( & mathutils_kxgameob_vector_cb ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									mathutils_kxgameob_matrix_cb_index =  Mathutils_RegisterCallback ( & mathutils_kxgameob_matrix_cb ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif  // USE_MATHUTILS
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-10-31 04:11:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef WITH_PYTHON 
  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/* ------- python stuff ---------------------------------------------------*/  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PyMethodDef  KX_GameObject : : Methods [ ]  =  {  
						 
					
						
							
								
									
										
										
										
											2008-12-09 04:13:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " applyForce " ,  ( PyCFunction ) 	KX_GameObject : : sPyApplyForce ,  METH_VARARGS } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ " applyTorque " ,  ( PyCFunction ) 	KX_GameObject : : sPyApplyTorque ,  METH_VARARGS } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ " applyRotation " ,  ( PyCFunction ) 	KX_GameObject : : sPyApplyRotation ,  METH_VARARGS } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ " applyMovement " ,  ( PyCFunction ) 	KX_GameObject : : sPyApplyMovement ,  METH_VARARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2004-05-26 12:06:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " getLinearVelocity " ,  ( PyCFunction )  KX_GameObject : : sPyGetLinearVelocity ,  METH_VARARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-03 01:34:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " setLinearVelocity " ,  ( PyCFunction )  KX_GameObject : : sPySetLinearVelocity ,  METH_VARARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-27 03:34:53 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " getAngularVelocity " ,  ( PyCFunction )  KX_GameObject : : sPyGetAngularVelocity ,  METH_VARARGS } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ " setAngularVelocity " ,  ( PyCFunction )  KX_GameObject : : sPySetAngularVelocity ,  METH_VARARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2004-05-26 12:06:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " getVelocity " ,  ( PyCFunction )  KX_GameObject : : sPyGetVelocity ,  METH_VARARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " getReactionForce " ,  ( PyCFunction )  KX_GameObject : : sPyGetReactionForce ,  METH_NOARGS } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ " alignAxisToVect " , ( PyCFunction )  KX_GameObject : : sPyAlignAxisToVect ,  METH_VARARGS } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ " getAxisVect " , ( PyCFunction )  KX_GameObject : : sPyGetAxisVect ,  METH_O } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ " suspendDynamics " ,  ( PyCFunction ) KX_GameObject : : sPySuspendDynamics , METH_NOARGS } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ " restoreDynamics " ,  ( PyCFunction ) KX_GameObject : : sPyRestoreDynamics , METH_NOARGS } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ " enableRigidBody " ,  ( PyCFunction ) KX_GameObject : : sPyEnableRigidBody , METH_NOARGS } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ " disableRigidBody " ,  ( PyCFunction ) KX_GameObject : : sPyDisableRigidBody , METH_NOARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ " applyImpulse " ,  ( PyCFunction )  KX_GameObject : : sPyApplyImpulse ,  METH_VARARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " setCollisionMargin " ,  ( PyCFunction )  KX_GameObject : : sPySetCollisionMargin ,  METH_O } , 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: user control to compound shape and setParent.
Compound shape control
======================
1) GUI control
It is now possible to control which child shape is added to 
a parent compound shape in the Physics buttons. The "Compound"
shape button becomes "Add to parent" on child objects and
determines whether the child shape is to be added to the top
parent compound shape when the game is stated.
Notes: * "Compound" is only available to top parent objects
         (objects without parent).
       * Nesting of compound shape is not possible: a child
         object with "Add to parent" button set will be added
         to the top parent compound shape, regardless of its
         position in the parent-child hierarchy and even if its
         immediate parent doesn't have the "Add to parent" button set.
2) runtime control
It is now possible to control the compound shape at runtime:
The SetParent actuator has a new "Compound" button that indicates
whether the object shape should be added to the compound shape
of the parent object, provided the parent has a compound shape
of course. If not, the object retain it's individual state
while parented.
Similarly, the KX_GameObject.setParent() python function has
a new compound parameter.
Notes: * When an object is dynamically added to a compound 
         shape, it looses temporarily all its physics capability
         to the benefit of the parent: it cannot register collisions
         and the characteristics of its shape are lost (ghost, sensor,
         dynamic, etc.). 
       * Nested compound shape is not supported: if the object
         being parented is already a compound shape, it is not
         added to the compound parent (as if the Compound option 
         was not set in the actuator or the setParent function).
       * To ensure compatibility with old blend files, the Blender
         subversion is changed to 2.48.5 and the old blend files
         are automatically converted to match the old behavior: 
         all children of a Compound object will have the "Add to
         parent" button set automatically.
Child ghost control
===================
It is now possible to control if an object should becomes ghost
or solid when parented. This is only applicable if the object
is not added to the parent compound shape (see above).
A new "Ghost" button is available on the SetParent actuator to 
that effect. Similarly the KX_GameObject.setParent() python function
has a new compound parameter.
Notes: * This option is not applicable to sensor objects: they stay
         ghost all the time.
       * Make sure the child object does not enter in collision with
         the parent shape when the Ghost option if off and the parent is
         dynamic: the collision creates a reaction force but the parent
         cannot escape the child, so the force builds up and produces
         eratic movements.
       * The collision capability of an ordinary object (dynamic or static)
         is limited when it is parented: it becomes automatically static
         and can only detect dynamic and sensor objects.
       * A sensor object retain its full collision capability when parented:
         it can detect static and dynamic object.
Python control
==============
KX_GameObject.setParent(parent,compound,ghost):
	Sets this object's parent. 
	Control the shape status with the optional compound and ghost parameters:
	compound=1: the object shape should be added to the parent compound shape (default)
	compound=0: the object should keep its individual shape. 
	In that case you can control if it should be ghost or not:
	ghost=1 if the object should be made ghost while parented (default)
	ghost=0 if the object should be solid while parented 
	Note: if the object type is sensor, it stays ghost regardless of ghost parameter
		
	parent: KX_GameObject reference or string (object name w/o OB prefix)
											 
										 
										
											2009-05-21 13:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " setParent " ,  ( PyCFunction ) KX_GameObject : : sPySetParent , METH_VARARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " setVisible " , ( PyCFunction )  KX_GameObject : : sPySetVisible ,  METH_VARARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-13 20:08:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " setOcclusion " , ( PyCFunction )  KX_GameObject : : sPySetOcclusion ,  METH_VARARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " removeParent " ,  ( PyCFunction ) KX_GameObject : : sPyRemoveParent , METH_NOARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2009-08-25 22:51:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " getPhysicsId " ,  ( PyCFunction ) KX_GameObject : : sPyGetPhysicsId , METH_NOARGS } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ " getPropertyNames " ,  ( PyCFunction ) KX_GameObject : : sPyGetPropertyNames , METH_NOARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2009-07-26 01:32:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " replaceMesh " , ( PyCFunction )  KX_GameObject : : sPyReplaceMesh ,  METH_VARARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " endObject " , ( PyCFunction )  KX_GameObject : : sPyEndObject ,  METH_NOARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2009-07-25 22:57:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ " reinstancePhysicsMesh " ,  ( PyCFunction ) KX_GameObject : : sPyReinstancePhysicsMesh , METH_VARARGS } , 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYMETHODTABLE ( KX_GameObject ,  rayCastTo ) , 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 22:50:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYMETHODTABLE ( KX_GameObject ,  rayCast ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYMETHODTABLE_O ( KX_GameObject ,  getDistanceTo ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYMETHODTABLE_O ( KX_GameObject ,  getVectTo ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-08 16:57:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYMETHODTABLE ( KX_GameObject ,  sendMessage ) , 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYMETHODTABLE_KEYWORDS ( KX_GameObject ,  playAction ) , 
							 
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYMETHODTABLE ( KX_GameObject ,  stopAction ) , 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-23 22:44:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYMETHODTABLE ( KX_GameObject ,  getActionFrame ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYMETHODTABLE ( KX_GameObject ,  setActionFrame ) , 
							 
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYMETHODTABLE ( KX_GameObject ,  isPlayingAction ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-26 16:15:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// dict style access for props
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ " get " , ( PyCFunction )  KX_GameObject : : sPyget ,  METH_VARARGS } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ NULL , NULL }  //Sentinel
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-02-26 09:04:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyAttributeDef  KX_GameObject : : Attributes [ ]  =  {  
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RO_FUNCTION ( " name " , 		KX_GameObject ,  pyattr_get_name ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RO_FUNCTION ( " parent " , 	KX_GameObject ,  pyattr_get_parent ) , 
							 
						 
					
						
							
								
									
										
										
										
											2010-10-11 10:47:20 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RO_FUNCTION ( " life " , 		KX_GameObject ,  pyattr_get_life ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " mass " , 		KX_GameObject ,  pyattr_get_mass , 		pyattr_set_mass ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-14 12:34:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " linVelocityMin " , 		KX_GameObject ,  pyattr_get_lin_vel_min ,  pyattr_set_lin_vel_min ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " linVelocityMax " , 		KX_GameObject ,  pyattr_get_lin_vel_max ,  pyattr_set_lin_vel_max ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " visible " , 	KX_GameObject ,  pyattr_get_visible , 	pyattr_set_visible ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-13 20:08:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_BOOL_RW     ( " occlusion " ,  KX_GameObject ,  m_bOccluder ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " position " , 	KX_GameObject ,  pyattr_get_worldPosition , 	pyattr_set_localPosition ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-08 16:25:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RO_FUNCTION ( " localInertia " , 	KX_GameObject ,  pyattr_get_localInertia ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " orientation " , KX_GameObject , pyattr_get_worldOrientation , pyattr_set_localOrientation ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " scaling " , 	KX_GameObject ,  pyattr_get_worldScaling , 	pyattr_set_localScaling ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " timeOffset " , KX_GameObject ,  pyattr_get_timeOffset , pyattr_set_timeOffset ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " state " , 		KX_GameObject ,  pyattr_get_state , 	pyattr_set_state ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-04 15:54:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RO_FUNCTION ( " meshes " , 	KX_GameObject ,  pyattr_get_meshes ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " localOrientation " , KX_GameObject , pyattr_get_localOrientation , pyattr_set_localOrientation ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-25 07:17:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " worldOrientation " , KX_GameObject , pyattr_get_worldOrientation , pyattr_set_worldOrientation ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " localPosition " , 	KX_GameObject ,  pyattr_get_localPosition , 	pyattr_set_localPosition ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " worldPosition " , 	KX_GameObject ,  pyattr_get_worldPosition ,     pyattr_set_worldPosition ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-15 03:26:53 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " localScale " , 	KX_GameObject ,  pyattr_get_localScaling , 	pyattr_set_localScaling ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RO_FUNCTION ( " worldScale " , 	KX_GameObject ,  pyattr_get_worldScaling ) , 
							 
						 
					
						
							
								
									
										
										
										
											2010-02-12 03:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " linearVelocity " ,  KX_GameObject ,  pyattr_get_localLinearVelocity ,  pyattr_set_worldLinearVelocity ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " localLinearVelocity " ,  KX_GameObject ,  pyattr_get_localLinearVelocity ,  pyattr_set_localLinearVelocity ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " worldLinearVelocity " ,  KX_GameObject ,  pyattr_get_worldLinearVelocity ,  pyattr_set_worldLinearVelocity ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " angularVelocity " ,  KX_GameObject ,  pyattr_get_localAngularVelocity ,  pyattr_set_worldAngularVelocity ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " localAngularVelocity " ,  KX_GameObject ,  pyattr_get_localAngularVelocity ,  pyattr_set_localAngularVelocity ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " worldAngularVelocity " ,  KX_GameObject ,  pyattr_get_worldAngularVelocity ,  pyattr_set_worldAngularVelocity ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-17 16:30:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RO_FUNCTION ( " children " , 	KX_GameObject ,  pyattr_get_children ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RO_FUNCTION ( " childrenRecursive " , 	KX_GameObject ,  pyattr_get_children_recursive ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-07 14:53:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RO_FUNCTION ( " attrDict " , 	KX_GameObject ,  pyattr_get_attrDict ) , 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-30 21:59:20 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RW_FUNCTION ( " color " ,  KX_GameObject ,  pyattr_get_obcolor ,  pyattr_set_obcolor ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-05 08:48:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/* Experemental, dont rely on these yet */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RO_FUNCTION ( " sensors " , 		KX_GameObject ,  pyattr_get_sensors ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RO_FUNCTION ( " controllers " , 	KX_GameObject ,  pyattr_get_controllers ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_PYATTRIBUTE_RO_FUNCTION ( " actuators " , 		KX_GameObject ,  pyattr_get_actuators ) , 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ NULL }  //Sentinel
 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-26 09:04:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-07-26 01:32:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyReplaceMesh ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2008-10-27 15:47:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-10-31 21:06:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_Scene  * scene  =  KX_GetActiveScene ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-07-26 01:32:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject  * value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  use_gfx =  1 ,  use_phys =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									RAS_MeshObject  * new_mesh ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTuple ( args , " O|ii:replaceMesh " ,  & value ,  & use_gfx ,  & use_phys ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-27 15:47:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-04-20 09:13:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! ConvertPythonToMesh ( value ,  & new_mesh ,  false ,  " gameOb.replaceMesh(value): KX_GameObject " ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-27 15:47:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-07-26 01:32:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									scene - > ReplaceMesh ( this ,  new_mesh ,  ( bool ) use_gfx ,  ( bool ) use_phys ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-10-27 15:47:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyEndObject ( )  
						 
					
						
							
								
									
										
										
										
											2008-06-27 11:35:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-10-31 21:06:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_Scene  * scene  =  KX_GetActiveScene ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-28 13:11:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2008-06-27 11:35:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									scene - > DelayedRemoveObject ( this ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 05:06:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-27 11:35:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-07-25 22:57:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyReinstancePhysicsMesh ( PyObject *  args )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject  * gameobj =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									RAS_MeshObject  * mesh =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject  * gameobj_py =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject  * mesh_py =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( 	! PyArg_ParseTuple ( args , " |OO:reinstancePhysicsMesh " , & gameobj_py ,  & mesh_py )  | | 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											( gameobj_py  & &  ! ConvertPythonToGameObject ( gameobj_py ,  & gameobj ,  true ,  " gameOb.reinstancePhysicsMesh(obj, mesh): KX_GameObject " ) )  | |  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											( mesh_py  & &  ! ConvertPythonToMesh ( mesh_py ,  & mesh ,  true ,  " gameOb.reinstancePhysicsMesh(obj, mesh): KX_GameObject " ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										)  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2010-10-10 07:01:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef USE_BULLET 
  
						 
					
						
							
								
									
										
										
										
											2009-07-25 22:57:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									/* gameobj and mesh can be NULL */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if ( KX_ReInstanceBulletShapeFromMesh ( this ,  gameobj ,  mesh ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Py_RETURN_TRUE ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-10-10 07:01:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
									
										
										
										
											2009-07-25 22:57:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Py_RETURN_FALSE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-12 12:56:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  PyObject  * Map_GetItem ( PyObject  * self_v ,  PyObject  * item )  
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > BGE_PROXY_REF ( self_v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-29 02:25:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  char  * attr_str =  _PyUnicode_AsString ( item ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CValue *  resultattr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  pyconvert ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( self = = NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-12 12:56:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyErr_SetString ( PyExc_SystemError ,  " val = gameOb[key]: KX_GameObject,  " BGE_PROXY_ERROR_MSG ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 10:57:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 10:57:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									/* first see if the attributes a string and try get the cvalue attribute */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if ( attr_str  & &  ( resultattr = self - > GetProperty ( attr_str ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										pyconvert  =  resultattr - > ConvertValueToPython ( ) ; 			
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  pyconvert  ?  pyconvert : resultattr - > GetProxy ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-17 20:06:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									/* no CValue attribute, try get the python only m_attr_dict attribute */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else  if  ( self - > m_attr_dict  & &  ( pyconvert = PyDict_GetItem ( self - > m_attr_dict ,  item ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( attr_str ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											PyErr_Clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Py_INCREF ( pyconvert ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  pyconvert ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 21:01:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if ( attr_str ) 	PyErr_Format ( PyExc_KeyError ,  " value = gameOb[key]: KX_GameObject, key  \" %s \"  does not exist " ,  attr_str ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										else 			PyErr_SetString ( PyExc_KeyError ,  " value = gameOb[key]: KX_GameObject, key does not exist " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-12 12:56:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  int  Map_SetItem ( PyObject  * self_v ,  PyObject  * key ,  PyObject  * val )  
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > BGE_PROXY_REF ( self_v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-29 02:25:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  char  * attr_str =  _PyUnicode_AsString ( key ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( attr_str = = NULL ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										PyErr_Clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( self = = NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-12 12:56:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyErr_SetString ( PyExc_SystemError ,  " gameOb[key] = value: KX_GameObject,  " BGE_PROXY_ERROR_MSG ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 10:57:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  - 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 10:57:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( val = = NULL )  {  /* del ob["key"] */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										int  del =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										/* try remove both just incase */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if ( attr_str ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											del  | =  ( self - > RemoveProperty ( attr_str ) = = true )  ?  1 : 0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
									
										
										
										
											2009-04-17 20:06:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if ( self - > m_attr_dict ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											del  | =  ( PyDict_DelItem ( self - > m_attr_dict ,  key ) = = 0 )  ?  1 : 0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( del = = 0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 21:01:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if ( attr_str ) 	PyErr_Format ( PyExc_KeyError ,  " gameOb[key] = value: KX_GameObject, key  \" %s \"  could not be set " ,  attr_str ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-26 07:41:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											else 			PyErr_SetString ( PyExc_KeyError ,  " del gameOb[key]: KX_GameObject, key could not be deleted " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-17 20:06:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										else  if  ( self - > m_attr_dict )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyErr_Clear ( ) ;  /* PyDict_DelItem sets an error when it fails */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else  {  /* ob["key"] = value */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										int  set =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										/* as CValue */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-29 12:06:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if ( attr_str  & &  PyObject_TypeCheck ( val ,  & PyObjectPlus : : Type ) = = 0 )  /* dont allow GameObjects for eg to be assigned to CValue props */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-23 00:32:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											CValue *  vallie  =  self - > ConvertPythonToValue ( val ,  " " ) ;  /* error unused */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if ( vallie ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												CValue *  oldprop  =  self - > GetProperty ( attr_str ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( oldprop ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													oldprop - > SetValue ( vallie ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													self - > SetProperty ( attr_str ,  vallie ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												vallie - > Release ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												set =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												/* try remove dict value to avoid double ups */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-17 20:06:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  ( self - > m_attr_dict ) { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													if  ( PyDict_DelItem ( self - > m_attr_dict ,  key )  ! =  0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
														PyErr_Clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												PyErr_Clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if ( set = = 0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-17 20:06:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( self - > m_attr_dict = = NULL )  /* lazy init */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												self - > m_attr_dict =  PyDict_New ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											
							 
						 
					
						
							
								
									
										
										
										
											2009-04-17 20:06:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if ( PyDict_SetItem ( self - > m_attr_dict ,  key ,  val ) = = 0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if ( attr_str ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													self - > RemoveProperty ( attr_str ) ;  /* overwrite the CValue if it exists */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												set =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											else  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 21:01:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if ( attr_str ) 	PyErr_Format ( PyExc_KeyError ,  " gameOb[key] = value: KX_GameObject, key  \" %s \"  not be added to internal dictionary " ,  attr_str ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												else 			PyErr_SetString ( PyExc_KeyError ,  " gameOb[key] = value: KX_GameObject, key not be added to internal dictionary " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if ( set = = 0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  - 1 ;  /* pythons error value */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  0 ;  /* success */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-12 12:56:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  int  Seq_Contains ( PyObject  * self_v ,  PyObject  * value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > BGE_PROXY_REF ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( self = = NULL )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										PyErr_SetString ( PyExc_SystemError ,  " val in gameOb: KX_GameObject,  " BGE_PROXY_ERROR_MSG ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  - 1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-06-29 02:25:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( PyUnicode_Check ( value )  & &  self - > GetProperty ( _PyUnicode_AsString ( value ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-12 12:56:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( self - > m_attr_dict  & &  PyDict_GetItem ( self - > m_attr_dict ,  value ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyMappingMethods  KX_GameObject : : Mapping  =  {  
						 
					
						
							
								
									
										
										
										
											2009-04-22 20:43:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									( lenfunc ) NULL 					,  			/*inquiry mp_length */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-12 12:56:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									( binaryfunc ) Map_GetItem , 		/*binaryfunc mp_subscript */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									( objobjargproc ) Map_SetItem , 	/*objobjargproc mp_ass_subscript */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PySequenceMethods  KX_GameObject : : Sequence  =  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NULL , 		/* Cant set the len otherwise it can evaluate as false */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NULL , 		/* sq_concat */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NULL , 		/* sq_repeat */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NULL , 		/* sq_item */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NULL , 		/* sq_slice */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NULL , 		/* sq_ass_item */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NULL , 		/* sq_ass_slice */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									( objobjproc ) Seq_Contains , 	/* sq_contains */ 
							 
						 
					
						
							
								
									
										
										
										
											2010-05-16 10:09:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									( binaryfunc )  NULL ,  /* sq_inplace_concat */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									( ssizeargfunc )  NULL ,  /* sq_inplace_repeat */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-02 05:38:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								PyTypeObject  KX_GameObject : : Type  =  {  
						 
					
						
							
								
									
										
										
										
											2009-04-29 16:54:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PyVarObject_HEAD_INIT ( NULL ,  0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-08-10 00:07:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									" KX_GameObject " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									sizeof ( PyObjectPlus_Proxy ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									py_base_dealloc , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									py_base_repr , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									& Sequence , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									& Mapping , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									0 , 0 , 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NULL , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									NULL , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_TPFLAGS_DEFAULT  |  Py_TPFLAGS_BASETYPE , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									0 , 0 , 0 , 0 , 0 , 0 , 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Methods , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									& SCA_IObject : : Type , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									0 , 0 , 0 , 0 , 0 , 0 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									py_base_new 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_name ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-29 02:25:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PyUnicode_FromString ( self - > GetName ( ) . ReadPtr ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_parent ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  parent  =  self - > GetParent ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-09 16:29:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( parent )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										parent - > Release ( ) ;  /* self->GetParent() AddRef's */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  parent - > GetProxy ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-09 16:29:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-10-11 10:47:20 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_life ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CValue  * life  =  self - > GetProperty ( " ::timebomb " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( life ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// this convert the timebomb seconds to frames, hard coded 50.0 (assuming 50fps)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// value hardcoded in KX_Scene::AddReplicaObject()
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PyFloat_FromDouble ( life - > GetNumber ( )  *  50.0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_mass ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_IPhysicsController  * spc  =  self - > GetPhysicsController ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PyFloat_FromDouble ( spc  ?  spc - > GetMass ( )  :  0.0f ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_mass ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_IPhysicsController  * spc  =  self - > GetPhysicsController ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Scalar  val  =  PyFloat_AsDouble ( value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( val  <  0.0f )  {  /* also accounts for non float */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 21:01:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyErr_SetString ( PyExc_AttributeError ,  " gameOb.mass = float: KX_GameObject, expected a float zero or above " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-05-26 12:06:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( spc ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										spc - > SetMass ( val ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-17 05:28:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-14 12:34:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_lin_vel_min ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_IPhysicsController  * spc  =  self - > GetPhysicsController ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PyFloat_FromDouble ( spc  ?  spc - > GetLinVelocityMax ( )  :  0.0f ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_lin_vel_min ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_IPhysicsController  * spc  =  self - > GetPhysicsController ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Scalar  val  =  PyFloat_AsDouble ( value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( val  <  0.0f )  {  /* also accounts for non float */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 21:01:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyErr_SetString ( PyExc_AttributeError ,  " gameOb.linVelocityMin = float: KX_GameObject, expected a float zero or above " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-14 12:34:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( spc ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										spc - > SetLinVelocityMin ( val ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-14 12:34:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_lin_vel_max ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_IPhysicsController  * spc  =  self - > GetPhysicsController ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PyFloat_FromDouble ( spc  ?  spc - > GetLinVelocityMax ( )  :  0.0f ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_lin_vel_max ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_IPhysicsController  * spc  =  self - > GetPhysicsController ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Scalar  val  =  PyFloat_AsDouble ( value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( val  <  0.0f )  {  /* also accounts for non float */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 21:01:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyErr_SetString ( PyExc_AttributeError ,  " gameOb.linVelocityMax = float: KX_GameObject, expected a float zero or above " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-14 12:34:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( spc ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										spc - > SetLinVelocityMax ( val ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-14 12:34:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_visible ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PyBool_FromLong ( self - > GetVisible ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_visible ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  param  =  PyObject_IsTrue (  value  ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( param  = =  - 1 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 21:01:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyErr_SetString ( PyExc_AttributeError ,  " gameOb.visible = bool: KX_GameObject, expected True or False " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-14 17:12:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									self - > SetVisible ( param ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									self - > UpdateBuckets ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_worldPosition ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef USE_MATHUTILS 
  
						 
					
						
							
								
									
										
										
										
											2009-08-27 16:34:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  newVectorObject_cb ( BGE_PROXY_FROM_REF ( self_v ) ,  3 ,  mathutils_kxgameob_vector_cb_index ,  MATHUTILS_VEC_CB_POS_GLOBAL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# else 
  
						 
					
						
							
								
									
										
										
										
											2009-08-19 10:26:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PyObjectFrom ( self - > NodeGetWorldPosition ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_worldPosition ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Point3  pos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyVecTo ( value ,  pos ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									self - > NodeSetWorldPosition ( pos ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									self - > NodeUpdateGS ( 0.f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_localPosition ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef USE_MATHUTILS	 
  
						 
					
						
							
								
									
										
										
										
											2009-08-27 16:34:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  newVectorObject_cb ( BGE_PROXY_FROM_REF ( self_v ) ,  3 ,  mathutils_kxgameob_vector_cb_index ,  MATHUTILS_VEC_CB_POS_LOCAL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# else	 
  
						 
					
						
							
								
									
										
										
										
											2009-08-19 10:26:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PyObjectFrom ( self - > NodeGetLocalPosition ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_localPosition ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
									
										
										
										
											2004-05-26 12:06:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Point3  pos ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyVecTo ( value ,  pos ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-05-26 12:06:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									self - > NodeSetLocalPosition ( pos ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									self - > NodeUpdateGS ( 0.f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-08 16:25:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_localInertia ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef USE_MATHUTILS 
  
						 
					
						
							
								
									
										
										
										
											2009-08-27 16:34:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  newVectorObject_cb ( BGE_PROXY_FROM_REF ( self_v ) ,  3 ,  mathutils_kxgameob_vector_cb_index ,  MATHUTILS_VEC_CB_INERTIA_LOCAL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# else 
  
						 
					
						
							
								
									
										
										
										
											2009-08-19 10:26:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-08 16:25:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( self - > GetPhysicsController ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PyObjectFrom ( self - > GetPhysicsController ( ) - > GetLocalInertia ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-08 17:40:09 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  Py_BuildValue ( " fff " ,  0.0f ,  0.0f ,  0.0f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
									
										
										
										
											2009-04-08 16:25:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_worldOrientation ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef USE_MATHUTILS 
  
						 
					
						
							
								
									
										
										
										
											2009-08-27 16:34:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  newMatrixObject_cb ( BGE_PROXY_FROM_REF ( self_v ) ,  3 ,  3 ,  mathutils_kxgameob_matrix_cb_index ,  MATHUTILS_MAT_CB_ORI_GLOBAL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# else 
  
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PyObjectFrom ( self - > NodeGetWorldOrientation ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-25 07:17:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_worldOrientation ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/* if value is not a sequence PyOrientationTo makes an error */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Matrix3x3  rot ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyOrientationTo ( value ,  rot ,  " gameOb.worldOrientation = sequence: KX_GameObject,  " ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-25 07:17:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-06-25 10:11:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									self - > NodeSetGlobalOrientation ( rot ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-25 07:17:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									self - > NodeUpdateGS ( 0.f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-25 07:17:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_localOrientation ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef USE_MATHUTILS 
  
						 
					
						
							
								
									
										
										
										
											2009-08-27 16:34:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  newMatrixObject_cb ( BGE_PROXY_FROM_REF ( self_v ) ,  3 ,  3 ,  mathutils_kxgameob_matrix_cb_index ,  MATHUTILS_MAT_CB_ORI_LOCAL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# else 
  
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-23 13:34:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PyObjectFrom ( self - > NodeGetLocalOrientation ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_localOrientation ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-20 09:13:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/* if value is not a sequence PyOrientationTo makes an error */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									MT_Matrix3x3  rot ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-25 07:17:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! PyOrientationTo ( value ,  rot ,  " gameOb.localOrientation = sequence: KX_GameObject,  " ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-05 06:08:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-20 09:13:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									self - > NodeSetLocalOrientation ( rot ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									self - > NodeUpdateGS ( 0.f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_worldScaling ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef USE_MATHUTILS 
  
						 
					
						
							
								
									
										
										
										
											2009-08-27 16:34:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  newVectorObject_cb ( BGE_PROXY_FROM_REF ( self_v ) ,  3 ,  mathutils_kxgameob_vector_cb_index ,  MATHUTILS_VEC_CB_SCALE_GLOBAL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# else 
  
						 
					
						
							
								
									
										
										
										
											2009-08-19 10:26:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PyObjectFrom ( self - > NodeGetWorldScaling ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_localScaling ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# ifdef USE_MATHUTILS 
  
						 
					
						
							
								
									
										
										
										
											2009-08-27 16:34:13 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  newVectorObject_cb ( BGE_PROXY_FROM_REF ( self_v ) ,  3 ,  mathutils_kxgameob_vector_cb_index ,  MATHUTILS_VEC_CB_SCALE_LOCAL ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# else 
  
						 
					
						
							
								
									
										
										
										
											2009-08-19 10:26:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-28 11:22:26 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PyObjectFrom ( self - > NodeGetLocalScaling ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-22 04:26:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_localScaling ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Vector3  scale ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyVecTo ( value ,  scale ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									self - > NodeSetLocalScale ( scale ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									self - > NodeUpdateGS ( 0.f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-02-12 03:40:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_worldLinearVelocity ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# ifdef USE_MATHUTILS 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  newVectorObject_cb ( BGE_PROXY_FROM_REF ( self_v ) ,  3 ,  mathutils_kxgameob_vector_cb_index ,  MATHUTILS_VEC_CB_LINVEL_GLOBAL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# else 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PyObjectFrom ( GetLinearVelocity ( false ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_worldLinearVelocity ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Vector3  velocity ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyVecTo ( value ,  velocity ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									self - > setLinearVelocity ( velocity ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_localLinearVelocity ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# ifdef USE_MATHUTILS 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  newVectorObject_cb ( BGE_PROXY_FROM_REF ( self_v ) ,  3 ,  mathutils_kxgameob_vector_cb_index ,  MATHUTILS_VEC_CB_LINVEL_LOCAL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# else 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PyObjectFrom ( GetLinearVelocity ( true ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_localLinearVelocity ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Vector3  velocity ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyVecTo ( value ,  velocity ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									self - > setLinearVelocity ( velocity ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_worldAngularVelocity ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# ifdef USE_MATHUTILS 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  newVectorObject_cb ( BGE_PROXY_FROM_REF ( self_v ) ,  3 ,  mathutils_kxgameob_vector_cb_index ,  MATHUTILS_VEC_CB_ANGVEL_GLOBAL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# else 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PyObjectFrom ( GetAngularVelocity ( false ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_worldAngularVelocity ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Vector3  velocity ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyVecTo ( value ,  velocity ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									self - > setAngularVelocity ( velocity ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_localAngularVelocity ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# ifdef USE_MATHUTILS 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  newVectorObject_cb ( BGE_PROXY_FROM_REF ( self_v ) ,  3 ,  mathutils_kxgameob_vector_cb_index ,  MATHUTILS_VEC_CB_ANGVEL_LOCAL ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# else 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PyObjectFrom ( GetAngularVelocity ( true ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_localAngularVelocity ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Vector3  velocity ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyVecTo ( value ,  velocity ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									self - > setAngularVelocity ( velocity ,  true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_timeOffset ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SG_Node *  sg_parent ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( self - > GetSGNode ( )  & &  ( sg_parent  =  self - > GetSGNode ( ) - > GetSGParent ( ) )  ! =  NULL  & &  sg_parent - > IsSlowParent ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PyFloat_FromDouble ( static_cast < KX_SlowParentRelation  * > ( sg_parent - > GetParentRelation ( ) ) - > GetTimeOffset ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PyFloat_FromDouble ( 0.0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_timeOffset ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( self - > GetSGNode ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Scalar  val  =  PyFloat_AsDouble ( value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										SG_Node *  sg_parent =  self - > GetSGNode ( ) - > GetSGParent ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( val  <  0.0f )  {  /* also accounts for non float */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 21:01:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyErr_SetString ( PyExc_AttributeError ,  " gameOb.timeOffset = float: KX_GameObject, expected a float zero or above " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 21:17:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( sg_parent  & &  sg_parent - > IsSlowParent ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											static_cast < KX_SlowParentRelation  * > ( sg_parent - > GetParentRelation ( ) ) - > SetTimeOffset ( val ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-17 05:28:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_state ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  state  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									state  | =  self - > GetState ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-29 02:25:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PyLong_FromSsize_t ( state ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_state ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-29 02:25:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									int  state_i  =  PyLong_AsSsize_t ( value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									unsigned  int  state  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-17 05:28:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( state_i  = =  - 1  & &  PyErr_Occurred ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 21:01:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyErr_SetString ( PyExc_TypeError ,  " gameOb.state = int: KX_GameObject, expected an int bit field " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-05-26 12:06:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									state  | =  state_i ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ( state  &  ( ( 1 < < 30 ) - 1 ) )  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 21:01:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyErr_SetString ( PyExc_AttributeError ,  " gameOb.state = int: KX_GameObject, state bitfield was not between 0 and 30 (1<<0 and 1<<29) " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									self - > SetState ( state ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-19 07:16:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-24 19:37:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-04 15:54:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_meshes ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject  * meshes =  PyList_New ( self - > m_meshes . size ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  i ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-04-22 09:47:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for ( i = 0 ;  i  <  ( int ) self - > m_meshes . size ( ) ;  i + + ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-04 15:54:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										KX_MeshProxy *  meshproxy  =  new  KX_MeshProxy ( self - > m_meshes [ i ] ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-09 18:18:04 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyList_SET_ITEM ( meshes ,  i ,  meshproxy - > NewProxy ( true ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-04 15:54:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  meshes ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-01-16 23:53:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_obcolor ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# ifdef USE_MATHUTILS 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  newVectorObject_cb ( BGE_PROXY_FROM_REF ( self_v ) ,  4 ,  mathutils_kxgameob_vector_cb_index ,  MATHUTILS_VEC_CB_OBJECT_COLOR ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# else 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PyObjectFrom ( self - > GetObjectColor ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# endif 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								int  KX_GameObject : : pyattr_set_obcolor ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef ,  PyObject  * value )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Vector4  obcolor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyVecTo ( value ,  obcolor ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PY_SET_ATTR_FAIL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									self - > SetObjectColor ( obcolor ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PY_SET_ATTR_SUCCESS ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* These are experimental! */  
						 
					
						
							
								
									
										
										
										
											2009-04-05 08:48:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_sensors ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-05-10 01:48:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  KX_PythonSeq_CreatePyObject ( ( static_cast < KX_GameObject * > ( self_v ) ) - > m_proxy ,  KX_PYGENSEQ_OB_TYPE_SENSORS ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-05 08:48:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_controllers ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-05-10 01:48:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  KX_PythonSeq_CreatePyObject ( ( static_cast < KX_GameObject * > ( self_v ) ) - > m_proxy ,  KX_PYGENSEQ_OB_TYPE_CONTROLLERS ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-05 08:48:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_actuators ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-05-10 01:48:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  KX_PythonSeq_CreatePyObject ( ( static_cast < KX_GameObject * > ( self_v ) ) - > m_proxy ,  KX_PYGENSEQ_OB_TYPE_ACTUATORS ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-05 08:48:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2010-01-16 23:53:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/* End experimental */  
						 
					
						
							
								
									
										
										
										
											2009-04-05 08:48:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-05-17 16:30:18 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_children ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  self - > GetChildren ( ) - > NewProxy ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_children_recursive ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  self - > GetChildrenRecursive ( ) - > NewProxy ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-05-07 14:53:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : pyattr_get_attrDict ( void  * self_v ,  const  KX_PYATTRIBUTE_DEF  * attrdef )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject *  self =  static_cast < KX_GameObject * > ( self_v ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if ( self - > m_attr_dict = = NULL ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										self - > m_attr_dict =  PyDict_New ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( self - > m_attr_dict ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  self - > m_attr_dict ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyApplyForce ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2008-12-09 04:13:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  local  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  pyvect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( PyArg_ParseTuple ( args ,  " O|i:applyForce " ,  & pyvect ,  & local ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-09 04:13:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										MT_Vector3  force ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( PyVecTo ( pyvect ,  force ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ApplyForce ( force ,  ( local ! = 0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyApplyTorque ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2008-12-09 04:13:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  local  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  pyvect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( PyArg_ParseTuple ( args ,  " O|i:applyTorque " ,  & pyvect ,  & local ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-09 04:13:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										MT_Vector3  torque ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( PyVecTo ( pyvect ,  torque ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ApplyTorque ( torque ,  ( local ! = 0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyApplyRotation ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2008-12-09 04:13:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  local  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  pyvect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( PyArg_ParseTuple ( args ,  " O|i:applyRotation " ,  & pyvect ,  & local ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-09 04:13:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										MT_Vector3  rotation ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( PyVecTo ( pyvect ,  rotation ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ApplyRotation ( rotation ,  ( local ! = 0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyApplyMovement ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2008-12-09 04:13:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  local  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  pyvect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( PyArg_ParseTuple ( args ,  " O|i:applyMovement " ,  & pyvect ,  & local ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-12-09 04:13:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										MT_Vector3  movement ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( PyVecTo ( pyvect ,  movement ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ApplyMovement ( movement ,  ( local ! = 0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyGetLinearVelocity ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// only can get the velocity if we have a physics object connected to us...
 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-06 20:55:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									int  local  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( PyArg_ParseTuple ( args , " |i:getLinearVelocity " , & local ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-06 20:55:55 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PyObjectFrom ( GetLinearVelocity ( ( local ! = 0 ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PySetLinearVelocity ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2008-07-03 01:34:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  local  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  pyvect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( PyArg_ParseTuple ( args , " O|i:setLinearVelocity " , & pyvect , & local ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-03 01:34:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										MT_Vector3  velocity ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( PyVecTo ( pyvect ,  velocity ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											setLinearVelocity ( velocity ,  ( local ! = 0 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											Py_RETURN_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-03 01:34:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyGetAngularVelocity ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2008-08-27 03:34:53 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// only can get the velocity if we have a physics object connected to us...
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  local  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( PyArg_ParseTuple ( args , " |i:getAngularVelocity " , & local ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-27 03:34:53 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PyObjectFrom ( GetAngularVelocity ( ( local ! = 0 ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PySetAngularVelocity ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2008-08-27 03:34:53 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  local  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  pyvect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( PyArg_ParseTuple ( args , " O|i:setAngularVelocity " , & pyvect , & local ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-27 03:34:53 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										MT_Vector3  velocity ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( PyVecTo ( pyvect ,  velocity ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											setAngularVelocity ( velocity ,  ( local ! = 0 ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PySetVisible ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-09-05 16:22:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									int  visible ,  recursive  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTuple ( args , " i|i:setVisible " , & visible ,  & recursive ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2008-09-05 16:22:14 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SetVisible ( visible  ?  true : false ,  recursive  ?  true : false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									UpdateBuckets ( recursive  ?  true : false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PySetOcclusion ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2009-04-13 20:08:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  occlusion ,  recursive  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTuple ( args , " i|i:setOcclusion " , & occlusion ,  & recursive ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									SetOccluder ( occlusion  ?  true : false ,  recursive  ?  true : false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyGetVelocity ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// only can get the velocity if we have a physics object connected to us...
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Point3  point ( 0.0 , 0.0 , 0.0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2004-05-26 12:06:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PyObject *  pypos  =  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-25 03:26:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-05-16 00:49:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTuple ( args ,  " |O:getVelocity " ,  & pypos )  | |  ( pypos  & &  ! PyVecTo ( pypos ,  point ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-01 16:43:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-25 03:26:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PyObjectFrom ( m_pPhysicsController1 - > GetVelocity ( point ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PyObjectFrom ( MT_Vector3 ( 0.0 , 0.0 , 0.0 ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyGetReactionForce ( )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// only can get the velocity if we have a physics object connected to us...
 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-05 14:01:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// XXX - Currently not working with bullet intergration, see KX_BulletPhysicsController.cpp's getReactionForce
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									/*
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( GetPhysicsController ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PyObjectFrom ( GetPhysicsController ( ) - > getReactionForce ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PyObjectFrom ( dummy_point ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									*/ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  Py_BuildValue ( " fff " ,  0.0f ,  0.0f ,  0.0f ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyEnableRigidBody ( )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-05 14:01:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( GetPhysicsController ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GetPhysicsController ( ) - > setRigidBody ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyDisableRigidBody ( )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-05 14:01:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( GetPhysicsController ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GetPhysicsController ( ) - > setRigidBody ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: user control to compound shape and setParent.
Compound shape control
======================
1) GUI control
It is now possible to control which child shape is added to 
a parent compound shape in the Physics buttons. The "Compound"
shape button becomes "Add to parent" on child objects and
determines whether the child shape is to be added to the top
parent compound shape when the game is stated.
Notes: * "Compound" is only available to top parent objects
         (objects without parent).
       * Nesting of compound shape is not possible: a child
         object with "Add to parent" button set will be added
         to the top parent compound shape, regardless of its
         position in the parent-child hierarchy and even if its
         immediate parent doesn't have the "Add to parent" button set.
2) runtime control
It is now possible to control the compound shape at runtime:
The SetParent actuator has a new "Compound" button that indicates
whether the object shape should be added to the compound shape
of the parent object, provided the parent has a compound shape
of course. If not, the object retain it's individual state
while parented.
Similarly, the KX_GameObject.setParent() python function has
a new compound parameter.
Notes: * When an object is dynamically added to a compound 
         shape, it looses temporarily all its physics capability
         to the benefit of the parent: it cannot register collisions
         and the characteristics of its shape are lost (ghost, sensor,
         dynamic, etc.). 
       * Nested compound shape is not supported: if the object
         being parented is already a compound shape, it is not
         added to the compound parent (as if the Compound option 
         was not set in the actuator or the setParent function).
       * To ensure compatibility with old blend files, the Blender
         subversion is changed to 2.48.5 and the old blend files
         are automatically converted to match the old behavior: 
         all children of a Compound object will have the "Add to
         parent" button set automatically.
Child ghost control
===================
It is now possible to control if an object should becomes ghost
or solid when parented. This is only applicable if the object
is not added to the parent compound shape (see above).
A new "Ghost" button is available on the SetParent actuator to 
that effect. Similarly the KX_GameObject.setParent() python function
has a new compound parameter.
Notes: * This option is not applicable to sensor objects: they stay
         ghost all the time.
       * Make sure the child object does not enter in collision with
         the parent shape when the Ghost option if off and the parent is
         dynamic: the collision creates a reaction force but the parent
         cannot escape the child, so the force builds up and produces
         eratic movements.
       * The collision capability of an ordinary object (dynamic or static)
         is limited when it is parented: it becomes automatically static
         and can only detect dynamic and sensor objects.
       * A sensor object retain its full collision capability when parented:
         it can detect static and dynamic object.
Python control
==============
KX_GameObject.setParent(parent,compound,ghost):
	Sets this object's parent. 
	Control the shape status with the optional compound and ghost parameters:
	compound=1: the object shape should be added to the parent compound shape (default)
	compound=0: the object should keep its individual shape. 
	In that case you can control if it should be ghost or not:
	ghost=1 if the object should be made ghost while parented (default)
	ghost=0 if the object should be solid while parented 
	Note: if the object type is sensor, it stays ghost regardless of ghost parameter
		
	parent: KX_GameObject reference or string (object name w/o OB prefix)
											 
										 
										
											2009-05-21 13:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PySetParent ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-28 13:11:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_Scene  * scene  =  KX_GetActiveScene ( ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: user control to compound shape and setParent.
Compound shape control
======================
1) GUI control
It is now possible to control which child shape is added to 
a parent compound shape in the Physics buttons. The "Compound"
shape button becomes "Add to parent" on child objects and
determines whether the child shape is to be added to the top
parent compound shape when the game is stated.
Notes: * "Compound" is only available to top parent objects
         (objects without parent).
       * Nesting of compound shape is not possible: a child
         object with "Add to parent" button set will be added
         to the top parent compound shape, regardless of its
         position in the parent-child hierarchy and even if its
         immediate parent doesn't have the "Add to parent" button set.
2) runtime control
It is now possible to control the compound shape at runtime:
The SetParent actuator has a new "Compound" button that indicates
whether the object shape should be added to the compound shape
of the parent object, provided the parent has a compound shape
of course. If not, the object retain it's individual state
while parented.
Similarly, the KX_GameObject.setParent() python function has
a new compound parameter.
Notes: * When an object is dynamically added to a compound 
         shape, it looses temporarily all its physics capability
         to the benefit of the parent: it cannot register collisions
         and the characteristics of its shape are lost (ghost, sensor,
         dynamic, etc.). 
       * Nested compound shape is not supported: if the object
         being parented is already a compound shape, it is not
         added to the compound parent (as if the Compound option 
         was not set in the actuator or the setParent function).
       * To ensure compatibility with old blend files, the Blender
         subversion is changed to 2.48.5 and the old blend files
         are automatically converted to match the old behavior: 
         all children of a Compound object will have the "Add to
         parent" button set automatically.
Child ghost control
===================
It is now possible to control if an object should becomes ghost
or solid when parented. This is only applicable if the object
is not added to the parent compound shape (see above).
A new "Ghost" button is available on the SetParent actuator to 
that effect. Similarly the KX_GameObject.setParent() python function
has a new compound parameter.
Notes: * This option is not applicable to sensor objects: they stay
         ghost all the time.
       * Make sure the child object does not enter in collision with
         the parent shape when the Ghost option if off and the parent is
         dynamic: the collision creates a reaction force but the parent
         cannot escape the child, so the force builds up and produces
         eratic movements.
       * The collision capability of an ordinary object (dynamic or static)
         is limited when it is parented: it becomes automatically static
         and can only detect dynamic and sensor objects.
       * A sensor object retain its full collision capability when parented:
         it can detect static and dynamic object.
Python control
==============
KX_GameObject.setParent(parent,compound,ghost):
	Sets this object's parent. 
	Control the shape status with the optional compound and ghost parameters:
	compound=1: the object shape should be added to the parent compound shape (default)
	compound=0: the object should keep its individual shape. 
	In that case you can control if it should be ghost or not:
	ghost=1 if the object should be made ghost while parented (default)
	ghost=0 if the object should be solid while parented 
	Note: if the object type is sensor, it stays ghost regardless of ghost parameter
		
	parent: KX_GameObject reference or string (object name w/o OB prefix)
											 
										 
										
											2009-05-21 13:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PyObject *  pyobj ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject  * obj ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: user control to compound shape and setParent.
Compound shape control
======================
1) GUI control
It is now possible to control which child shape is added to 
a parent compound shape in the Physics buttons. The "Compound"
shape button becomes "Add to parent" on child objects and
determines whether the child shape is to be added to the top
parent compound shape when the game is stated.
Notes: * "Compound" is only available to top parent objects
         (objects without parent).
       * Nesting of compound shape is not possible: a child
         object with "Add to parent" button set will be added
         to the top parent compound shape, regardless of its
         position in the parent-child hierarchy and even if its
         immediate parent doesn't have the "Add to parent" button set.
2) runtime control
It is now possible to control the compound shape at runtime:
The SetParent actuator has a new "Compound" button that indicates
whether the object shape should be added to the compound shape
of the parent object, provided the parent has a compound shape
of course. If not, the object retain it's individual state
while parented.
Similarly, the KX_GameObject.setParent() python function has
a new compound parameter.
Notes: * When an object is dynamically added to a compound 
         shape, it looses temporarily all its physics capability
         to the benefit of the parent: it cannot register collisions
         and the characteristics of its shape are lost (ghost, sensor,
         dynamic, etc.). 
       * Nested compound shape is not supported: if the object
         being parented is already a compound shape, it is not
         added to the compound parent (as if the Compound option 
         was not set in the actuator or the setParent function).
       * To ensure compatibility with old blend files, the Blender
         subversion is changed to 2.48.5 and the old blend files
         are automatically converted to match the old behavior: 
         all children of a Compound object will have the "Add to
         parent" button set automatically.
Child ghost control
===================
It is now possible to control if an object should becomes ghost
or solid when parented. This is only applicable if the object
is not added to the parent compound shape (see above).
A new "Ghost" button is available on the SetParent actuator to 
that effect. Similarly the KX_GameObject.setParent() python function
has a new compound parameter.
Notes: * This option is not applicable to sensor objects: they stay
         ghost all the time.
       * Make sure the child object does not enter in collision with
         the parent shape when the Ghost option if off and the parent is
         dynamic: the collision creates a reaction force but the parent
         cannot escape the child, so the force builds up and produces
         eratic movements.
       * The collision capability of an ordinary object (dynamic or static)
         is limited when it is parented: it becomes automatically static
         and can only detect dynamic and sensor objects.
       * A sensor object retain its full collision capability when parented:
         it can detect static and dynamic object.
Python control
==============
KX_GameObject.setParent(parent,compound,ghost):
	Sets this object's parent. 
	Control the shape status with the optional compound and ghost parameters:
	compound=1: the object shape should be added to the parent compound shape (default)
	compound=0: the object should keep its individual shape. 
	In that case you can control if it should be ghost or not:
	ghost=1 if the object should be made ghost while parented (default)
	ghost=0 if the object should be solid while parented 
	Note: if the object type is sensor, it stays ghost regardless of ghost parameter
		
	parent: KX_GameObject reference or string (object name w/o OB prefix)
											 
										 
										
											2009-05-21 13:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									int  addToCompound = 1 ,  ghost = 1 ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-28 13:11:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: user control to compound shape and setParent.
Compound shape control
======================
1) GUI control
It is now possible to control which child shape is added to 
a parent compound shape in the Physics buttons. The "Compound"
shape button becomes "Add to parent" on child objects and
determines whether the child shape is to be added to the top
parent compound shape when the game is stated.
Notes: * "Compound" is only available to top parent objects
         (objects without parent).
       * Nesting of compound shape is not possible: a child
         object with "Add to parent" button set will be added
         to the top parent compound shape, regardless of its
         position in the parent-child hierarchy and even if its
         immediate parent doesn't have the "Add to parent" button set.
2) runtime control
It is now possible to control the compound shape at runtime:
The SetParent actuator has a new "Compound" button that indicates
whether the object shape should be added to the compound shape
of the parent object, provided the parent has a compound shape
of course. If not, the object retain it's individual state
while parented.
Similarly, the KX_GameObject.setParent() python function has
a new compound parameter.
Notes: * When an object is dynamically added to a compound 
         shape, it looses temporarily all its physics capability
         to the benefit of the parent: it cannot register collisions
         and the characteristics of its shape are lost (ghost, sensor,
         dynamic, etc.). 
       * Nested compound shape is not supported: if the object
         being parented is already a compound shape, it is not
         added to the compound parent (as if the Compound option 
         was not set in the actuator or the setParent function).
       * To ensure compatibility with old blend files, the Blender
         subversion is changed to 2.48.5 and the old blend files
         are automatically converted to match the old behavior: 
         all children of a Compound object will have the "Add to
         parent" button set automatically.
Child ghost control
===================
It is now possible to control if an object should becomes ghost
or solid when parented. This is only applicable if the object
is not added to the parent compound shape (see above).
A new "Ghost" button is available on the SetParent actuator to 
that effect. Similarly the KX_GameObject.setParent() python function
has a new compound parameter.
Notes: * This option is not applicable to sensor objects: they stay
         ghost all the time.
       * Make sure the child object does not enter in collision with
         the parent shape when the Ghost option if off and the parent is
         dynamic: the collision creates a reaction force but the parent
         cannot escape the child, so the force builds up and produces
         eratic movements.
       * The collision capability of an ordinary object (dynamic or static)
         is limited when it is parented: it becomes automatically static
         and can only detect dynamic and sensor objects.
       * A sensor object retain its full collision capability when parented:
         it can detect static and dynamic object.
Python control
==============
KX_GameObject.setParent(parent,compound,ghost):
	Sets this object's parent. 
	Control the shape status with the optional compound and ghost parameters:
	compound=1: the object shape should be added to the parent compound shape (default)
	compound=0: the object should keep its individual shape. 
	In that case you can control if it should be ghost or not:
	ghost=1 if the object should be made ghost while parented (default)
	ghost=0 if the object should be solid while parented 
	Note: if the object type is sensor, it stays ghost regardless of ghost parameter
		
	parent: KX_GameObject reference or string (object name w/o OB prefix)
											 
										 
										
											2009-05-21 13:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTuple ( args , " O|ii:setParent " ,  & pyobj ,  & addToCompound ,  & ghost ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  NULL ;  // Python sets a simple error
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! ConvertPythonToGameObject ( pyobj ,  & obj ,  true ,  " gameOb.setParent(obj): KX_GameObject " ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-01 16:43:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE: user control to compound shape and setParent.
Compound shape control
======================
1) GUI control
It is now possible to control which child shape is added to 
a parent compound shape in the Physics buttons. The "Compound"
shape button becomes "Add to parent" on child objects and
determines whether the child shape is to be added to the top
parent compound shape when the game is stated.
Notes: * "Compound" is only available to top parent objects
         (objects without parent).
       * Nesting of compound shape is not possible: a child
         object with "Add to parent" button set will be added
         to the top parent compound shape, regardless of its
         position in the parent-child hierarchy and even if its
         immediate parent doesn't have the "Add to parent" button set.
2) runtime control
It is now possible to control the compound shape at runtime:
The SetParent actuator has a new "Compound" button that indicates
whether the object shape should be added to the compound shape
of the parent object, provided the parent has a compound shape
of course. If not, the object retain it's individual state
while parented.
Similarly, the KX_GameObject.setParent() python function has
a new compound parameter.
Notes: * When an object is dynamically added to a compound 
         shape, it looses temporarily all its physics capability
         to the benefit of the parent: it cannot register collisions
         and the characteristics of its shape are lost (ghost, sensor,
         dynamic, etc.). 
       * Nested compound shape is not supported: if the object
         being parented is already a compound shape, it is not
         added to the compound parent (as if the Compound option 
         was not set in the actuator or the setParent function).
       * To ensure compatibility with old blend files, the Blender
         subversion is changed to 2.48.5 and the old blend files
         are automatically converted to match the old behavior: 
         all children of a Compound object will have the "Add to
         parent" button set automatically.
Child ghost control
===================
It is now possible to control if an object should becomes ghost
or solid when parented. This is only applicable if the object
is not added to the parent compound shape (see above).
A new "Ghost" button is available on the SetParent actuator to 
that effect. Similarly the KX_GameObject.setParent() python function
has a new compound parameter.
Notes: * This option is not applicable to sensor objects: they stay
         ghost all the time.
       * Make sure the child object does not enter in collision with
         the parent shape when the Ghost option if off and the parent is
         dynamic: the collision creates a reaction force but the parent
         cannot escape the child, so the force builds up and produces
         eratic movements.
       * The collision capability of an ordinary object (dynamic or static)
         is limited when it is parented: it becomes automatically static
         and can only detect dynamic and sensor objects.
       * A sensor object retain its full collision capability when parented:
         it can detect static and dynamic object.
Python control
==============
KX_GameObject.setParent(parent,compound,ghost):
	Sets this object's parent. 
	Control the shape status with the optional compound and ghost parameters:
	compound=1: the object shape should be added to the parent compound shape (default)
	compound=0: the object should keep its individual shape. 
	In that case you can control if it should be ghost or not:
	ghost=1 if the object should be made ghost while parented (default)
	ghost=0 if the object should be solid while parented 
	Note: if the object type is sensor, it stays ghost regardless of ghost parameter
		
	parent: KX_GameObject reference or string (object name w/o OB prefix)
											 
										 
										
											2009-05-21 13:32:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( obj ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										this - > SetParent ( scene ,  obj ,  addToCompound ,  ghost ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyRemoveParent ( )  
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-10-31 21:06:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_Scene  * scene  =  KX_GetActiveScene ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-28 13:11:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									this - > RemoveParent ( scene ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-04-06 18:30:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2006-06-18 22:10:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PySetCollisionMargin ( PyObject *  value )  
						 
					
						
							
								
									
										
										
										
											2006-06-18 22:10:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									float  collisionMargin  =  PyFloat_AsDouble ( value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( collisionMargin = = - 1  & &  PyErr_Occurred ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										PyErr_SetString ( PyExc_TypeError ,  " expected a float " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-06-18 22:10:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_pPhysicsController1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_pPhysicsController1 - > setMargin ( collisionMargin ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyErr_SetString ( PyExc_RuntimeError ,  " This object has no physics controller " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2006-06-18 22:10:00 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyApplyImpulse ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2004-05-26 12:06:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PyObject *  pyattach ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  pyimpulse ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! m_pPhysicsController1 ) 	{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										PyErr_SetString ( PyExc_RuntimeError ,  " This object has no physics controller " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( PyArg_ParseTuple ( args ,  " OO:applyImpulse " ,  & pyattach ,  & pyimpulse ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2004-07-17 05:28:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										MT_Point3   attach ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Vector3  impulse ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( PyVecTo ( pyattach ,  attach )  & &  PyVecTo ( pyimpulse ,  impulse ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											m_pPhysicsController1 - > applyImpulse ( attach ,  impulse ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Py_RETURN_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2004-05-26 12:06:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2004-07-17 05:28:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PySuspendDynamics ( )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-06-25 14:09:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SuspendDynamics ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyRestoreDynamics ( )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-06-25 14:09:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									RestoreDynamics ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyAlignAxisToVect ( PyObject *  args )  
						 
					
						
							
								
									
										
										
										
											2008-06-02 17:31:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  pyvect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									int  axis  =  2 ;  //z axis is the default
 
							 
						 
					
						
							
								
									
										
											 
										
											
												added a factor argument for aligning to vector, this isn't correct since it does linear interpolation of the vector and renormalizes.
(can be improved to rotate correctly but for our  use ist ok for now, would also be useful to have an argument to clamp the maximum rotation angle to get a constant rotation speed),
This will used to make franky upright when falling from an angle, to track to a surface when hanging onto a ledge and setting the glide pitch.
Without this rotation is instant and jerky.
currently this is done with Mathutils which isnt available in Blender Player.
def do_rotate_up(own):
	own.alignAxisToVect([0,0,1], 2, 0.1)
replaces...
def do_rotate_up(own):
	up_nor = Vector(0,0,1)
	own_mat = Matrix(*own.getOrientation()).transpose()
	own_up = up_nor * own_mat
	ang = AngleBetweenVecs(own_up, up_nor)
	if ang > 0.005:
		# Set orientation
		cross = CrossVecs(own_up, up_nor)
		new_mat = own_mat * RotationMatrix(ang*0.1, 3, 'r', cross)
		own.setOrientation(new_mat.transpose())
M    source/gameengine/Ketsji/KX_GameObject.cpp
M    source/gameengine/Ketsji/KX_GameObject.h
											 
										 
										
											2008-07-09 09:21:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									float  fac  =  1.0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-02 17:31:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( PyArg_ParseTuple ( args , " O|if:alignAxisToVect " , & pyvect , & axis ,  & fac ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-02 17:31:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										MT_Vector3  vect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( PyVecTo ( pyvect ,  vect ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-06 04:09:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( fac < = 0.0 )  Py_RETURN_NONE ;  // Nothing to do.
 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-07 11:25:45 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  ( fac >  1.0 )  fac =  1.0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-06 04:09:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											
							 
						 
					
						
							
								
									
										
											 
										
											
												added a factor argument for aligning to vector, this isn't correct since it does linear interpolation of the vector and renormalizes.
(can be improved to rotate correctly but for our  use ist ok for now, would also be useful to have an argument to clamp the maximum rotation angle to get a constant rotation speed),
This will used to make franky upright when falling from an angle, to track to a surface when hanging onto a ledge and setting the glide pitch.
Without this rotation is instant and jerky.
currently this is done with Mathutils which isnt available in Blender Player.
def do_rotate_up(own):
	own.alignAxisToVect([0,0,1], 2, 0.1)
replaces...
def do_rotate_up(own):
	up_nor = Vector(0,0,1)
	own_mat = Matrix(*own.getOrientation()).transpose()
	own_up = up_nor * own_mat
	ang = AngleBetweenVecs(own_up, up_nor)
	if ang > 0.005:
		# Set orientation
		cross = CrossVecs(own_up, up_nor)
		new_mat = own_mat * RotationMatrix(ang*0.1, 3, 'r', cross)
		own.setOrientation(new_mat.transpose())
M    source/gameengine/Ketsji/KX_GameObject.cpp
M    source/gameengine/Ketsji/KX_GameObject.h
											 
										 
										
											2008-07-09 09:21:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											AlignAxisToVect ( vect , axis , fac ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-07 22:14:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											NodeUpdateGS ( 0.f ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											Py_RETURN_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-02 17:31:05 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyGetAxisVect ( PyObject *  value )  
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Vector3  vect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( PyVecTo ( value ,  vect ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 19:00:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  PyObjectFrom ( NodeGetWorldOrientation ( )  *  vect ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-09-09 22:40:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyGetPhysicsId ( )  
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_IPhysicsController *  ctrl  =  GetPhysicsController ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2005-11-28 06:51:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									uint_ptr  physid = 0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if  ( ctrl ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2005-11-28 06:51:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										physid =  ( uint_ptr ) ctrl - > GetUserData ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-29 02:25:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PyLong_FromSsize_t ( ( long ) physid ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2002-10-12 11:37:38 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 17:29:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : PyGetPropertyNames ( )  
						 
					
						
							
								
									
										
										
										
											2008-06-26 12:39:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PyObject  * list =   ConvertKeysToPython ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-04-17 20:06:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( m_attr_dict )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyObject  * key ,  * value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Py_ssize_t  pos  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-17 20:06:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										while  ( PyDict_Next ( m_attr_dict ,  & pos ,  & key ,  & value ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-12 14:22:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyList_Append ( list ,  key ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  list ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-06-26 12:39:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								KX_PYMETHODDEF_DOC_O ( KX_GameObject ,  getDistanceTo ,  
						 
					
						
							
								
									
										
										
										
											2005-01-16 05:55:04 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								" getDistanceTo(other): get distance to another point/KX_GameObject " )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Point3  b ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( PyVecTo ( value ,  b ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-16 05:55:04 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PyFloat_FromDouble ( NodeGetWorldPosition ( ) . distance ( b ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyErr_Clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject  * other ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-20 09:13:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ConvertPythonToGameObject ( value ,  & other ,  false ,  " gameOb.getDistanceTo(value): KX_GameObject " ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2005-01-16 05:55:04 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  PyFloat_FromDouble ( NodeGetWorldPosition ( ) . distance ( other - > NodeGetWorldPosition ( ) ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								KX_PYMETHODDEF_DOC_O ( KX_GameObject ,  getVectTo ,  
						 
					
						
							
								
									
										
										
										
											2008-08-03 21:59:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								" getVectTo(other): get vector and the distance to another point/KX_GameObject \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								" Returns a 3-tuple with (distance,worldVector,localVector) \n " )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Point3  toPoint ,  fromPoint ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Vector3  toDir ,  locToDir ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Scalar  distance ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-08-04 01:57:22 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PyObject  * returnValue ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-03 21:59:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! PyVecTo ( value ,  toPoint ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-03 21:59:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										PyErr_Clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										KX_GameObject  * other ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-20 09:13:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( ConvertPythonToGameObject ( value ,  & other ,  false ,  " " ) )  /* error will be overwritten */ 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-03 21:59:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											toPoint  =  other - > NodeGetWorldPosition ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}  else 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-03 21:59:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 21:01:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyErr_SetString ( PyExc_TypeError ,  " gameOb.getVectTo(other): KX_GameObject, expected a 3D Vector or KX_GameObject type " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-03 21:59:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									fromPoint  =  NodeGetWorldPosition ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									toDir  =  toPoint - fromPoint ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									distance  =  toDir . length ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( MT_fuzzyZero ( distance ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										//cout << "getVectTo() Error: Null vector!\n";
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										locToDir  =  toDir  =  MT_Vector3 ( 0.0 , 0.0 , 0.0 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										distance  =  0.0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										toDir . normalize ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										locToDir  =  toDir  *  NodeGetWorldOrientation ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-04 01:57:22 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									returnValue  =  PyTuple_New ( 3 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( returnValue )  {  // very unlikely to fail, python sets a memory error here.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										PyTuple_SET_ITEM ( returnValue ,  0 ,  PyFloat_FromDouble ( distance ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										PyTuple_SET_ITEM ( returnValue ,  1 ,  PyObjectFrom ( toDir ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										PyTuple_SET_ITEM ( returnValue ,  2 ,  PyObjectFrom ( locToDir ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-03 21:59:36 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  returnValue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  KX_GameObject : : RayHit ( KX_ClientObjectInfo *  client ,  KX_RayCast *  result ,  void  *  const  data )  
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  hitKXObj  =  client - > m_gameobject ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// if X-ray option is selected, the unwnted objects were not tested, so get here only with true hit
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// if not, all objects were tested and the front one may not be the correct one.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_xray  | |  m_testPropName . Length ( )  = =  0  | |  hitKXObj - > GetProperty ( m_testPropName )  ! =  NULL ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_pHitObject  =  hitKXObj ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// return true to stop RayCast::RayTest from looping, the above test was decisive
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// We would want to loop only if we want to get more than one hit point
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/* this function is used to pre-filter the object before casting the ray on them.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								   This  is  useful  for  " X-Ray "  option  when  we  want  to  see  " through "  unwanted  object . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								bool  KX_GameObject : : NeedRayCast ( KX_ClientObjectInfo *  client )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_GameObject *  hitKXObj  =  client - > m_gameobject ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( client - > m_type  >  KX_ClientObjectInfo : : ACTOR ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Unknown type of object, skip it.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Should not occur as the sensor objects are filtered in RayTest()
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										printf ( " Invalid client type %d found in ray casting \n " ,  client - > m_type ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// if X-Ray option is selected, skip object that don't match the criteria as we see through them
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// if not, test all objects because we don't know yet which one will be on front
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! m_xray  | |  m_testPropName . Length ( )  = =  0  | |  hitKXObj - > GetProperty ( m_testPropName )  ! =  NULL ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// skip the object
 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								KX_PYMETHODDEF_DOC ( KX_GameObject ,  rayCastTo ,  
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								" rayCastTo(other,dist,prop): look towards another point/KX_GameObject and return first object hit within dist that matches prop \n "  
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"  prop = property name that object must have; can be omitted => detect any object \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"  dist = max distance to look (can be negative => look behind); 0 or omitted => detect up to other \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"  other = 3-tuple or object reference " )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Point3  toPoint ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  pyarg ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									float  dist  =  0.0f ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									char  * propName  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTuple ( args , " O|fs:rayCastTo " ,  & pyarg ,  & dist ,  & propName ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-04 01:57:22 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  NULL ;  // python sets simple error
 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-23 21:37:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyVecTo ( pyarg ,  toPoint ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										KX_GameObject  * other ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										PyErr_Clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
									
										
										
										
											2009-04-20 09:13:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( ConvertPythonToGameObject ( pyarg ,  & other ,  false ,  " " ) )  /* error will be overwritten */ 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											toPoint  =  other - > NodeGetWorldPosition ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 21:01:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyErr_SetString ( PyExc_TypeError ,  " gameOb.rayCastTo(other,dist,prop): KX_GameObject, the first argument to rayCastTo must be a vector or a KX_GameObject " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-06 14:11:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Point3  fromPoint  =  NodeGetWorldPosition ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-08-27 06:55:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( dist  ! =  0.0f ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-08-27 06:55:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										toPoint  =  fromPoint  +  dist  *  ( toPoint - fromPoint ) . safe_normalized ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-08-04 05:14:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PHY_IPhysicsEnvironment *  pe  =  KX_GetActiveScene ( ) - > GetPhysicsEnvironment ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_IPhysicsController  * spc  =  GetPhysicsController ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject  * parent  =  GetParent ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! spc  & &  parent ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										spc  =  parent - > GetPhysicsController ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( parent ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										parent - > Release ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_pHitObject  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( propName ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_testPropName  =  propName ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_testPropName . SetLength ( 0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-28 11:13:04 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_RayCast : : Callback < KX_GameObject >  callback ( this , spc ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_RayCast : : RayTest ( pe ,  fromPoint ,  toPoint ,  callback ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-05-16 10:09:07 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_pHitObject ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  m_pHitObject - > GetProxy ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2008-07-04 00:05:50 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-03-15 17:08:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-05-16 06:57:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/* faster then Py_BuildValue since some scripts call raycast a lot */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  PyObject  * none_tuple_3 ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject  * ret =  PyTuple_New ( 3 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyTuple_SET_ITEM ( ret ,  0 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyTuple_SET_ITEM ( ret ,  1 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyTuple_SET_ITEM ( ret ,  2 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  ret ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  PyObject  * none_tuple_4 ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject  * ret =  PyTuple_New ( 4 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyTuple_SET_ITEM ( ret ,  0 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyTuple_SET_ITEM ( ret ,  1 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyTuple_SET_ITEM ( ret ,  2 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyTuple_SET_ITEM ( ret ,  3 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  ret ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-01-06 08:44:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  PyObject  * none_tuple_5 ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject  * ret =  PyTuple_New ( 5 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyTuple_SET_ITEM ( ret ,  0 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyTuple_SET_ITEM ( ret ,  1 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyTuple_SET_ITEM ( ret ,  2 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyTuple_SET_ITEM ( ret ,  3 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyTuple_SET_ITEM ( ret ,  4 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  ret ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 22:50:31 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								KX_PYMETHODDEF_DOC ( KX_GameObject ,  rayCast ,  
						 
					
						
							
								
									
										
										
										
											2009-12-04 11:27:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												   " rayCast(to,from,dist,prop,face,xray,poly): cast a ray and return 3-tuple (object,hit,normal) or 4-tuple (object,hit,normal,polygon) or 4-tuple (object,hit,normal,polygon,hituv) of contact point with object within dist that matches prop. \n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												   "  If no hit, return (None,None,None) or (None,None,None,None) or (None,None,None,None,None). \n " 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"  to   = 3-tuple or object reference for destination of ray (if object, use center of object) \n "  
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"  from = 3-tuple or object reference for origin of ray (if object, use center of object) \n "  
						 
					
						
							
								
									
										
										
										
											2008-07-23 21:37:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"         Can be None or omitted => start from self object center \n "  
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"  dist = max distance to look (can be negative => look behind); 0 or omitted => detect up to to \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"  prop = property name that object must have; can be omitted => detect any object \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"  face = normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"  xray = X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"  poly = polygon option: 1=>return value is a 4-tuple and the 4th element is a KX_PolyProxy object \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"                            which can be None if hit object has no mesh or if there is no hit \n "  
						 
					
						
							
								
									
										
										
										
											2009-12-04 11:27:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"                         2=>return value is a 5-tuple, the 4th element is the KX_PolyProxy object \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"                            and the 5th element is the vector of UV coordinates at the hit point of the None if there is no UV mapping \n "  
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								"         If 0 or omitted, return value is a 3-tuple \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								" Note: The object on which you call this method matters: the ray will ignore it. \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"       prop and xray option interact as follow: \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"         prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"         prop off, xray on : idem \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"         prop on,  xray off: return closest hit if it matches prop, no hit otherwise \n "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								"         prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray \n " )  
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Point3  toPoint ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									MT_Point3  fromPoint ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  pyto ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  pyfrom  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									float  dist  =  0.0f ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									char  * propName  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject  * other ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									int  face = 0 ,  xray = 0 ,  poly = 0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-02-23 06:41:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTuple ( args , " O|Ofsiii:rayCast " ,  & pyto ,  & pyfrom ,  & dist ,  & propName ,  & face ,  & xray ,  & poly ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-04 01:57:22 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  NULL ;  // Python sets a simple error
 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-23 21:37:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyVecTo ( pyto ,  toPoint ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										PyErr_Clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
									
										
										
										
											2009-04-20 09:13:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( ConvertPythonToGameObject ( pyto ,  & other ,  false ,  " " ) )   /* error will be overwritten */ 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											toPoint  =  other - > NodeGetWorldPosition ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-06 14:11:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyErr_SetString ( PyExc_TypeError ,  " the first argument to rayCast must be a vector or a KX_GameObject " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-06 14:11:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! pyfrom  | |  pyfrom  = =  Py_None ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										fromPoint  =  NodeGetWorldPosition ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else  if  ( ! PyVecTo ( pyfrom ,  fromPoint ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										PyErr_Clear ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
									
										
										
										
											2009-04-20 09:13:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( ConvertPythonToGameObject ( pyfrom ,  & other ,  false ,  " " ) )  /* error will be overwritten */ 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											fromPoint  =  other - > NodeGetWorldPosition ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 21:01:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyErr_SetString ( PyExc_TypeError ,  " gameOb.rayCast(to,from,dist,prop,face,xray,poly): KX_GameObject, the second optional argument to rayCast must be a vector or a KX_GameObject " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-06 14:11:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-09 15:30:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( dist  ! =  0.0f )  { 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										MT_Vector3  toDir  =  toPoint - fromPoint ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-09 15:30:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( MT_fuzzyZero ( toDir . length2 ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-16 06:57:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											//return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  none_tuple_3 ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-09 15:30:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										toDir . normalize ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										toPoint  =  fromPoint  +  ( dist )  *  toDir ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-09 15:30:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  if  ( MT_fuzzyZero ( ( toPoint - fromPoint ) . length2 ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-16 06:57:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										//return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  none_tuple_3 ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-09 15:30:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-08-04 05:14:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PHY_IPhysicsEnvironment *  pe  =  KX_GetActiveScene ( ) - > GetPhysicsEnvironment ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_IPhysicsController  * spc  =  GetPhysicsController ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									KX_GameObject  * parent  =  GetParent ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! spc  & &  parent ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										spc  =  parent - > GetPhysicsController ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( parent ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										parent - > Release ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									m_pHitObject  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( propName ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_testPropName  =  propName ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										m_testPropName . SetLength ( 0 ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									m_xray  =  xray ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// to get the hit results
 
							 
						 
					
						
							
								
									
										
										
										
											2009-12-04 11:27:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_RayCast : : Callback < KX_GameObject >  callback ( this , spc , NULL , face , ( poly = = 2 ) ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_RayCast : : RayTest ( pe ,  fromPoint ,  toPoint ,  callback ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( m_pHitObject ) 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2009-12-04 11:27:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyObject *  returnValue  =  ( poly = = 2 )  ?  PyTuple_New ( 5 )  :  ( poly )  ?  PyTuple_New ( 4 )  :  PyTuple_New ( 3 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-04 01:57:22 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( returnValue )  {  // unlikely this would ever fail, if it does python sets an error
 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyTuple_SET_ITEM ( returnValue ,  0 ,  m_pHitObject - > GetProxy ( ) ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyTuple_SET_ITEM ( returnValue ,  1 ,  PyObjectFrom ( callback . m_hitPoint ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											PyTuple_SET_ITEM ( returnValue ,  2 ,  PyObjectFrom ( callback . m_hitNormal ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if  ( poly ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  ( callback . m_hitMesh ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													// if this field is set, then we can trust that m_hitPolygon is a valid polygon
 
							 
						 
					
						
							
								
									
										
										
										
											2009-02-25 03:26:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													RAS_Polygon *  polygon  =  callback . m_hitMesh - > GetPolygon ( callback . m_hitPolygon ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													KX_PolyProxy *  polyproxy  =  new  KX_PolyProxy ( callback . m_hitMesh ,  polygon ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													PyTuple_SET_ITEM ( returnValue ,  3 ,  polyproxy - > NewProxy ( true ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-12-04 11:27:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													if  ( poly  = =  2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														if  ( callback . m_hitUVOK ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															PyTuple_SET_ITEM ( returnValue ,  4 ,  PyObjectFrom ( callback . m_hitUV ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
															PyTuple_SET_ITEM ( returnValue ,  4 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													PyTuple_SET_ITEM ( returnValue ,  3 ,  Py_None ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-12-04 11:27:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													if  ( poly = = 2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														Py_INCREF ( Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														PyTuple_SET_ITEM ( returnValue ,  4 ,  Py_None ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													} 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2008-07-23 21:37:37 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  returnValue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// no hit
 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-06 08:44:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( poly  = =  2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  none_tuple_5 ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else  if  ( poly ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-16 06:57:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  none_tuple_4 ( ) ; 
							 
						 
					
						
							
								
									
										
											 
										
											
												BGE patch: KX_GameObject::rayCast() improvements to have X-Ray option, return true face normal and hit polygon information.
rayCast(to,from,dist,prop,face,xray,poly):
The face paremeter determines the orientation of the normal: 
  0 or omitted => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
  1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
The prop and xray parameters interact as follow:
    prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
    prop off, xray on : idem.
    prop on,  xray off: return closest hit if it matches prop, no hit otherwise.
    prop on,  xray on : return closest hit matching prop or no hit if there is no object matching prop on the full extend of the ray.
if poly is 0 or omitted, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
if poly is 1, returns a 4-tuple with in addition a KX_PolyProxy as 4th element.
The KX_PolyProxy object holds information on the polygon hit by the ray: the index of the vertex forming the poylgon, material, etc.
Attributes (read-only):
 matname: The name of polygon material, empty if no material.
 material: The material of the polygon
 texture: The texture name of the polygon.
 matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
 v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
 v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
     use this to retrieve vertex proxy from mesh proxy
 visible: visible state of the polygon: 1=visible, 0=invisible
 collide: collide state of the polygon: 1=receives collision, 0=collision free.
Methods:
 getMaterialName(): Returns the polygon material name with MA prefix
 getMaterial(): Returns the polygon material
 getTextureName(): Returns the polygon texture name
 getMaterialIndex(): Returns the material bucket index of the polygon. 
 getNumVertex(): Returns the number of vertex of the polygon.
 isVisible(): Returns whether the polygon is visible or not
 isCollider(): Returns whether the polygon is receives collision or not
 getVertexIndex(vertex): Returns the mesh vertex index of a polygon vertex
 getMesh(): Returns a mesh proxy
New methods of KX_MeshProxy have been implemented to retrieve KX_PolyProxy objects:
 getNumPolygons(): Returns the number of polygon in the mesh.
 getPolygon(index): Gets the specified polygon from the mesh.
More details in PyDoc.
											 
										 
										
											2008-08-27 19:34:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									else 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-16 06:57:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  none_tuple_3 ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-05-24 18:06:58 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-08 16:57:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								KX_PYMETHODDEF_DOC_VARARGS ( KX_GameObject ,  sendMessage ,   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
														   " sendMessage(subject, [body, to]) \n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								" sends a message in same manner as a message actuator "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								" subject = Subject of the message (string) "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								" body = Message body (string) "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								" to = Name of object to send the message to " )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2009-04-28 13:11:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									KX_Scene  * scene  =  KX_GetActiveScene ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-08 16:57:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									char *  subject ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-17 20:06:06 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									char *  body  =  ( char  * ) " " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									char *  to  =  ( char  * ) " " ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-08 16:57:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									const  STR_String &  from  =  GetName ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-08-31 15:28:43 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTuple ( args ,  " s|ss:sendMessage " ,  & subject ,  & body ,  & to ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-08 16:57:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-28 13:11:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									scene - > GetNetworkScene ( ) - > SendMessage ( to ,  from ,  subject ,  body ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-08 16:57:08 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  void  layer_check ( short  & layer ,  const  char  * method_name )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( layer  <  0  | |  layer  >  MAX_ACTION_LAYERS ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										printf ( " KX_GameObject.%s(): given layer (%d) is out of range (0 - %d), setting to 0. \n " ,  method_name ,  layer ,  MAX_ACTION_LAYERS - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										layer  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								KX_PYMETHODDEF_DOC ( KX_GameObject ,  playAction ,  
						 
					
						
							
								
									
										
										
										
											2011-07-03 01:59:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									" playAction(name, start_frame, end_frame, layer=0, priority=0 blendin=0, play_mode=ACT_MODE_PLAY, layer_weight=0.0, ipo_flags=0, speed=1.0) \n " 
							 
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									" Plays an action \n " ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									const  char *  name ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-07-03 01:59:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									float  start ,  end ,  blendin = 0.f ,  speed = 1.f ,  layer_weight = 0.f ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-23 22:12:49 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									short  layer = 0 ,  priority = 0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-16 01:18:52 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									short  ipo_flags = 0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-07-03 01:59:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									short  play_mode = 0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-07-03 01:59:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									static  const  char  * kwlist [ ]  =  { " name " ,  " start_frame " ,  " end_frame " ,  " layer " ,  " priority " ,  " blendin " ,  " play_mode " ,  " layer_weight " ,  " ipo_flags " ,  " speed " ,  NULL } ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-07-03 01:59:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTupleAndKeywords ( args ,  kwds ,  " sff|hhfhfhf:playAction " ,  const_cast < char * * > ( kwlist ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
																	& name ,  & start ,  & end ,  & layer ,  & priority ,  & blendin ,  & play_mode ,  & layer_weight ,  & ipo_flags ,  & speed ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									layer_check ( layer ,  " playAction " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( play_mode  <  0  | |  play_mode  >  BL_Action : : ACT_MODE_MAX ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										printf ( " KX_GameObject.playAction(): given play_mode (%d) is out of range (0 - %d), setting to ACT_MODE_PLAY " ,  play_mode ,  BL_Action : : ACT_MODE_MAX - 1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										play_mode  =  BL_Action : : ACT_MODE_MAX ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-07-03 01:59:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( layer_weight  <  0.f  | |  layer_weight  >  1.f ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2011-07-03 01:59:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										printf ( " KX_GameObject.playAction(): given layer_weight (%f) is out of range (0.0 - 1.0), setting to 0.0 " ,  layer_weight ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										layer_weight  =  0.f ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-07-03 01:59:17 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									PlayAction ( name ,  start ,  end ,  layer ,  priority ,  blendin ,  play_mode ,  layer_weight ,  ipo_flags ,  speed ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-24 07:52:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2011-06-23 22:44:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								KX_PYMETHODDEF_DOC ( KX_GameObject ,  stopAction ,  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" stopAction(layer=0) \n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" Stop playing the action on the given layer \n " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									short  layer = 0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTuple ( args ,  " |h:stopAction " ,  & layer ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									layer_check ( layer ,  " stopAction " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									StopAction ( layer ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-06-23 22:44:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								KX_PYMETHODDEF_DOC ( KX_GameObject ,  getActionFrame ,  
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									" getActionFrame(layer=0) \n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" Gets the current frame of the action playing in the supplied layer \n " ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-23 22:44:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									short  layer = 0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-23 22:44:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTuple ( args ,  " |h:getActionFrame " ,  & layer ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-23 22:44:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									layer_check ( layer ,  " getActionFrame " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-06-23 22:44:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  PyLong_FromLong ( GetActionFrame ( layer ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								KX_PYMETHODDEF_DOC ( KX_GameObject ,  setActionFrame ,  
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									" setActionFrame(frame, layer=0) \n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" Set the current frame of the action playing in the supplied layer \n " ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-23 22:44:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									short  layer = 0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-23 23:18:53 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									float  frame ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-23 22:44:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTuple ( args ,  " f|h:setActionFrame " ,  & frame ,  & layer ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-06-23 22:44:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									layer_check ( layer ,  " setActionFrame " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-06-23 22:44:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									SetActionFrame ( layer ,  frame ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_RETURN_NONE ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-07-16 05:25:15 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								KX_PYMETHODDEF_DOC ( KX_GameObject ,  isPlayingAction ,  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" isPlayingAction(layer=0) \n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" Checks to see if there is an action playing in the given layer \n " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									short  layer = 0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTuple ( args ,  " |h:isPlayingAction " ,  & layer ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									layer_check ( layer ,  " isPlayingAction " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  PyBool_FromLong ( ! IsActionDone ( layer ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-05-26 16:15:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								/* dict style access */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								/* Matches python dict.get(key, [default]) */  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								PyObject *  KX_GameObject : : Pyget ( PyObject  * args )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject  * key ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  def  =  Py_None ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									PyObject *  ret ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( ! PyArg_ParseTuple ( args ,  " O|O:get " ,  & key ,  & def ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-06-29 02:25:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if ( PyUnicode_Check ( key ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CValue  * item  =  GetProperty ( _PyUnicode_AsString ( key ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-31 17:44:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( item )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ret  =  item - > ConvertValueToPython ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if ( ret ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return  ret ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return  item - > GetProxy ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-26 16:15:40 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( m_attr_dict  & &  ( ret = PyDict_GetItem ( m_attr_dict ,  key ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Py_INCREF ( ret ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  ret ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Py_INCREF ( def ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  def ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2009-04-20 09:13:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  ConvertPythonToGameObject ( PyObject  *  value ,  KX_GameObject  * * object ,  bool  py_none_ok ,  const  char  * error_prefix )  
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( value = = NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-20 09:13:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyErr_Format ( PyExc_TypeError ,  " %s, python pointer NULL, should never happen " ,  error_prefix ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										* object  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( value = = Py_None )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										* object  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( py_none_ok )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-20 09:13:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyErr_Format ( PyExc_TypeError ,  " %s, expected KX_GameObject or a KX_GameObject name, None is invalid " ,  error_prefix ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-06-29 02:25:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( PyUnicode_Check ( value ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										* object  =  ( KX_GameObject * ) SCA_ILogicBrick : : m_sCurrentLogicManager - > GetGameObjectByName ( STR_String (  _PyUnicode_AsString ( value )  ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  ( * object )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-06-29 02:25:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyErr_Format ( PyExc_ValueError ,  " %s, requested name  \" %s \"  did not match any KX_GameObject in this scene " ,  error_prefix ,  _PyUnicode_AsString ( value ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
									
										
										
										
											2009-05-24 23:43:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ( 	PyObject_TypeCheck ( value ,  & KX_GameObject : : Type ) 	| | 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											PyObject_TypeCheck ( value ,  & KX_LightObject : : Type ) 	| | 
							 
						 
					
						
							
								
									
										
											 
										
											
												Patch:[#25163] BGE support for Blender Font objects - unicode support
Problem/Bug:
------------
There were no way to have proper unicode characters (e.g. Japanese) in Blender Game Engine. Now we can :)
You can see a sample here: http://blog.mikepan.com/multi-language-support-in-blender/
Functionality Explanation:
--------------------------
This patch converts the Blender Font Objects to a new BGE type: KX_FontObject
This object inherits KX_GameObject.cpp and has the following properties:
- text (the text of the object)
- size (taken from the Blender object, usually is 1.0)
- resolution (1.0 by default, maybe not really needed, but at least for debugging/the time being it's nice to have) 
The way we deal with linked objects is different than Blender. In Blender the text and size are a property of the Text databock. Therefore linked objects necessarily share the same text (and size, although the size of the object datablock affects that too). In BGE they are stored and accessed per object. Without that it would be problematic to have addObject adding texts that don't share the same data.
Known problems/limitations/ToDo:
--------------------------------
1) support for packed font and the <builtin>
2) figure why some fonts are displayed in a different size in 3DView/BGE (BLF)
3) investigate some glitches I see some times
4) support for multiline
5) support for more Blender Font Object options (text aligment, text boxes, ...)
[1] Diego (bdiego) evantually will help on that. For the time being we are using the "default" (ui) font to replace the <builtin>.
[2] but not all of them. I need to cross check who is calculating the size/dpi in/correctly - Blender or BLF. (e.g. fonts that work well - MS Gothic)
[3] I think this may be related to the resolution we are drawing the font
[4] It can't/will not be handled inside BFL. So the way I see it is to implement a mini text library/api that works as a middlelayer between the drawing step and BLF. 
    So instead of:
      BLF_draw(fontid, (char *)text, strlen(text));
    We would do:
      MAGIC_ROUTINE_IM_NOT_BLF_draw(fontir, (char *)text, styleflag, width, height);
[5] don't hold your breath ... but if someone wants to have fun in the holidays the (4) and (5) are part of the same problem.
Code Explanation:
-----------------
The patch should be simple to read. They are three may parts:
1) BL_BlenderDataConversion.cpp:: converts the OB_FONT object into a KX_FontObject.cpp and store it in the KX_Scene->m_fonts
2) KetsjiEngine.cpp::RenderFonts:: loop through the texts and call their internal drawing routine.
3) KX_FontObject.cpp::
  a) constructor: load the font of the object, and store other values.
  b) DrawText: calculate the aspect for the given size (sounds hacky but this is how blf works) and call the render routine in RenderTools
4) KX_BlenderGL.cpp (called from rendertools) ::BL_print_game_line:: Draws the text. Using the BLF API
*) In order to handle visibility of the object added with AddObject I'm adding to the m_scene.m_fonts list only the Fonts in a visible layer - unlike Cameras and Lamps where all the objects are added.
Acknowledgements:
----------------
Thanks Benoit for the review and adjustment suggestions.
Thanks Diego for the BFL expertise, patches and support (Latin community ftw)
Thanks my boss for letting me do part of this patch during work time. Good thing we are starting a project in a partnership with a Japanese Foundation and eventual will need unicode in BGE :) for more details on that - www.nereusprogram.org - let's call it the main sponsor of this "bug feature" ;)
											 
										 
										
											2010-12-16 10:25:41 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyObject_TypeCheck ( value ,  & KX_Camera : : Type ) 			| | 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											PyObject_TypeCheck ( value ,  & KX_FontObject : : Type ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2009-05-24 23:43:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										* object  =  static_cast < KX_GameObject * > BGE_PROXY_REF ( value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 10:57:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										/* sets the error */ 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ( * object = = NULL )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-23 00:32:33 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											PyErr_Format ( PyExc_SystemError ,  " %s,  "  BGE_PROXY_ERROR_MSG ,  error_prefix ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 10:57:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-19 12:46:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-15 10:57:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									* object  =  NULL ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ( py_none_ok )  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-20 09:13:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyErr_Format ( PyExc_TypeError ,  " %s, expect a KX_GameObject, a string or None " ,  error_prefix ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2009-04-20 09:13:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										PyErr_Format ( PyExc_TypeError ,  " %s, expect a KX_GameObject or a string " ,  error_prefix ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2008-08-14 08:58:25 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2010-10-31 04:11:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# endif  // WITH_PYTHON