Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-13 00:16:53 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2008-11-13 00:16:53 +0300
commitbdfe7d89e2f1292644577972c716931b4ce3c6c3 (patch)
treed00eb50b749cb001e2b08272c91791e66740b05d /source/gameengine
parent78a1c27c4a6abe0ed31ca93ad21910f3df04da56 (diff)
parent7e4db234cee71ead34ee81a12e27da4bd548eb4b (diff)
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416 Issues: * GHOST/X11 had conflicting changes. Some code was added in 2.5, which was later added in trunk also, but reverted partially, specifically revision 16683. I have left out this reversion in the 2.5 branch since I think it is needed there. http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683 * Scons had various conflicting changes, I decided to go with trunk version for everything except priorities and some library renaming. * In creator.c, there were various fixes and fixes for fixes related to the -w -W and -p options. In 2.5 -w and -W is not coded yet, and -p is done differently. Since this is changed so much, and I don't think those fixes would be needed in 2.5, I've left them out. * Also in creator.c: there was code for a python bugfix where the screen was not initialized when running with -P. The code that initializes the screen there I had to disable, that can't work in 2.5 anymore but left it commented as a reminder. Further I had to disable some new function calls. using src/ and python/, as was done already in this branch, disabled function calls: * bpath.c: error reporting * BME_conversions.c: editmesh conversion functions. * SHD_dynamic: disabled almost completely, there is no python/. * KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled. * text.c: clipboard copy call. * object.c: OB_SUPPORT_MATERIAL. * DerivedMesh.c and subsurf_ccg, stipple_quarttone. Still to be done: * Go over files and functions that were moved to a different location but could still use changes that were done in trunk.
Diffstat (limited to 'source/gameengine')
-rw-r--r--source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp269
-rw-r--r--source/gameengine/BlenderRoutines/CMakeLists.txt2
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp12
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderCanvas.h12
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderGL.cpp129
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderGL.h3
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp114
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h99
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp280
-rw-r--r--source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h74
-rw-r--r--source/gameengine/BlenderRoutines/Makefile5
-rw-r--r--source/gameengine/BlenderRoutines/SConscript1
-rw-r--r--source/gameengine/CMakeLists.txt1
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.cpp259
-rw-r--r--source/gameengine/Converter/BL_ActionActuator.h12
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.cpp94
-rw-r--r--source/gameengine/Converter/BL_ArmatureObject.h10
-rw-r--r--source/gameengine/Converter/BL_BlenderDataConversion.cpp1414
-rw-r--r--source/gameengine/Converter/BL_DeformableGameObject.cpp55
-rw-r--r--source/gameengine/Converter/BL_DeformableGameObject.h53
-rw-r--r--source/gameengine/Converter/BL_MeshDeformer.cpp227
-rw-r--r--source/gameengine/Converter/BL_MeshDeformer.h28
-rw-r--r--source/gameengine/Converter/BL_ShapeActionActuator.cpp842
-rw-r--r--source/gameengine/Converter/BL_ShapeActionActuator.h138
-rw-r--r--source/gameengine/Converter/BL_ShapeDeformer.cpp182
-rw-r--r--source/gameengine/Converter/BL_ShapeDeformer.h88
-rw-r--r--source/gameengine/Converter/BL_SkinDeformer.cpp172
-rw-r--r--source/gameengine/Converter/BL_SkinDeformer.h56
-rw-r--r--source/gameengine/Converter/BL_SkinMeshObject.cpp186
-rw-r--r--source/gameengine/Converter/BL_SkinMeshObject.h134
-rw-r--r--source/gameengine/Converter/CMakeLists.txt1
-rw-r--r--source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp13
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.cpp196
-rw-r--r--source/gameengine/Converter/KX_BlenderSceneConverter.h21
-rw-r--r--source/gameengine/Converter/KX_ConvertActuators.cpp506
-rw-r--r--source/gameengine/Converter/KX_ConvertControllers.cpp31
-rw-r--r--source/gameengine/Converter/KX_ConvertProperties.cpp15
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.cpp92
-rw-r--r--source/gameengine/Converter/KX_ConvertSensors.h1
-rw-r--r--source/gameengine/Converter/KX_IpoConvert.cpp104
-rw-r--r--source/gameengine/Converter/KX_IpoConvert.h2
-rw-r--r--source/gameengine/Converter/Makefile1
-rw-r--r--source/gameengine/Converter/SConscript2
-rw-r--r--source/gameengine/Expressions/Expression.cpp4
-rw-r--r--source/gameengine/Expressions/InputParser.cpp5
-rw-r--r--source/gameengine/Expressions/ListValue.cpp13
-rw-r--r--source/gameengine/Expressions/Makefile1
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.cpp16
-rw-r--r--source/gameengine/Expressions/PyObjectPlus.h128
-rw-r--r--source/gameengine/Expressions/Value.cpp183
-rw-r--r--source/gameengine/Expressions/Value.h5
-rw-r--r--source/gameengine/GameLogic/CMakeLists.txt1
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp333
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_Joystick.h260
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h8
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp89
-rw-r--r--source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h7
-rw-r--r--source/gameengine/GameLogic/Makefile2
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.cpp118
-rw-r--r--source/gameengine/GameLogic/SCA_2DFilterActuator.h44
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp67
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorEventManager.h51
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.cpp196
-rw-r--r--source/gameengine/GameLogic/SCA_ActuatorSensor.h74
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp11
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysEventManager.h1
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysSensor.cpp7
-rw-r--r--source/gameengine/GameLogic/SCA_AlwaysSensor.h2
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.cpp257
-rw-r--r--source/gameengine/GameLogic/SCA_DelaySensor.h77
-rw-r--r--source/gameengine/GameLogic/SCA_EventManager.cpp17
-rw-r--r--source/gameengine/GameLogic/SCA_EventManager.h10
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.cpp10
-rw-r--r--source/gameengine/GameLogic/SCA_IActuator.h17
-rw-r--r--source/gameengine/GameLogic/SCA_IController.cpp99
-rw-r--r--source/gameengine/GameLogic/SCA_IController.h4
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.cpp21
-rw-r--r--source/gameengine/GameLogic/SCA_ILogicBrick.h7
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.cpp104
-rw-r--r--source/gameengine/GameLogic/SCA_IObject.h39
-rw-r--r--source/gameengine/GameLogic/SCA_IScene.cpp22
-rw-r--r--source/gameengine/GameLogic/SCA_IScene.h3
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.cpp163
-rw-r--r--source/gameengine/GameLogic/SCA_ISensor.h53
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickManager.cpp43
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickManager.h5
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.cpp331
-rw-r--r--source/gameengine/GameLogic/SCA_JoystickSensor.h54
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardManager.cpp15
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardManager.h1
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.cpp191
-rw-r--r--source/gameengine/GameLogic/SCA_KeyboardSensor.h2
-rw-r--r--source/gameengine/GameLogic/SCA_LogicManager.cpp92
-rw-r--r--source/gameengine/GameLogic/SCA_LogicManager.h9
-rw-r--r--source/gameengine/GameLogic/SCA_MouseManager.cpp14
-rw-r--r--source/gameengine/GameLogic/SCA_MouseManager.h1
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.cpp51
-rw-r--r--source/gameengine/GameLogic/SCA_MouseSensor.h2
-rw-r--r--source/gameengine/GameLogic/SCA_NANDController.cpp144
-rw-r--r--source/gameengine/GameLogic/SCA_NANDController.h56
-rw-r--r--source/gameengine/GameLogic/SCA_NORController.cpp144
-rw-r--r--source/gameengine/GameLogic/SCA_NORController.h56
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.cpp63
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyActuator.h8
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyEventManager.cpp11
-rw-r--r--source/gameengine/GameLogic/SCA_PropertyEventManager.h1
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.cpp73
-rw-r--r--source/gameengine/GameLogic/SCA_PropertySensor.h2
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.cpp172
-rw-r--r--source/gameengine/GameLogic/SCA_PythonController.h30
-rw-r--r--source/gameengine/GameLogic/SCA_RandomActuator.cpp74
-rw-r--r--source/gameengine/GameLogic/SCA_RandomEventManager.cpp11
-rw-r--r--source/gameengine/GameLogic/SCA_RandomEventManager.h1
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.cpp54
-rw-r--r--source/gameengine/GameLogic/SCA_RandomSensor.h2
-rw-r--r--source/gameengine/GameLogic/SCA_TimeEventManager.cpp5
-rw-r--r--source/gameengine/GameLogic/SCA_TimeEventManager.h1
-rw-r--r--source/gameengine/GameLogic/SCA_XNORController.cpp148
-rw-r--r--source/gameengine/GameLogic/SCA_XNORController.h56
-rw-r--r--source/gameengine/GameLogic/SCA_XORController.cpp148
-rw-r--r--source/gameengine/GameLogic/SCA_XORController.h56
-rw-r--r--source/gameengine/GameLogic/SConscript12
-rw-r--r--source/gameengine/GamePlayer/CMakeLists.txt4
-rw-r--r--source/gameengine/GamePlayer/Makefile2
-rw-r--r--source/gameengine/GamePlayer/SConscript2
-rw-r--r--source/gameengine/GamePlayer/common/CMakeLists.txt3
-rw-r--r--source/gameengine/GamePlayer/common/GPC_Canvas.h24
-rw-r--r--source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp30
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RawImage.cpp2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RawImage.h2
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RenderTools.cpp538
-rw-r--r--source/gameengine/GamePlayer/common/GPC_RenderTools.h179
-rw-r--r--source/gameengine/GamePlayer/common/Makefile3
-rw-r--r--source/gameengine/GamePlayer/common/SConscript96
-rw-r--r--source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h4
-rw-r--r--source/gameengine/GamePlayer/common/windows/GPW_Canvas.h2
-rw-r--r--source/gameengine/GamePlayer/ghost/CMakeLists.txt2
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.cpp159
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_Application.h18
-rw-r--r--source/gameengine/GamePlayer/ghost/GPG_ghost.cpp157
-rw-r--r--source/gameengine/GamePlayer/ghost/Makefile6
-rw-r--r--source/gameengine/GamePlayer/ghost/SConscript74
-rw-r--r--source/gameengine/Ketsji/BL_BlenderShader.cpp170
-rw-r--r--source/gameengine/Ketsji/BL_BlenderShader.h53
-rw-r--r--source/gameengine/Ketsji/BL_Material.cpp7
-rw-r--r--source/gameengine/Ketsji/BL_Material.h19
-rw-r--r--source/gameengine/Ketsji/BL_Shader.cpp395
-rw-r--r--source/gameengine/Ketsji/BL_Shader.h6
-rw-r--r--source/gameengine/Ketsji/BL_Texture.cpp108
-rw-r--r--source/gameengine/Ketsji/BL_Texture.h8
-rw-r--r--source/gameengine/Ketsji/CMakeLists.txt18
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp17
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h3
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp14
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp100
-rw-r--r--source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h11
-rw-r--r--source/gameengine/Ketsji/KX_BlenderMaterial.cpp476
-rw-r--r--source/gameengine/Ketsji/KX_BlenderMaterial.h32
-rw-r--r--source/gameengine/Ketsji/KX_BulletPhysicsController.cpp98
-rw-r--r--source/gameengine/Ketsji/KX_BulletPhysicsController.h14
-rw-r--r--source/gameengine/Ketsji/KX_Camera.cpp48
-rw-r--r--source/gameengine/Ketsji/KX_Camera.h23
-rw-r--r--source/gameengine/Ketsji/KX_CameraActuator.cpp164
-rw-r--r--source/gameengine/Ketsji/KX_CameraActuator.h12
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.cpp805
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintActuator.h85
-rw-r--r--source/gameengine/Ketsji/KX_ConstraintWrapper.cpp4
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObject.h42
-rw-r--r--source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp695
-rw-r--r--source/gameengine/Ketsji/KX_GameActuator.cpp74
-rw-r--r--source/gameengine/Ketsji/KX_GameActuator.h2
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.cpp1414
-rw-r--r--source/gameengine/Ketsji/KX_GameObject.h341
-rw-r--r--source/gameengine/Ketsji/KX_IPO_SGController.cpp232
-rw-r--r--source/gameengine/Ketsji/KX_IPO_SGController.h47
-rw-r--r--source/gameengine/Ketsji/KX_IPhysicsController.h10
-rw-r--r--source/gameengine/Ketsji/KX_ISceneConverter.h9
-rw-r--r--source/gameengine/Ketsji/KX_IpoActuator.cpp327
-rw-r--r--source/gameengine/Ketsji/KX_IpoActuator.h26
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.cpp340
-rw-r--r--source/gameengine/Ketsji/KX_KetsjiEngine.h34
-rw-r--r--source/gameengine/Ketsji/KX_Light.cpp98
-rw-r--r--source/gameengine/Ketsji/KX_Light.h23
-rw-r--r--source/gameengine/Ketsji/KX_MaterialIpoController.cpp11
-rw-r--r--source/gameengine/Ketsji/KX_MaterialIpoController.h8
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.cpp60
-rw-r--r--source/gameengine/Ketsji/KX_MeshProxy.h2
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.cpp81
-rw-r--r--source/gameengine/Ketsji/KX_MouseFocusSensor.h17
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.cpp97
-rw-r--r--source/gameengine/Ketsji/KX_NearSensor.h3
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.cpp364
-rw-r--r--source/gameengine/Ketsji/KX_ObjectActuator.h59
-rw-r--r--source/gameengine/Ketsji/KX_OdePhysicsController.cpp10
-rw-r--r--source/gameengine/Ketsji/KX_OdePhysicsController.h6
-rw-r--r--source/gameengine/Ketsji/KX_ParentActuator.cpp221
-rw-r--r--source/gameengine/Ketsji/KX_ParentActuator.h89
-rw-r--r--source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp22
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.cpp265
-rw-r--r--source/gameengine/Ketsji/KX_PolyProxy.h71
-rw-r--r--source/gameengine/Ketsji/KX_PolygonMaterial.cpp60
-rw-r--r--source/gameengine/Ketsji/KX_PolygonMaterial.h5
-rw-r--r--source/gameengine/Ketsji/KX_PyConstraintBinding.cpp141
-rw-r--r--source/gameengine/Ketsji/KX_PyMath.h23
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.cpp1063
-rw-r--r--source/gameengine/Ketsji/KX_PythonInit.h17
-rw-r--r--source/gameengine/Ketsji/KX_RadarSensor.cpp55
-rw-r--r--source/gameengine/Ketsji/KX_RayCast.cpp80
-rw-r--r--source/gameengine/Ketsji/KX_RayCast.h60
-rw-r--r--source/gameengine/Ketsji/KX_RayEventManager.cpp9
-rw-r--r--source/gameengine/Ketsji/KX_RayEventManager.h1
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.cpp96
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.h9
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp243
-rw-r--r--source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h47
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp206
-rw-r--r--source/gameengine/Ketsji/KX_SCA_DynamicActuator.h76
-rw-r--r--source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp43
-rw-r--r--source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h2
-rw-r--r--source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp2
-rw-r--r--source/gameengine/Ketsji/KX_SG_NodeRelationships.h21
-rw-r--r--source/gameengine/Ketsji/KX_Scene.cpp660
-rw-r--r--source/gameengine/Ketsji/KX_Scene.h66
-rw-r--r--source/gameengine/Ketsji/KX_SceneActuator.cpp78
-rw-r--r--source/gameengine/Ketsji/KX_SceneActuator.h3
-rw-r--r--source/gameengine/Ketsji/KX_SoundActuator.cpp125
-rw-r--r--source/gameengine/Ketsji/KX_StateActuator.cpp207
-rw-r--r--source/gameengine/Ketsji/KX_StateActuator.h83
-rw-r--r--source/gameengine/Ketsji/KX_SumoPhysicsController.cpp10
-rw-r--r--source/gameengine/Ketsji/KX_SumoPhysicsController.h7
-rw-r--r--source/gameengine/Ketsji/KX_TouchEventManager.cpp70
-rw-r--r--source/gameengine/Ketsji/KX_TouchEventManager.h9
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.cpp85
-rw-r--r--source/gameengine/Ketsji/KX_TouchSensor.h11
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.cpp185
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.h7
-rw-r--r--source/gameengine/Ketsji/KX_VehicleWrapper.cpp105
-rw-r--r--source/gameengine/Ketsji/KX_VertexProxy.cpp14
-rw-r--r--source/gameengine/Ketsji/KX_VisibilityActuator.cpp14
-rw-r--r--source/gameengine/Ketsji/KX_VisibilityActuator.h2
-rw-r--r--source/gameengine/Ketsji/Makefile7
-rw-r--r--source/gameengine/Ketsji/SConscript23
-rw-r--r--source/gameengine/Makefile2
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsController.h2
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp5
-rw-r--r--source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h4
-rw-r--r--source/gameengine/Physics/BlOde/SConscript6
-rw-r--r--source/gameengine/Physics/Bullet/CMakeLists.txt4
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.cpp1175
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsController.h293
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp949
-rw-r--r--source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h59
-rw-r--r--source/gameengine/Physics/Bullet/Makefile5
-rw-r--r--source/gameengine/Physics/Bullet/SConscript6
-rw-r--r--source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp6
-rw-r--r--source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h6
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h1
-rw-r--r--source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp17
-rw-r--r--source/gameengine/Physics/Sumo/SConscript17
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsController.h1
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp43
-rw-r--r--source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h6
-rw-r--r--source/gameengine/Physics/common/PHY_DynamicTypes.h16
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsController.h4
-rw-r--r--source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h51
-rw-r--r--source/gameengine/PyDoc/BL_ActionActuator.py28
-rw-r--r--source/gameengine/PyDoc/BL_ShapeActionActuator.py167
-rw-r--r--source/gameengine/PyDoc/GameKeys.py9
-rw-r--r--source/gameengine/PyDoc/GameLogic.py95
-rw-r--r--source/gameengine/PyDoc/KX_ActuatorSensor.py25
-rw-r--r--source/gameengine/PyDoc/KX_CameraActuator.py8
-rw-r--r--source/gameengine/PyDoc/KX_ConstraintActuator.py126
-rw-r--r--source/gameengine/PyDoc/KX_GameObject.py221
-rw-r--r--source/gameengine/PyDoc/KX_IpoActuator.py17
-rw-r--r--source/gameengine/PyDoc/KX_MeshProxy.py15
-rw-r--r--source/gameengine/PyDoc/KX_ObjectActuator.py106
-rw-r--r--source/gameengine/PyDoc/KX_ParentActuator.py23
-rw-r--r--source/gameengine/PyDoc/KX_PolyProxy.py100
-rw-r--r--source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py30
-rw-r--r--source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py5
-rw-r--r--source/gameengine/PyDoc/KX_StateActuator.py26
-rw-r--r--source/gameengine/PyDoc/KX_TrackToActuator.py10
-rw-r--r--source/gameengine/PyDoc/Makefile13
-rw-r--r--source/gameengine/PyDoc/Rasterizer.py53
-rw-r--r--source/gameengine/PyDoc/SCA_DelaySensor.py56
-rw-r--r--source/gameengine/PyDoc/SCA_ISensor.py31
-rw-r--r--source/gameengine/PyDoc/SCA_JoystickSensor.py106
-rw-r--r--source/gameengine/PyDoc/SCA_PythonController.py8
-rw-r--r--source/gameengine/PyDoc/SConscript28
-rw-r--r--source/gameengine/PyDoc/epy_docgen.sh11
-rw-r--r--source/gameengine/Rasterizer/CMakeLists.txt3
-rw-r--r--source/gameengine/Rasterizer/Makefile7
-rw-r--r--source/gameengine/Rasterizer/RAS_2DFilterManager.cpp500
-rw-r--r--source/gameengine/Rasterizer/RAS_2DFilterManager.h98
-rw-r--r--source/gameengine/Rasterizer/RAS_BucketManager.cpp268
-rw-r--r--source/gameengine/Rasterizer/RAS_BucketManager.h22
-rw-r--r--source/gameengine/Rasterizer/RAS_CameraData.h9
-rw-r--r--source/gameengine/Rasterizer/RAS_Deformer.h8
-rw-r--r--source/gameengine/Rasterizer/RAS_FramingManager.h15
-rw-r--r--source/gameengine/Rasterizer/RAS_ICanvas.h8
-rw-r--r--source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp60
-rw-r--r--source/gameengine/Rasterizer/RAS_IPolygonMaterial.h24
-rw-r--r--source/gameengine/Rasterizer/RAS_IRasterizer.h125
-rw-r--r--source/gameengine/Rasterizer/RAS_IRenderTools.cpp24
-rw-r--r--source/gameengine/Rasterizer/RAS_IRenderTools.h58
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.cpp633
-rw-r--r--source/gameengine/Rasterizer/RAS_MaterialBucket.h235
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.cpp761
-rw-r--r--source/gameengine/Rasterizer/RAS_MeshObject.h246
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h51
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h51
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h50
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h41
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h41
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h53
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h58
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h41
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h52
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h57
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/ARB_multitexture.h150
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt2
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/EXT_separate_specular_color.h12
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile5
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp677
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h500
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp159
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h44
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp1537
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h96
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp441
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h29
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript6
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/glext.h6495
-rw-r--r--source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py627
-rw-r--r--source/gameengine/Rasterizer/RAS_Polygon.cpp101
-rw-r--r--source/gameengine/Rasterizer/RAS_Polygon.h56
-rw-r--r--source/gameengine/Rasterizer/RAS_TexVert.cpp65
-rw-r--r--source/gameengine/Rasterizer/RAS_TexVert.h67
-rw-r--r--source/gameengine/Rasterizer/SConscript8
-rw-r--r--source/gameengine/SConscript37
-rw-r--r--source/gameengine/SceneGraph/SG_Controller.h4
-rw-r--r--source/gameengine/SceneGraph/SG_IObject.cpp11
-rw-r--r--source/gameengine/SceneGraph/SG_IObject.h2
-rw-r--r--source/gameengine/SceneGraph/SG_Node.cpp50
-rw-r--r--source/gameengine/SceneGraph/SG_Node.h18
-rw-r--r--source/gameengine/SceneGraph/SG_ParentRelation.h19
-rw-r--r--source/gameengine/SceneGraph/SG_Spatial.cpp7
-rw-r--r--source/gameengine/SceneGraph/SG_Spatial.h4
-rw-r--r--source/gameengine/VideoTexture/BlendType.h75
-rw-r--r--source/gameengine/VideoTexture/CMakeLists.txt61
-rw-r--r--source/gameengine/VideoTexture/Common.h55
-rw-r--r--source/gameengine/VideoTexture/Exception.cpp209
-rw-r--r--source/gameengine/VideoTexture/Exception.h210
-rw-r--r--source/gameengine/VideoTexture/FilterBase.cpp150
-rw-r--r--source/gameengine/VideoTexture/FilterBase.h138
-rw-r--r--source/gameengine/VideoTexture/FilterBlueScreen.cpp178
-rw-r--r--source/gameengine/VideoTexture/FilterBlueScreen.h97
-rw-r--r--source/gameengine/VideoTexture/FilterColor.cpp350
-rw-r--r--source/gameengine/VideoTexture/FilterColor.h168
-rw-r--r--source/gameengine/VideoTexture/FilterNormal.cpp162
-rw-r--r--source/gameengine/VideoTexture/FilterNormal.h107
-rw-r--r--source/gameengine/VideoTexture/FilterSource.cpp171
-rw-r--r--source/gameengine/VideoTexture/FilterSource.h258
-rw-r--r--source/gameengine/VideoTexture/ImageBase.cpp529
-rw-r--r--source/gameengine/VideoTexture/ImageBase.h349
-rw-r--r--source/gameengine/VideoTexture/ImageBuff.cpp166
-rw-r--r--source/gameengine/VideoTexture/ImageBuff.h51
-rw-r--r--source/gameengine/VideoTexture/ImageMix.cpp205
-rw-r--r--source/gameengine/VideoTexture/ImageMix.h123
-rw-r--r--source/gameengine/VideoTexture/ImageRender.cpp267
-rw-r--r--source/gameengine/VideoTexture/ImageRender.h90
-rw-r--r--source/gameengine/VideoTexture/ImageViewport.cpp297
-rw-r--r--source/gameengine/VideoTexture/ImageViewport.h84
-rw-r--r--source/gameengine/VideoTexture/Makefile65
-rw-r--r--source/gameengine/VideoTexture/PyTypeList.cpp83
-rw-r--r--source/gameengine/VideoTexture/PyTypeList.h85
-rw-r--r--source/gameengine/VideoTexture/SConscript32
-rw-r--r--source/gameengine/VideoTexture/Texture.cpp475
-rw-r--r--source/gameengine/VideoTexture/Texture.h86
-rw-r--r--source/gameengine/VideoTexture/VideoBase.cpp195
-rw-r--r--source/gameengine/VideoTexture/VideoBase.h185
-rw-r--r--source/gameengine/VideoTexture/VideoFFmpeg.cpp927
-rw-r--r--source/gameengine/VideoTexture/VideoFFmpeg.h173
-rw-r--r--source/gameengine/VideoTexture/blendVideoTex.cpp194
386 files changed, 30886 insertions, 18722 deletions
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
index 12c550c52b7..0dab583567d 100644
--- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
+++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp
@@ -33,15 +33,14 @@
#endif
#include <signal.h>
+#include <stdlib.h>
#ifdef WIN32
// don't show stl-warnings
#pragma warning (disable:4786)
#endif
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#endif
+#include "GL/glew.h"
#include "KX_BlenderGL.h"
#include "KX_BlenderCanvas.h"
@@ -56,10 +55,10 @@
#include "KX_PythonInit.h"
#include "KX_PyConstraintBinding.h"
+#include "RAS_GLExtensionManager.h"
#include "RAS_OpenGLRasterizer.h"
#include "RAS_VAOpenGLRasterizer.h"
#include "RAS_ListRasterizer.h"
-#include "RAS_GLExtensionManager.h"
#include "NG_LoopBackNetworkDeviceInterface.h"
#include "SND_DeviceManager.h"
@@ -71,6 +70,7 @@
#include "DNA_view3d_types.h"
#include "DNA_screen_types.h"
#include "BKE_global.h"
+#include "BKE_utildefines.h"
//XXX #include "BIF_screen.h"
//XXX #include "BIF_scrarea.h"
@@ -80,6 +80,8 @@
#include "DNA_scene_types.h"
/***/
+#include "GPU_extensions.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -91,28 +93,10 @@ void update_for_newframe();
static BlendFileData *load_game_data(char *filename) {
BlendReadError error;
- //this doesn't work anymore for relative paths, so use BLO_read_from_memory instead
- //BlendFileData *bfd= BLO_read_from_file(filename, &error);
- FILE* file = fopen(filename,"rb");
- BlendFileData *bfd = 0;
- if (file)
- {
- fseek(file, 0L, SEEK_END);
- int len= ftell(file);
- fseek(file, 0L, SEEK_SET);
- char* filebuffer= new char[len];//MEM_mallocN(len, "text_buffer");
- int sizeread = fread(filebuffer,len,1,file);
- if (sizeread==1)
- {
- bfd = BLO_read_from_memory(filebuffer, len, &error);
- }
- fclose(file);
- }
-
+ BlendFileData *bfd= BLO_read_from_file(filename, &error);
if (!bfd) {
printf("Loading %s failed: %s\n", filename, BLO_bre_as_string(error));
}
-
return bfd;
}
@@ -127,17 +111,26 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
Main* blenderdata = maggie1;
char* startscenename = scenename;
- char pathname[160];
- strcpy (pathname, blenderdata->name);
+ char pathname[FILE_MAXDIR+FILE_MAXFILE], oldsce[FILE_MAXDIR+FILE_MAXFILE];
STR_String exitstring = "";
BlendFileData *bfd= NULL;
- bgl::InitExtensions(1);
+ BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));
+ BLI_strncpy(oldsce, G.sce, sizeof(oldsce));
+ setGamePythonPath(G.sce);
+
+ // Acquire Python's GIL (global interpreter lock)
+ // so we can safely run Python code and API calls
+ PyGILState_STATE gilstate = PyGILState_Ensure();
+
+ PyObject *pyGlobalDict = PyDict_New(); /* python utility storage, spans blend file loading */
+ bgl::InitExtensions(true);
+
do
{
View3D *v3d= (View3D*) area->spacedata.first;
-
+
// get some preferences
SYS_SystemHandle syshandle = SYS_GetSystem();
bool properties = (SYS_GetCommandLineInt(syshandle, "show_properties", 0) != 0);
@@ -146,20 +139,6 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
bool game2ipo = (SYS_GetCommandLineInt(syshandle, "game2ipo", 0) != 0);
bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0);
- bool usemat = false;
-
- #ifdef GL_ARB_multitexture
- if(bgl::RAS_EXT_support._ARB_multitexture && bgl::QueryVersion(1, 1)) {
- usemat = (SYS_GetCommandLineInt(syshandle, "blender_material", 0) != 0);
- int unitmax=0;
- glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&unitmax);
- bgl::max_texture_units = MAXTEX>unitmax?unitmax:MAXTEX;
- //std::cout << "using(" << bgl::max_texture_units << ") of(" << unitmax << ") texture units." << std::endl;
- } else {
- bgl::max_texture_units = 0;
- }
- #endif
-
// create the canvas, rasterizer and rendertools
RAS_ICanvas* canvas = new KX_BlenderCanvas(area);
@@ -167,16 +146,14 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
RAS_IRenderTools* rendertools = new KX_BlenderRenderTools();
RAS_IRasterizer* rasterizer = NULL;
- // let's see if we want to use vertexarrays or not
- int usevta = SYS_GetCommandLineInt(syshandle,"vertexarrays",1);
- bool useVertexArrays = (usevta > 0);
-
- bool lock_arrays = (displaylists && useVertexArrays);
-
- if(displaylists && !useVertexArrays)
- rasterizer = new RAS_ListRasterizer(canvas);
- else if (useVertexArrays && bgl::QueryVersion(1, 1))
- rasterizer = new RAS_VAOpenGLRasterizer(canvas, lock_arrays);
+ if(displaylists) {
+ if (GLEW_VERSION_1_1)
+ rasterizer = new RAS_ListRasterizer(canvas, true, true);
+ else
+ rasterizer = new RAS_ListRasterizer(canvas);
+ }
+ else if (GLEW_VERSION_1_1)
+ rasterizer = new RAS_VAOpenGLRasterizer(canvas, false);
else
rasterizer = new RAS_OpenGLRasterizer(canvas);
@@ -188,6 +165,13 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
NG_NetworkDeviceInterface* networkdevice = new
NG_LoopBackNetworkDeviceInterface();
+ //
+ SYS_SystemHandle hSystem = SYS_GetSystem();
+ bool noaudio = SYS_GetCommandLineInt(hSystem,"noaudio",0);
+
+ if (noaudio)/*(noaudio) intrr: disable game engine audio (openal) */
+ SND_DeviceManager::SetDeviceType(snd_e_dummydevice);
+
// get an audiodevice
SND_DeviceManager::Subscribe();
SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
@@ -211,11 +195,21 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
ketsjiengine->SetUseFixedTime(usefixed);
ketsjiengine->SetTimingDisplay(frameRate, profile, properties);
-
+
+ //lock frame and camera enabled - storing global values
+ int tmp_lay= G.scene->lay;
+ Object *tmp_camera = G.scene->camera;
+
+ if (G.vd->scenelock==0){
+ G.scene->lay= v3d->lay;
+ G.scene->camera= v3d->camera;
+ }
+
// some blender stuff
MT_CmMatrix4x4 projmat;
MT_CmMatrix4x4 viewmat;
+ float camzoom;
int i;
for (i = 0; i < 16; i++)
@@ -229,8 +223,13 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
projmat.setElem(i, projmat_linear[i]);
}
- float camzoom = (1.41421 + (v3d->camzoom / 50.0));
- camzoom *= camzoom;
+ if(v3d->persp==V3D_CAMOB) {
+ camzoom = (1.41421 + (v3d->camzoom / 50.0));
+ camzoom *= camzoom;
+ }
+ else
+ camzoom = 2.0;
+
camzoom = 4.0 / camzoom;
ketsjiengine->SetDrawType(v3d->drawtype);
@@ -242,24 +241,29 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
exitrequested = KX_EXIT_REQUEST_NO_REQUEST;
if (bfd) BLO_blendfiledata_free(bfd);
- char basedpath[160];
+ char basedpath[240];
// base the actuator filename with respect
// to the original file working directory
+
if (exitstring != "")
strcpy(basedpath, exitstring.Ptr());
- BLI_convertstringcode(basedpath, pathname, 0);
+ // load relative to the last loaded file, this used to be relative
+ // to the first file but that makes no sense, relative paths in
+ // blend files should be relative to that file, not some other file
+ // that happened to be loaded first
+ BLI_convertstringcode(basedpath, pathname);
bfd = load_game_data(basedpath);
// if it wasn't loaded, try it forced relative
if (!bfd)
{
// just add "//" in front of it
- char temppath[162];
+ char temppath[242];
strcpy(temppath, "//");
strcat(temppath, basedpath);
- BLI_convertstringcode(temppath, pathname, 0);
+ BLI_convertstringcode(temppath, pathname);
bfd = load_game_data(temppath);
}
@@ -268,6 +272,11 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
{
blenderdata = bfd->main;
startscenename = bfd->curscene->id.name + 2;
+
+ if(blenderdata) {
+ BLI_strncpy(G.sce, blenderdata->name, sizeof(G.sce));
+ BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));
+ }
}
// else forget it, we can't find it
else
@@ -305,12 +314,13 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
{
- if (v3d->persp != 2)
+ if (v3d->persp != V3D_CAMOB)
{
ketsjiengine->EnableCameraOverride(startscenename);
- ketsjiengine->SetCameraOverrideUseOrtho((v3d->persp == 0));
+ ketsjiengine->SetCameraOverrideUseOrtho((v3d->persp == V3D_ORTHO));
ketsjiengine->SetCameraOverrideProjectionMatrix(projmat);
ketsjiengine->SetCameraOverrideViewMatrix(viewmat);
+ ketsjiengine->SetCameraOverrideClipping(v3d->near, v3d->far);
}
// create a scene converter, create and convert the startingscene
@@ -319,25 +329,43 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
sceneconverter->addInitFromFrame=false;
if (always_use_expand_framing)
sceneconverter->SetAlwaysUseExpandFraming(true);
-
- if(usemat)
+
+ bool usemat = false, useglslmat = false;
+
+ if(GLEW_ARB_multitexture && GLEW_VERSION_1_1)
+ usemat = true;
+
+ if(GPU_extensions_minimum_support())
+ useglslmat = true;
+ else if(G.fileflags & G_FILE_GAME_MAT_GLSL)
+ usemat = false;
+
+ if(usemat && (G.fileflags & G_FILE_GAME_MAT))
sceneconverter->SetMaterials(true);
+ if(useglslmat && (G.fileflags & G_FILE_GAME_MAT_GLSL))
+ sceneconverter->SetGLSLMaterials(true);
KX_Scene* startscene = new KX_Scene(keyboarddevice,
mousedevice,
networkdevice,
audiodevice,
- startscenename);
+ startscenename,
+ blscene);
// some python things
PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest);
ketsjiengine->SetPythonDictionary(dictionaryobject);
initRasterizer(rasterizer, canvas);
- PyObject *gameLogic = initGameLogic(startscene);
+ PyObject *gameLogic = initGameLogic(ketsjiengine, startscene);
+ PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module.
+ PyObject *gameLogic_keys = PyDict_Keys(PyModule_GetDict(gameLogic));
+ PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module.
+
initGameKeys();
initPythonConstraintBinding();
+ initMathutils();
+ initVideoTexture();
-
if (sceneconverter)
{
// convert and add scene
@@ -356,7 +384,14 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
// start the engine
ketsjiengine->StartEngine(true);
+
+ // Set the animation playback rate for ipo's and actions
+ // the framerate below should patch with FPS macro defined in blendef.h
+ // Could be in StartEngine set the framerate, we need the scene to do this
+ ketsjiengine->SetAnimFrameRate( (((double) blscene->r.frs_sec) / blscene->r.frs_sec_base) );
+
// the mainloop
+ printf("\nBlender Game Engine Started\n\n");
while (!exitrequested)
{
// first check if we want to exit
@@ -392,10 +427,32 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
mousedevice->ConvertBlenderEvent(event,val);
}
}
+ printf("\nBlender Game Engine Finished\n\n");
exitstring = ketsjiengine->GetExitString();
-
+
+
// when exiting the mainloop
- dictionaryClearByHand(gameLogic);
+
+ // Clears the dictionary by hand:
+ // This prevents, extra references to global variables
+ // inside the GameLogic dictionary when the python interpreter is finalized.
+ // which allows the scene to safely delete them :)
+ // see: (space.c)->start_game
+
+ //PyDict_Clear(PyModule_GetDict(gameLogic));
+
+ // Keep original items, means python plugins will autocomplete members
+ int listIndex;
+ PyObject *gameLogic_keys_new = PyDict_Keys(PyModule_GetDict(gameLogic));
+ for (listIndex=0; listIndex < PyList_Size(gameLogic_keys_new); listIndex++) {
+ PyObject* item = PyList_GET_ITEM(gameLogic_keys_new, listIndex);
+ if (!PySequence_Contains(gameLogic_keys, item)) {
+ PyDict_DelItem( PyModule_GetDict(gameLogic), item);
+ }
+ }
+ Py_DECREF(gameLogic_keys_new);
+ gameLogic_keys_new = NULL;
+
ketsjiengine->StopEngine();
exitGamePythonScripting();
networkdevice->Disconnect();
@@ -405,7 +462,16 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
delete sceneconverter;
sceneconverter = NULL;
}
+
+ Py_DECREF(gameLogic_keys);
+ gameLogic_keys = NULL;
+ }
+ //lock frame and camera enabled - restoring global values
+ if (G.vd->scenelock==0){
+ G.scene->lay= tmp_lay;
+ G.scene->camera= tmp_camera;
}
+
// set the cursor back to normal
canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
@@ -457,6 +523,11 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
} while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME);
if (bfd) BLO_blendfiledata_free(bfd);
+
+ BLI_strncpy(G.sce, oldsce, sizeof(G.sce));
+
+ // Release Python's GIL
+ PyGILState_Release(gilstate);
}
extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
@@ -470,12 +541,16 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
Main* blenderdata = maggie;
char* startscenename = scenename;
- char pathname[160];
- strcpy (pathname, maggie->name);
+ char pathname[FILE_MAXDIR+FILE_MAXFILE];
STR_String exitstring = "";
- BlendFileData *bfd= NULL;
- bgl::InitExtensions(1);
+ BLI_strncpy(pathname, blenderdata->name, sizeof(pathname));
+
+ // Acquire Python's GIL (global interpreter lock)
+ // so we can safely run Python code and API calls
+ PyGILState_STATE gilstate = PyGILState_Ensure();
+
+ bgl::InitExtensions(true);
do
{
@@ -496,16 +571,14 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
RAS_IRenderTools* rendertools = new KX_BlenderRenderTools();
RAS_IRasterizer* rasterizer = NULL;
- // let's see if we want to use vertexarrays or not
- int usevta = SYS_GetCommandLineInt(syshandle,"vertexarrays",1);
- bool useVertexArrays = (usevta > 0);
-
- bool lock_arrays = (displaylists && useVertexArrays);
-
- if(displaylists && !useVertexArrays)
- rasterizer = new RAS_ListRasterizer(canvas);
- else if (useVertexArrays && bgl::QueryVersion(1, 1))
- rasterizer = new RAS_VAOpenGLRasterizer(canvas, lock_arrays);
+ if(displaylists) {
+ if (GLEW_VERSION_1_1)
+ rasterizer = new RAS_ListRasterizer(canvas, true, true);
+ else
+ rasterizer = new RAS_ListRasterizer(canvas);
+ }
+ else if (GLEW_VERSION_1_1)
+ rasterizer = new RAS_VAOpenGLRasterizer(canvas, false);
else
rasterizer = new RAS_OpenGLRasterizer(canvas);
@@ -528,24 +601,19 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
// create the ketsjiengine
KX_KetsjiEngine* ketsjiengine = new KX_KetsjiEngine(kxsystem);
- int i;
-
Scene *blscene = NULL;
- if (!bfd)
+
+ blscene = (Scene*) maggie->scene.first;
+ for (Scene *sce= (Scene*) maggie->scene.first; sce; sce= (Scene*) sce->id.next)
{
- blscene = (Scene*) maggie->scene.first;
- for (Scene *sce= (Scene*) maggie->scene.first; sce; sce= (Scene*) sce->id.next)
+ if (startscenename == (sce->id.name+2))
{
- if (startscenename == (sce->id.name+2))
- {
- blscene = sce;
- break;
- }
+ blscene = sce;
+ break;
}
- } else {
- blscene = bfd->curscene;
}
- int cframe,startFrame;
+
+ int cframe = 1, startFrame;
if (blscene)
{
cframe=blscene->r.cfra;
@@ -576,14 +644,19 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
mousedevice,
networkdevice,
audiodevice,
- startscenename);
+ startscenename,
+ blscene);
+
// some python things
PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest);
ketsjiengine->SetPythonDictionary(dictionaryobject);
initRasterizer(rasterizer, canvas);
- PyObject *gameLogic = initGameLogic(startscene);
+ PyObject *gameLogic = initGameLogic(ketsjiengine, startscene);
+ PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module
initGameKeys();
initPythonConstraintBinding();
+ initMathutils();
+ initVideoTexture();
if (sceneconverter)
{
@@ -661,5 +734,7 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
SND_DeviceManager::Unsubscribe();
} while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME);
- if (bfd) BLO_blendfiledata_free(bfd);
+
+ // Release Python's GIL
+ PyGILState_Release(gilstate);
}
diff --git a/source/gameengine/BlenderRoutines/CMakeLists.txt b/source/gameengine/BlenderRoutines/CMakeLists.txt
index 11a87460f20..2300323a55e 100644
--- a/source/gameengine/BlenderRoutines/CMakeLists.txt
+++ b/source/gameengine/BlenderRoutines/CMakeLists.txt
@@ -33,8 +33,10 @@ SET(INC
../../../intern/SoundSystem
../../../source/blender/misc
../../../source/blender/blenloader
+ ../../../source/blender/gpu
../../../extern/bullet2/src
../../../extern/solid
+ ../../../extern/glew/include
${PYTHON_INC}
)
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
index a65275dda8f..750a1ef3f93 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.cpp
@@ -101,6 +101,13 @@ int KX_BlenderCanvas::GetHeight(
return 0; //XXX scrarea_get_win_height(m_area);
}
+RAS_Rect &
+KX_BlenderCanvas::
+GetWindowArea(
+){
+ return m_area_rect;
+}
+
void
KX_BlenderCanvas::
SetViewPort(
@@ -112,6 +119,11 @@ SetViewPort(
int minx = 0;//XXX scrarea_get_win_x(m_area);
int miny = 0;//XXX scrarea_get_win_y(m_area);
+ m_area_rect.SetLeft(minx + x1);
+ m_area_rect.SetBottom(miny + y1);
+ m_area_rect.SetRight(minx + x2);
+ m_area_rect.SetTop(miny + y2);
+
glViewport(minx + x1, miny + y1, vp_width, vp_height);
glScissor(minx + x1, miny + y1, vp_width, vp_height);
}
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
index 0b3519efdbd..bc202a8558c 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderCanvas.h
@@ -32,11 +32,8 @@
#ifdef WIN32
#include <windows.h>
#endif
-#ifdef __APPLE__
-#include <OpenGL/gl.h>
-#else
-#include <GL/gl.h>
-#endif
+
+#include "GL/glew.h"
#include "RAS_ICanvas.h"
#include "RAS_Rect.h"
@@ -120,6 +117,10 @@ public:
return m_displayarea;
};
+ RAS_Rect &
+ GetWindowArea(
+ );
+
void
SetViewPort(
int x1, int y1,
@@ -162,6 +163,7 @@ public:
private:
/** Blender area the game engine is running within */
struct ScrArea* m_area;
+ RAS_Rect m_area_rect;
};
#endif // __KX_BLENDERCANVAS
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
index bd3ae4ee912..b3b10e8bf07 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.cpp
@@ -44,21 +44,8 @@
#include "BMF_Api.h"
+#include "BIF_gl.h"
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#include <OpenGL/glu.h>
-#else
-#include <GL/gl.h>
-#if defined(__sun__) && !defined(__sparc__)
-#include <mesa/glu.h>
-#else
-#include <GL/glu.h>
-#endif
-#endif
-#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h"
-#include "RAS_OpenGLRasterizer/ARB_multitexture.h"
#include "BL_Material.h" // MAXTEX
/* Data types encoding the game world: */
@@ -77,7 +64,6 @@
#include "BKE_bmfont.h"
#include "BKE_image.h"
-#include "BIF_gl.h"
extern "C" {
//XXX #include "BDR_drawmesh.h"
//XXX #include "BIF_mywindow.h"
@@ -88,12 +74,6 @@ extern "C" {
/* end of blender block */
-#ifdef __APPLE__
-#include <OpenGL/gl.h>
-#else
-#include <GL/gl.h>
-#endif
-
/* was in drawmesh.c */
void spack(unsigned int ucol)
{
@@ -112,103 +92,40 @@ void BL_SwapBuffers()
//XXX myswapbuffers();
}
-void BL_RenderText(int mode,const char* textstr,int textlen,struct MTFace* tface,
- unsigned int *col,float v1[3],float v2[3],float v3[3],float v4[3])
-{
- Image* ima;
-
- if(mode & TF_BMFONT) {
- //char string[MAX_PROPSTRING];
- int characters, index, character;
- float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance;
-
-// bProperty *prop;
-
- // string = "Frank van Beek";
-
- characters = textlen;
-
- ima = (struct Image*) tface->tpage;
- if (ima == NULL) {
- characters = 0;
- }
-
- if(!col) glColor3f(1.0f, 1.0f, 1.0f);
-
- glPushMatrix();
- for (index = 0; index < characters; index++) {
- // lets calculate offset stuff
- character = textstr[index];
-
- // space starts at offset 1
- // character = character - ' ' + 1;
-
- matrixGlyph((ImBuf *)ima->ibufs.first, character, & centerx, &centery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
-
- glBegin(GL_POLYGON);
- // printf(" %c %f %f %f %f\n", character, tface->uv[0][0], tface->uv[0][1], );
- // glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy);
- glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy);
-
- if(col) spack(col[0]);
- // glVertex3fv(v1);
- glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]);
-
- glTexCoord2f((tface->uv[1][0] - centerx) * sizex + transx, (tface->uv[1][1] - centery) * sizey + transy);
- if(col) spack(col[1]);
- // glVertex3fv(v2);
- glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]);
-
- glTexCoord2f((tface->uv[2][0] - centerx) * sizex + transx, (tface->uv[2][1] - centery) * sizey + transy);
- if(col) spack(col[2]);
- // glVertex3fv(v3);
- glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]);
-
- if(v4) {
- // glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, 1.0 - (1.0 - tface->uv[3][1]) * sizey - transy);
- glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, (tface->uv[3][1] - centery) * sizey + transy);
- if(col) spack(col[3]);
- // glVertex3fv(v4);
- glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]);
- }
- glEnd();
-
- glTranslatef(advance, 0.0, 0.0);
- }
- glPopMatrix();
-
- }
-}
-
-
void DisableForText()
{
- if(glIsEnabled(GL_BLEND))
- glDisable(GL_BLEND);
+ if(glIsEnabled(GL_BLEND)) glDisable(GL_BLEND);
+ if(glIsEnabled(GL_ALPHA_TEST)) glDisable(GL_ALPHA_TEST);
if(glIsEnabled(GL_LIGHTING)) {
glDisable(GL_LIGHTING);
glDisable(GL_COLOR_MATERIAL);
}
-#ifdef GL_ARB_multitexture
- for(int i=0; i<MAXTEX; i++) {
- if(bgl::RAS_EXT_support._ARB_multitexture)
- bgl::blActiveTextureARB(GL_TEXTURE0_ARB+i);
-#ifdef GL_ARB_texture_cube_map
- if(bgl::RAS_EXT_support._ARB_texture_cube_map)
- if(glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB))
- glDisable(GL_TEXTURE_CUBE_MAP_ARB);
-#endif
+
+ if(GLEW_ARB_multitexture) {
+ for(int i=0; i<MAXTEX; i++) {
+ glActiveTextureARB(GL_TEXTURE0_ARB+i);
+
+ if(GLEW_ARB_texture_cube_map)
+ if(glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB))
+ glDisable(GL_TEXTURE_CUBE_MAP_ARB);
+
+ if(glIsEnabled(GL_TEXTURE_2D))
+ glDisable(GL_TEXTURE_2D);
+ }
+
+ glActiveTextureARB(GL_TEXTURE0_ARB);
+ }
+ else {
+ if(GLEW_ARB_texture_cube_map)
+ if(glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB))
+ glDisable(GL_TEXTURE_CUBE_MAP_ARB);
+
if(glIsEnabled(GL_TEXTURE_2D))
glDisable(GL_TEXTURE_2D);
}
-#else//GL_ARB_multitexture
- if(glIsEnabled(GL_TEXTURE_2D))
- glDisable(GL_TEXTURE_2D);
-#endif
}
-
void BL_print_gamedebug_line(char* text, int xco, int yco, int width, int height)
{
/* gl prepping */
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderGL.h b/source/gameengine/BlenderRoutines/KX_BlenderGL.h
index c8e0d47afb6..b891a7343c2 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderGL.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderGL.h
@@ -46,9 +46,6 @@ void BL_HideMouse();
void BL_NormalMouse();
void BL_WaitMouse();
-void BL_RenderText(int mode,const char* textstr,int textlen,struct MTFace* tface,
- unsigned int *col,float v1[3],float v2[3],float v3[3],float v4[3]);
-
void BL_print_gamedebug_line(char* text, int xco, int yco, int width, int height);
void BL_print_gamedebug_line_padded(char* text, int xco, int yco, int width, int height);
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp b/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp
deleted file mode 100644
index d173b1c66d9..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.cpp
+++ /dev/null
@@ -1,114 +0,0 @@
-/**
- * $Id$
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * 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
- * of the License, or (at your option) any later version.
- *
- * 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,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include "KX_BlenderPolyMaterial.h"
-#include "BKE_mesh.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#if 0
-KX_BlenderPolyMaterial::KX_BlenderPolyMaterial(const STR_String &texname,
- bool ba,
- const STR_String& matname,
- int tile,
- int tilexrep,
- int tileyrep,
- int mode,
- bool transparant,
- bool zsort,
- int lightlayer,
- bool bIsTriangle,
- void* clientobject,
- struct MTFace* tface)
- : RAS_IPolyMaterial(texname,
- false,
- matname,
- tile,
- tilexrep,
- tileyrep,
- mode,
- transparant,
- zsort,
- lightlayer,
- bIsTriangle,
- clientobject),
- m_tface(tface)
-{
-}
-
-void KX_BlenderPolyMaterial::Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const
-{
-
-
- if (GetCachingInfo() != cachingInfo)
- {
- if (!cachingInfo)
- {
- set_tpage(NULL);
- }
- cachingInfo = GetCachingInfo();
-
- if ((m_drawingmode & 4)&& (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED))
- {
- update_realtime_texture((struct MTFace*) m_tface, rasty->GetTime());
- set_tpage(m_tface);
- rasty->EnableTextures(true);
- }
- else
- {
- set_tpage(NULL);
- rasty->EnableTextures(false);
- }
-
- if(m_drawingmode & RAS_IRasterizer::KX_TWOSIDE)
- {
- rasty->SetCullFace(false);
- }
- else
- {
- rasty->SetCullFace(true);
- }
-
- if (m_drawingmode & RAS_IRasterizer::KX_LINES) {
- rasty->SetLines(true);
- }
- else {
- rasty->SetLines(false);
- }
- }
-
- rasty->SetSpecularity(m_specular[0],m_specular[1],m_specular[2],m_specularity);
- rasty->SetShinyness(m_shininess);
- rasty->SetDiffuse(m_diffuse[0], m_diffuse[1],m_diffuse[2], 1.0);
-}
-
-
-#endif
-
-
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h b/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h
deleted file mode 100644
index 35823b2125b..00000000000
--- a/source/gameengine/BlenderRoutines/KX_BlenderPolyMaterial.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * $Id$
- *
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * 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
- * of the License, or (at your option) any later version.
- *
- * 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,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * 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.
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-#ifndef __KX_BLENDERPOLYMATERIAL
-#define __KX_BLENDERPOLYMATERIAL
-
-#include "RAS_MaterialBucket.h"
-#include "RAS_IRasterizer.h"
-
-struct MTFace;
-extern "C" int set_tpage(MTFace* tface); /* Worst hack ever */
-
-#if 0
-class KX_BlenderPolyMaterial : public RAS_IPolyMaterial
-{
- /** Blender texture face structure. */
- MTFace* m_tface;
-
-public:
-
- KX_BlenderPolyMaterial(const STR_String &texname,
- bool ba,
- const STR_String& matname,
- int tile,
- int tilexrep,
- int tileyrep,
- int mode,
- bool transparant,
- bool zsort,
- int lightlayer,
- bool bIsTriangle,
- void* clientobject,
- struct MTFace* tface);
-
- /**
- * Returns the caching information for this material,
- * This can be used to speed up the rasterizing process.
- * @return The caching information.
- */
- virtual TCachingInfo GetCachingInfo(void) const;
-
- /**
- * Activates the material in the (OpenGL) rasterizer.
- * On entry, the cachingInfo contains info about the last activated material.
- * On exit, the cachingInfo should contain updated info about this material.
- * @param rasty The rasterizer in which the material should be active.
- * @param cachingInfo The information about the material used to speed up rasterizing.
- */
- virtual void Activate(RAS_IRasterizer* rasty, TCachingInfo& cachingInfo) const;
-
- /**
- * Returns the Blender texture face structure that is used for this material.
- * @return The material's texture face.
- */
- MTFace* GetMTFace(void) const;
-protected:
-private:
-};
-
-
-inline MTFace* KX_BlenderPolyMaterial::GetMTFace(void) const
-{
- return m_tface;
-}
-
-inline RAS_IPolyMaterial::TCachingInfo KX_BlenderPolyMaterial::GetCachingInfo(void) const
-{
- return GetMTFace();
-}
-
-#endif
-
-#endif // __KX_BLENDERPOLYMATERIAL
-
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
index 6a098cc5491..1797d6c1a0f 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
+++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.cpp
@@ -26,18 +26,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#include "KX_BlenderRenderTools.h"
-
-#ifdef WIN32
-// OpenGL gl.h needs 'windows.h' on windows platforms
-#include <windows.h>
-#endif //WIN32
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#else
-#include <GL/gl.h>
-#endif
+#include "GL/glew.h"
#include "RAS_IRenderTools.h"
#include "RAS_IRasterizer.h"
@@ -45,24 +34,22 @@
#include "RAS_ICanvas.h"
#include "RAS_GLExtensionManager.h"
-// next two includes/dependencies come from the shadow feature
-// it needs the gameobject and the sumo physics scene for a raycast
#include "KX_GameObject.h"
-
-#include "KX_BlenderPolyMaterial.h"
#include "KX_PolygonMaterial.h"
#include "KX_BlenderMaterial.h"
+#include "KX_RayCast.h"
+#include "KX_IPhysicsController.h"
-#include "Value.h"
+#include "PHY_IPhysicsEnvironment.h"
-#include "KX_BlenderGL.h" // for text printing
#include "STR_String.h"
-#include "RAS_BucketManager.h" // for polymaterial (needed for textprinting)
-#include "KX_RayCast.h"
-#include "KX_IPhysicsController.h"
-#include "PHY_IPhysicsEnvironment.h"
-#include "KX_Scene.h"
+#include "GPU_draw.h"
+
+#include "KX_BlenderGL.h" // for text printing
+#include "KX_BlenderRenderTools.h"
+
+unsigned int KX_BlenderRenderTools::m_numgllights;
KX_BlenderRenderTools::KX_BlenderRenderTools()
{
@@ -71,61 +58,98 @@ KX_BlenderRenderTools::KX_BlenderRenderTools()
m_numgllights = 8;
}
-/**
-ProcessLighting performs lighting on objects. the layer is a bitfield that contains layer information.
-There are 20 'official' layers in blender.
-A light is applied on an object only when they are in the same layer.
-OpenGL has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in a scene.
-*/
+KX_BlenderRenderTools::~KX_BlenderRenderTools()
+{
+}
-int KX_BlenderRenderTools::ProcessLighting(int layer)
+void KX_BlenderRenderTools::BeginFrame(RAS_IRasterizer* rasty)
{
-
- int result = false;
+ m_clientobject = NULL;
+ m_lastlightlayer = -1;
+ m_lastlighting = false;
+ DisableOpenGLLights();
+}
- if (layer < 0)
- {
- DisableOpenGLLights();
- result = false;
- } else
+void KX_BlenderRenderTools::EndFrame(RAS_IRasterizer* rasty)
+{
+}
+
+/* ProcessLighting performs lighting on objects. the layer is a bitfield that
+ * contains layer information. There are 20 'official' layers in blender. A
+ * light is applied on an object only when they are in the same layer. OpenGL
+ * has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in
+ * a scene. */
+
+void KX_BlenderRenderTools::ProcessLighting(int layer, const MT_Transform& viewmat)
+{
+ if(m_lastlightlayer == layer)
+ return;
+
+ m_lastlightlayer = layer;
+
+ bool enable = false;
+
+ if (layer >= 0)
{
if (m_clientobject)
{
- if (applyLights(layer))
- {
- EnableOpenGLLights();
- result = true;
- } else
- {
- DisableOpenGLLights();
- result = false;
- }
+ if (layer == RAS_LIGHT_OBJECT_LAYER)
+ layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer();
+
+ enable = applyLights(layer, viewmat);
}
}
- return result;
-
-
+
+ if(enable)
+ EnableOpenGLLights();
+ else
+ DisableOpenGLLights();
}
+void KX_BlenderRenderTools::EnableOpenGLLights()
+{
+ if(m_lastlighting == true)
+ return;
-void KX_BlenderRenderTools::BeginFrame(RAS_IRasterizer* rasty)
+ glEnable(GL_LIGHTING);
+ glEnable(GL_COLOR_MATERIAL);
+
+ glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, true);
+ if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2)
+ glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
+
+ m_lastlighting = true;
+}
+
+void KX_BlenderRenderTools::DisableOpenGLLights()
{
- m_clientobject = NULL;
- m_lastblenderobject = NULL;
- m_lastblenderlights = false;
- m_lastlayer = -1;
+ if(m_lastlighting == false)
+ return;
+
+ glDisable(GL_LIGHTING);
+ glDisable(GL_COLOR_MATERIAL);
+
m_lastlighting = false;
- m_modified = true;
- DisableOpenGLLights();
+}
+
+void KX_BlenderRenderTools::SetClientObject(RAS_IRasterizer *rasty, void* obj)
+{
+ if (m_clientobject != obj)
+ {
+ bool ccw = (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling());
+ rasty->SetFrontFace(ccw);
+ m_clientobject = obj;
+ }
}
-bool KX_BlenderRenderTools::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data)
+bool KX_BlenderRenderTools::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data)
{
double* const oglmatrix = (double* const) data;
- MT_Point3 resultpoint(hit_point);
- MT_Vector3 resultnormal(hit_normal);
+ MT_Point3 resultpoint(result->m_hitPoint);
+ MT_Vector3 resultnormal(result->m_hitNormal);
MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized();
left = (dir.cross(resultnormal)).safe_normalized();
@@ -172,7 +196,7 @@ void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmat
MT_Vector3 dir = (campos - objpos).safe_normalized();
MT_Vector3 up(0,0,1.0);
- KX_GameObject* gameobj = (KX_GameObject*) this->m_clientobject;
+ KX_GameObject* gameobj = (KX_GameObject*)m_clientobject;
// get scaling of halo object
MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale();
@@ -208,7 +232,7 @@ void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmat
{
// shadow must be cast to the ground, physics system needed here!
MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
- KX_GameObject *gameobj = (KX_GameObject*) this->m_clientobject;
+ KX_GameObject *gameobj = (KX_GameObject*)m_clientobject;
MT_Vector3 direction = MT_Vector3(0,0,-1);
direction.normalize();
@@ -226,9 +250,8 @@ void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmat
if (parent)
parent->Release();
- MT_Point3 resultpoint;
- MT_Vector3 resultnormal;
- if (!KX_RayCast::RayTest(physics_controller, physics_environment, frompoint, topoint, resultpoint, resultnormal, KX_RayCast::Callback<KX_BlenderRenderTools>(this, oglmatrix)))
+ KX_RayCast::Callback<KX_BlenderRenderTools> callback(this, physics_controller, oglmatrix);
+ if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))
{
// couldn't find something to cast the shadow on...
glMultMatrixd(oglmatrix);
@@ -243,13 +266,29 @@ void KX_BlenderRenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmat
}
-/**
-Render Text renders text into a (series of) polygon, using a texture font,
-Each character consists of one polygon (one quad or two triangles)
-*/
-void KX_BlenderRenderTools::RenderText(int mode,RAS_IPolyMaterial* polymat,float v1[3],float v2[3],float v3[3],float v4[3])
+void KX_BlenderRenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode,
+ const char* text,
+ int xco,
+ int yco,
+ int width,
+ int height)
+{
+ STR_String tmpstr(text);
+
+ if(mode == RAS_IRenderTools::RAS_TEXT_PADDED)
+ BL_print_gamedebug_line_padded(tmpstr.Ptr(), xco, yco, width, height);
+ else
+ BL_print_gamedebug_line(tmpstr.Ptr(), xco, yco, width, height);
+}
+
+/* Render Text renders text into a (series of) polygon, using a texture font,
+ * Each character consists of one polygon (one quad or two triangles) */
+
+void KX_BlenderRenderTools::RenderText(
+ int mode,
+ RAS_IPolyMaterial* polymat,
+ float v1[3], float v2[3], float v3[3], float v4[3], int glattrib)
{
-
STR_String mytext = ((CValue*)m_clientobject)->GetPropertyText("Text");
const unsigned int flag = polymat->GetFlag();
@@ -266,67 +305,9 @@ void KX_BlenderRenderTools::RenderText(int mode,RAS_IPolyMaterial* polymat,float
col = blenderpoly->GetMCol();
}
- BL_RenderText( mode,mytext,mytext.Length(),tface,col,v1,v2,v3,v4);
-
-}
-
-
-
-KX_BlenderRenderTools::~KX_BlenderRenderTools()
-{
-};
-
-
-void KX_BlenderRenderTools::EndFrame(RAS_IRasterizer* rasty)
-{
-}
-
-
-
-void KX_BlenderRenderTools::DisableOpenGLLights()
-{
- glDisable(GL_LIGHTING);
- glDisable(GL_COLOR_MATERIAL);
-}
-
-
-void KX_BlenderRenderTools::EnableOpenGLLights()
-{
- glEnable(GL_LIGHTING);
-
- glEnable(GL_COLOR_MATERIAL);
- glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
- glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, true);
- if (bgl::QueryExtension(bgl::_GL_EXT_separate_specular_color) || bgl::QueryVersion(1, 2))
- glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
-
-}
-
-
-/**
- * Rendering text using 2D bitmap functionality.
- */
-void KX_BlenderRenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco,
- int yco,
- int width,
- int height)
-{
- switch (mode) {
- case RAS_IRenderTools::RAS_TEXT_PADDED: {
- STR_String tmpstr(text);
- BL_print_gamedebug_line_padded(tmpstr.Ptr(),xco,yco,width,height);
- break;
- }
- default: {
- STR_String tmpstr(text);
- BL_print_gamedebug_line(tmpstr.Ptr(),xco,yco,width,height);
- }
- }
+ GPU_render_text(tface, mode, mytext, mytext.Length(), col, v1, v2, v3, v4, glattrib);
}
-
void KX_BlenderRenderTools::PushMatrix()
{
@@ -339,14 +320,13 @@ void KX_BlenderRenderTools::PopMatrix()
}
-
-int KX_BlenderRenderTools::applyLights(int objectlayer)
+int KX_BlenderRenderTools::applyLights(int objectlayer, const MT_Transform& viewmat)
{
-// taken from blender source, incompatibility between Blender Object / GameObject
-
+ // taken from blender source, incompatibility between Blender Object / GameObject
+ float glviewmat[16];
unsigned int count;
float vec[4];
-
+
vec[3]= 1.0;
for(count=0; count<m_numgllights; count++)
@@ -354,9 +334,11 @@ int KX_BlenderRenderTools::applyLights(int objectlayer)
//std::vector<struct RAS_LightObject*> m_lights;
std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin();
+
+ viewmat.getValue(glviewmat);
glPushMatrix();
- glLoadMatrixf(m_viewmat);
+ glLoadMatrixf(glviewmat);
for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit)
{
RAS_LightObject* lightdata = (*lit);
@@ -424,7 +406,6 @@ int KX_BlenderRenderTools::applyLights(int objectlayer)
glEnable((GLenum)(GL_LIGHT0+count));
count++;
-
}
}
glPopMatrix();
@@ -433,22 +414,6 @@ int KX_BlenderRenderTools::applyLights(int objectlayer)
}
-
-
-RAS_IPolyMaterial* KX_BlenderRenderTools::CreateBlenderPolyMaterial(
- const STR_String &texname,
- bool ba,const STR_String& matname,int tile,int tilexrep,int tileyrep,int mode,bool transparant,bool zsort, int lightlayer
- ,bool bIsTriangle,void* clientobject,void* tface)
-{
- assert(!"Deprecated");
-/* return new KX_BlenderPolyMaterial(
-
- texname,
- ba,matname,tile,tilexrep,tileyrep,mode,transparant,zsort, lightlayer
- ,bIsTriangle,clientobject,(struct MTFace*)tface);*/
- return NULL;
-}
-
void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer)
{
int state = rasterizer->GetMotionBlurState();
@@ -472,4 +437,13 @@ void KX_BlenderRenderTools::MotionBlur(RAS_IRasterizer* rasterizer)
}
}
-unsigned int KX_BlenderRenderTools::m_numgllights;
+void KX_BlenderRenderTools::Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)
+{
+ m_filtermanager.EnableFilter(propNames, gameObj, filtermode, pass, text);
+}
+
+void KX_BlenderRenderTools::Render2DFilters(RAS_ICanvas* canvas)
+{
+ m_filtermanager.RenderFilters(canvas);
+}
+
diff --git a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
index 117d6a2be54..a7618462c9b 100644
--- a/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
+++ b/source/gameengine/BlenderRoutines/KX_BlenderRenderTools.h
@@ -26,6 +26,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
+
#ifndef __KX_BLENDERRENDERTOOLS
#define __KX_BLENDERRENDERTOOLS
@@ -37,70 +38,65 @@
#include "RAS_IRenderTools.h"
struct KX_ClientObjectInfo;
+class KX_RayCast;
-/**
-BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which are not
-part of the (polygon) Rasterizer.
-Effects like 2D text, 3D (polygon) text, lighting.
-*/
+/* BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which
+ * are not part of the (polygon) Rasterizer. Effects like 2D text, 3D (polygon)
+ * text, lighting.
+ *
+ * Most of this code is duplicated in GPC_RenderTools, so this should be
+ * moved to some common location to avoid duplication. */
class KX_BlenderRenderTools : public RAS_IRenderTools
{
- bool m_lastblenderlights;
- void* m_lastblenderobject;
- int m_lastlayer;
+ int m_lastlightlayer;
bool m_lastlighting;
static unsigned int m_numgllights;
-
+
public:
-
KX_BlenderRenderTools();
virtual ~KX_BlenderRenderTools();
- virtual void EndFrame(class RAS_IRasterizer* rasty);
- virtual void BeginFrame(class RAS_IRasterizer* rasty);
- void DisableOpenGLLights();
+ void EndFrame(RAS_IRasterizer* rasty);
+ void BeginFrame(RAS_IRasterizer* rasty);
+
void EnableOpenGLLights();
- int ProcessLighting(int layer);
+ void DisableOpenGLLights();
+ void ProcessLighting(int layer, const MT_Transform& viewmat);
- virtual void RenderText2D(RAS_TEXT_RENDER_MODE mode,
+ void RenderText2D(RAS_TEXT_RENDER_MODE mode,
const char* text,
int xco,
int yco,
int width,
int height);
- virtual void RenderText(int mode,
+ void RenderText(int mode,
class RAS_IPolyMaterial* polymat,
float v1[3],
float v2[3],
float v3[3],
- float v4[3]);
- void applyTransform(class RAS_IRasterizer* rasty,
- double* oglmatrix,
- int objectdrawmode );
- int applyLights(int objectlayer);
- virtual void PushMatrix();
- virtual void PopMatrix();
-
- virtual class RAS_IPolyMaterial* CreateBlenderPolyMaterial(const STR_String &texname,
- bool ba,
- const STR_String& matname,
- int tile,
- int tilexrep,
- int tileyrep,
- int mode,
- bool transparant,
- bool zsort,
- int lightlayer,
- bool bIsTriangle,
- void* clientobject,
- void* tface);
-
- bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data);
+ float v4[3],
+ int glattrib);
+
+ void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode);
+ int applyLights(int objectlayer, const MT_Transform& viewmat);
+
+ void PushMatrix();
+ void PopMatrix();
+
+ bool RayHit(KX_ClientObjectInfo* client, class KX_RayCast* result, void * const data);
+ bool NeedRayCast(KX_ClientObjectInfo*) { return true; }
virtual void MotionBlur(RAS_IRasterizer* rasterizer);
+
+ virtual void Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text);
+
+ virtual void Render2DFilters(RAS_ICanvas* canvas);
+
+ virtual void SetClientObject(RAS_IRasterizer *rasty, void* obj);
};
#endif //__KX_BLENDERRENDERTOOLS
+
diff --git a/source/gameengine/BlenderRoutines/Makefile b/source/gameengine/BlenderRoutines/Makefile
index 8d7ed46bc28..7ee825d186b 100644
--- a/source/gameengine/BlenderRoutines/Makefile
+++ b/source/gameengine/BlenderRoutines/Makefile
@@ -35,7 +35,6 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
-CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_SUMO)/include -I$(NAN_SOLID)/include
CPPFLAGS += -I$(NAN_SOLID)
CPPFLAGS += -I$(NAN_STRING)/include
@@ -43,6 +42,8 @@ CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I$(NAN_BMFONT)/include
CPPFLAGS += -I$(NAN_FUZZICS)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
+CPPFLAGS += -I$(NAN_GLEW)/include
+CPPFLAGS += -I$(OPENGL_HEADERS)
# because of kernel dependency on makesdna
CPPFLAGS += -I../../blender/makesdna
CPPFLAGS += -I../../blender/editors/include
@@ -54,6 +55,7 @@ CPPFLAGS += -I../../blender/blenkernel
CPPFLAGS += -I../../blender/render/extern/include
CPPFLAGS += -I../../blender/blenloader
CPPFLAGS += -I../../blender/blenkernel
+CPPFLAGS += -I../../blender/gpu
CPPFLAGS += -I../Converter
CPPFLAGS += -I../Expressions
CPPFLAGS += -I../GameLogic
@@ -66,6 +68,7 @@ CPPFLAGS += -I../Network
CPPFLAGS += -I../Network/LoopBackNetwork
CPPFLAGS += -I../Physics/common
CPPFLAGS += -I../Physics/Sumo
+CPPFLAGS += -I.
ifeq ($(OS),windows)
CPPFLAGS += -I../../blender
diff --git a/source/gameengine/BlenderRoutines/SConscript b/source/gameengine/BlenderRoutines/SConscript
index 52d187cbe20..7722b6f69a6 100644
--- a/source/gameengine/BlenderRoutines/SConscript
+++ b/source/gameengine/BlenderRoutines/SConscript
@@ -15,6 +15,7 @@ incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common'
incs += ' #source/gameengine/Physics/Bullet #source/gameengine/Physics/Sumo'
incs += ' #source/gameengine/Physics/Sumo/Fuzzics/include #source/gameengine/Network/LoopBackNetwork'
incs += ' #intern/SoundSystem #source/blender/misc #source/blender/blenloader'
+incs += ' #extern/glew/include #source/blender/gpu'
incs += ' #source/blender/windowmanager'
incs += ' ' + env['BF_PYTHON_INC']
diff --git a/source/gameengine/CMakeLists.txt b/source/gameengine/CMakeLists.txt
index 93de588ba00..3ea788791e2 100644
--- a/source/gameengine/CMakeLists.txt
+++ b/source/gameengine/CMakeLists.txt
@@ -40,6 +40,7 @@ SUBDIRS(
SceneGraph
Physics/Bullet
Physics/Sumo
+ VideoTexture
)
IF(WITH_PLAYER)
diff --git a/source/gameengine/Converter/BL_ActionActuator.cpp b/source/gameengine/Converter/BL_ActionActuator.cpp
index 1055c8771ef..4d748948c27 100644
--- a/source/gameengine/Converter/BL_ActionActuator.cpp
+++ b/source/gameengine/Converter/BL_ActionActuator.cpp
@@ -49,6 +49,8 @@
#include "BLI_arithb.h"
#include "MT_Matrix4x4.h"
#include "BKE_utildefines.h"
+#include "FloatValue.h"
+#include "PyObjectPlus.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -56,24 +58,12 @@
BL_ActionActuator::~BL_ActionActuator()
{
-
- if (m_pose) {
- free_pose_channels(m_pose);
- MEM_freeN(m_pose);
- m_pose = NULL;
- };
-
- if (m_userpose){
- free_pose_channels(m_userpose);
- MEM_freeN(m_userpose);
- m_userpose=NULL;
- }
- if (m_blendpose) {
- free_pose_channels(m_blendpose);
- MEM_freeN(m_blendpose);
- m_blendpose = NULL;
- };
-
+ if (m_pose)
+ game_free_pose(m_pose);
+ if (m_userpose)
+ game_free_pose(m_userpose);
+ if (m_blendpose)
+ game_free_pose(m_blendpose);
}
void BL_ActionActuator::ProcessReplica(){
@@ -134,14 +124,14 @@ void BL_ActionActuator::SetStartTime(float curtime)
float direction = m_startframe < m_endframe ? 1.0 : -1.0;
if (!(m_flag & ACT_FLAG_REVERSE))
- m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_FIXED_FRAME_PER_SEC;
+ m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_KetsjiEngine::GetAnimFrameRate();
else
- m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_FIXED_FRAME_PER_SEC;
+ m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_KetsjiEngine::GetAnimFrameRate();
}
void BL_ActionActuator::SetLocalTime(float curtime)
{
- float delta_time = (curtime - m_starttime)*KX_FIXED_FRAME_PER_SEC;
+ float delta_time = (curtime - m_starttime)*KX_KetsjiEngine::GetAnimFrameRate();
if (m_endframe < m_startframe)
delta_time = -delta_time;
@@ -162,6 +152,8 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
bool apply=true;
int priority;
float newweight;
+
+ curtime -= KX_KetsjiEngine::GetSuspendedDelta();
// result = true if animation has to be continued, false if animation stops
// maybe there are events for us in the queue !
@@ -183,6 +175,11 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
if (bNegativeEvent)
{
+ // dont continue where we left off when restarting
+ if (m_end_reset) {
+ m_flag &= ~ACT_FLAG_LOCKINPUT;
+ }
+
if (!(m_flag & ACT_FLAG_ACTIVE))
return false;
m_flag &= ~ACT_FLAG_ACTIVE;
@@ -348,6 +345,18 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
break;
}
+ /* Set the property if its defined */
+ if (m_framepropname[0] != '\0') {
+ CValue* propowner = GetParent();
+ CValue* oldprop = propowner->GetProperty(m_framepropname);
+ CValue* newval = new CFloatValue(m_localtime);
+ if (oldprop) {
+ oldprop->SetValue(newval);
+ } else {
+ propowner->SetProperty(m_framepropname, newval);
+ }
+ newval->Release();
+ }
if (bNegativeEvent)
m_blendframe=0.0;
@@ -385,7 +394,7 @@ bool BL_ActionActuator::Update(double curtime, bool frame)
blend_poses(m_pose, m_blendpose, 1.0 - newweight, ACTSTRIPMODE_BLEND);
/* Increment current blending percentage */
- m_blendframe = (curtime - m_blendstart)*KX_FIXED_FRAME_PER_SEC;
+ m_blendframe = (curtime - m_blendstart)*KX_KetsjiEngine::GetAnimFrameRate();
if (m_blendframe>m_blendin)
m_blendframe = m_blendin;
@@ -439,26 +448,30 @@ PyParentObject BL_ActionActuator::Parents[] = {
};
PyMethodDef BL_ActionActuator::Methods[] = {
- {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, SetAction_doc},
- {"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, SetStart_doc},
- {"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, SetEnd_doc},
- {"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, SetBlendin_doc},
- {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, SetPriority_doc},
- {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, SetFrame_doc},
- {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, SetProperty_doc},
- {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, SetBlendtime_doc},
-
- {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, GetAction_doc},
- {"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, GetStart_doc},
- {"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, GetEnd_doc},
- {"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, GetBlendin_doc},
- {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, GetPriority_doc},
- {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, GetFrame_doc},
- {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, GetProperty_doc},
- {"setChannel", (PyCFunction) BL_ActionActuator::sPySetChannel, METH_VARARGS, SetChannel_doc},
+ {"setAction", (PyCFunction) BL_ActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc},
+ {"setStart", (PyCFunction) BL_ActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc},
+ {"setEnd", (PyCFunction) BL_ActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc},
+ {"setBlendin", (PyCFunction) BL_ActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc},
+ {"setPriority", (PyCFunction) BL_ActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc},
+ {"setFrame", (PyCFunction) BL_ActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc},
+ {"setProperty", (PyCFunction) BL_ActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
+ {"setFrameProperty", (PyCFunction) BL_ActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc},
+ {"setBlendtime", (PyCFunction) BL_ActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc},
+
+ {"getAction", (PyCFunction) BL_ActionActuator::sPyGetAction, METH_VARARGS, (PY_METHODCHAR)GetAction_doc},
+ {"getStart", (PyCFunction) BL_ActionActuator::sPyGetStart, METH_VARARGS, (PY_METHODCHAR)GetStart_doc},
+ {"getEnd", (PyCFunction) BL_ActionActuator::sPyGetEnd, METH_VARARGS, (PY_METHODCHAR)GetEnd_doc},
+ {"getBlendin", (PyCFunction) BL_ActionActuator::sPyGetBlendin, METH_VARARGS, (PY_METHODCHAR)GetBlendin_doc},
+ {"getPriority", (PyCFunction) BL_ActionActuator::sPyGetPriority, METH_VARARGS, (PY_METHODCHAR)GetPriority_doc},
+ {"getFrame", (PyCFunction) BL_ActionActuator::sPyGetFrame, METH_VARARGS, (PY_METHODCHAR)GetFrame_doc},
+ {"getProperty", (PyCFunction) BL_ActionActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
+ {"getFrameProperty", (PyCFunction) BL_ActionActuator::sPyGetFrameProperty, METH_VARARGS, (PY_METHODCHAR)GetFrameProperty_doc},
+ {"setChannel", (PyCFunction) BL_ActionActuator::sPySetChannel, METH_VARARGS, (PY_METHODCHAR)SetChannel_doc},
// {"getChannel", (PyCFunction) BL_ActionActuator::sPyGetChannel, METH_VARARGS},
- {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, GetType_doc},
- {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, SetType_doc},
+ {"getType", (PyCFunction) BL_ActionActuator::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc},
+ {"setType", (PyCFunction) BL_ActionActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc},
+ {"getContinue", (PyCFunction) BL_ActionActuator::sPyGetContinue, METH_NOARGS, 0},
+ {"setContinue", (PyCFunction) BL_ActionActuator::sPySetContinue, METH_O, 0},
{NULL,NULL} //Sentinel
};
@@ -467,28 +480,21 @@ PyObject* BL_ActionActuator::_getattr(const STR_String& attr) {
}
/* setStart */
-char BL_ActionActuator::GetAction_doc[] =
+const char BL_ActionActuator::GetAction_doc[] =
"getAction()\n"
"\tReturns a string containing the name of the current action.\n";
PyObject* BL_ActionActuator::PyGetAction(PyObject* self,
PyObject* args,
PyObject* kwds) {
- PyObject *result;
-
if (m_action){
- result = Py_BuildValue("s", m_action->id.name+2);
- }
- else{
- Py_INCREF(Py_None);
- result = Py_None;
+ return PyString_FromString(m_action->id.name+2);
}
-
- return result;
+ Py_RETURN_NONE;
}
/* getProperty */
-char BL_ActionActuator::GetProperty_doc[] =
+const char BL_ActionActuator::GetProperty_doc[] =
"getProperty()\n"
"\tReturns the name of the property to be used in FromProp mode.\n";
@@ -502,8 +508,23 @@ PyObject* BL_ActionActuator::PyGetProperty(PyObject* self,
return result;
}
+/* getProperty */
+const char BL_ActionActuator::GetFrameProperty_doc[] =
+"getFrameProperty()\n"
+"\tReturns the name of the property, that is set to the current frame number.\n";
+
+PyObject* BL_ActionActuator::PyGetFrameProperty(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ PyObject *result;
+
+ result = Py_BuildValue("s", (const char *)m_framepropname);
+
+ return result;
+}
+
/* getFrame */
-char BL_ActionActuator::GetFrame_doc[] =
+const char BL_ActionActuator::GetFrame_doc[] =
"getFrame()\n"
"\tReturns the current frame number.\n";
@@ -518,7 +539,7 @@ PyObject* BL_ActionActuator::PyGetFrame(PyObject* self,
}
/* getEnd */
-char BL_ActionActuator::GetEnd_doc[] =
+const char BL_ActionActuator::GetEnd_doc[] =
"getEnd()\n"
"\tReturns the last frame of the action.\n";
@@ -533,7 +554,7 @@ PyObject* BL_ActionActuator::PyGetEnd(PyObject* self,
}
/* getStart */
-char BL_ActionActuator::GetStart_doc[] =
+const char BL_ActionActuator::GetStart_doc[] =
"getStart()\n"
"\tReturns the starting frame of the action.\n";
@@ -548,7 +569,7 @@ PyObject* BL_ActionActuator::PyGetStart(PyObject* self,
}
/* getBlendin */
-char BL_ActionActuator::GetBlendin_doc[] =
+const char BL_ActionActuator::GetBlendin_doc[] =
"getBlendin()\n"
"\tReturns the number of interpolation animation frames to be\n"
"\tgenerated when this actuator is triggered.\n";
@@ -564,7 +585,7 @@ PyObject* BL_ActionActuator::PyGetBlendin(PyObject* self,
}
/* getPriority */
-char BL_ActionActuator::GetPriority_doc[] =
+const char BL_ActionActuator::GetPriority_doc[] =
"getPriority()\n"
"\tReturns the priority for this actuator. Actuators with lower\n"
"\tPriority numbers will override actuators with higher numbers.\n";
@@ -580,7 +601,7 @@ PyObject* BL_ActionActuator::PyGetPriority(PyObject* self,
}
/* setAction */
-char BL_ActionActuator::SetAction_doc[] =
+const char BL_ActionActuator::SetAction_doc[] =
"setAction(action, (reset))\n"
"\t - action : The name of the action to set as the current action.\n"
"\t - reset : Optional parameter indicating whether to reset the\n"
@@ -611,13 +632,15 @@ PyObject* BL_ActionActuator::PySetAction(PyObject* self,
m_blendframe = 0;
}
}
+ else {
+ return NULL;
+ }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
/* setStart */
-char BL_ActionActuator::SetStart_doc[] =
+const char BL_ActionActuator::SetStart_doc[] =
"setStart(start)\n"
"\t - start : Specifies the starting frame of the animation.\n";
@@ -630,13 +653,15 @@ PyObject* BL_ActionActuator::PySetStart(PyObject* self,
{
m_startframe = start;
}
+ else {
+ return NULL;
+ }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
/* setEnd */
-char BL_ActionActuator::SetEnd_doc[] =
+const char BL_ActionActuator::SetEnd_doc[] =
"setEnd(end)\n"
"\t - end : Specifies the ending frame of the animation.\n";
@@ -649,13 +674,15 @@ PyObject* BL_ActionActuator::PySetEnd(PyObject* self,
{
m_endframe = end;
}
+ else {
+ return NULL;
+ }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
/* setBlendin */
-char BL_ActionActuator::SetBlendin_doc[] =
+const char BL_ActionActuator::SetBlendin_doc[] =
"setBlendin(blendin)\n"
"\t - blendin : Specifies the number of frames of animation to generate\n"
"\t when making transitions between actions.\n";
@@ -669,13 +696,15 @@ PyObject* BL_ActionActuator::PySetBlendin(PyObject* self,
{
m_blendin = blendin;
}
+ else {
+ return NULL;
+ }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
/* setBlendtime */
-char BL_ActionActuator::SetBlendtime_doc[] =
+const char BL_ActionActuator::SetBlendtime_doc[] =
"setBlendtime(blendtime)\n"
"\t - blendtime : Allows the script to directly modify the internal timer\n"
"\t used when generating transitions between actions. This\n"
@@ -694,13 +723,15 @@ PyObject* BL_ActionActuator::PySetBlendtime(PyObject* self,
if (m_blendframe>m_blendin)
m_blendframe = m_blendin;
}
+ else {
+ return NULL;
+ }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
/* setPriority */
-char BL_ActionActuator::SetPriority_doc[] =
+const char BL_ActionActuator::SetPriority_doc[] =
"setPriority(priority)\n"
"\t - priority : Specifies the new priority. Actuators will lower\n"
"\t priority numbers will override actuators with higher\n"
@@ -715,13 +746,15 @@ PyObject* BL_ActionActuator::PySetPriority(PyObject* self,
{
m_priority = priority;
}
+ else {
+ return NULL;
+ }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
/* setFrame */
-char BL_ActionActuator::SetFrame_doc[] =
+const char BL_ActionActuator::SetFrame_doc[] =
"setFrame(frame)\n"
"\t - frame : Specifies the new current frame for the animation\n";
@@ -738,13 +771,15 @@ PyObject* BL_ActionActuator::PySetFrame(PyObject* self,
else if (m_localtime>m_endframe)
m_localtime=m_endframe;
}
+ else {
+ return NULL;
+ }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
/* setProperty */
-char BL_ActionActuator::SetProperty_doc[] =
+const char BL_ActionActuator::SetProperty_doc[] =
"setProperty(prop)\n"
"\t - prop : A string specifying the property name to be used in\n"
"\t FromProp playback mode.\n";
@@ -758,9 +793,32 @@ PyObject* BL_ActionActuator::PySetProperty(PyObject* self,
{
m_propname = string;
}
+ else {
+ return NULL;
+ }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
+}
+
+/* setFrameProperty */
+const char BL_ActionActuator::SetFrameProperty_doc[] =
+"setFrameProperty(prop)\n"
+"\t - prop : A string specifying the property of the frame set up update.\n";
+
+PyObject* BL_ActionActuator::PySetFrameProperty(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ char *string;
+
+ if (PyArg_ParseTuple(args,"s",&string))
+ {
+ m_framepropname = string;
+ }
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
}
/*
@@ -773,14 +831,16 @@ PyObject* BL_ActionActuator::PyGetChannel(PyObject* self,
{
m_propname = string;
}
+ else {
+ return NULL;
+ }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
*/
/* setChannel */
-char BL_ActionActuator::SetChannel_doc[] =
+const char BL_ActionActuator::SetChannel_doc[] =
"setChannel(channel, matrix)\n"
"\t - channel : A string specifying the name of the bone channel.\n"
"\t - matrix : A 4x4 matrix specifying the overriding transformation\n"
@@ -797,7 +857,8 @@ PyObject* BL_ActionActuator::PySetChannel(PyObject* self,
int row,col;
int mode = 0; /* 0 for bone space, 1 for armature/world space */
- PyArg_ParseTuple(args,"sO|i", &string, &pylist, &mode);
+ if (!PyArg_ParseTuple(args,"sO|i", &string, &pylist, &mode))
+ return NULL;
if (pylist->ob_type == &CListValue::Type)
{
@@ -859,12 +920,11 @@ PyObject* BL_ActionActuator::PySetChannel(PyObject* self,
}
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
/* getType */
-char BL_ActionActuator::GetType_doc[] =
+const char BL_ActionActuator::GetType_doc[] =
"getType()\n"
"\tReturns the operation mode of the actuator.\n";
PyObject* BL_ActionActuator::PyGetType(PyObject* self,
@@ -874,7 +934,7 @@ PyObject* BL_ActionActuator::PyGetType(PyObject* self,
}
/* setType */
-char BL_ActionActuator::SetType_doc[] =
+const char BL_ActionActuator::SetType_doc[] =
"setType(mode)\n"
"\t - mode: Play (0), Flipper (2), LoopStop (3), LoopEnd (4) or Property (6)\n"
"\tSet the operation mode of the actuator.\n";
@@ -898,7 +958,26 @@ PyObject* BL_ActionActuator::PySetType(PyObject* self,
default:
printf("Invalid type for action actuator: %d\n", typeArg); /* error */
}
+ Py_RETURN_NONE;
+}
+
+PyObject* BL_ActionActuator::PyGetContinue(PyObject* self) {
+ return PyInt_FromLong((long)(m_end_reset==0));
+}
+
+PyObject* BL_ActionActuator::PySetContinue(PyObject* self, PyObject* value) {
+ int param = PyObject_IsTrue( value );
- Py_Return;
+ if( param == -1 ) {
+ PyErr_SetString( PyExc_TypeError, "expected True/False or 0/1" );
+ return NULL;
+ }
+
+ if (param) {
+ m_end_reset = 0;
+ } else {
+ m_end_reset = 1;
+ }
+ Py_RETURN_NONE;
}
diff --git a/source/gameengine/Converter/BL_ActionActuator.h b/source/gameengine/Converter/BL_ActionActuator.h
index 62edcc7fad7..a67b6d29b74 100644
--- a/source/gameengine/Converter/BL_ActionActuator.h
+++ b/source/gameengine/Converter/BL_ActionActuator.h
@@ -40,12 +40,14 @@ public:
Py_Header;
BL_ActionActuator(SCA_IObject* gameobj,
const STR_String& propname,
+ const STR_String& framepropname,
float starttime,
float endtime,
struct bAction *action,
short playtype,
short blendin,
short priority,
+ short end_reset,
float stride,
PyTypeObject* T=&Type)
: SCA_IActuator(gameobj,T),
@@ -63,11 +65,13 @@ public:
m_stridelength(stride),
m_playtype(playtype),
m_priority(priority),
+ m_end_reset(end_reset),
m_pose(NULL),
m_blendpose(NULL),
m_userpose(NULL),
m_action(action),
- m_propname(propname)
+ m_propname(propname),
+ m_framepropname(framepropname)
{
};
virtual ~BL_ActionActuator();
@@ -84,6 +88,7 @@ public:
KX_PYMETHOD_DOC(BL_ActionActuator,SetEnd);
KX_PYMETHOD_DOC(BL_ActionActuator,SetFrame);
KX_PYMETHOD_DOC(BL_ActionActuator,SetProperty);
+ KX_PYMETHOD_DOC(BL_ActionActuator,SetFrameProperty);
KX_PYMETHOD_DOC(BL_ActionActuator,SetBlendtime);
KX_PYMETHOD_DOC(BL_ActionActuator,SetChannel);
@@ -94,9 +99,12 @@ public:
KX_PYMETHOD_DOC(BL_ActionActuator,GetEnd);
KX_PYMETHOD_DOC(BL_ActionActuator,GetFrame);
KX_PYMETHOD_DOC(BL_ActionActuator,GetProperty);
+ KX_PYMETHOD_DOC(BL_ActionActuator,GetFrameProperty);
// KX_PYMETHOD(BL_ActionActuator,GetChannel);
KX_PYMETHOD_DOC(BL_ActionActuator,GetType);
KX_PYMETHOD_DOC(BL_ActionActuator,SetType);
+ KX_PYMETHOD_NOARGS(BL_ActionActuator,GetContinue);
+ KX_PYMETHOD_O(BL_ActionActuator,SetContinue);
virtual PyObject* _getattr(const STR_String& attr);
@@ -133,11 +141,13 @@ protected:
float m_stridelength;
short m_playtype;
short m_priority;
+ short m_end_reset;
struct bPose* m_pose;
struct bPose* m_blendpose;
struct bPose* m_userpose;
struct bAction *m_action;
STR_String m_propname;
+ STR_String m_framepropname;
};
enum {
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
index ff9c6a75aa9..d2001212f7d 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -45,7 +45,6 @@
#include <config.h>
#endif
-
BL_ArmatureObject::BL_ArmatureObject(
void* sgReplicationInfo,
SG_Callbacks callbacks,
@@ -53,15 +52,20 @@ BL_ArmatureObject::BL_ArmatureObject(
: KX_GameObject(sgReplicationInfo,callbacks),
m_objArma(armature),
- m_mrdPose(NULL),
- m_lastframe(0.),
+ m_framePose(NULL),
+ m_lastframe(0.0),
m_activeAct(NULL),
- m_activePriority(999)
+ m_activePriority(999),
+ m_lastapplyframe(0.0)
{
m_armature = get_armature(m_objArma);
- m_pose = m_objArma->pose;
-}
+ /* we make a copy of blender object's pose, and then always swap it with
+ * the original pose before calling into blender functions, to deal with
+ * replica's or other objects using the same blender object */
+ m_pose = NULL;
+ game_copy_pose(&m_pose, m_objArma->pose);
+}
CValue* BL_ArmatureObject::GetReplica()
{
@@ -78,35 +82,37 @@ void BL_ArmatureObject::ProcessReplica(BL_ArmatureObject *replica)
{
KX_GameObject::ProcessReplica(replica);
+ replica->m_pose = NULL;
+ game_copy_pose(&replica->m_pose, m_pose);
}
BL_ArmatureObject::~BL_ArmatureObject()
{
- if (m_mrdPose){
- free_pose_channels(m_mrdPose);
- MEM_freeN(m_mrdPose);
- }
+ if (m_pose)
+ game_free_pose(m_pose);
}
-/* note, you can only call this for exisiting Armature objects, and not mix it with other Armatures */
-/* there is only 1 unique Pose per Armature */
void BL_ArmatureObject::ApplyPose()
{
- if (m_pose){
- // copy to armature object
- extract_pose_from_pose(m_objArma->pose, m_pose);
-
- // is this needed anymore?
- //if (!m_mrdPose)
- // copy_pose (&m_mrdPose, m_pose, 0);
- //else
- // extract_pose_from_pose(m_mrdPose, m_pose);
+ m_armpose = m_objArma->pose;
+ m_objArma->pose = m_pose;
+
+ if(m_lastapplyframe != m_lastframe) {
+ where_is_pose(m_objArma);
+ m_lastapplyframe = m_lastframe;
}
}
+void BL_ArmatureObject::RestorePose()
+{
+ m_objArma->pose = m_armpose;
+ m_armpose = NULL;
+}
+
void BL_ArmatureObject::SetPose(bPose *pose)
{
- m_pose = pose;
+ extract_pose_from_pose(m_pose, pose);
+ m_lastapplyframe = -1.0;
}
bool BL_ArmatureObject::SetActiveAction(BL_ActionActuator *act, short priority, double curtime)
@@ -115,10 +121,15 @@ bool BL_ArmatureObject::SetActiveAction(BL_ActionActuator *act, short priority,
m_activePriority = 9999;
m_lastframe= curtime;
m_activeAct = NULL;
+ // remember the pose at the start of the frame
+ m_framePose = m_pose;
}
if (priority<=m_activePriority)
{
+ if (priority<m_activePriority)
+ // this action overwrites the previous ones, start from initial pose to cancel their effects
+ m_pose = m_framePose;
if (m_activeAct && (m_activeAct!=act))
m_activeAct->SetBlendTime(0.0); /* Reset the blend timer */
m_activeAct = act;
@@ -143,19 +154,22 @@ void BL_ArmatureObject::GetPose(bPose **pose)
{
/* If the caller supplies a null pose, create a new one. */
/* Otherwise, copy the armature's pose channels into the caller-supplied pose */
-
+
if (!*pose) {
/* probably not to good of an idea to
duplicate everying, but it clears up
a crash and memory leakage when
&BL_ActionActuator::m_pose is freed
*/
- int copy_constraint_channels_hack = 1;
- copy_pose(pose, m_pose, copy_constraint_channels_hack);
+ game_copy_pose(pose, m_pose);
}
- else
- extract_pose_from_pose(*pose, m_pose);
+ else {
+ if (*pose == m_pose)
+ // no need to copy if the pointers are the same
+ return;
+ extract_pose_from_pose(*pose, m_pose);
+ }
}
void BL_ArmatureObject::GetMRDPose(bPose **pose)
@@ -163,16 +177,10 @@ void BL_ArmatureObject::GetMRDPose(bPose **pose)
/* If the caller supplies a null pose, create a new one. */
/* Otherwise, copy the armature's pose channels into the caller-supplied pose */
- // is this needed anymore?
- //if (!m_mrdPose){
- // copy_pose (&m_mrdPose, m_pose, 0);
- //}
-
if (!*pose)
- copy_pose(pose, m_objArma->pose, 0);
+ game_copy_pose(pose, m_pose);
else
- extract_pose_from_pose(*pose, m_objArma->pose);
-
+ extract_pose_from_pose(*pose, m_pose);
}
short BL_ArmatureObject::GetActivePriority()
@@ -185,17 +193,17 @@ double BL_ArmatureObject::GetLastFrame()
return m_lastframe;
}
-bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix) const
+bool BL_ArmatureObject::GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix)
{
- Object* par_arma = m_objArma;
- where_is_pose(par_arma);
- bPoseChannel *pchan= get_pose_channel(par_arma->pose, bone->name);
+ bPoseChannel *pchan;
- if(pchan) {
+ ApplyPose();
+ pchan = get_pose_channel(m_objArma->pose, bone->name);
+ if(pchan)
matrix.setValue(&pchan->pose_mat[0][0]);
- return true;
- }
- return false;
+ RestorePose();
+
+ return (pchan != NULL);
}
float BL_ArmatureObject::GetBoneLength(Bone* bone) const
diff --git a/source/gameengine/Converter/BL_ArmatureObject.h b/source/gameengine/Converter/BL_ArmatureObject.h
index 752bd5eb365..d68e37d9e37 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.h
+++ b/source/gameengine/Converter/BL_ArmatureObject.h
@@ -59,7 +59,10 @@ public:
void GetMRDPose(struct bPose **pose);
void GetPose(struct bPose **pose);
void SetPose (struct bPose *pose);
+
void ApplyPose();
+ void RestorePose();
+
bool SetActiveAction(class BL_ActionActuator *act, short priority, double curtime);
struct bArmature * GetArmature() { return m_armature; }
@@ -69,7 +72,7 @@ public:
/// Retrieve the pose matrix for the specified bone.
/// Returns true on success.
- bool GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix) const;
+ bool GetBoneMatrix(Bone* bone, MT_Matrix4x4& matrix);
/// Returns the bone length. The end of the bone is in the local y direction.
float GetBoneLength(Bone* bone) const;
@@ -79,10 +82,13 @@ protected:
Object *m_objArma;
struct bArmature *m_armature;
struct bPose *m_pose;
- struct bPose *m_mrdPose;
+ struct bPose *m_armpose;
+ struct bPose *m_framePose;
double m_lastframe;
class BL_ActionActuator *m_activeAct;
short m_activePriority;
+
+ double m_lastapplyframe;
};
#endif
diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
index f04aa2eac16..dc2a14e1793 100644
--- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp
+++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp
@@ -87,7 +87,10 @@
#include "DNA_action_types.h"
#include "BKE_main.h"
#include "BKE_global.h"
+#include "BKE_object.h"
+#include "BKE_scene.h"
#include "BL_SkinMeshObject.h"
+#include "BL_ShapeDeformer.h"
#include "BL_SkinDeformer.h"
#include "BL_MeshDeformer.h"
//#include "BL_ArmatureController.h"
@@ -126,6 +129,7 @@
#include "DNA_sound_types.h"
#include "DNA_key_types.h"
#include "DNA_armature_types.h"
+#include "DNA_object_force.h"
#include "MEM_guardedalloc.h"
#include "BKE_utildefines.h"
@@ -133,8 +137,12 @@
#include "BKE_mesh.h"
#include "MT_Point3.h"
+#include "BLI_arithb.h"
+
extern "C" {
- #include "BKE_customdata.h"
+#include "BKE_customdata.h"
+#include "BKE_cdderivedmesh.h"
+#include "BKE_DerivedMesh.h"
}
#include "BKE_material.h" /* give_current_material */
@@ -221,15 +229,16 @@ static unsigned int KX_Mcol2uint_new(MCol col)
static void SetDefaultFaceType(Scene* scene)
{
default_face_mode = TF_DYNAMIC;
- Base *base = static_cast<Base*>(scene->base.first);
- while(base)
+ Scene *sce;
+ Base *base;
+
+ for(SETLOOPER(scene,base))
{
if (base->object->type == OB_LAMP)
{
default_face_mode = TF_DYNAMIC|TF_LIGHT;
return;
}
- base = base->next;
}
}
@@ -300,38 +309,40 @@ static void GetRGB(short type,
typedef struct MTF_localLayer
{
MTFace *face;
- char *name;
+ const char *name;
}MTF_localLayer;
// ------------------------------------
BL_Material* ConvertMaterial(
- Mesh* mesh,
Material *mat,
MTFace* tface,
+ const char *tfaceName,
MFace* mface,
MCol* mmcol,
int lightlayer,
Object* blenderobj,
- MTF_localLayer *layers)
+ MTF_localLayer *layers,
+ bool glslmat)
{
//this needs some type of manager
BL_Material *material = new BL_Material();
- int numchan = -1;
+ int numchan = -1, texalpha = 0;
bool validmat = (mat!=0);
- bool validface = (mesh->mtface && tface);
+ bool validface = (tface!=0);
short type = 0;
if( validmat )
type = 1; // material color
material->IdMode = DEFAULT_BLENDER;
+ material->glslmat = (validmat)? glslmat: false;
// --------------------------------
if(validmat) {
// use vertex colors by explicitly setting
- if(mat->mode &MA_VERTEXCOLP)
+ if(mat->mode &MA_VERTEXCOLP || glslmat)
type = 0;
// use lighting?
@@ -361,12 +372,14 @@ BL_Material* ConvertMaterial(
if(i==0 && facetex ) {
Image*tmp = (Image*)(tface->tpage);
+
if(tmp) {
material->img[i] = tmp;
material->texname[i] = material->img[i]->id.name;
material->flag[i] |= ( tface->transp &TF_ALPHA )?USEALPHA:0;
material->flag[i] |= ( tface->transp &TF_ADD )?CALCALPHA:0;
- material->ras_mode|= ( tface->transp &(TF_ADD | TF_ALPHA))?TRANSP:0;
+ material->flag[i] |= MIPMAP;
+
if(material->img[i]->flag & IMA_REFLECT)
material->mapping[i].mapping |= USEREFL;
else
@@ -424,6 +437,8 @@ BL_Material* ConvertMaterial(
material->flag[i] |= ( mttmp->mapto & MAP_ALPHA )?TEXALPHA:0;
material->flag[i] |= ( mttmp->texflag& MTEX_NEGATIVE )?TEXNEG:0;
+ if(!glslmat && (material->flag[i] & TEXALPHA))
+ texalpha = 1;
}
}
else if(mttmp->tex->type == TEX_ENVMAP) {
@@ -508,6 +523,7 @@ BL_Material* ConvertMaterial(
}
}
}
+
// above one tex the switches here
// are not used
switch(valid_index) {
@@ -539,20 +555,11 @@ BL_Material* ConvertMaterial(
material->ref = mat->ref;
material->amb = mat->amb;
- // set alpha testing without z-sorting
- if( ( validface && (!tface->transp)) && mat->mode & MA_ZTRA) {
- // sets the RAS_IPolyMaterial::m_flag |RAS_FORCEALPHA
- // this is so we don't have the overhead of the z-sorting code
- material->ras_mode|=ALPHA_TEST;
- }
- else{
- // use regular z-sorting
- material->ras_mode |= ((mat->mode & MA_ZTRA) != 0)?ZSORT:0;
- }
- material->ras_mode |= ((mat->mode & MA_WIRE) != 0)?WIRE:0;
+ material->ras_mode |= (mat->mode & MA_WIRE)? WIRE: 0;
}
else {
int valid = 0;
+
// check for tface tex to fallback on
if( validface ){
@@ -566,7 +573,6 @@ BL_Material* ConvertMaterial(
material->mapping[0].mapping |= ( (material->img[0]->flag & IMA_REFLECT)!=0 )?USEREFL:0;
material->flag[0] |= ( tface->transp &TF_ALPHA )?USEALPHA:0;
material->flag[0] |= ( tface->transp &TF_ADD )?CALCALPHA:0;
- material->ras_mode|= ( tface->transp & (TF_ADD|TF_ALPHA))?TRANSP:0;
valid++;
}
}
@@ -585,6 +591,10 @@ BL_Material* ConvertMaterial(
}
MT_Point2 uv[4];
MT_Point2 uv2[4];
+ const char *uvName = "", *uv2Name = "";
+
+ uv[0]= uv[1]= uv[2]= uv[3]= MT_Point2(0.0f, 0.0f);
+ uv2[0]= uv2[1]= uv2[2]= uv2[3]= MT_Point2(0.0f, 0.0f);
if( validface ) {
@@ -593,12 +603,7 @@ BL_Material* ConvertMaterial(
(tface->mode & TF_INVISIBLE)
)?POLY_VIS:0;
- material->ras_mode |= ( (tface->mode & TF_DYNAMIC)!= 0 )?COLLIDER:0;
material->transp = tface->transp;
-
- if(tface->transp)
- material->ras_mode |= TRANSP;
-
material->tile = tface->tile;
material->mode = tface->mode;
@@ -608,16 +613,33 @@ BL_Material* ConvertMaterial(
if (mface->v4)
uv[3] = MT_Point2(tface->uv[3]);
+
+ uvName = tfaceName;
}
else {
// nothing at all
- material->ras_mode |= (COLLIDER|POLY_VIS| (validmat?0:USE_LIGHT));
+ material->ras_mode |= (POLY_VIS| (validmat?0:USE_LIGHT));
material->mode = default_face_mode;
material->transp = TF_SOLID;
material->tile = 0;
}
+ // with ztransp enabled, enforce alpha blending mode
+ if(validmat && (mat->mode & MA_ZTRA) && (material->transp == TF_SOLID))
+ material->transp = TF_ALPHA;
+ // always zsort alpha + add
+ if((material->transp == TF_ALPHA || material->transp == TF_ADD || texalpha) && (material->transp != TF_CLIP)) {
+ material->ras_mode |= ALPHA;
+ material->ras_mode |= (material->mode & TF_ALPHASORT)? ZSORT: 0;
+ }
+
+ // collider or not?
+ material->ras_mode |= (material->mode & TF_DYNAMIC)? COLLIDER: 0;
+
+ // these flags are irrelevant at this point, remove so they
+ // don't hurt material bucketing
+ material->mode &= ~(TF_DYNAMIC|TF_ALPHASORT|TF_TEX);
// get uv sets
if(validmat)
@@ -629,43 +651,43 @@ BL_Material* ConvertMaterial(
for (int vind = 0; vind<material->num_enabled; vind++)
{
BL_Mapping &map = material->mapping[vind];
+
if (map.uvCoName.IsEmpty())
isFirstSet = false;
else
{
- MT_Point2 uvSet[4];
for (int lay=0; lay<MAX_MTFACE; lay++)
{
MTF_localLayer& layer = layers[lay];
if (layer.face == 0) break;
-
- bool processed = false;
if (strcmp(map.uvCoName.ReadPtr(), layer.name)==0)
{
+ MT_Point2 uvSet[4];
+
uvSet[0] = MT_Point2(layer.face->uv[0]);
uvSet[1] = MT_Point2(layer.face->uv[1]);
uvSet[2] = MT_Point2(layer.face->uv[2]);
if (mface->v4)
uvSet[3] = MT_Point2(layer.face->uv[3]);
+ else
+ uvSet[3] = MT_Point2(0.0f, 0.0f);
- processed = true;
- }
-
- if (!processed) continue;
-
- if (isFirstSet)
- {
- uv[0] = uvSet[0]; uv[1] = uvSet[1];
- uv[2] = uvSet[2]; uv[3] = uvSet[3];
- isFirstSet = false;
- }
- else
- {
- uv2[0] = uvSet[0]; uv2[1] = uvSet[1];
- uv2[2] = uvSet[2]; uv2[3] = uvSet[3];
- map.mapping |= USECUSTOMUV;
+ if (isFirstSet)
+ {
+ uv[0] = uvSet[0]; uv[1] = uvSet[1];
+ uv[2] = uvSet[2]; uv[3] = uvSet[3];
+ isFirstSet = false;
+ uvName = layer.name;
+ }
+ else if(strcmp(layer.name, uvName) != 0)
+ {
+ uv2[0] = uvSet[0]; uv2[1] = uvSet[1];
+ uv2[2] = uvSet[2]; uv2[3] = uvSet[3];
+ map.mapping |= USECUSTOMUV;
+ uv2Name = layer.name;
+ }
}
}
}
@@ -685,11 +707,9 @@ BL_Material* ConvertMaterial(
}
material->SetConversionRGB(rgb);
- material->SetConversionUV(uv);
- material->SetConversionUV2(uv2);
+ material->SetConversionUV(uvName, uv);
+ material->SetConversionUV2(uv2Name, uv2);
-
- material->ras_mode |= (mface->v4==0)?TRIANGLE:0;
if(validmat)
material->matname =(mat->id.name);
@@ -699,399 +719,294 @@ BL_Material* ConvertMaterial(
}
-static void BL_ComputeTriTangentSpace(const MT_Vector3 &v1, const MT_Vector3 &v2, const MT_Vector3 &v3,
- const MT_Vector2 &uv1, const MT_Vector2 &uv2, const MT_Vector2 &uv3,
- MFace* mface, MT_Vector3 *tan1, MT_Vector3 *tan2)
-{
- MT_Vector3 dx1(v2 - v1), dx2(v3 - v1);
- MT_Vector2 duv1(uv2 - uv1), duv2(uv3 - uv1);
-
- MT_Scalar r = 1.0 / (duv1.x() * duv2.y() - duv2.x() * duv1.y());
- duv1 *= r;
- duv2 *= r;
- MT_Vector3 sdir(duv2.y() * dx1 - duv1.y() * dx2);
- MT_Vector3 tdir(duv1.x() * dx2 - duv2.x() * dx1);
-
- tan1[mface->v1] += sdir;
- tan1[mface->v2] += sdir;
- tan1[mface->v3] += sdir;
-
- tan2[mface->v1] += tdir;
- tan2[mface->v2] += tdir;
- tan2[mface->v3] += tdir;
-}
-
-static MT_Vector4* BL_ComputeMeshTangentSpace(Mesh* mesh)
-{
- MFace* mface = static_cast<MFace*>(mesh->mface);
- MTFace* tface = static_cast<MTFace*>(mesh->mtface);
-
- MT_Vector3 *tan1 = new MT_Vector3[mesh->totvert];
- MT_Vector3 *tan2 = new MT_Vector3[mesh->totvert];
-
- unsigned int v;
- for (v = 0; v < mesh->totvert; v++)
- {
- tan1[v] = MT_Vector3(0.0, 0.0, 0.0);
- tan2[v] = MT_Vector3(0.0, 0.0, 0.0);
- }
-
- for (unsigned int p = 0; p < mesh->totface; p++, mface++, tface++)
- {
- MT_Vector3 v1(mesh->mvert[mface->v1].co),
- v2(mesh->mvert[mface->v2].co),
- v3(mesh->mvert[mface->v3].co);
-
- MT_Vector2 uv1(tface->uv[0]),
- uv2(tface->uv[1]),
- uv3(tface->uv[2]);
-
- BL_ComputeTriTangentSpace(v1, v2, v3, uv1, uv2, uv3, mface, tan1, tan2);
- if (mface->v4)
- {
- MT_Vector3 v4(mesh->mvert[mface->v4].co);
- MT_Vector2 uv4(tface->uv[3]);
-
- BL_ComputeTriTangentSpace(v1, v3, v4, uv1, uv3, uv4, mface, tan1, tan2);
- }
- }
-
- MT_Vector4 *tangent = new MT_Vector4[mesh->totvert];
- for (v = 0; v < mesh->totvert; v++)
- {
- const MT_Vector3 no(mesh->mvert[v].no[0]/32767.0,
- mesh->mvert[v].no[1]/32767.0,
- mesh->mvert[v].no[2]/32767.0);
- // Gram-Schmidt orthogonalize
- MT_Vector3 t(tan1[v] - no.cross(no.cross(tan1[v])));
- if (!MT_fuzzyZero(t))
- t /= t.length();
-
- tangent[v].x() = t.x();
- tangent[v].y() = t.y();
- tangent[v].z() = t.z();
- // Calculate handedness
- tangent[v].w() = no.dot(tan1[v].cross(tan2[v])) < 0.0 ? -1.0 : 1.0;
- }
-
- delete [] tan1;
- delete [] tan2;
-
- return tangent;
-}
-
RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools* rendertools, KX_Scene* scene, KX_BlenderSceneConverter *converter)
{
RAS_MeshObject *meshobj;
- bool skinMesh = false;
-
+ bool skinMesh = false;
int lightlayer = blenderobj->lay;
-
- MFace* mface = static_cast<MFace*>(mesh->mface);
- MTFace* tface = static_cast<MTFace*>(mesh->mtface);
- MCol* mmcol = mesh->mcol;
- MT_assert(mface || mesh->totface == 0);
+ // Get DerivedMesh data
+ DerivedMesh *dm = CDDM_from_mesh(mesh, blenderobj);
+
+ MVert *mvert = dm->getVertArray(dm);
+ int totvert = dm->getNumVerts(dm);
+
+ MFace *mface = dm->getFaceArray(dm);
+ MTFace *tface = static_cast<MTFace*>(dm->getFaceDataArray(dm, CD_MTFACE));
+ MCol *mcol = static_cast<MCol*>(dm->getFaceDataArray(dm, CD_MCOL));
+ float (*tangent)[3] = NULL;
+ int totface = dm->getNumFaces(dm);
+ const char *tfaceName = "";
+
+ if(tface) {
+ DM_add_tangent_layer(dm);
+ tangent = (float(*)[3])dm->getFaceDataArray(dm, CD_TANGENT);
+ }
// Determine if we need to make a skinned mesh
- if (mesh->dvert){
- meshobj = new BL_SkinMeshObject(lightlayer);
+ if (mesh->dvert || mesh->key || ((blenderobj->gameflag & OB_SOFT_BODY) != 0))
+ {
+ meshobj = new BL_SkinMeshObject(mesh, lightlayer);
skinMesh = true;
}
- else {
- meshobj = new RAS_MeshObject(lightlayer);
- }
- MT_Vector4 *tangent = 0;
- if (tface)
- tangent = BL_ComputeMeshTangentSpace(mesh);
-
+ else
+ meshobj = new RAS_MeshObject(mesh, lightlayer);
// Extract avaiable layers
MTF_localLayer *layers = new MTF_localLayer[MAX_MTFACE];
- for (int lay=0; lay<MAX_MTFACE; lay++)
- {
+ for (int lay=0; lay<MAX_MTFACE; lay++) {
layers[lay].face = 0;
layers[lay].name = "";
}
-
int validLayers = 0;
- for (int i=0; i<mesh->fdata.totlayer; i++)
+ for (int i=0; i<dm->faceData.totlayer; i++)
{
- if (mesh->fdata.layers[i].type == CD_MTFACE)
+ if (dm->faceData.layers[i].type == CD_MTFACE)
{
assert(validLayers <= 8);
- layers[validLayers].face = (MTFace*)mesh->fdata.layers[i].data;;
- layers[validLayers].name = mesh->fdata.layers[i].name;
+ layers[validLayers].face = (MTFace*)(dm->faceData.layers[i].data);
+ layers[validLayers].name = dm->faceData.layers[i].name;
+ if(tface == layers[validLayers].face)
+ tfaceName = layers[validLayers].name;
validLayers++;
}
}
-
meshobj->SetName(mesh->id.name);
- meshobj->m_xyz_index_to_vertex_index_mapping.resize(mesh->totvert);
- for (int f=0;f<mesh->totface;f++,mface++)
+ meshobj->m_sharedvertex_map.resize(totvert);
+
+ for (int f=0;f<totface;f++,mface++)
{
-
+ Material* ma = 0;
bool collider = true;
-
- // only add valid polygons
- if (mface->v3)
- {
- MT_Point2 uv0(0.0,0.0),uv1(0.0,0.0),uv2(0.0,0.0),uv3(0.0,0.0);
- MT_Point2 uv20(0.0,0.0),uv21(0.0,0.0),uv22(0.0,0.0),uv23(0.0,0.0);
- // rgb3 is set from the adjoint face in a square
- unsigned int rgb0,rgb1,rgb2,rgb3 = 0;
- MT_Vector3 no0(mesh->mvert[mface->v1].no[0], mesh->mvert[mface->v1].no[1], mesh->mvert[mface->v1].no[2]),
- no1(mesh->mvert[mface->v2].no[0], mesh->mvert[mface->v2].no[1], mesh->mvert[mface->v2].no[2]),
- no2(mesh->mvert[mface->v3].no[0], mesh->mvert[mface->v3].no[1], mesh->mvert[mface->v3].no[2]),
- no3(0.0, 0.0, 0.0);
- MT_Point3 pt0(mesh->mvert[mface->v1].co),
- pt1(mesh->mvert[mface->v2].co),
- pt2(mesh->mvert[mface->v3].co),
- pt3(0.0, 0.0, 0.0);
- MT_Vector4 tan0(0.0, 0.0, 0.0, 0.0),
- tan1(0.0, 0.0, 0.0, 0.0),
- tan2(0.0, 0.0, 0.0, 0.0),
- tan3(0.0, 0.0, 0.0, 0.0);
-
- no0 /= 32767.0;
- no1 /= 32767.0;
- no2 /= 32767.0;
- if (mface->v4)
- {
- pt3 = MT_Point3(mesh->mvert[mface->v4].co);
- no3 = MT_Vector3(mesh->mvert[mface->v4].no[0], mesh->mvert[mface->v4].no[1], mesh->mvert[mface->v4].no[2]);
- no3 /= 32767.0;
+ MT_Point2 uv0(0.0,0.0),uv1(0.0,0.0),uv2(0.0,0.0),uv3(0.0,0.0);
+ MT_Point2 uv20(0.0,0.0),uv21(0.0,0.0),uv22(0.0,0.0),uv23(0.0,0.0);
+ unsigned int rgb0,rgb1,rgb2,rgb3 = 0;
+
+ MT_Point3 pt0, pt1, pt2, pt3;
+ MT_Vector3 no0(0,0,0), no1(0,0,0), no2(0,0,0), no3(0,0,0);
+ MT_Vector4 tan0(0,0,0,0), tan1(0,0,0,0), tan2(0,0,0,0), tan3(0,0,0,0);
+
+ /* get coordinates, normals and tangents */
+ pt0 = MT_Point3(mvert[mface->v1].co);
+ pt1 = MT_Point3(mvert[mface->v2].co);
+ pt2 = MT_Point3(mvert[mface->v3].co);
+ pt3 = (mface->v4)? MT_Point3(mvert[mface->v4].co): MT_Point3(0.0, 0.0, 0.0);
+
+ if(mface->flag & ME_SMOOTH) {
+ float n0[3], n1[3], n2[3], n3[3];
+
+ NormalShortToFloat(n0, mvert[mface->v1].no);
+ NormalShortToFloat(n1, mvert[mface->v2].no);
+ NormalShortToFloat(n2, mvert[mface->v3].no);
+ no0 = n0;
+ no1 = n1;
+ no2 = n2;
+
+ if(mface->v4) {
+ NormalShortToFloat(n3, mvert[mface->v4].no);
+ no3 = n3;
}
+ }
+ else {
+ float fno[3];
+
+ if(mface->v4)
+ CalcNormFloat4(mvert[mface->v1].co, mvert[mface->v2].co,
+ mvert[mface->v3].co, mvert[mface->v4].co, fno);
+ else
+ CalcNormFloat(mvert[mface->v1].co, mvert[mface->v2].co,
+ mvert[mface->v3].co, fno);
+
+ no0 = no1 = no2 = no3 = MT_Vector3(fno);
+ }
+
+ if(tangent) {
+ tan0 = tangent[f*4 + 0];
+ tan1 = tangent[f*4 + 1];
+ tan2 = tangent[f*4 + 2];
+
+ if (mface->v4)
+ tan3 = tangent[f*4 + 3];
+ }
+
+ /* get material */
+ ma = give_current_material(blenderobj, mface->mat_nr+1);
- if(!(mface->flag & ME_SMOOTH))
- {
- MT_Vector3 norm = ((pt1-pt0).cross(pt2-pt0)).safe_normalized();
- norm[0] = ((int) (10*norm[0]))/10.0;
- norm[1] = ((int) (10*norm[1]))/10.0;
- norm[2] = ((int) (10*norm[2]))/10.0;
- no0=no1=no2=no3= norm;
-
+ {
+ bool visible = true;
+ RAS_IPolyMaterial* polymat = NULL;
+ BL_Material *bl_mat = NULL;
+
+ if(converter->GetMaterials()) {
+ /* do Blender Multitexture and Blender GLSL materials */
+ unsigned int rgb[4];
+ MT_Point2 uv[4];
+
+ /* first is the BL_Material */
+ bl_mat = ConvertMaterial(ma, tface, tfaceName, mface, mcol,
+ lightlayer, blenderobj, layers, converter->GetGLSLMaterials());
+
+ bl_mat->material_index = (int)mface->mat_nr;
+
+ visible = ((bl_mat->ras_mode & POLY_VIS)!=0);
+ collider = ((bl_mat->ras_mode & COLLIDER)!=0);
+
+ /* vertex colors and uv's were stored in bl_mat temporarily */
+ bl_mat->GetConversionRGB(rgb);
+ rgb0 = rgb[0]; rgb1 = rgb[1];
+ rgb2 = rgb[2]; rgb3 = rgb[3];
+
+ bl_mat->GetConversionUV(uv);
+ uv0 = uv[0]; uv1 = uv[1];
+ uv2 = uv[2]; uv3 = uv[3];
+
+ bl_mat->GetConversionUV2(uv);
+ uv20 = uv[0]; uv21 = uv[1];
+ uv22 = uv[2]; uv23 = uv[3];
+
+ /* then the KX_BlenderMaterial */
+ polymat = new KX_BlenderMaterial(scene, bl_mat, skinMesh, lightlayer);
}
+ else {
+ /* do Texture Face materials */
+ Image* bima = (tface)? (Image*)tface->tpage: NULL;
+ STR_String imastr = (tface)? (bima? (bima)->id.name : "" ) : "";
- {
- Material* ma = 0;
- bool polyvisible = true;
- RAS_IPolyMaterial* polymat = NULL;
-
- if(converter->GetMaterials())
- {
- if(mesh->totcol > 1)
- ma = mesh->mat[mface->mat_nr];
- else
- ma = give_current_material(blenderobj, 1);
-
- BL_Material *bl_mat = ConvertMaterial(mesh, ma, tface, mface, mmcol, lightlayer, blenderobj, layers);
- // set the index were dealing with
- bl_mat->material_index = (int)mface->mat_nr;
-
- polyvisible = ((bl_mat->ras_mode & POLY_VIS)!=0);
- collider = ((bl_mat->ras_mode & COLLIDER)!=0);
+ char transp=0;
+ short mode=0, tile=0;
+ int tilexrep=4,tileyrep = 4;
+
+ if (bima) {
+ tilexrep = bima->xrep;
+ tileyrep = bima->yrep;
+ }
+
+ /* get tface properties if available */
+ if(tface) {
+ /* TF_DYNAMIC means the polygon is a collision face */
+ collider = ((tface->mode & TF_DYNAMIC) != 0);
+ transp = tface->transp;
+ tile = tface->tile;
+ mode = tface->mode;
- polymat = new KX_BlenderMaterial(scene, bl_mat, skinMesh, lightlayer, blenderobj );
- converter->RegisterBlenderMaterial(bl_mat);
+ visible = !((mface->flag & ME_HIDE)||(tface->mode & TF_INVISIBLE));
- unsigned int rgb[4];
- bl_mat->GetConversionRGB(rgb);
- rgb0 = rgb[0]; rgb1 = rgb[1];
- rgb2 = rgb[2]; rgb3 = rgb[3];
- MT_Point2 uv[4];
- bl_mat->GetConversionUV(uv);
- uv0 = uv[0]; uv1 = uv[1];
- uv2 = uv[2]; uv3 = uv[3];
-
- bl_mat->GetConversionUV2(uv);
- uv20 = uv[0]; uv21 = uv[1];
- uv22 = uv[2]; uv23 = uv[3];
-
- if(tangent){
- tan0 = tangent[mface->v1];
- tan1 = tangent[mface->v2];
- tan2 = tangent[mface->v3];
- if (mface->v4)
- tan3 = tangent[mface->v4];
- }
- // this is needed to free up memory afterwards
- converter->RegisterPolyMaterial(polymat);
+ uv0 = MT_Point2(tface->uv[0]);
+ uv1 = MT_Point2(tface->uv[1]);
+ uv2 = MT_Point2(tface->uv[2]);
+
+ if (mface->v4)
+ uv3 = MT_Point2(tface->uv[3]);
+ }
+ else {
+ /* no texfaces, set COLLSION true and everything else FALSE */
+ mode = default_face_mode;
+ transp = TF_SOLID;
+ tile = 0;
}
- else
- {
- ma = give_current_material(blenderobj, 1);
- Image* bima = ((mesh->mtface && tface) ? (Image*) tface->tpage : NULL);
-
- STR_String imastr =
- ((mesh->mtface && tface) ?
- (bima? (bima)->id.name : "" ) : "" );
-
- char transp=0;
- short mode=0, tile=0;
- int tilexrep=4,tileyrep = 4;
+ /* get vertex colors */
+ if (mcol) {
+ /* we have vertex colors */
+ rgb0 = KX_Mcol2uint_new(mcol[0]);
+ rgb1 = KX_Mcol2uint_new(mcol[1]);
+ rgb2 = KX_Mcol2uint_new(mcol[2]);
- if (bima)
- {
- tilexrep = bima->xrep;
- tileyrep = bima->yrep;
-
- }
+ if (mface->v4)
+ rgb3 = KX_Mcol2uint_new(mcol[3]);
+ }
+ else {
+ /* no vertex colors, take from material, otherwise white */
+ unsigned int color = 0xFFFFFFFFL;
- if (mesh->mtface && tface)
+ if (ma)
{
- // Use texface colors if available
- //TF_DYNAMIC means the polygon is a collision face
- collider = ((tface->mode & TF_DYNAMIC) != 0);
- transp = tface->transp;
- tile = tface->tile;
- mode = tface->mode;
-
- polyvisible = !((mface->flag & ME_HIDE)||(tface->mode & TF_INVISIBLE));
+ union
+ {
+ unsigned char cp[4];
+ unsigned int integer;
+ } col_converter;
- uv0 = MT_Point2(tface->uv[0]);
- uv1 = MT_Point2(tface->uv[1]);
- uv2 = MT_Point2(tface->uv[2]);
-
- if (mface->v4)
- uv3 = MT_Point2(tface->uv[3]);
- }
- else
- {
- // no texfaces, set COLLSION true and everything else FALSE
+ col_converter.cp[3] = (unsigned char) (ma->r*255.0);
+ col_converter.cp[2] = (unsigned char) (ma->g*255.0);
+ col_converter.cp[1] = (unsigned char) (ma->b*255.0);
+ col_converter.cp[0] = (unsigned char) (ma->alpha*255.0);
- mode = default_face_mode;
- transp = TF_SOLID;
- tile = 0;
+ color = col_converter.integer;
}
- if (mmcol)
- {
- // Use vertex colors
- rgb0 = KX_Mcol2uint_new(mmcol[0]);
- rgb1 = KX_Mcol2uint_new(mmcol[1]);
- rgb2 = KX_Mcol2uint_new(mmcol[2]);
-
- if (mface->v4)
- rgb3 = KX_Mcol2uint_new(mmcol[3]);
- }
- else {
- // no vertex colors: take from material if we have one,
- // otherwise set to white
- unsigned int color = 0xFFFFFFFFL;
-
- if (ma)
- {
- union
- {
- unsigned char cp[4];
- unsigned int integer;
- } col_converter;
-
- col_converter.cp[3] = (unsigned char) (ma->r*255.0);
- col_converter.cp[2] = (unsigned char) (ma->g*255.0);
- col_converter.cp[1] = (unsigned char) (ma->b*255.0);
- col_converter.cp[0] = (unsigned char) (ma->alpha*255.0);
-
- color = col_converter.integer;
- }
-
- rgb0 = KX_rgbaint2uint_new(color);
- rgb1 = KX_rgbaint2uint_new(color);
- rgb2 = KX_rgbaint2uint_new(color);
-
- if (mface->v4)
- rgb3 = KX_rgbaint2uint_new(color);
- }
+ rgb0 = KX_rgbaint2uint_new(color);
+ rgb1 = KX_rgbaint2uint_new(color);
+ rgb2 = KX_rgbaint2uint_new(color);
- bool istriangle = (mface->v4==0);
- bool zsort = ma?(ma->mode & MA_ZTRA) != 0:false;
-
- polymat = new KX_PolygonMaterial(imastr, ma,
- tile, tilexrep, tileyrep,
- mode, transp, zsort, lightlayer, istriangle, blenderobj, tface, (unsigned int*)mmcol);
-
- if (ma)
- {
- polymat->m_specular = MT_Vector3(ma->specr, ma->specg, ma->specb)*ma->spec;
- polymat->m_shininess = (float)ma->har/4.0; // 0 < ma->har <= 512
- polymat->m_diffuse = MT_Vector3(ma->r, ma->g, ma->b)*(ma->emit + ma->ref);
-
- } else
- {
- polymat->m_specular = MT_Vector3(0.0f,0.0f,0.0f);
- polymat->m_shininess = 35.0;
- }
- // this is needed to free up memory afterwards
- converter->RegisterPolyMaterial(polymat);
-
+ if (mface->v4)
+ rgb3 = KX_rgbaint2uint_new(color);
}
-
- RAS_MaterialBucket* bucket = scene->FindBucket(polymat);
-
- int nverts = mface->v4?4:3;
- int vtxarray = meshobj->FindVertexArray(nverts,polymat);
- RAS_Polygon* poly = new RAS_Polygon(bucket,polyvisible,nverts,vtxarray);
- if (skinMesh) {
- int d1, d2, d3, d4=0;
- bool flat;
-
- /* If the face is set to solid, all fnors are the same */
- if (mface->flag & ME_SMOOTH)
- flat = false;
- else
- flat = true;
-
- d1=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v1, &mesh->dvert[mface->v1], polymat);
- d2=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v2, &mesh->dvert[mface->v2], polymat);
- d3=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v3, &mesh->dvert[mface->v3], polymat);
- if (nverts==4)
- d4=((BL_SkinMeshObject*)meshobj)->FindOrAddDeform(vtxarray, mface->v4, &mesh->dvert[mface->v4], polymat);
- poly->SetVertex(0,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,d1,flat, polymat));
- poly->SetVertex(1,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,d2,flat, polymat));
- poly->SetVertex(2,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,d3,flat, polymat));
- if (nverts==4)
- poly->SetVertex(3,((BL_SkinMeshObject*)meshobj)->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,d4, flat,polymat));
+
+ // only zsort alpha + add
+ bool alpha = (transp == TF_ALPHA || transp == TF_ADD);
+ bool zsort = (mode & TF_ALPHASORT)? alpha: 0;
+
+ polymat = new KX_PolygonMaterial(imastr, ma,
+ tile, tilexrep, tileyrep,
+ mode, transp, alpha, zsort, lightlayer, tface, (unsigned int*)mcol);
+
+ if (ma) {
+ polymat->m_specular = MT_Vector3(ma->specr, ma->specg, ma->specb)*ma->spec;
+ polymat->m_shininess = (float)ma->har/4.0; // 0 < ma->har <= 512
+ polymat->m_diffuse = MT_Vector3(ma->r, ma->g, ma->b)*(ma->emit + ma->ref);
}
- else
- {
- poly->SetVertex(0,meshobj->FindOrAddVertex(vtxarray,pt0,uv0,uv20,tan0,rgb0,no0,polymat,mface->v1));
- poly->SetVertex(1,meshobj->FindOrAddVertex(vtxarray,pt1,uv1,uv21,tan1,rgb1,no1,polymat,mface->v2));
- poly->SetVertex(2,meshobj->FindOrAddVertex(vtxarray,pt2,uv2,uv22,tan2,rgb2,no2,polymat,mface->v3));
- if (nverts==4)
- poly->SetVertex(3,meshobj->FindOrAddVertex(vtxarray,pt3,uv3,uv23,tan3,rgb3,no3,polymat,mface->v4));
+ else {
+ polymat->m_specular = MT_Vector3(0.0f,0.0f,0.0f);
+ polymat->m_shininess = 35.0;
}
- meshobj->AddPolygon(poly);
- if (poly->IsCollider())
- {
- RAS_TriangleIndex idx;
- idx.m_index[0] = mface->v1;
- idx.m_index[1] = mface->v2;
- idx.m_index[2] = mface->v3;
- idx.m_collider = collider;
- meshobj->m_triangle_indices.push_back(idx);
- if (nverts==4)
- {
- idx.m_index[0] = mface->v1;
- idx.m_index[1] = mface->v3;
- idx.m_index[2] = mface->v4;
- idx.m_collider = collider;
- meshobj->m_triangle_indices.push_back(idx);
- }
+ }
+
+ /* mark face as flat, so vertices are split */
+ bool flat = (mface->flag & ME_SMOOTH) == 0;
+
+ // see if a bucket was reused or a new one was created
+ // this way only one KX_BlenderMaterial object has to exist per bucket
+ bool bucketCreated;
+ RAS_MaterialBucket* bucket = scene->FindBucket(polymat, bucketCreated);
+ if (bucketCreated) {
+ // this is needed to free up memory afterwards
+ converter->RegisterPolyMaterial(polymat);
+ if(converter->GetMaterials()) {
+ converter->RegisterBlenderMaterial(bl_mat);
}
-
-// poly->SetVisibleWireframeEdges(mface->edcode);
- poly->SetCollider(collider);
+ } else {
+ // delete the material objects since they are no longer needed
+ // from now on, use the polygon material from the material bucket
+ delete polymat;
+ if(converter->GetMaterials()) {
+ delete bl_mat;
+ }
+ polymat = bucket->GetPolyMaterial();
}
+
+ int nverts = (mface->v4)? 4: 3;
+ RAS_Polygon *poly = meshobj->AddPolygon(bucket, nverts);
+
+ poly->SetVisible(visible);
+ poly->SetCollider(collider);
+ //poly->SetEdgeCode(mface->edcode);
+
+ meshobj->AddVertex(poly,0,pt0,uv0,uv20,tan0,rgb0,no0,flat,mface->v1);
+ meshobj->AddVertex(poly,1,pt1,uv1,uv21,tan1,rgb1,no1,flat,mface->v2);
+ meshobj->AddVertex(poly,2,pt2,uv2,uv22,tan2,rgb2,no2,flat,mface->v3);
+
+ if (nverts==4)
+ meshobj->AddVertex(poly,3,pt3,uv3,uv23,tan3,rgb3,no3,flat,mface->v4);
}
+
if (tface)
tface++;
- if (mmcol)
- mmcol+=4;
+ if (mcol)
+ mcol+=4;
for (int lay=0; lay<MAX_MTFACE; lay++)
{
@@ -1101,19 +1016,18 @@ RAS_MeshObject* BL_ConvertMesh(Mesh* mesh, Object* blenderobj, RAS_IRenderTools*
layer.face++;
}
}
- meshobj->UpdateMaterialList();
+ meshobj->m_sharedvertex_map.clear();
// pre calculate texture generation
- for(RAS_MaterialBucket::Set::iterator mit = meshobj->GetFirstMaterial();
+ for(list<RAS_MeshMaterial>::iterator mit = meshobj->GetFirstMaterial();
mit != meshobj->GetLastMaterial(); ++ mit) {
- (*mit)->GetPolyMaterial()->OnConstruction();
+ mit->m_bucket->GetPolyMaterial()->OnConstruction();
}
- if(tangent)
- delete [] tangent;
-
if (layers)
delete []layers;
+
+ dm->release(dm);
return meshobj;
}
@@ -1367,6 +1281,10 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
//int userigidbody = SYS_GetCommandLineInt(syshandle,"norigidbody",0);
//bool bRigidBody = (userigidbody == 0);
+ // object has physics representation?
+ if (!(blenderobject->gameflag & OB_COLLISION))
+ return;
+
// get Root Parent of blenderobject
struct Object* parent= blenderobject->parent;
while(parent && parent->parent) {
@@ -1398,19 +1316,97 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
objprop.m_isCompoundChild = isCompoundChild;
objprop.m_hasCompoundChildren = (blenderobject->gameflag & OB_CHILD) != 0;
-
- if ((objprop.m_isactor = (blenderobject->gameflag & OB_ACTOR)!=0))
+ objprop.m_margin = blenderobject->margin;
+ // ACTOR is now a separate feature
+ objprop.m_isactor = (blenderobject->gameflag & OB_ACTOR)!=0;
+ objprop.m_dyna = (blenderobject->gameflag & OB_DYNAMIC) != 0;
+ objprop.m_softbody = (blenderobject->gameflag & OB_SOFT_BODY) != 0;
+ objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0;
+
+ if (objprop.m_softbody)
{
- objprop.m_dyna = (blenderobject->gameflag & OB_DYNAMIC) != 0;
- objprop.m_angular_rigidbody = (blenderobject->gameflag & OB_RIGID_BODY) != 0;
- objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0;
- objprop.m_disableSleeping = (blenderobject->gameflag & OB_COLLISION_RESPONSE) != 0;//abuse the OB_COLLISION_RESPONSE flag
- } else {
- objprop.m_dyna = false;
- objprop.m_angular_rigidbody = false;
- objprop.m_ghost = false;
- objprop.m_disableSleeping = false;
+ ///for game soft bodies
+ if (blenderobject->bsoft)
+ {
+ objprop.m_gamesoftFlag = blenderobject->bsoft->flag;
+ ///////////////////
+ objprop.m_soft_linStiff = blenderobject->bsoft->linStiff;
+ objprop.m_soft_angStiff = blenderobject->bsoft->angStiff; /* angular stiffness 0..1 */
+ objprop.m_soft_volume= blenderobject->bsoft->volume; /* volume preservation 0..1 */
+
+ objprop.m_soft_viterations= blenderobject->bsoft->viterations; /* Velocities solver iterations */
+ objprop.m_soft_piterations= blenderobject->bsoft->piterations; /* Positions solver iterations */
+ objprop.m_soft_diterations= blenderobject->bsoft->diterations; /* Drift solver iterations */
+ objprop.m_soft_citerations= blenderobject->bsoft->citerations; /* Cluster solver iterations */
+
+ objprop.m_soft_kSRHR_CL= blenderobject->bsoft->kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */
+ objprop.m_soft_kSKHR_CL= blenderobject->bsoft->kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */
+ objprop.m_soft_kSSHR_CL= blenderobject->bsoft->kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */
+ objprop.m_soft_kSR_SPLT_CL= blenderobject->bsoft->kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+
+ objprop.m_soft_kSK_SPLT_CL= blenderobject->bsoft->kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+ objprop.m_soft_kSS_SPLT_CL= blenderobject->bsoft->kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+ objprop.m_soft_kVCF= blenderobject->bsoft->kVCF; /* Velocities correction factor (Baumgarte) */
+ objprop.m_soft_kDP= blenderobject->bsoft->kDP; /* Damping coefficient [0,1] */
+
+ objprop.m_soft_kDG= blenderobject->bsoft->kDG; /* Drag coefficient [0,+inf] */
+ objprop.m_soft_kLF= blenderobject->bsoft->kLF; /* Lift coefficient [0,+inf] */
+ objprop.m_soft_kPR= blenderobject->bsoft->kPR; /* Pressure coefficient [-inf,+inf] */
+ objprop.m_soft_kVC= blenderobject->bsoft->kVC; /* Volume conversation coefficient [0,+inf] */
+
+ objprop.m_soft_kDF= blenderobject->bsoft->kDF; /* Dynamic friction coefficient [0,1] */
+ objprop.m_soft_kMT= blenderobject->bsoft->kMT; /* Pose matching coefficient [0,1] */
+ objprop.m_soft_kCHR= blenderobject->bsoft->kCHR; /* Rigid contacts hardness [0,1] */
+ objprop.m_soft_kKHR= blenderobject->bsoft->kKHR; /* Kinetic contacts hardness [0,1] */
+
+ objprop.m_soft_kSHR= blenderobject->bsoft->kSHR; /* Soft contacts hardness [0,1] */
+ objprop.m_soft_kAHR= blenderobject->bsoft->kAHR; /* Anchors hardness [0,1] */
+ objprop.m_soft_collisionflags= blenderobject->bsoft->collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
+ objprop.m_soft_numclusteriterations= blenderobject->bsoft->numclusteriterations; /* number of iterations to refine collision clusters*/
+
+ } else
+ {
+ objprop.m_gamesoftFlag = OB_BSB_BENDING_CONSTRAINTS | OB_BSB_SHAPE_MATCHING | OB_BSB_AERO_VPOINT;
+
+ objprop.m_soft_linStiff = 0.5;;
+ objprop.m_soft_angStiff = 1.f; /* angular stiffness 0..1 */
+ objprop.m_soft_volume= 1.f; /* volume preservation 0..1 */
+
+
+ objprop.m_soft_viterations= 0;
+ objprop.m_soft_piterations= 1;
+ objprop.m_soft_diterations= 0;
+ objprop.m_soft_citerations= 4;
+
+ objprop.m_soft_kSRHR_CL= 0.1f;
+ objprop.m_soft_kSKHR_CL= 1.f;
+ objprop.m_soft_kSSHR_CL= 0.5;
+ objprop.m_soft_kSR_SPLT_CL= 0.5f;
+
+ objprop.m_soft_kSK_SPLT_CL= 0.5f;
+ objprop.m_soft_kSS_SPLT_CL= 0.5f;
+ objprop.m_soft_kVCF= 1;
+ objprop.m_soft_kDP= 0;
+
+ objprop.m_soft_kDG= 0;
+ objprop.m_soft_kLF= 0;
+ objprop.m_soft_kPR= 0;
+ objprop.m_soft_kVC= 0;
+
+ objprop.m_soft_kDF= 0.2f;
+ objprop.m_soft_kMT= 0.05f;
+ objprop.m_soft_kCHR= 1.0f;
+ objprop.m_soft_kKHR= 0.1f;
+
+ objprop.m_soft_kSHR= 1.f;
+ objprop.m_soft_kAHR= 0.7f;
+ objprop.m_soft_collisionflags= OB_BSB_COL_SDF_RS + OB_BSB_COL_VF_SS;
+ objprop.m_soft_numclusteriterations= 16;
+ }
}
+
+ objprop.m_ghost = (blenderobject->gameflag & OB_GHOST) != 0;
+ objprop.m_disableSleeping = (blenderobject->gameflag & OB_COLLISION_RESPONSE) != 0;//abuse the OB_COLLISION_RESPONSE flag
//mmm, for now, taks this for the size of the dynamicobject
// Blender uses inertia for radius of dynamic object
objprop.m_radius = blenderobject->inertia;
@@ -1418,6 +1414,12 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
objprop.m_dynamic_parent=NULL;
objprop.m_isdeformable = ((blenderobject->gameflag2 & 2)) != 0;
objprop.m_boundclass = objprop.m_dyna?KX_BOUNDSPHERE:KX_BOUNDMESH;
+
+ if ((blenderobject->gameflag & OB_SOFT_BODY) && !(blenderobject->gameflag & OB_BOUNDS))
+ {
+ objprop.m_boundclass = KX_BOUNDMESH;
+ }
+
KX_BoxBounds bb;
my_get_local_bounds(blenderobject,objprop.m_boundobject.box.m_center,bb.m_extends);
if (blenderobject->gameflag & OB_BOUNDS)
@@ -1511,14 +1513,15 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
default:
break;
}
-
+ delete shapeprops;
+ delete smmaterial;
}
-static KX_LightObject *gamelight_from_blamp(Lamp *la, unsigned int layerflag, KX_Scene *kxscene, RAS_IRenderTools *rendertools, KX_BlenderSceneConverter *converter) {
+static KX_LightObject *gamelight_from_blamp(Object *ob, Lamp *la, unsigned int layerflag, KX_Scene *kxscene, RAS_IRenderTools *rendertools, KX_BlenderSceneConverter *converter) {
RAS_LightObject lightobj;
KX_LightObject *gamelight;
@@ -1550,15 +1553,18 @@ static KX_LightObject *gamelight_from_blamp(Lamp *la, unsigned int layerflag, KX
} else {
lightobj.m_type = RAS_LightObject::LIGHT_NORMAL;
}
-
- gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools, lightobj);
+
+ gamelight = new KX_LightObject(kxscene, KX_Scene::m_callbacks, rendertools,
+ lightobj, converter->GetGLSLMaterials());
+
BL_ConvertLampIpos(la, gamelight, converter);
return gamelight;
}
-static KX_Camera *gamecamera_from_bcamera(Camera *ca, KX_Scene *kxscene, KX_BlenderSceneConverter *converter) {
- RAS_CameraData camdata(ca->lens, ca->clipsta, ca->clipend, ca->type == CAM_PERSP);
+static KX_Camera *gamecamera_from_bcamera(Object *ob, KX_Scene *kxscene, KX_BlenderSceneConverter *converter) {
+ Camera* ca = static_cast<Camera*>(ob->data);
+ RAS_CameraData camdata(ca->lens, ca->clipsta, ca->clipend, ca->type == CAM_PERSP, dof_camera(ob));
KX_Camera *gamecamera;
gamecamera= new KX_Camera(kxscene, KX_Scene::m_callbacks, camdata);
@@ -1582,21 +1588,22 @@ static KX_GameObject *gameobject_from_blenderobject(
{
case OB_LAMP:
{
- KX_LightObject* gamelight= gamelight_from_blamp(static_cast<Lamp*>(ob->data), ob->lay, kxscene, rendertools, converter);
+ KX_LightObject* gamelight= gamelight_from_blamp(ob, static_cast<Lamp*>(ob->data), ob->lay, kxscene, rendertools, converter);
gameobj = gamelight;
gamelight->AddRef();
kxscene->GetLightList()->Add(gamelight);
-
+
break;
}
case OB_CAMERA:
{
- KX_Camera* gamecamera = gamecamera_from_bcamera(static_cast<Camera*>(ob->data), kxscene, converter);
+ KX_Camera* gamecamera = gamecamera_from_bcamera(ob, kxscene, converter);
gameobj = gamecamera;
- gamecamera->AddRef();
+ //don't add a reference: the camera list in kxscene->m_cameras is not released at the end
+ //gamecamera->AddRef();
kxscene->AddCamera(gamecamera);
break;
@@ -1617,7 +1624,7 @@ static KX_GameObject *gameobject_from_blenderobject(
// needed for python scripting
kxscene->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj);
- gameobj = new BL_DeformableGameObject(kxscene,KX_Scene::m_callbacks);
+ gameobj = new BL_DeformableGameObject(ob,kxscene,KX_Scene::m_callbacks);
// set transformation
gameobj->AddMesh(meshobj);
@@ -1628,14 +1635,30 @@ static KX_GameObject *gameobject_from_blenderobject(
((ob->gameflag2 & OB_NEVER_DO_ACTIVITY_CULLING)!=0);
gameobj->SetIgnoreActivityCulling(ignoreActivityCulling);
- // If this is a skin object, make Skin Controller
- if (ob->parent && ob->parent->type == OB_ARMATURE && ob->partype==PARSKEL && ((Mesh*)ob->data)->dvert){
- BL_SkinDeformer *dcont = new BL_SkinDeformer(ob, (BL_SkinMeshObject*)meshobj );
- ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont;
- }
- else if (((Mesh*)ob->data)->dvert){
- BL_MeshDeformer *dcont = new BL_MeshDeformer(ob, (BL_SkinMeshObject*)meshobj );
- ((BL_DeformableGameObject*)gameobj)->m_pDeformer = dcont;
+ // two options exists for deform: shape keys and armature
+ // only support relative shape key
+ bool bHasShapeKey = mesh->key != NULL && mesh->key->type==KEY_RELATIVE;
+ bool bHasDvert = mesh->dvert != NULL && ob->defbase.first;
+ bool bHasArmature = (ob->parent && ob->parent->type == OB_ARMATURE && ob->partype==PARSKEL && bHasDvert);
+
+ if (bHasShapeKey) {
+ // not that we can have shape keys without dvert!
+ BL_ShapeDeformer *dcont = new BL_ShapeDeformer((BL_DeformableGameObject*)gameobj,
+ ob, (BL_SkinMeshObject*)meshobj);
+ ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
+ if (bHasArmature)
+ dcont->LoadShapeDrivers(ob->parent);
+ } else if (bHasArmature) {
+ BL_SkinDeformer *dcont = new BL_SkinDeformer((BL_DeformableGameObject*)gameobj,
+ ob, (BL_SkinMeshObject*)meshobj);
+ ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
+ } else if (bHasDvert) {
+ // this case correspond to a mesh that can potentially deform but not with the
+ // object to which it is attached for the moment. A skin mesh was created in
+ // BL_ConvertMesh() so must create a deformer too!
+ BL_MeshDeformer *dcont = new BL_MeshDeformer((BL_DeformableGameObject*)gameobj,
+ ob, (BL_SkinMeshObject*)meshobj);
+ ((BL_DeformableGameObject*)gameobj)->SetDeformer(dcont);
}
MT_Point3 min = MT_Point3(center) - MT_Vector3(extents);
@@ -1665,7 +1688,14 @@ static KX_GameObject *gameobject_from_blenderobject(
break;
}
}
-
+ if (gameobj)
+ {
+ gameobj->SetPhysicsEnvironment(kxscene->GetPhysicsEnvironment());
+ gameobj->SetLayer(ob->lay);
+ gameobj->SetBlenderObject(ob);
+ /* set the visibility state based on the objects render option in the outliner */
+ if(ob->restrictflag & OB_RESTRICT_RENDER) gameobj->SetVisible(0, 0);
+ }
return gameobj;
}
@@ -1674,20 +1704,6 @@ struct parentChildLink {
SG_Node* m_gamechildnode;
};
- /**
- * Find the specified scene by name, or the first
- * scene if nothing matches (shouldn't happen).
- */
-static struct Scene *GetSceneForName(struct Main *maggie, const STR_String& scenename) {
- Scene *sce;
-
- for (sce= (Scene*) maggie->scene.first; sce; sce= (Scene*) sce->id.next)
- if (scenename == (sce->id.name+2))
- return sce;
-
- return (Scene*) maggie->scene.first;
-}
-
#include "DNA_constraint_types.h"
//XXX #include "BIF_editconstraint.h"
@@ -1770,7 +1786,7 @@ KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist){
return 0;
}
-#include "BLI_arithb.h"
+
// convert blender objects into ketsji gameobjects
void BL_ConvertBlenderObjects(struct Main* maggie,
const STR_String& scenename,
@@ -1786,7 +1802,10 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
)
{
- Scene *blenderscene = GetSceneForName(maggie, scenename);
+ Scene *blenderscene = converter->GetBlenderSceneForName(scenename);
+ // for SETLOOPER
+ Scene *sce;
+ Base *base;
// Get the frame settings of the canvas.
// Get the aspect ratio of the canvas as designed by the user.
@@ -1795,7 +1814,10 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
int aspect_width;
int aspect_height;
vector<MT_Vector3> inivel,iniang;
-
+ set<Group*> grouplist; // list of groups to be converted
+ set<Object*> allblobj; // all objects converted
+ set<Object*> groupobj; // objects from groups (never in active layer)
+
if (alwaysUseExpandFraming) {
frame_type = RAS_FrameSettings::e_frame_extend;
aspect_width = canvas->GetWidth();
@@ -1842,6 +1864,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
vector<parentChildLink> vec_parent_child;
CListValue* objectlist = kxscene->GetObjectList();
+ CListValue* inactivelist = kxscene->GetInactiveList();
CListValue* parentlist = kxscene->GetRootParentList();
SCA_LogicManager* logicmgr = kxscene->GetLogicManager();
@@ -1849,7 +1872,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
CListValue* logicbrick_conversionlist = new CListValue();
- SG_TreeFactory tf;
+ //SG_TreeFactory tf;
// Convert actions to actionmap
bAction *curAct;
@@ -1859,11 +1882,15 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
}
SetDefaultFaceType(blenderscene);
-
- Base *base = static_cast<Base*>(blenderscene->base.first);
- while(base)
+ // Let's support scene set.
+ // Beware of name conflict in linked data, it will not crash but will create confusion
+ // in Python scripting and in certain actuators (replace mesh). Linked scene *should* have
+ // no conflicting name for Object, Object data and Action.
+ for (SETLOOPER(blenderscene, base))
{
Object* blenderobject = base->object;
+ allblobj.insert(blenderobject);
+
KX_GameObject* gameobj = gameobject_from_blenderobject(
base->object,
kxscene,
@@ -1877,7 +1904,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
if (converter->addInitFromFrame)
if (!isInActiveLayer)
addobj=false;
-
+
if (gameobj&&addobj)
{
MT_Point3 posPrev;
@@ -1929,10 +1956,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
gameobj->NodeUpdateGS(0,true);
BL_ConvertIpos(blenderobject,gameobj,converter);
- // TODO: expand to multiple ipos per mesh
- Material *mat = give_current_material(blenderobject, 1);
- if(mat) BL_ConvertMaterialIpos(mat, gameobj, converter);
-
+ BL_ConvertMaterialIpos(blenderobject, gameobj, converter);
+
sumolist->Add(gameobj->AddRef());
BL_ConvertProperties(blenderobject,gameobj,timemgr,kxscene,isInActiveLayer);
@@ -1961,7 +1986,29 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
float* fl = (float*) blenderobject->parentinv;
MT_Transform parinvtrans(fl);
parentinversenode->SetLocalPosition(parinvtrans.getOrigin());
- parentinversenode->SetLocalOrientation(parinvtrans.getBasis());
+ // problem here: the parent inverse transform combines scaling and rotation
+ // in the basis but the scenegraph needs separate rotation and scaling.
+ // This is not important for OpenGL (it uses 4x4 matrix) but it is important
+ // for the physic engine that needs a separate scaling
+ //parentinversenode->SetLocalOrientation(parinvtrans.getBasis());
+
+ // Extract the rotation and the scaling from the basis
+ MT_Matrix3x3 ori(parinvtrans.getBasis());
+ MT_Vector3 x(ori.getColumn(0));
+ MT_Vector3 y(ori.getColumn(1));
+ MT_Vector3 z(ori.getColumn(2));
+ MT_Vector3 scale(x.length(), y.length(), z.length());
+ if (!MT_fuzzyZero(scale[0]))
+ x /= scale[0];
+ if (!MT_fuzzyZero(scale[1]))
+ y /= scale[1];
+ if (!MT_fuzzyZero(scale[2]))
+ z /= scale[2];
+ ori.setColumn(0, x);
+ ori.setColumn(1, y);
+ ori.setColumn(2, z);
+ parentinversenode->SetLocalOrientation(ori);
+ parentinversenode->SetLocalScale(scale);
parentinversenode->AddChild(gameobj->GetSGNode());
}
@@ -1969,8 +2016,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
// needed for python scripting
logicmgr->RegisterGameObjectName(gameobj->GetName(),gameobj);
- // needed for dynamic object morphing
- logicmgr->RegisterGameObj(gameobj, blenderobject);
+ // needed for group duplication
+ logicmgr->RegisterGameObj(blenderobject, gameobj);
for (int i = 0; i < gameobj->GetMeshCount(); i++)
logicmgr->RegisterGameMeshName(gameobj->GetMesh(i)->GetName(), blenderobject);
@@ -1987,40 +2034,258 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
if (isInActiveLayer)
{
objectlist->Add(gameobj->AddRef());
- tf.Add(gameobj->GetSGNode());
+ //tf.Add(gameobj->GetSGNode());
gameobj->NodeUpdateGS(0,true);
- gameobj->Bucketize();
-
+ gameobj->AddMeshUser();
+
}
+ else
+ {
+ //we must store this object otherwise it will be deleted
+ //at the end of this function if it is not a root object
+ inactivelist->Add(gameobj->AddRef());
+ }
+ if (gameobj->IsDupliGroup())
+ grouplist.insert(blenderobject->dup_group);
if (converter->addInitFromFrame){
gameobj->NodeSetLocalPosition(posPrev);
gameobj->NodeSetLocalOrientation(angor);
}
}
-
- base = base->next;
+ /* Note about memory leak issues:
+ When a CValue derived class is created, m_refcount is initialized to 1
+ so the class must be released after being used to make sure that it won't
+ hang in memory. If the object needs to be stored for a long time,
+ use AddRef() so that this Release() does not free the object.
+ Make sure that for any AddRef() there is a Release()!!!!
+ Do the same for any object derived from CValue, CExpression and NG_NetworkMessage
+ */
+ if (gameobj)
+ gameobj->Release();
+
+ }
+
+ if (!grouplist.empty())
+ {
+ // now convert the group referenced by dupli group object
+ // keep track of all groups already converted
+ set<Group*> allgrouplist = grouplist;
+ set<Group*> tempglist;
+ // recurse
+ while (!grouplist.empty())
+ {
+ set<Group*>::iterator git;
+ tempglist.clear();
+ tempglist.swap(grouplist);
+ for (git=tempglist.begin(); git!=tempglist.end(); git++)
+ {
+ Group* group = *git;
+ GroupObject* go;
+ for(go=(GroupObject*)group->gobject.first; go; go=(GroupObject*)go->next)
+ {
+ Object* blenderobject = go->ob;
+ if (converter->FindGameObject(blenderobject) == NULL)
+ {
+ allblobj.insert(blenderobject);
+ groupobj.insert(blenderobject);
+ KX_GameObject* gameobj = gameobject_from_blenderobject(
+ blenderobject,
+ kxscene,
+ rendertools,
+ converter,
+ blenderscene);
+
+ // this code is copied from above except that
+ // object from groups are never in active layer
+ bool isInActiveLayer = false;
+ bool addobj=true;
+
+ if (converter->addInitFromFrame)
+ if (!isInActiveLayer)
+ addobj=false;
+
+ if (gameobj&&addobj)
+ {
+ MT_Point3 posPrev;
+ MT_Matrix3x3 angor;
+ if (converter->addInitFromFrame)
+ blenderscene->r.cfra=blenderscene->r.sfra;
+
+ MT_Point3 pos = MT_Point3(
+ blenderobject->loc[0]+blenderobject->dloc[0],
+ blenderobject->loc[1]+blenderobject->dloc[1],
+ blenderobject->loc[2]+blenderobject->dloc[2]
+ );
+ MT_Vector3 eulxyz = MT_Vector3(
+ blenderobject->rot[0],
+ blenderobject->rot[1],
+ blenderobject->rot[2]
+ );
+ MT_Vector3 scale = MT_Vector3(
+ blenderobject->size[0],
+ blenderobject->size[1],
+ blenderobject->size[2]
+ );
+ if (converter->addInitFromFrame){//rcruiz
+ float eulxyzPrev[3];
+ blenderscene->r.cfra=blenderscene->r.sfra-1;
+ update_for_newframe();
+ MT_Vector3 tmp=pos-MT_Point3(blenderobject->loc[0]+blenderobject->dloc[0],
+ blenderobject->loc[1]+blenderobject->dloc[1],
+ blenderobject->loc[2]+blenderobject->dloc[2]
+ );
+ eulxyzPrev[0]=blenderobject->rot[0];
+ eulxyzPrev[1]=blenderobject->rot[1];
+ eulxyzPrev[2]=blenderobject->rot[2];
+
+ double fps = (double) blenderscene->r.frs_sec/
+ (double) blenderscene->r.frs_sec_base;
+
+ tmp.scale(fps, fps, fps);
+ inivel.push_back(tmp);
+ tmp=eulxyz-eulxyzPrev;
+ tmp.scale(fps, fps, fps);
+ iniang.push_back(tmp);
+ blenderscene->r.cfra=blenderscene->r.sfra;
+ update_for_newframe();
+ }
+
+ gameobj->NodeSetLocalPosition(pos);
+ gameobj->NodeSetLocalOrientation(MT_Matrix3x3(eulxyz));
+ gameobj->NodeSetLocalScale(scale);
+ gameobj->NodeUpdateGS(0,true);
+
+ BL_ConvertIpos(blenderobject,gameobj,converter);
+ BL_ConvertMaterialIpos(blenderobject,gameobj, converter);
+
+ sumolist->Add(gameobj->AddRef());
+
+ BL_ConvertProperties(blenderobject,gameobj,timemgr,kxscene,isInActiveLayer);
+
+
+ gameobj->SetName(blenderobject->id.name);
+
+ // templist to find Root Parents (object with no parents)
+ templist->Add(gameobj->AddRef());
+
+ // update children/parent hierarchy
+ if ((blenderobject->parent != 0)&&(!converter->addInitFromFrame))
+ {
+ // blender has an additional 'parentinverse' offset in each object
+ SG_Node* parentinversenode = new SG_Node(NULL,NULL,SG_Callbacks());
+
+ // define a normal parent relationship for this node.
+ KX_NormalParentRelation * parent_relation = KX_NormalParentRelation::New();
+ parentinversenode->SetParentRelation(parent_relation);
+
+ parentChildLink pclink;
+ pclink.m_blenderchild = blenderobject;
+ pclink.m_gamechildnode = parentinversenode;
+ vec_parent_child.push_back(pclink);
+
+ float* fl = (float*) blenderobject->parentinv;
+ MT_Transform parinvtrans(fl);
+ parentinversenode->SetLocalPosition(parinvtrans.getOrigin());
+
+ // Extract the rotation and the scaling from the basis
+ MT_Matrix3x3 ori(parinvtrans.getBasis());
+ MT_Vector3 x(ori.getColumn(0));
+ MT_Vector3 y(ori.getColumn(1));
+ MT_Vector3 z(ori.getColumn(2));
+ MT_Vector3 scale(x.length(), y.length(), z.length());
+ if (!MT_fuzzyZero(scale[0]))
+ x /= scale[0];
+ if (!MT_fuzzyZero(scale[1]))
+ y /= scale[1];
+ if (!MT_fuzzyZero(scale[2]))
+ z /= scale[2];
+ ori.setColumn(0, x);
+ ori.setColumn(1, y);
+ ori.setColumn(2, z);
+ parentinversenode->SetLocalOrientation(ori);
+ parentinversenode->SetLocalScale(scale);
+
+ parentinversenode->AddChild(gameobj->GetSGNode());
+ }
+
+ // needed for python scripting
+ logicmgr->RegisterGameObjectName(gameobj->GetName(),gameobj);
+
+ // needed for group duplication
+ logicmgr->RegisterGameObj(blenderobject, gameobj);
+ for (int i = 0; i < gameobj->GetMeshCount(); i++)
+ logicmgr->RegisterGameMeshName(gameobj->GetMesh(i)->GetName(), blenderobject);
+
+ converter->RegisterGameObject(gameobj, blenderobject);
+ // this was put in rapidly, needs to be looked at more closely
+ // only draw/use objects in active 'blender' layers
+
+ logicbrick_conversionlist->Add(gameobj->AddRef());
+
+ if (converter->addInitFromFrame){
+ posPrev=gameobj->NodeGetWorldPosition();
+ angor=gameobj->NodeGetWorldOrientation();
+ }
+ if (isInActiveLayer)
+ {
+ objectlist->Add(gameobj->AddRef());
+ //tf.Add(gameobj->GetSGNode());
+
+ gameobj->NodeUpdateGS(0,true);
+ gameobj->AddMeshUser();
+ }
+ else
+ {
+ //we must store this object otherwise it will be deleted
+ //at the end of this function if it is not a root object
+ inactivelist->Add(gameobj->AddRef());
+
+ }
+ if (gameobj->IsDupliGroup())
+ {
+ // check that the group is not already converted
+ if (allgrouplist.insert(blenderobject->dup_group).second)
+ grouplist.insert(blenderobject->dup_group);
+ }
+ if (converter->addInitFromFrame){
+ gameobj->NodeSetLocalPosition(posPrev);
+ gameobj->NodeSetLocalOrientation(angor);
+ }
+
+ }
+ if (gameobj)
+ gameobj->Release();
+ }
+ }
+ }
+ }
}
- if (blenderscene->camera) {
+ // non-camera objects not supported as camera currently
+ if (blenderscene->camera && blenderscene->camera->type == OB_CAMERA) {
KX_Camera *gamecamera= (KX_Camera*) converter->FindGameObject(blenderscene->camera);
- kxscene->SetActiveCamera(gamecamera);
+ if(gamecamera)
+ kxscene->SetActiveCamera(gamecamera);
}
// Set up armatures
- for (base = static_cast<Base*>(blenderscene->base.first); base; base=base->next){
- if (base->object->type==OB_MESH){
- Mesh *me = (Mesh*)base->object->data;
+ set<Object*>::iterator oit;
+ for(oit=allblobj.begin(); oit!=allblobj.end(); oit++)
+ {
+ Object* blenderobj = *oit;
+ if (blenderobj->type==OB_MESH) {
+ Mesh *me = (Mesh*)blenderobj->data;
if (me->dvert){
- KX_GameObject *obj = converter->FindGameObject(base->object);
+ BL_DeformableGameObject *obj = (BL_DeformableGameObject*)converter->FindGameObject(blenderobj);
- if (base->object->parent && base->object->parent->type==OB_ARMATURE && base->object->partype==PARSKEL){
- KX_GameObject *par = converter->FindGameObject(base->object->parent);
- if (par)
- ((BL_SkinDeformer*)(((BL_DeformableGameObject*)obj)->m_pDeformer))->SetArmature((BL_ArmatureObject*) par);
+ if (obj && blenderobj->parent && blenderobj->parent->type==OB_ARMATURE && blenderobj->partype==PARSKEL){
+ KX_GameObject *par = converter->FindGameObject(blenderobj->parent);
+ if (par && obj->GetDeformer())
+ ((BL_SkinDeformer*)obj->GetDeformer())->SetArmature((BL_ArmatureObject*) par);
}
}
}
@@ -2034,6 +2299,41 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
{
struct Object* blenderchild = pcit->m_blenderchild;
+ struct Object* blenderparent = blenderchild->parent;
+ KX_GameObject* parentobj = converter->FindGameObject(blenderparent);
+ KX_GameObject* childobj = converter->FindGameObject(blenderchild);
+
+ assert(childobj);
+
+ if (!parentobj || objectlist->SearchValue(childobj) != objectlist->SearchValue(parentobj))
+ {
+ // special case: the parent and child object are not in the same layer.
+ // This weird situation is used in Apricot for test purposes.
+ // Resolve it by not converting the child
+ childobj->GetSGNode()->DisconnectFromParent();
+ delete pcit->m_gamechildnode;
+ // Now destroy the child object but also all its descendent that may already be linked
+ // Remove the child reference in the local list!
+ // Note: there may be descendents already if the children of the child were processed
+ // by this loop before the child. In that case, we must remove the children also
+ CListValue* childrenlist = (CListValue*)childobj->PyGetChildrenRecursive(childobj);
+ childrenlist->Add(childobj->AddRef());
+ for ( i=0;i<childrenlist->GetCount();i++)
+ {
+ KX_GameObject* obj = static_cast<KX_GameObject*>(childrenlist->GetValue(i));
+ if (templist->RemoveValue(obj))
+ obj->Release();
+ if (sumolist->RemoveValue(obj))
+ obj->Release();
+ if (logicbrick_conversionlist->RemoveValue(obj))
+ obj->Release();
+ }
+ childrenlist->Release();
+ // now destroy recursively
+ kxscene->RemoveObject(childobj);
+ continue;
+ }
+
switch (blenderchild->partype)
{
case PARVERT1:
@@ -2054,8 +2354,11 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
{
// parent this to a bone
Bone *parent_bone = get_named_bone(get_armature(blenderchild->parent), blenderchild->parsubstr);
- KX_BoneParentRelation *bone_parent_relation = KX_BoneParentRelation::New(parent_bone);
- pcit->m_gamechildnode->SetParentRelation(bone_parent_relation);
+
+ if(parent_bone) {
+ KX_BoneParentRelation *bone_parent_relation = KX_BoneParentRelation::New(parent_bone);
+ pcit->m_gamechildnode->SetParentRelation(bone_parent_relation);
+ }
break;
}
@@ -2070,12 +2373,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
break;
}
- struct Object* blenderparent = blenderchild->parent;
- KX_GameObject* parentobj = converter->FindGameObject(blenderparent);
- if (parentobj)
- {
- parentobj-> GetSGNode()->AddChild(pcit->m_gamechildnode);
- }
+ parentobj-> GetSGNode()->AddChild(pcit->m_gamechildnode);
}
vec_parent_child.clear();
@@ -2103,7 +2401,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
{
meshobj = gameobj->GetMesh(0);
}
- BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,activeLayerBitInfo,physics_engine,converter,processCompoundChildren);
+ int layerMask = (groupobj.find(blenderobject) == groupobj.end()) ? activeLayerBitInfo : 0;
+ BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,layerMask,physics_engine,converter,processCompoundChildren);
}
processCompoundChildren = true;
@@ -2118,7 +2417,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
{
meshobj = gameobj->GetMesh(0);
}
- BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,activeLayerBitInfo,physics_engine,converter,processCompoundChildren);
+ int layerMask = (groupobj.find(blenderobject) == groupobj.end()) ? activeLayerBitInfo : 0;
+ BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,layerMask,physics_engine,converter,processCompoundChildren);
}
@@ -2140,70 +2440,71 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
{
KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
struct Object* blenderobject = converter->FindBlenderObject(gameobj);
- int nummeshes = gameobj->GetMeshCount();
- RAS_MeshObject* meshobj = 0;
- ListBase *conlist;
- bConstraint *curcon;
- conlist = get_active_constraints2(blenderobject);
- if (conlist) {
- for (curcon = (bConstraint *)conlist->first; curcon; curcon=(bConstraint *)curcon->next) {
- if (curcon->type==CONSTRAINT_TYPE_RIGIDBODYJOINT){
- bRigidBodyJointConstraint *dat=(bRigidBodyJointConstraint *)curcon->data;
- //if (dat->tar)
- if (!dat->child){
- PHY_IPhysicsController* physctr2 = 0;
- if (dat->tar)
- {
- KX_GameObject *gotar=getGameOb(dat->tar->id.name,sumolist);
- if (gotar && gotar->GetPhysicsController())
- physctr2 = (PHY_IPhysicsController*) gotar->GetPhysicsController()->GetUserData();
- }
+ ListBase *conlist;
+ bConstraint *curcon;
+ conlist = get_active_constraints2(blenderobject);
- if (gameobj->GetPhysicsController())
- {
- float radsPerDeg = 6.283185307179586232f / 360.f;
+ if (conlist) {
+ for (curcon = (bConstraint *)conlist->first; curcon; curcon=(bConstraint *)curcon->next) {
+ if (curcon->type==CONSTRAINT_TYPE_RIGIDBODYJOINT){
+
+ bRigidBodyJointConstraint *dat=(bRigidBodyJointConstraint *)curcon->data;
+
+ if (!dat->child){
+
+ PHY_IPhysicsController* physctr2 = 0;
- PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData();
- //we need to pass a full constraint frame, not just axis
+ if (dat->tar)
+ {
+ KX_GameObject *gotar=getGameOb(dat->tar->id.name,sumolist);
+ if (gotar && gotar->GetPhysicsController())
+ physctr2 = (PHY_IPhysicsController*) gotar->GetPhysicsController()->GetUserData();
+ }
+
+ if (gameobj->GetPhysicsController())
+ {
+ float radsPerDeg = 6.283185307179586232f / 360.f;
+
+ PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData();
+ //we need to pass a full constraint frame, not just axis
- //localConstraintFrameBasis
- MT_Matrix3x3 localCFrame(MT_Vector3(radsPerDeg*dat->axX,radsPerDeg*dat->axY,radsPerDeg*dat->axZ));
- MT_Vector3 axis0 = localCFrame.getColumn(0);
- MT_Vector3 axis1 = localCFrame.getColumn(1);
- MT_Vector3 axis2 = localCFrame.getColumn(2);
+ //localConstraintFrameBasis
+ MT_Matrix3x3 localCFrame(MT_Vector3(radsPerDeg*dat->axX,radsPerDeg*dat->axY,radsPerDeg*dat->axZ));
+ MT_Vector3 axis0 = localCFrame.getColumn(0);
+ MT_Vector3 axis1 = localCFrame.getColumn(1);
+ MT_Vector3 axis2 = localCFrame.getColumn(2);
- int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX,(float)dat->pivY,(float)dat->pivZ,
+ int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX,
+ (float)dat->pivY,(float)dat->pivZ,
(float)axis0.x(),(float)axis0.y(),(float)axis0.z(),
(float)axis1.x(),(float)axis1.y(),(float)axis1.z(),
- (float)axis2.x(),(float)axis2.y(),(float)axis2.z()
- );
- if (constraintId)
+ (float)axis2.x(),(float)axis2.y(),(float)axis2.z(),dat->flag);
+ if (constraintId)
+ {
+ //if it is a generic 6DOF constraint, set all the limits accordingly
+ if (dat->type == PHY_GENERIC_6DOF_CONSTRAINT)
{
- //if it is a generic 6DOF constraint, set all the limits accordingly
- if (dat->type == PHY_GENERIC_6DOF_CONSTRAINT)
+ int dof;
+ int dofbit=1;
+ for (dof=0;dof<6;dof++)
{
- int dof;
- int dofbit=1;
- for (dof=0;dof<6;dof++)
+ if (dat->flag & dofbit)
+ {
+ kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
+ } else
{
- if (dat->flag & dofbit)
- {
- kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,dat->minLimit[dof],dat->maxLimit[dof]);
- } else
- {
- //minLimit > maxLimit means free(disabled limit) for this degree of freedom
- kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1);
- }
- dofbit<<=1;
+ //minLimit > maxLimit means free(disabled limit) for this degree of freedom
+ kxscene->GetPhysicsEnvironment()->setConstraintParam(constraintId,dof,1,-1);
}
+ dofbit<<=1;
}
}
}
- }
- }
- }
- }
-
+ }
+ }
+ }
+ }
+ }
}
templist->Release();
@@ -2239,23 +2540,35 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
{
KX_GameObject* gameobj = static_cast<KX_GameObject*>(logicbrick_conversionlist->GetValue(i));
struct Object* blenderobj = converter->FindBlenderObject(gameobj);
- bool isInActiveLayer = (blenderobj->lay & activeLayerBitInfo)!=0;
- BL_ConvertActuators(maggie->name, blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,executePriority, activeLayerBitInfo,isInActiveLayer,rendertools,converter);
+ int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0;
+ bool isInActiveLayer = (blenderobj->lay & layerMask)!=0;
+ BL_ConvertActuators(maggie->name, blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,executePriority, layerMask,isInActiveLayer,rendertools,converter);
}
for ( i=0;i<logicbrick_conversionlist->GetCount();i++)
{
KX_GameObject* gameobj = static_cast<KX_GameObject*>(logicbrick_conversionlist->GetValue(i));
struct Object* blenderobj = converter->FindBlenderObject(gameobj);
- bool isInActiveLayer = (blenderobj->lay & activeLayerBitInfo)!=0;
- BL_ConvertControllers(blenderobj,gameobj,logicmgr,pythondictionary,executePriority,activeLayerBitInfo,isInActiveLayer,converter);
+ int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0;
+ bool isInActiveLayer = (blenderobj->lay & layerMask)!=0;
+ BL_ConvertControllers(blenderobj,gameobj,logicmgr,pythondictionary,executePriority,layerMask,isInActiveLayer,converter);
}
for ( i=0;i<logicbrick_conversionlist->GetCount();i++)
{
KX_GameObject* gameobj = static_cast<KX_GameObject*>(logicbrick_conversionlist->GetValue(i));
struct Object* blenderobj = converter->FindBlenderObject(gameobj);
- bool isInActiveLayer = (blenderobj->lay & activeLayerBitInfo)!=0;
- BL_ConvertSensors(blenderobj,gameobj,logicmgr,kxscene,keydev,executePriority,activeLayerBitInfo,isInActiveLayer,canvas,converter);
+ int layerMask = (groupobj.find(blenderobj) == groupobj.end()) ? activeLayerBitInfo : 0;
+ bool isInActiveLayer = (blenderobj->lay & layerMask)!=0;
+ BL_ConvertSensors(blenderobj,gameobj,logicmgr,kxscene,ketsjiEngine,keydev,executePriority,layerMask,isInActiveLayer,canvas,converter);
+ // set the init state to all objects
+ gameobj->SetInitState((blenderobj->init_state)?blenderobj->init_state:blenderobj->state);
}
+ // apply the initial state to controllers, only on the active objects as this registers the sensors
+ for ( i=0;i<objectlist->GetCount();i++)
+ {
+ KX_GameObject* gameobj = static_cast<KX_GameObject*>(objectlist->GetValue(i));
+ gameobj->ResetState();
+ }
+
#endif //CONVERT_LOGIC
logicbrick_conversionlist->Release();
@@ -2263,5 +2576,24 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
// Calculate the scene btree -
// too slow - commented out.
//kxscene->SetNodeTree(tf.MakeTree());
+
+ // instantiate dupli group, we will loop trough the object
+ // that are in active layers. Note that duplicating group
+ // has the effect of adding objects at the end of objectlist.
+ // Only loop through the first part of the list.
+ int objcount = objectlist->GetCount();
+ for (i=0;i<objcount;i++)
+ {
+ KX_GameObject* gameobj = (KX_GameObject*) objectlist->GetValue(i);
+ if (gameobj->IsDupliGroup())
+ {
+ kxscene->DupliGroupRecurse(gameobj, 0);
+ }
+ }
+
+ KX_Camera *activecam = kxscene->GetActiveCamera();
+ MT_Scalar distance = (activecam)? activecam->GetCameraFar() - activecam->GetCameraNear(): 100.0f;
+ RAS_BucketManager *bucketmanager = kxscene->GetBucketManager();
+ bucketmanager->OptimizeBuckets(distance);
}
diff --git a/source/gameengine/Converter/BL_DeformableGameObject.cpp b/source/gameengine/Converter/BL_DeformableGameObject.cpp
index 68a2e41ca47..e2610d2b405 100644
--- a/source/gameengine/Converter/BL_DeformableGameObject.cpp
+++ b/source/gameengine/Converter/BL_DeformableGameObject.cpp
@@ -28,6 +28,8 @@
*/
#include "BL_DeformableGameObject.h"
+#include "BL_ShapeDeformer.h"
+#include "BL_ShapeActionActuator.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -39,12 +41,14 @@ BL_DeformableGameObject::~BL_DeformableGameObject()
delete m_pDeformer; // __NLA : Temporary until we decide where to put this
}
-void BL_DeformableGameObject::ProcessReplica(KX_GameObject* replica)
+void BL_DeformableGameObject::ProcessReplica(KX_GameObject* replica)
{
+ BL_MeshDeformer *deformer;
KX_GameObject::ProcessReplica(replica);
- if (m_pDeformer){
- ((BL_DeformableGameObject*)replica)->m_pDeformer = m_pDeformer->GetReplica();
+ if (m_pDeformer) {
+ deformer = (BL_MeshDeformer*)m_pDeformer->GetReplica(replica);
+ ((BL_DeformableGameObject*)replica)->m_pDeformer = deformer;
}
}
@@ -60,3 +64,48 @@ CValue* BL_DeformableGameObject::GetReplica()
ProcessReplica(replica);
return replica;
}
+
+bool BL_DeformableGameObject::SetActiveAction(BL_ShapeActionActuator *act, short priority, double curtime)
+{
+ if (curtime != m_lastframe){
+ m_activePriority = 9999;
+ m_lastframe= curtime;
+ m_activeAct = NULL;
+ }
+
+ if (priority<=m_activePriority)
+ {
+ if (m_activeAct && (m_activeAct!=act))
+ m_activeAct->SetBlendTime(0.0f); /* Reset the blend timer */
+ m_activeAct = act;
+ m_activePriority = priority;
+ m_lastframe = curtime;
+
+ return true;
+ }
+ else{
+ act->SetBlendTime(0.0f);
+ return false;
+ }
+}
+
+bool BL_DeformableGameObject::GetShape(vector<float> &shape)
+{
+ shape.clear();
+ if (m_pDeformer)
+ {
+ Mesh* mesh = ((BL_MeshDeformer*)m_pDeformer)->GetMesh();
+ // this check is normally superfluous: a shape deformer can only be created if the mesh
+ // has relative keys
+ if (mesh && mesh->key && mesh->key->type==KEY_RELATIVE)
+ {
+ KeyBlock *kb;
+ for (kb = (KeyBlock*)mesh->key->block.first; kb; kb = (KeyBlock*)kb->next)
+ {
+ shape.push_back(kb->curval);
+ }
+ }
+ }
+ return !shape.empty();
+}
+
diff --git a/source/gameengine/Converter/BL_DeformableGameObject.h b/source/gameengine/Converter/BL_DeformableGameObject.h
index d943cc7388a..126a1fcb1e7 100644
--- a/source/gameengine/Converter/BL_DeformableGameObject.h
+++ b/source/gameengine/Converter/BL_DeformableGameObject.h
@@ -34,29 +34,74 @@
#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
#endif //WIN32
+#include "DNA_mesh_types.h"
#include "KX_GameObject.h"
-#include "RAS_Deformer.h"
+#include "BL_MeshDeformer.h"
+#include <vector>
+
+class BL_ShapeActionActuator;
+struct Key;
class BL_DeformableGameObject : public KX_GameObject
{
public:
- RAS_Deformer *m_pDeformer;
CValue* GetReplica();
+
+ double GetLastFrame ()
+ {
+ return m_lastframe;
+ }
+ Object* GetBlendObject()
+ {
+ return m_blendobj;
+ }
virtual void Relink(GEN_Map<GEN_HashedPtr, void*>*map)
{
if (m_pDeformer)
m_pDeformer->Relink (map);
+ KX_GameObject::Relink(map);
};
void ProcessReplica(KX_GameObject* replica);
- BL_DeformableGameObject(void* sgReplicationInfo, SG_Callbacks callbacks) :
+ BL_DeformableGameObject(Object* blendobj, void* sgReplicationInfo, SG_Callbacks callbacks) :
KX_GameObject(sgReplicationInfo,callbacks),
- m_pDeformer(NULL)
+ m_pDeformer(NULL),
+ m_activeAct(NULL),
+ m_lastframe(0.),
+ m_blendobj(blendobj),
+ m_activePriority(9999)
{
m_isDeformable = true;
};
virtual ~BL_DeformableGameObject();
+ bool SetActiveAction(class BL_ShapeActionActuator *act, short priority, double curtime);
+
+ bool GetShape(vector<float> &shape);
+ Key* GetKey()
+ {
+ return (m_pDeformer) ? ((BL_MeshDeformer*)m_pDeformer)->GetMesh()->key : NULL;
+ }
+
+ virtual void SetDeformer(class RAS_Deformer* deformer)
+ {
+ m_pDeformer = deformer;
+ }
+ virtual class RAS_Deformer* GetDeformer()
+ {
+ return m_pDeformer;
+ }
+
+public:
+
+protected:
+
+ RAS_Deformer *m_pDeformer;
+
+ class BL_ShapeActionActuator *m_activeAct;
+ double m_lastframe;
+ Object* m_blendobj;
+ short m_activePriority;
};
diff --git a/source/gameengine/Converter/BL_MeshDeformer.cpp b/source/gameengine/Converter/BL_MeshDeformer.cpp
index ab31179b047..fa3b8185fe2 100644
--- a/source/gameengine/Converter/BL_MeshDeformer.cpp
+++ b/source/gameengine/Converter/BL_MeshDeformer.cpp
@@ -39,118 +39,193 @@
#endif
#include "RAS_IPolygonMaterial.h"
+#include "BL_DeformableGameObject.h"
#include "BL_MeshDeformer.h"
#include "BL_SkinMeshObject.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
-#include "BLI_arithb.h"
#include "GEN_Map.h"
#include "STR_HashedString.h"
-
-bool BL_MeshDeformer::Apply(RAS_IPolyMaterial *mat)
+bool BL_MeshDeformer::Apply(RAS_IPolyMaterial*)
{
- size_t i, j, index;
- vecVertexArray array;
- vecIndexArrays mvarray;
- vecIndexArrays diarray;
-
- RAS_TexVert *tv;
- MVert *mvert;
-
- // For each material
- array = m_pMeshObject->GetVertexCache(mat);
- mvarray = m_pMeshObject->GetMVertCache(mat);
- diarray = m_pMeshObject->GetDIndexCache(mat);
-
- // For each array
- for (i=0; i<array.size(); i++){
- // For each vertex
- for (j=0; j<array[i]->size(); j++){
- tv = &((*array[i])[j]);
- index = ((*diarray[i])[j]);
-
- mvert = &(m_bmesh->mvert[((*mvarray[i])[index])]);
- tv->SetXYZ(MT_Point3(mvert->co));
+ size_t i;
+ float *co;
+
+ // only apply once per frame if the mesh is actually modified
+ if(m_pMeshObject->MeshModified() &&
+ m_lastDeformUpdate != m_gameobj->GetLastFrame()) {
+ // For each material
+ for(list<RAS_MeshMaterial>::iterator mit= m_pMeshObject->GetFirstMaterial();
+ mit != m_pMeshObject->GetLastMaterial(); ++ mit) {
+ if(!mit->m_slots[(void*)m_gameobj])
+ continue;
+
+ RAS_MeshSlot *slot = *mit->m_slots[(void*)m_gameobj];
+ RAS_MeshSlot::iterator it;
+
+ // for each array
+ for(slot->begin(it); !slot->end(it); slot->next(it)) {
+ // For each vertex
+ for(i=it.startvertex; i<it.endvertex; i++) {
+ RAS_TexVert& v = it.vertex[i];
+ co = m_bmesh->mvert[v.getOrigIndex()].co;
+ v.SetXYZ(MT_Point3(co));
+ }
+ }
}
+
+ m_lastDeformUpdate = m_gameobj->GetLastFrame();
+
+ return true;
}
- return true;
+
+ return false;
}
BL_MeshDeformer::~BL_MeshDeformer()
{
if (m_transverts)
- delete []m_transverts;
+ delete [] m_transverts;
if (m_transnors)
- delete []m_transnors;
-};
+ delete [] m_transnors;
+}
+
+void BL_MeshDeformer::Relink(GEN_Map<class GEN_HashedPtr, void*>*map)
+{
+ void **h_obj = (*map)[m_gameobj];
+
+ if (h_obj)
+ m_gameobj = (BL_DeformableGameObject*)(*h_obj);
+ else
+ m_gameobj = NULL;
+}
/**
* @warning This function is expensive!
*/
void BL_MeshDeformer::RecalcNormals()
{
- int v, f;
- float fnor[3], co1[3], co2[3], co3[3], co4[3];
+ /* We don't normalize for performance, not doing it for faces normals
+ * gives area-weight normals which often look better anyway, and use
+ * GL_NORMALIZE so we don't have to do per vertex normalization either
+ * since the GPU can do it faster */
+ list<RAS_MeshMaterial>::iterator mit;
+ RAS_MeshSlot::iterator it;
+ size_t i;
- /* Clear all vertex normal accumulators */
- for (v =0; v<m_bmesh->totvert; v++){
- m_transnors[v]=MT_Point3(0,0,0);
- }
-
- /* Find the face normals */
- for (f = 0; f<m_bmesh->totface; f++){
- // Make new face normal based on the transverts
- MFace *mf= &((MFace*)m_bmesh->mface)[f];
-
- if (mf->v3) {
- for (int vl=0; vl<3; vl++){
- co1[vl]=m_transverts[mf->v1][vl];
- co2[vl]=m_transverts[mf->v2][vl];
- co3[vl]=m_transverts[mf->v3][vl];
- if (mf->v4)
- co4[vl]=m_transverts[mf->v4][vl];
+ /* set vertex normals to zero */
+ memset(m_transnors, 0, sizeof(float)*3*m_bmesh->totvert);
+
+ /* add face normals to vertices. */
+ for(mit = m_pMeshObject->GetFirstMaterial();
+ mit != m_pMeshObject->GetLastMaterial(); ++ mit) {
+ if(!mit->m_slots[(void*)m_gameobj])
+ continue;
+
+ RAS_MeshSlot *slot = *mit->m_slots[(void*)m_gameobj];
+
+ for(slot->begin(it); !slot->end(it); slot->next(it)) {
+ int nvert = (int)it.array->m_type;
+
+ for(i=0; i<it.totindex; i+=nvert) {
+ RAS_TexVert& v1 = it.vertex[it.index[i]];
+ RAS_TexVert& v2 = it.vertex[it.index[i+1]];
+ RAS_TexVert& v3 = it.vertex[it.index[i+2]];
+ RAS_TexVert *v4 = NULL;
+
+ const float *co1 = v1.getXYZ();
+ const float *co2 = v2.getXYZ();
+ const float *co3 = v3.getXYZ();
+ const float *co4 = NULL;
+
+ /* compute face normal */
+ float fnor[3], n1[3], n2[3];
+
+ if(nvert == 4) {
+ v4 = &it.vertex[it.index[i+3]];
+ co4 = v4->getXYZ();
+
+ n1[0]= co1[0]-co3[0];
+ n1[1]= co1[1]-co3[1];
+ n1[2]= co1[2]-co3[2];
+
+ n2[0]= co2[0]-co4[0];
+ n2[1]= co2[1]-co4[1];
+ n2[2]= co2[2]-co4[2];
+ }
+ else {
+ n1[0]= co1[0]-co2[0];
+ n2[0]= co2[0]-co3[0];
+ n1[1]= co1[1]-co2[1];
+
+ n2[1]= co2[1]-co3[1];
+ n1[2]= co1[2]-co2[2];
+ n2[2]= co2[2]-co3[2];
+ }
+
+ fnor[0]= n1[1]*n2[2] - n1[2]*n2[1];
+ fnor[1]= n1[2]*n2[0] - n1[0]*n2[2];
+ fnor[2]= n1[0]*n2[1] - n1[1]*n2[0];
+
+ /* add to vertices for smooth normals */
+ float *vn1 = m_transnors[v1.getOrigIndex()];
+ float *vn2 = m_transnors[v2.getOrigIndex()];
+ float *vn3 = m_transnors[v3.getOrigIndex()];
+
+ vn1[0] += fnor[0]; vn1[1] += fnor[1]; vn1[2] += fnor[2];
+ vn2[0] += fnor[0]; vn2[1] += fnor[1]; vn2[2] += fnor[2];
+ vn3[0] += fnor[0]; vn3[1] += fnor[1]; vn3[2] += fnor[2];
+
+ if(v4) {
+ float *vn4 = m_transnors[v4->getOrigIndex()];
+ vn4[0] += fnor[0]; vn4[1] += fnor[1]; vn4[2] += fnor[2];
+ }
+
+ /* in case of flat - just assign, the vertices are split */
+ if(v1.getFlag() & RAS_TexVert::FLAT) {
+ v1.SetNormal(fnor);
+ v2.SetNormal(fnor);
+ v3.SetNormal(fnor);
+ if(v4)
+ v4->SetNormal(fnor);
+ }
}
+ }
+ }
+
+ /* assign smooth vertex normals */
+ for(mit = m_pMeshObject->GetFirstMaterial();
+ mit != m_pMeshObject->GetLastMaterial(); ++ mit) {
+ if(!mit->m_slots[(void*)m_gameobj])
+ continue;
+
+ RAS_MeshSlot *slot = *mit->m_slots[(void*)m_gameobj];
+
+ for(slot->begin(it); !slot->end(it); slot->next(it)) {
+ for(i=it.startvertex; i<it.endvertex; i++) {
+ RAS_TexVert& v = it.vertex[i];
- /* FIXME: Use moto */
- if (mf->v4)
- CalcNormFloat4(co1, co2, co3, co4, fnor);
- else
- CalcNormFloat(co1, co2, co3, fnor);
-
- /* Decide which normals are affected by this face's normal */
- m_transnors[mf->v1]+=MT_Point3(fnor);
- m_transnors[mf->v2]+=MT_Point3(fnor);
- m_transnors[mf->v3]+=MT_Point3(fnor);
- if (mf->v4)
- m_transnors[mf->v4]+=MT_Point3(fnor);
+ if(!(v.getFlag() & RAS_TexVert::FLAT))
+ v.SetNormal(m_transnors[v.getOrigIndex()]); //.safe_normalized()
+ }
}
}
-
- for (v =0; v<m_bmesh->totvert; v++){
-// float nor[3];
-
- m_transnors[v]=m_transnors[v].safe_normalized();
-// nor[0]=m_transnors[v][0];
-// nor[1]=m_transnors[v][1];
-// nor[2]=m_transnors[v][2];
-
- };
}
void BL_MeshDeformer::VerifyStorage()
{
/* Ensure that we have the right number of verts assigned */
- if (m_tvtot!=m_bmesh->totvert+m_bmesh->totface){
+ if (m_tvtot!=m_bmesh->totvert){
if (m_transverts)
- delete []m_transverts;
+ delete [] m_transverts;
if (m_transnors)
- delete []m_transnors;
+ delete [] m_transnors;
- m_transnors =new MT_Point3[m_bmesh->totvert+m_bmesh->totface];
- m_transverts=new float[(sizeof(*m_transverts)*m_bmesh->totvert)][3];
+ m_transverts=new float[m_bmesh->totvert][3];
+ m_transnors=new float[m_bmesh->totvert][3];
m_tvtot = m_bmesh->totvert;
}
}
-
+
diff --git a/source/gameengine/Converter/BL_MeshDeformer.h b/source/gameengine/Converter/BL_MeshDeformer.h
index a6be11d786e..8de59c1cdf3 100644
--- a/source/gameengine/Converter/BL_MeshDeformer.h
+++ b/source/gameengine/Converter/BL_MeshDeformer.h
@@ -32,6 +32,7 @@
#include "RAS_Deformer.h"
#include "DNA_object_types.h"
+#include "DNA_key_types.h"
#include "MT_Point3.h"
#include <stdlib.h>
@@ -39,38 +40,47 @@
#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
#endif //WIN32
+class BL_DeformableGameObject;
+
class BL_MeshDeformer : public RAS_Deformer
{
public:
void VerifyStorage();
void RecalcNormals();
- virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map){};
- BL_MeshDeformer(struct Object* obj, class BL_SkinMeshObject *meshobj ):
+ virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map);
+ BL_MeshDeformer(BL_DeformableGameObject *gameobj,
+ struct Object* obj,
+ class BL_SkinMeshObject *meshobj ):
m_pMeshObject(meshobj),
m_bmesh((struct Mesh*)(obj->data)),
+ m_transverts(0),
+ m_transnors(0),
m_objMesh(obj),
- m_transnors(NULL),
- m_transverts(NULL),
- m_tvtot(0)
+ m_tvtot(0),
+ m_gameobj(gameobj),
+ m_lastDeformUpdate(-1)
{};
virtual ~BL_MeshDeformer();
virtual void SetSimulatedTime(double time){};
virtual bool Apply(class RAS_IPolyMaterial *mat);
- virtual void Update(void){};
- virtual RAS_Deformer* GetReplica(){return NULL;};
+ virtual bool Update(void){ return false; };
+ virtual RAS_Deformer* GetReplica(class KX_GameObject* replica){return NULL;};
+ struct Mesh* GetMesh() { return m_bmesh; };
// virtual void InitDeform(double time){};
+
protected:
class BL_SkinMeshObject* m_pMeshObject;
struct Mesh* m_bmesh;
- MT_Point3* m_transnors;
- //MT_Point3* m_transverts;
// this is so m_transverts doesn't need to be converted
// before deformation
float (*m_transverts)[3];
+ float (*m_transnors)[3];
struct Object* m_objMesh;
// --
int m_tvtot;
+ BL_DeformableGameObject* m_gameobj;
+ double m_lastDeformUpdate;
};
#endif
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.cpp b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
new file mode 100644
index 00000000000..46f3141be29
--- /dev/null
+++ b/source/gameengine/Converter/BL_ShapeActionActuator.cpp
@@ -0,0 +1,842 @@
+/**
+* $Id$
+*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+*/
+
+#if defined (__sgi)
+#include <math.h>
+#else
+#include <cmath>
+#endif
+
+#include "SCA_LogicManager.h"
+#include "BL_ShapeActionActuator.h"
+#include "BL_ActionActuator.h"
+#include "BL_ShapeDeformer.h"
+#include "KX_GameObject.h"
+#include "STR_HashedString.h"
+#include "DNA_action_types.h"
+#include "DNA_nla_types.h"
+#include "DNA_actuator_types.h"
+#include "BKE_action.h"
+#include "DNA_armature_types.h"
+#include "MEM_guardedalloc.h"
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+#include "MT_Matrix4x4.h"
+#include "BKE_utildefines.h"
+#include "FloatValue.h"
+#include "PyObjectPlus.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+BL_ShapeActionActuator::~BL_ShapeActionActuator()
+{
+}
+
+void BL_ShapeActionActuator::ProcessReplica()
+{
+ m_localtime=m_startframe;
+ m_lastUpdate=-1;
+}
+
+void BL_ShapeActionActuator::SetBlendTime (float newtime)
+{
+ m_blendframe = newtime;
+}
+
+CValue* BL_ShapeActionActuator::GetReplica()
+{
+ BL_ShapeActionActuator* replica = new BL_ShapeActionActuator(*this);//m_float,GetName());
+ replica->ProcessReplica();
+
+ // this will copy properties and so on...
+ CValue::AddDataToReplica(replica);
+ return replica;
+}
+
+bool BL_ShapeActionActuator::ClampLocalTime()
+{
+ if (m_startframe < m_endframe) {
+ if (m_localtime < m_startframe)
+ {
+ m_localtime = m_startframe;
+ return true;
+ }
+ else if (m_localtime > m_endframe)
+ {
+ m_localtime = m_endframe;
+ return true;
+ }
+ } else {
+ if (m_localtime > m_startframe)
+ {
+ m_localtime = m_startframe;
+ return true;
+ }
+ else if (m_localtime < m_endframe)
+ {
+ m_localtime = m_endframe;
+ return true;
+ }
+ }
+ return false;
+}
+
+void BL_ShapeActionActuator::SetStartTime(float curtime)
+{
+ float direction = m_startframe < m_endframe ? 1.0 : -1.0;
+
+ if (!(m_flag & ACT_FLAG_REVERSE))
+ m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_KetsjiEngine::GetAnimFrameRate();
+ else
+ m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_KetsjiEngine::GetAnimFrameRate();
+}
+
+void BL_ShapeActionActuator::SetLocalTime(float curtime)
+{
+ float delta_time = (curtime - m_starttime)*KX_KetsjiEngine::GetAnimFrameRate();
+
+ if (m_endframe < m_startframe)
+ delta_time = -delta_time;
+
+ if (!(m_flag & ACT_FLAG_REVERSE))
+ m_localtime = m_startframe + delta_time;
+ else
+ m_localtime = m_endframe - delta_time;
+}
+
+void BL_ShapeActionActuator::BlendShape(Key* key, float srcweight)
+{
+ vector<float>::const_iterator it;
+ float dstweight;
+ KeyBlock *kb;
+
+ dstweight = 1.0F - srcweight;
+
+ for (it=m_blendshape.begin(), kb = (KeyBlock*)key->block.first;
+ kb && it != m_blendshape.end();
+ kb = (KeyBlock*)kb->next, it++) {
+ kb->curval = kb->curval * dstweight + (*it) * srcweight;
+ }
+}
+
+bool BL_ShapeActionActuator::Update(double curtime, bool frame)
+{
+ bool bNegativeEvent = false;
+ bool bPositiveEvent = false;
+ bool keepgoing = true;
+ bool wrap = false;
+ bool apply=true;
+ int priority;
+ float newweight;
+
+ curtime -= KX_KetsjiEngine::GetSuspendedDelta();
+
+ // result = true if animation has to be continued, false if animation stops
+ // maybe there are events for us in the queue !
+ if (frame)
+ {
+ for (vector<CValue*>::iterator i=m_events.begin(); !(i==m_events.end());i++)
+ {
+ if ((*i)->GetNumber() == 0.0f)
+ bNegativeEvent = true;
+ else
+ bPositiveEvent= true;
+ (*i)->Release();
+
+ }
+ m_events.clear();
+
+ if (bPositiveEvent)
+ m_flag |= ACT_FLAG_ACTIVE;
+
+ if (bNegativeEvent)
+ {
+ if (!(m_flag & ACT_FLAG_ACTIVE))
+ return false;
+ m_flag &= ~ACT_FLAG_ACTIVE;
+ }
+ }
+
+ /* This action can only be attached to a deform object */
+ BL_DeformableGameObject *obj = (BL_DeformableGameObject*)GetParent();
+ float length = m_endframe - m_startframe;
+
+ priority = m_priority;
+
+ /* Determine pre-incrementation behaviour and set appropriate flags */
+ switch (m_playtype){
+ case ACT_ACTION_MOTION:
+ if (bNegativeEvent){
+ keepgoing=false;
+ apply=false;
+ };
+ break;
+ case ACT_ACTION_FROM_PROP:
+ if (bNegativeEvent){
+ apply=false;
+ keepgoing=false;
+ }
+ break;
+ case ACT_ACTION_LOOP_END:
+ if (bPositiveEvent){
+ if (!(m_flag & ACT_FLAG_LOCKINPUT)){
+ m_flag &= ~ACT_FLAG_KEYUP;
+ m_flag &= ~ACT_FLAG_REVERSE;
+ m_flag |= ACT_FLAG_LOCKINPUT;
+ m_localtime = m_startframe;
+ m_starttime = curtime;
+ }
+ }
+ if (bNegativeEvent){
+ m_flag |= ACT_FLAG_KEYUP;
+ }
+ break;
+ case ACT_ACTION_LOOP_STOP:
+ if (bPositiveEvent){
+ if (!(m_flag & ACT_FLAG_LOCKINPUT)){
+ m_flag &= ~ACT_FLAG_REVERSE;
+ m_flag &= ~ACT_FLAG_KEYUP;
+ m_flag |= ACT_FLAG_LOCKINPUT;
+ SetStartTime(curtime);
+ }
+ }
+ if (bNegativeEvent){
+ m_flag |= ACT_FLAG_KEYUP;
+ m_flag &= ~ACT_FLAG_LOCKINPUT;
+ keepgoing=false;
+ apply=false;
+ }
+ break;
+ case ACT_ACTION_FLIPPER:
+ if (bPositiveEvent){
+ if (!(m_flag & ACT_FLAG_LOCKINPUT)){
+ m_flag &= ~ACT_FLAG_REVERSE;
+ m_flag |= ACT_FLAG_LOCKINPUT;
+ SetStartTime(curtime);
+ }
+ }
+ else if (bNegativeEvent){
+ m_flag |= ACT_FLAG_REVERSE;
+ m_flag &= ~ACT_FLAG_LOCKINPUT;
+ SetStartTime(curtime);
+ }
+ break;
+ case ACT_ACTION_PLAY:
+ if (bPositiveEvent){
+ if (!(m_flag & ACT_FLAG_LOCKINPUT)){
+ m_flag &= ~ACT_FLAG_REVERSE;
+ m_localtime = m_starttime;
+ m_starttime = curtime;
+ m_flag |= ACT_FLAG_LOCKINPUT;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ /* Perform increment */
+ if (keepgoing){
+ if (m_playtype == ACT_ACTION_MOTION){
+ MT_Point3 newpos;
+ MT_Point3 deltapos;
+
+ newpos = obj->NodeGetWorldPosition();
+
+ /* Find displacement */
+ deltapos = newpos-m_lastpos;
+ m_localtime += (length/m_stridelength) * deltapos.length();
+ m_lastpos = newpos;
+ }
+ else{
+ SetLocalTime(curtime);
+ }
+ }
+
+ /* Check if a wrapping response is needed */
+ if (length){
+ if (m_localtime < m_startframe || m_localtime > m_endframe)
+ {
+ m_localtime = m_startframe + fmod(m_localtime, length);
+ wrap = true;
+ }
+ }
+ else
+ m_localtime = m_startframe;
+
+ /* Perform post-increment tasks */
+ switch (m_playtype){
+ case ACT_ACTION_FROM_PROP:
+ {
+ CValue* propval = GetParent()->GetProperty(m_propname);
+ if (propval)
+ m_localtime = propval->GetNumber();
+
+ if (bNegativeEvent){
+ keepgoing=false;
+ }
+ }
+ break;
+ case ACT_ACTION_MOTION:
+ break;
+ case ACT_ACTION_LOOP_STOP:
+ break;
+ case ACT_ACTION_FLIPPER:
+ if (wrap){
+ if (!(m_flag & ACT_FLAG_REVERSE)){
+ m_localtime=m_endframe;
+ //keepgoing = false;
+ }
+ else {
+ m_localtime=m_startframe;
+ keepgoing = false;
+ }
+ }
+ break;
+ case ACT_ACTION_LOOP_END:
+ if (wrap){
+ if (m_flag & ACT_FLAG_KEYUP){
+ keepgoing = false;
+ m_localtime = m_endframe;
+ m_flag &= ~ACT_FLAG_LOCKINPUT;
+ }
+ SetStartTime(curtime);
+ }
+ break;
+ case ACT_ACTION_PLAY:
+ if (wrap){
+ m_localtime = m_endframe;
+ keepgoing = false;
+ m_flag &= ~ACT_FLAG_LOCKINPUT;
+ }
+ break;
+ default:
+ keepgoing = false;
+ break;
+ }
+
+ /* Set the property if its defined */
+ if (m_framepropname[0] != '\0') {
+ CValue* propowner = GetParent();
+ CValue* oldprop = propowner->GetProperty(m_framepropname);
+ CValue* newval = new CFloatValue(m_localtime);
+ if (oldprop) {
+ oldprop->SetValue(newval);
+ } else {
+ propowner->SetProperty(m_framepropname, newval);
+ }
+ newval->Release();
+ }
+
+ if (bNegativeEvent)
+ m_blendframe=0.0f;
+
+ /* Apply the pose if necessary*/
+ if (apply) {
+
+ /* Priority test */
+ if (obj->SetActiveAction(this, priority, curtime)){
+ Key *key = obj->GetKey();
+
+ if (!key) {
+ // this could happen if the mesh was changed in the middle of an action
+ // and the new mesh has no key, stop the action
+ keepgoing = false;
+ }
+ else {
+ ListBase tchanbase= {NULL, NULL};
+
+ if (m_blendin && m_blendframe==0.0f){
+ // this is the start of the blending, remember the startup shape
+ obj->GetShape(m_blendshape);
+ m_blendstart = curtime;
+ }
+ // only interested in shape channel
+ extract_ipochannels_from_action(&tchanbase, &key->id, m_action, "Shape", m_localtime);
+
+ if (!execute_ipochannels(&tchanbase)) {
+ // no update, this is possible if action does not match the keys, stop the action
+ keepgoing = false;
+ }
+ else {
+ // the key have changed, apply blending if needed
+ if (m_blendin && (m_blendframe<m_blendin)){
+ newweight = (m_blendframe/(float)m_blendin);
+
+ BlendShape(key, 1.0f - newweight);
+
+ /* Increment current blending percentage */
+ m_blendframe = (curtime - m_blendstart)*KX_KetsjiEngine::GetAnimFrameRate();
+ if (m_blendframe>m_blendin)
+ m_blendframe = m_blendin;
+ }
+ m_lastUpdate = m_localtime;
+ }
+ BLI_freelistN(&tchanbase);
+ }
+ }
+ else{
+ m_blendframe = 0.0f;
+ }
+ }
+
+ if (!keepgoing){
+ m_blendframe = 0.0f;
+ }
+ return keepgoing;
+};
+
+/* ------------------------------------------------------------------------- */
+/* Python functions */
+/* ------------------------------------------------------------------------- */
+
+/* Integration hooks ------------------------------------------------------- */
+
+PyTypeObject BL_ShapeActionActuator::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "BL_ShapeActionActuator",
+ sizeof(BL_ShapeActionActuator),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject BL_ShapeActionActuator::Parents[] = {
+ &BL_ShapeActionActuator::Type,
+ &SCA_IActuator::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+PyMethodDef BL_ShapeActionActuator::Methods[] = {
+ {"setAction", (PyCFunction) BL_ShapeActionActuator::sPySetAction, METH_VARARGS, (PY_METHODCHAR)SetAction_doc},
+ {"setStart", (PyCFunction) BL_ShapeActionActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc},
+ {"setEnd", (PyCFunction) BL_ShapeActionActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc},
+ {"setBlendin", (PyCFunction) BL_ShapeActionActuator::sPySetBlendin, METH_VARARGS, (PY_METHODCHAR)SetBlendin_doc},
+ {"setPriority", (PyCFunction) BL_ShapeActionActuator::sPySetPriority, METH_VARARGS, (PY_METHODCHAR)SetPriority_doc},
+ {"setFrame", (PyCFunction) BL_ShapeActionActuator::sPySetFrame, METH_VARARGS, (PY_METHODCHAR)SetFrame_doc},
+ {"setProperty", (PyCFunction) BL_ShapeActionActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
+ {"setFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPySetFrameProperty, METH_VARARGS, (PY_METHODCHAR)SetFrameProperty_doc},
+ {"setBlendtime", (PyCFunction) BL_ShapeActionActuator::sPySetBlendtime, METH_VARARGS, (PY_METHODCHAR)SetBlendtime_doc},
+
+ {"getAction", (PyCFunction) BL_ShapeActionActuator::sPyGetAction, METH_NOARGS, (PY_METHODCHAR)GetAction_doc},
+ {"getStart", (PyCFunction) BL_ShapeActionActuator::sPyGetStart, METH_NOARGS, (PY_METHODCHAR)GetStart_doc},
+ {"getEnd", (PyCFunction) BL_ShapeActionActuator::sPyGetEnd, METH_NOARGS, (PY_METHODCHAR)GetEnd_doc},
+ {"getBlendin", (PyCFunction) BL_ShapeActionActuator::sPyGetBlendin, METH_NOARGS, (PY_METHODCHAR)GetBlendin_doc},
+ {"getPriority", (PyCFunction) BL_ShapeActionActuator::sPyGetPriority, METH_NOARGS, (PY_METHODCHAR)GetPriority_doc},
+ {"getFrame", (PyCFunction) BL_ShapeActionActuator::sPyGetFrame, METH_NOARGS, (PY_METHODCHAR)GetFrame_doc},
+ {"getProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetProperty, METH_NOARGS, (PY_METHODCHAR)GetProperty_doc},
+ {"getFrameProperty", (PyCFunction) BL_ShapeActionActuator::sPyGetFrameProperty, METH_NOARGS, (PY_METHODCHAR)GetFrameProperty_doc},
+ {"getType", (PyCFunction) BL_ShapeActionActuator::sPyGetType, METH_NOARGS, (PY_METHODCHAR)GetType_doc},
+ {"setType", (PyCFunction) BL_ShapeActionActuator::sPySetType, METH_NOARGS, (PY_METHODCHAR)SetType_doc},
+ {NULL,NULL} //Sentinel
+};
+
+PyObject* BL_ShapeActionActuator::_getattr(const STR_String& attr) {
+ _getattr_up(SCA_IActuator);
+}
+
+/* setStart */
+const char BL_ShapeActionActuator::GetAction_doc[] =
+"getAction()\n"
+"\tReturns a string containing the name of the current action.\n";
+
+PyObject* BL_ShapeActionActuator::PyGetAction(PyObject* self) {
+ if (m_action){
+ return PyString_FromString(m_action->id.name+2);
+ }
+ Py_RETURN_NONE;
+}
+
+/* getProperty */
+const char BL_ShapeActionActuator::GetProperty_doc[] =
+"getProperty()\n"
+"\tReturns the name of the property to be used in FromProp mode.\n";
+
+PyObject* BL_ShapeActionActuator::PyGetProperty(PyObject* self) {
+ PyObject *result;
+
+ result = Py_BuildValue("s", (const char *)m_propname);
+
+ return result;
+}
+
+/* getFrame */
+const char BL_ShapeActionActuator::GetFrame_doc[] =
+"getFrame()\n"
+"\tReturns the current frame number.\n";
+
+PyObject* BL_ShapeActionActuator::PyGetFrame(PyObject* self) {
+ PyObject *result;
+
+ result = Py_BuildValue("f", m_localtime);
+
+ return result;
+}
+
+/* getEnd */
+const char BL_ShapeActionActuator::GetEnd_doc[] =
+"getEnd()\n"
+"\tReturns the last frame of the action.\n";
+
+PyObject* BL_ShapeActionActuator::PyGetEnd(PyObject* self) {
+ PyObject *result;
+
+ result = Py_BuildValue("f", m_endframe);
+
+ return result;
+}
+
+/* getStart */
+const char BL_ShapeActionActuator::GetStart_doc[] =
+"getStart()\n"
+"\tReturns the starting frame of the action.\n";
+
+PyObject* BL_ShapeActionActuator::PyGetStart(PyObject* self) {
+ PyObject *result;
+
+ result = Py_BuildValue("f", m_startframe);
+
+ return result;
+}
+
+/* getBlendin */
+const char BL_ShapeActionActuator::GetBlendin_doc[] =
+"getBlendin()\n"
+"\tReturns the number of interpolation animation frames to be\n"
+"\tgenerated when this actuator is triggered.\n";
+
+PyObject* BL_ShapeActionActuator::PyGetBlendin(PyObject* self) {
+ PyObject *result;
+
+ result = Py_BuildValue("f", m_blendin);
+
+ return result;
+}
+
+/* getPriority */
+const char BL_ShapeActionActuator::GetPriority_doc[] =
+"getPriority()\n"
+"\tReturns the priority for this actuator. Actuators with lower\n"
+"\tPriority numbers will override actuators with higher numbers.\n";
+
+PyObject* BL_ShapeActionActuator::PyGetPriority(PyObject* self) {
+ PyObject *result;
+
+ result = Py_BuildValue("i", m_priority);
+
+ return result;
+}
+
+/* setAction */
+const char BL_ShapeActionActuator::SetAction_doc[] =
+"setAction(action, (reset))\n"
+"\t - action : The name of the action to set as the current action.\n"
+"\t Should be an action with Shape channels.\n"
+"\t - reset : Optional parameter indicating whether to reset the\n"
+"\t blend timer or not. A value of 1 indicates that the\n"
+"\t timer should be reset. A value of 0 will leave it\n"
+"\t unchanged. If reset is not specified, the timer will"
+"\t be reset.\n";
+
+PyObject* BL_ShapeActionActuator::PySetAction(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ char *string;
+ int reset = 1;
+
+ if (PyArg_ParseTuple(args,"s|i",&string, &reset))
+ {
+ bAction *action;
+
+ action = (bAction*)SCA_ILogicBrick::m_sCurrentLogicManager->GetActionByName(STR_String(string));
+
+ if (!action){
+ /* NOTE! Throw an exception or something */
+ // printf ("setAction failed: Action not found\n", string);
+ }
+ else{
+ m_action=action;
+ if (reset)
+ m_blendframe = 0.f;
+ }
+ }
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+/* setStart */
+const char BL_ShapeActionActuator::SetStart_doc[] =
+"setStart(start)\n"
+"\t - start : Specifies the starting frame of the animation.\n";
+
+PyObject* BL_ShapeActionActuator::PySetStart(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ float start;
+
+ if (PyArg_ParseTuple(args,"f",&start))
+ {
+ m_startframe = start;
+ }
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+/* setEnd */
+const char BL_ShapeActionActuator::SetEnd_doc[] =
+"setEnd(end)\n"
+"\t - end : Specifies the ending frame of the animation.\n";
+
+PyObject* BL_ShapeActionActuator::PySetEnd(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ float end;
+
+ if (PyArg_ParseTuple(args,"f",&end))
+ {
+ m_endframe = end;
+ }
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+/* setBlendin */
+const char BL_ShapeActionActuator::SetBlendin_doc[] =
+"setBlendin(blendin)\n"
+"\t - blendin : Specifies the number of frames of animation to generate\n"
+"\t when making transitions between actions.\n";
+
+PyObject* BL_ShapeActionActuator::PySetBlendin(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ float blendin;
+
+ if (PyArg_ParseTuple(args,"f",&blendin))
+ {
+ m_blendin = blendin;
+ }
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+/* setBlendtime */
+const char BL_ShapeActionActuator::SetBlendtime_doc[] =
+"setBlendtime(blendtime)\n"
+"\t - blendtime : Allows the script to directly modify the internal timer\n"
+"\t used when generating transitions between actions. This\n"
+"\t parameter must be in the range from 0.0 to 1.0.\n";
+
+PyObject* BL_ShapeActionActuator::PySetBlendtime(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ float blendframe;
+
+ if (PyArg_ParseTuple(args,"f",&blendframe))
+ {
+ m_blendframe = blendframe * m_blendin;
+ if (m_blendframe<0.f)
+ m_blendframe = 0.f;
+ if (m_blendframe>m_blendin)
+ m_blendframe = m_blendin;
+ }
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+/* setPriority */
+const char BL_ShapeActionActuator::SetPriority_doc[] =
+"setPriority(priority)\n"
+"\t - priority : Specifies the new priority. Actuators will lower\n"
+"\t priority numbers will override actuators with higher\n"
+"\t numbers.\n";
+
+PyObject* BL_ShapeActionActuator::PySetPriority(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ int priority;
+
+ if (PyArg_ParseTuple(args,"i",&priority))
+ {
+ m_priority = priority;
+ }
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+/* getProperty */
+const char BL_ShapeActionActuator::GetFrameProperty_doc[] =
+"getFrameProperty()\n"
+"\tReturns the name of the property, that is set to the current frame number.\n";
+
+PyObject* BL_ShapeActionActuator::PyGetFrameProperty(PyObject* self) {
+ PyObject *result;
+
+ result = Py_BuildValue("s", (const char *)m_framepropname);
+
+ return result;
+}
+
+
+/* setFrame */
+const char BL_ShapeActionActuator::SetFrame_doc[] =
+"setFrame(frame)\n"
+"\t - frame : Specifies the new current frame for the animation\n";
+
+PyObject* BL_ShapeActionActuator::PySetFrame(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ float frame;
+
+ if (PyArg_ParseTuple(args,"f",&frame))
+ {
+ m_localtime = frame;
+ if (m_localtime<m_startframe)
+ m_localtime=m_startframe;
+ else if (m_localtime>m_endframe)
+ m_localtime=m_endframe;
+ }
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+/* setProperty */
+const char BL_ShapeActionActuator::SetProperty_doc[] =
+"setProperty(prop)\n"
+"\t - prop : A string specifying the property name to be used in\n"
+"\t FromProp playback mode.\n";
+
+PyObject* BL_ShapeActionActuator::PySetProperty(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ char *string;
+
+ if (PyArg_ParseTuple(args,"s",&string))
+ {
+ m_propname = string;
+ }
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+/* setFrameProperty */
+const char BL_ShapeActionActuator::SetFrameProperty_doc[] =
+"setFrameProperty(prop)\n"
+"\t - prop : A string specifying the property of the frame set up update.\n";
+
+PyObject* BL_ShapeActionActuator::PySetFrameProperty(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ char *string;
+
+ if (PyArg_ParseTuple(args,"s",&string))
+ {
+ m_framepropname = string;
+ }
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
+}
+
+/* getType */
+const char BL_ShapeActionActuator::GetType_doc[] =
+"getType()\n"
+"\tReturns the operation mode of the actuator.\n";
+PyObject* BL_ShapeActionActuator::PyGetType(PyObject* self) {
+ return Py_BuildValue("h", m_playtype);
+}
+
+/* setType */
+const char BL_ShapeActionActuator::SetType_doc[] =
+"setType(mode)\n"
+"\t - mode: Play (0), Flipper (2), LoopStop (3), LoopEnd (4) or Property (6)\n"
+"\tSet the operation mode of the actuator.\n";
+PyObject* BL_ShapeActionActuator::PySetType(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ short typeArg;
+
+ if (!PyArg_ParseTuple(args, "h", &typeArg)) {
+ return NULL;
+ }
+
+ switch (typeArg) {
+ case ACT_ACTION_PLAY:
+ case ACT_ACTION_FLIPPER:
+ case ACT_ACTION_LOOP_STOP:
+ case ACT_ACTION_LOOP_END:
+ case ACT_ACTION_FROM_PROP:
+ m_playtype = typeArg;
+ break;
+ default:
+ printf("Invalid type for action actuator: %d\n", typeArg); /* error */
+ }
+
+ Py_Return;
+}
+
diff --git a/source/gameengine/Converter/BL_ShapeActionActuator.h b/source/gameengine/Converter/BL_ShapeActionActuator.h
new file mode 100644
index 00000000000..30b2d41fc67
--- /dev/null
+++ b/source/gameengine/Converter/BL_ShapeActionActuator.h
@@ -0,0 +1,138 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef BL_SHAPEACTIONACTUATOR
+#define BL_SHAPEACTIONACTUATOR
+
+#include "GEN_HashedPtr.h"
+#include "SCA_IActuator.h"
+#include "MT_Point3.h"
+#include <vector>
+
+struct Key;
+class BL_ShapeActionActuator : public SCA_IActuator
+{
+public:
+ Py_Header;
+ BL_ShapeActionActuator(SCA_IObject* gameobj,
+ const STR_String& propname,
+ const STR_String& framepropname,
+ float starttime,
+ float endtime,
+ struct bAction *action,
+ short playtype,
+ short blendin,
+ short priority,
+ float stride,
+ PyTypeObject* T=&Type)
+ : SCA_IActuator(gameobj,T),
+
+ m_lastpos(0, 0, 0),
+ m_blendframe(0),
+ m_flag(0),
+ m_startframe (starttime),
+ m_endframe(endtime) ,
+ m_starttime(0),
+ m_localtime(starttime),
+ m_lastUpdate(-1),
+ m_blendin(blendin),
+ m_blendstart(0),
+ m_stridelength(stride),
+ m_playtype(playtype),
+ m_priority(priority),
+ m_action(action),
+ m_framepropname(framepropname),
+ m_propname(propname)
+ {
+ };
+ virtual ~BL_ShapeActionActuator();
+ virtual bool Update(double curtime, bool frame);
+ virtual CValue* GetReplica();
+ virtual void ProcessReplica();
+
+ void SetBlendTime (float newtime);
+ void BlendShape(struct Key* key, float weigth);
+
+ KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetAction);
+ KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetBlendin);
+ KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetPriority);
+ KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetStart);
+ KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetEnd);
+ KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetFrame);
+ KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetProperty);
+ KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetFrameProperty);
+ KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetBlendtime);
+ KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetChannel);
+
+ KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetAction);
+ KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetBlendin);
+ KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetPriority);
+ KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetStart);
+ KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetEnd);
+ KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetFrame);
+ KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetProperty);
+ KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetFrameProperty);
+// KX_PYMETHOD(BL_ActionActuator,GetChannel);
+ KX_PYMETHOD_DOC_NOARGS(BL_ShapeActionActuator,GetType);
+ KX_PYMETHOD_DOC(BL_ShapeActionActuator,SetType);
+
+ virtual PyObject* _getattr(const STR_String& attr);
+
+protected:
+
+ void SetStartTime(float curtime);
+ void SetLocalTime(float curtime);
+ bool ClampLocalTime();
+
+ MT_Point3 m_lastpos;
+ float m_blendframe;
+ int m_flag;
+ /** The frame this action starts */
+ float m_startframe;
+ /** The frame this action ends */
+ float m_endframe;
+ /** The time this action started */
+ float m_starttime;
+ /** The current time of the action */
+ float m_localtime;
+
+ float m_lastUpdate;
+ float m_blendin;
+ float m_blendstart;
+ float m_stridelength;
+ short m_playtype;
+ short m_priority;
+ struct bAction *m_action;
+ STR_String m_propname;
+ STR_String m_framepropname;
+ vector<float> m_blendshape;
+};
+
+#endif
+
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.cpp b/source/gameengine/Converter/BL_ShapeDeformer.cpp
new file mode 100644
index 00000000000..fc6498579ad
--- /dev/null
+++ b/source/gameengine/Converter/BL_ShapeDeformer.cpp
@@ -0,0 +1,182 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifdef WIN32
+#pragma warning (disable : 4786)
+#endif //WIN32
+
+#include "MEM_guardedalloc.h"
+#include "BL_ShapeDeformer.h"
+#include "GEN_Map.h"
+#include "STR_HashedString.h"
+#include "RAS_IPolygonMaterial.h"
+#include "BL_SkinMeshObject.h"
+
+//#include "BL_ArmatureController.h"
+#include "DNA_armature_types.h"
+#include "DNA_action_types.h"
+#include "DNA_key_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_meshdata_types.h"
+#include "DNA_ipo_types.h"
+#include "DNA_curve_types.h"
+#include "BKE_armature.h"
+#include "BKE_action.h"
+#include "BKE_key.h"
+#include "BKE_ipo.h"
+#include "MT_Point3.h"
+
+extern "C"{
+ #include "BKE_lattice.h"
+}
+ #include "BKE_utildefines.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_arithb.h"
+
+#define __NLA_DEFNORMALS
+//#undef __NLA_DEFNORMALS
+
+
+BL_ShapeDeformer::~BL_ShapeDeformer()
+{
+};
+
+RAS_Deformer *BL_ShapeDeformer::GetReplica(class KX_GameObject* replica)
+{
+ BL_ShapeDeformer *result;
+
+ result = new BL_ShapeDeformer(*this);
+ result->ProcessReplica();
+ return result;
+}
+
+void BL_ShapeDeformer::ProcessReplica()
+{
+}
+
+bool BL_ShapeDeformer::LoadShapeDrivers(Object* arma)
+{
+ IpoCurve *icu;
+
+ m_shapeDrivers.clear();
+ // check if this mesh has armature driven shape keys
+ if (m_bmesh->key->ipo) {
+ for(icu= (IpoCurve*)m_bmesh->key->ipo->curve.first; icu; icu= (IpoCurve*)icu->next) {
+ if(icu->driver &&
+ (icu->flag & IPO_MUTE) == 0 &&
+ icu->driver->type == IPO_DRIVER_TYPE_NORMAL &&
+ icu->driver->ob == arma &&
+ icu->driver->blocktype == ID_AR) {
+ // this shape key ipo curve has a driver on the parent armature
+ // record this curve in the shape deformer so that the corresponding
+ m_shapeDrivers.push_back(icu);
+ }
+ }
+ }
+ return !m_shapeDrivers.empty();
+}
+
+bool BL_ShapeDeformer::ExecuteShapeDrivers(void)
+{
+ if (!m_shapeDrivers.empty() && PoseUpdated()) {
+ vector<IpoCurve*>::iterator it;
+ void *poin;
+ int type;
+
+ // the shape drivers use the bone matrix as input. Must
+ // update the matrix now
+ m_armobj->ApplyPose();
+
+ for (it=m_shapeDrivers.begin(); it!=m_shapeDrivers.end(); it++) {
+ // no need to set a specific time: this curve has a driver
+ IpoCurve *icu = *it;
+ calc_icu(icu, 1.0f);
+ poin = get_ipo_poin((ID*)m_bmesh->key, icu, &type);
+ if (poin)
+ write_ipo_poin(poin, type, icu->curval);
+ }
+
+ ForceUpdate();
+ m_armobj->RestorePose();
+
+ return true;
+ }
+ return false;
+}
+
+bool BL_ShapeDeformer::Update(void)
+{
+ bool bShapeUpdate = false;
+ bool bSkinUpdate = false;
+
+ ExecuteShapeDrivers();
+
+ /* See if the object shape has changed */
+ if (m_lastShapeUpdate != m_gameobj->GetLastFrame()) {
+ /* the key coefficient have been set already, we just need to blend the keys */
+ Object* blendobj = m_gameobj->GetBlendObject();
+
+ // make sure the vertex weight cache is in line with this object
+ m_pMeshObject->CheckWeightCache(blendobj);
+
+ /* we will blend the key directly in mvert array: it is used by armature as the start position */
+ do_rel_key(0, m_bmesh->totvert, m_bmesh->totvert, (char *)m_bmesh->mvert->co, m_bmesh->key, 0);
+
+ // Don't release the weight array as in Blender, it will most likely be reusable on next frame
+ // The weight array are ultimately deleted when the skin mesh is destroyed
+
+ /* Update the current frame */
+ m_lastShapeUpdate=m_gameobj->GetLastFrame();
+
+ // As we have changed, the mesh, the skin deformer must update as well.
+ // This will force the update
+ BL_SkinDeformer::ForceUpdate();
+ bShapeUpdate = true;
+ }
+ // check for armature deform
+ bSkinUpdate = BL_SkinDeformer::Update();
+
+ if (!bSkinUpdate && bShapeUpdate) {
+ // this means that there is no armature, we still need to copy the vertex to m_transverts
+ // and update the normal (was not done after shape key calculation)
+
+ /* store verts locally */
+ VerifyStorage();
+
+ for (int v =0; v<m_bmesh->totvert; v++)
+ VECCOPY(m_transverts[v], m_bmesh->mvert[v].co);
+
+#ifdef __NLA_DEFNORMALS
+ RecalcNormals();
+#endif
+ bSkinUpdate = true;
+ }
+ return bSkinUpdate;
+}
diff --git a/source/gameengine/Converter/BL_ShapeDeformer.h b/source/gameengine/Converter/BL_ShapeDeformer.h
new file mode 100644
index 00000000000..90b9f5caea1
--- /dev/null
+++ b/source/gameengine/Converter/BL_ShapeDeformer.h
@@ -0,0 +1,88 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef BL_SHAPEDEFORMER
+#define BL_SHAPEDEFORMER
+
+#ifdef WIN32
+#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
+#endif //WIN32
+
+#include "BL_SkinDeformer.h"
+#include "BL_DeformableGameObject.h"
+#include <vector>
+
+struct IpoCurve;
+
+class BL_ShapeDeformer : public BL_SkinDeformer
+{
+public:
+ BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
+ Object *bmeshobj,
+ BL_SkinMeshObject *mesh)
+ :
+ BL_SkinDeformer(gameobj,bmeshobj, mesh),
+ m_lastShapeUpdate(-1)
+ {
+ };
+
+ /* this second constructor is needed for making a mesh deformable on the fly. */
+ BL_ShapeDeformer(BL_DeformableGameObject *gameobj,
+ struct Object *bmeshobj_old,
+ struct Object *bmeshobj_new,
+ class BL_SkinMeshObject *mesh,
+ bool release_object,
+ BL_ArmatureObject* arma = NULL)
+ :
+ BL_SkinDeformer(gameobj, bmeshobj_old, bmeshobj_new, mesh, release_object, arma),
+ m_lastShapeUpdate(-1)
+ {
+ };
+
+ virtual void ProcessReplica();
+ virtual RAS_Deformer *GetReplica(class KX_GameObject* replica);
+ virtual ~BL_ShapeDeformer();
+
+ bool Update (void);
+ bool LoadShapeDrivers(Object* arma);
+ bool ExecuteShapeDrivers(void);
+
+ void ForceUpdate()
+ {
+ m_lastShapeUpdate = -1.0;
+ };
+
+protected:
+ vector<IpoCurve*> m_shapeDrivers;
+ double m_lastShapeUpdate;
+
+};
+
+#endif
+
diff --git a/source/gameengine/Converter/BL_SkinDeformer.cpp b/source/gameengine/Converter/BL_SkinDeformer.cpp
index d6aee363a16..d8563763954 100644
--- a/source/gameengine/Converter/BL_SkinDeformer.cpp
+++ b/source/gameengine/Converter/BL_SkinDeformer.cpp
@@ -57,86 +57,96 @@ extern "C"{
#define __NLA_DEFNORMALS
//#undef __NLA_DEFNORMALS
-BL_SkinDeformer::~BL_SkinDeformer()
+BL_SkinDeformer::BL_SkinDeformer(BL_DeformableGameObject *gameobj,
+ struct Object *bmeshobj,
+ class BL_SkinMeshObject *mesh,
+ BL_ArmatureObject* arma)
+ : //
+ BL_MeshDeformer(gameobj, bmeshobj, mesh),
+ m_armobj(arma),
+ m_lastArmaUpdate(-1),
+ m_defbase(&bmeshobj->defbase),
+ m_releaseobject(false),
+ m_poseApplied(false)
{
- if(m_releaseobject && m_armobj)
- m_armobj->Release();
+ Mat4CpyMat4(m_obmat, bmeshobj->obmat);
};
-/* XXX note, this __NLA_OLDDEFORM define seems to be obsolete */
+BL_SkinDeformer::BL_SkinDeformer(
+ BL_DeformableGameObject *gameobj,
+ struct Object *bmeshobj_old, // Blender object that owns the new mesh
+ struct Object *bmeshobj_new, // Blender object that owns the original mesh
+ class BL_SkinMeshObject *mesh,
+ bool release_object,
+ BL_ArmatureObject* arma) :
+ BL_MeshDeformer(gameobj, bmeshobj_old, mesh),
+ m_armobj(arma),
+ m_lastArmaUpdate(-1),
+ m_defbase(&bmeshobj_old->defbase),
+ m_releaseobject(release_object)
+ {
+ // this is needed to ensure correct deformation of mesh:
+ // the deformation is done with Blender's armature_deform_verts() function
+ // that takes an object as parameter and not a mesh. The object matrice is used
+ // in the calculation, so we must use the matrix of the original object to
+ // simulate a pure replacement of the mesh.
+ Mat4CpyMat4(m_obmat, bmeshobj_new->obmat);
+ }
-bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat)
+BL_SkinDeformer::~BL_SkinDeformer()
{
- size_t i, j, index;
- vecVertexArray array;
-#ifdef __NLA_OLDDEFORM
- vecMVertArray mvarray;
-#else
- vecIndexArrays mvarray;
-#endif
- vecMDVertArray dvarray;
- vecIndexArrays diarray;
+ if(m_releaseobject && m_armobj)
+ m_armobj->Release();
+}
- RAS_TexVert *tv;
-#ifdef __NLA_OLDDEFORM
- MVert *mvert;
- MDeformVert *dvert;
-#endif
- MT_Point3 pt;
-// float co[3];
+void BL_SkinDeformer::Relink(GEN_Map<class GEN_HashedPtr, void*>*map)
+{
+ if (m_armobj) {
+ void **h_obj = (*map)[m_armobj];
- if (!m_armobj)
- return false;
+ if (h_obj)
+ SetArmature( (BL_ArmatureObject*)(*h_obj) );
+ else
+ m_armobj=NULL;
+ }
- Update();
+ BL_MeshDeformer::Relink(map);
+}
- array = m_pMeshObject->GetVertexCache(mat);
-#ifdef __NLA_OLDDEFORM
- dvarray = m_pMeshObject->GetDVertCache(mat);
-#endif
- mvarray = m_pMeshObject->GetMVertCache(mat);
- diarray = m_pMeshObject->GetDIndexCache(mat);
-
+bool BL_SkinDeformer::Apply(RAS_IPolyMaterial *mat)
+{
+ RAS_MeshSlot::iterator it;
+ RAS_MeshMaterial *mmat;
+ RAS_MeshSlot *slot;
+ size_t i;
- // For each array
- for (i=0; i<array.size(); i++){
- // For each vertex
- for (j=0; j<array[i]->size(); j++){
-
- tv = &((*array[i])[j]);
-
- index = ((*diarray[i])[j]);
-#ifdef __NLA_OLDDEFORM
- pt = tv->xyz();
- mvert = ((*mvarray[i])[index]);
- dvert = ((*dvarray[i])[index]);
-#endif
-
- // Copy the untransformed data from the original mvert
-#ifdef __NLA_OLDDEFORM
- co[0]=mvert->co[0];
- co[1]=mvert->co[1];
- co[2]=mvert->co[2];
-
- // Do the deformation
-/* XXX note, doesnt exist anymore */
-// GB_calc_armature_deform(co, dvert);
- tv->SetXYZ(co);
-#else
- // Set the data
- tv->SetXYZ(m_transverts[((*mvarray[i])[index])]);
-#ifdef __NLA_DEFNORMALS
+ // update the vertex in m_transverts
+ Update();
- tv->SetNormal(m_transnors[((*mvarray[i])[index])]);
-#endif
-#endif
+ // The vertex cache can only be updated for this deformer:
+ // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object)
+ // share the same mesh (=the same cache). As the rendering is done per polymaterial
+ // cycling through the objects, the entire mesh cache cannot be updated in one shot.
+ mmat = m_pMeshObject->GetMeshMaterial(mat);
+ if(!mmat->m_slots[(void*)m_gameobj])
+ return true;
+
+ slot = *mmat->m_slots[(void*)m_gameobj];
+
+ // for each array
+ for(slot->begin(it); !slot->end(it); slot->next(it)) {
+ // for each vertex
+ // copy the untransformed data from the original mvert
+ for(i=it.startvertex; i<it.endvertex; i++) {
+ RAS_TexVert& v = it.vertex[i];
+ v.SetXYZ(m_transverts[v.getOrigIndex()]);
}
}
-
+
return true;
}
-RAS_Deformer *BL_SkinDeformer::GetReplica()
+RAS_Deformer *BL_SkinDeformer::GetReplica(class KX_GameObject* replica)
{
BL_SkinDeformer *result;
@@ -151,19 +161,15 @@ void BL_SkinDeformer::ProcessReplica()
//void where_is_pose (Object *ob);
//void armature_deform_verts(Object *armOb, Object *target, float (*vertexCos)[3], int numVerts, int deformflag);
-void BL_SkinDeformer::Update(void)
+bool BL_SkinDeformer::Update(void)
{
/* See if the armature has been updated for this frame */
- if (m_lastUpdate!=m_armobj->GetLastFrame()){
-
- /* Do all of the posing necessary */
- m_armobj->ApplyPose();
-
+ if (PoseUpdated()){
+ float obmat[4][4]; // the original object matrice
+
/* XXX note: where_is_pose() (from BKE_armature.h) calculates all matrices needed to start deforming */
/* but it requires the blender object pointer... */
-
Object* par_arma = m_armobj->GetArmatureObject();
- where_is_pose( par_arma );
/* store verts locally */
VerifyStorage();
@@ -172,12 +178,32 @@ void BL_SkinDeformer::Update(void)
for (int v =0; v<m_bmesh->totvert; v++)
VECCOPY(m_transverts[v], m_bmesh->mvert[v].co);
+ m_armobj->ApplyPose();
+
+ // save matrix first
+ Mat4CpyMat4(obmat, m_objMesh->obmat);
+ // set reference matrix
+ Mat4CpyMat4(m_objMesh->obmat, m_obmat);
+
armature_deform_verts( par_arma, m_objMesh, NULL, m_transverts, NULL, m_bmesh->totvert, ARM_DEF_VGROUP, NULL, NULL );
+
+ // restore matrix
+ Mat4CpyMat4(m_objMesh->obmat, obmat);
+
+#ifdef __NLA_DEFNORMALS
RecalcNormals();
+#endif
/* Update the current frame */
- m_lastUpdate=m_armobj->GetLastFrame();
+ m_lastArmaUpdate=m_armobj->GetLastFrame();
+
+ m_armobj->RestorePose();
+
+ /* indicate that the m_transverts and normals are up to date */
+ return true;
}
+
+ return false;
}
/* XXX note: I propose to drop this function */
diff --git a/source/gameengine/Converter/BL_SkinDeformer.h b/source/gameengine/Converter/BL_SkinDeformer.h
index f14baf09651..f87860021c6 100644
--- a/source/gameengine/Converter/BL_SkinDeformer.h
+++ b/source/gameengine/Converter/BL_SkinDeformer.h
@@ -50,56 +50,48 @@ class BL_SkinDeformer : public BL_MeshDeformer
{
public:
// void SetArmatureController (BL_ArmatureController *cont);
- virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map)
- {
- void **h_obj = (*map)[m_armobj];
- if (h_obj){
- SetArmature( (BL_ArmatureObject*)(*h_obj) );
- }
- else
- m_armobj=NULL;
- }
+ virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map);
void SetArmature (class BL_ArmatureObject *armobj);
- BL_SkinDeformer(struct Object *bmeshobj,
+ BL_SkinDeformer(BL_DeformableGameObject *gameobj,
+ struct Object *bmeshobj,
class BL_SkinMeshObject *mesh,
- BL_ArmatureObject* arma = NULL)
- : //
- BL_MeshDeformer(bmeshobj, mesh),
- m_armobj(arma),
- m_lastUpdate(-1),
- m_defbase(&bmeshobj->defbase),
- m_releaseobject(false)
- {
- };
+ BL_ArmatureObject* arma = NULL);
/* this second constructor is needed for making a mesh deformable on the fly. */
- BL_SkinDeformer(struct Object *bmeshobj_old,
+ BL_SkinDeformer(BL_DeformableGameObject *gameobj,
+ struct Object *bmeshobj_old,
struct Object *bmeshobj_new,
class BL_SkinMeshObject *mesh,
bool release_object,
- BL_ArmatureObject* arma = NULL)
- : //
- BL_MeshDeformer(bmeshobj_old, mesh),
- m_armobj(arma),
- m_lastUpdate(-1),
- m_defbase(&bmeshobj_old->defbase),
- m_releaseobject(release_object)
- {
- };
+ BL_ArmatureObject* arma = NULL);
virtual void ProcessReplica();
- virtual RAS_Deformer *GetReplica();
+ virtual RAS_Deformer *GetReplica(class KX_GameObject* replica);
virtual ~BL_SkinDeformer();
- void Update (void);
+ bool Update (void);
bool Apply (class RAS_IPolyMaterial *polymat);
+ bool PoseUpdated(void)
+ {
+ if (m_armobj && m_lastArmaUpdate!=m_armobj->GetLastFrame()) {
+ return true;
+ }
+ return false;
+ }
+
+ void ForceUpdate()
+ {
+ m_lastArmaUpdate = -1.0;
+ };
protected:
BL_ArmatureObject* m_armobj; // Our parent object
float m_time;
- double m_lastUpdate;
+ double m_lastArmaUpdate;
ListBase* m_defbase;
+ float m_obmat[4][4]; // the reference matrix for skeleton deform
bool m_releaseobject;
+ bool m_poseApplied;
};
diff --git a/source/gameengine/Converter/BL_SkinMeshObject.cpp b/source/gameengine/Converter/BL_SkinMeshObject.cpp
index 8bc78c7f757..eb3f9d0588d 100644
--- a/source/gameengine/Converter/BL_SkinMeshObject.cpp
+++ b/source/gameengine/Converter/BL_SkinMeshObject.cpp
@@ -28,127 +28,129 @@
* Deformer that supports armature skinning
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifdef WIN32
#pragma warning (disable:4786) // get rid of stupid stl-visual compiler debug warning
#endif //WIN32
-#include "RAS_IPolygonMaterial.h"
-#include "BL_SkinMeshObject.h"
-#include "BL_DeformableGameObject.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_key_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
-#include "KX_GameObject.h"
+
#include "RAS_BucketManager.h"
+#include "RAS_IPolygonMaterial.h"
-void BL_SkinMeshObject::AddPolygon(RAS_Polygon* poly)
-{
- /* We're overriding this so that we can eventually associate faces with verts somehow */
+#include "KX_GameObject.h"
- // For vertIndex in poly:
- // find the appropriate normal
+#include "BL_SkinMeshObject.h"
+#include "BL_DeformableGameObject.h"
- RAS_MeshObject::AddPolygon(poly);
-}
+BL_SkinMeshObject::BL_SkinMeshObject(Mesh* mesh, int lightlayer)
+ : RAS_MeshObject (mesh, lightlayer)
+{
+ m_bDeformed = true;
-#ifdef __NLA_OLDDEFORM
-int BL_SkinMeshObject::FindOrAddDeform(int vtxarray, struct MVert *mv, struct MDeformVert *dv, RAS_IPolyMaterial* mat)
-#else
-int BL_SkinMeshObject::FindOrAddDeform(unsigned int vtxarray, unsigned int mv, struct MDeformVert *dv, RAS_IPolyMaterial* mat)
-#endif
-{
- BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
- int numvert = ao->m_MvertArrayCache1[vtxarray]->size();
-
- /* Check to see if this has already been pushed */
- for (unsigned int i=0; i<ao->m_MvertArrayCache1[vtxarray]->size(); i++){
- if (mv == (*ao->m_MvertArrayCache1[vtxarray])[i])
- return i;
+ if (m_mesh && m_mesh->key)
+ {
+ KeyBlock *kb;
+ int count=0;
+ // initialize weight cache for shape objects
+ // count how many keys in this mesh
+ for(kb= (KeyBlock*)m_mesh->key->block.first; kb; kb= (KeyBlock*)kb->next)
+ count++;
+ m_cacheWeightIndex.resize(count,-1);
}
+}
- ao->m_MvertArrayCache1[vtxarray]->push_back(mv);
- ao->m_DvertArrayCache1[vtxarray]->push_back(dv);
-
- return numvert;
-};
-
-int BL_SkinMeshObject::FindVertexArray(int numverts,RAS_IPolyMaterial* polymat)
+BL_SkinMeshObject::~BL_SkinMeshObject()
{
- int array=-1;
-
- BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(polymat);
-
-
- for (size_t i=0;i<ao->m_VertexArrayCache1.size();i++)
+ if (m_mesh && m_mesh->key)
{
- if ( (ao->m_TriangleArrayCount[i] + (numverts-2)) < BUCKET_MAX_TRIANGLES)
- {
- if((ao->m_VertexArrayCache1[i]->size()+numverts < BUCKET_MAX_INDICES))
- {
- array = i;
- ao->m_TriangleArrayCount[array]+=numverts-2;
- break;
- }
+ KeyBlock *kb;
+ // remove the weight cache to avoid memory leak
+ for(kb= (KeyBlock*)m_mesh->key->block.first; kb; kb= (KeyBlock*)kb->next) {
+ if(kb->weights)
+ MEM_freeN(kb->weights);
+ kb->weights= NULL;
}
}
-
+}
- if (array == -1)
- {
- array = ao->m_VertexArrayCache1.size();
-
- vector<RAS_TexVert>* va = new vector<RAS_TexVert>;
- ao->m_VertexArrayCache1.push_back(va);
-
- KX_IndexArray *ia = new KX_IndexArray();
- ao->m_IndexArrayCache1.push_back(ia);
+void BL_SkinMeshObject::UpdateBuckets(void* clientobj,double* oglmatrix,bool useObjectColor,const MT_Vector4& rgbavec, bool visible, bool culled)
+{
+ list<RAS_MeshMaterial>::iterator it;
+ list<RAS_MeshSlot*>::iterator sit;
-#ifdef __NLA_OLDDEFORM
- BL_MVertArray *bva = new BL_MVertArray();
-#else
- KX_IndexArray *bva = new KX_IndexArray();
-#endif
- ao->m_MvertArrayCache1.push_back(bva);
+ for(it = m_materials.begin();it!=m_materials.end();++it) {
+ if(!it->m_slots[clientobj])
+ continue;
- BL_DeformVertArray *dva = new BL_DeformVertArray();
- ao->m_DvertArrayCache1.push_back(dva);
+ RAS_MeshSlot *slot = *it->m_slots[clientobj];
+ slot->m_pDeformer = ((BL_DeformableGameObject*)clientobj)->GetDeformer();
+ }
- KX_IndexArray *da = new KX_IndexArray();
- ao->m_DIndexArrayCache1.push_back(da);
+ RAS_MeshObject::UpdateBuckets(clientobj, oglmatrix, useObjectColor, rgbavec, visible, culled);
+}
- ao->m_TriangleArrayCount.push_back(numverts-2);
+static int get_def_index(Object* ob, const char* vgroup)
+{
+ bDeformGroup *curdef;
+ int index = 0;
- }
+ for (curdef = (bDeformGroup*)ob->defbase.first; curdef; curdef=(bDeformGroup*)curdef->next, index++)
+ if (!strcmp(curdef->name, vgroup))
+ return index;
-
- return array;
+ return -1;
}
-
-//void BL_SkinMeshObject::Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec,RAS_BucketManager* bucketmgr)
-void BL_SkinMeshObject::Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec)
+void BL_SkinMeshObject::CheckWeightCache(Object* obj)
{
+ KeyBlock *kb;
+ int kbindex, defindex;
+ MDeformVert *dvert= NULL;
+ int totvert, i, j;
+ float *weights;
- KX_MeshSlot ms;
- ms.m_clientObj = clientobj;
- ms.m_mesh = this;
- ms.m_OpenGLMatrix = oglmatrix;
- ms.m_bObjectColor = useObjectColor;
- ms.m_RGBAcolor = rgbavec;
- ms.m_pDeformer = ((BL_DeformableGameObject*)clientobj)->m_pDeformer;
-
- for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();it++)
- {
-
- RAS_MaterialBucket* materialbucket = (*it);
+ if (!m_mesh->key)
+ return;
-// KX_ArrayOptimizer* oa = GetArrayOptimizer(materialbucket->GetPolyMaterial());
- materialbucket->SetMeshSlot(ms);
+ for(kbindex=0, kb= (KeyBlock*)m_mesh->key->block.first; kb; kb= (KeyBlock*)kb->next, kbindex++)
+ {
+ // first check the cases where the weight must be cleared
+ if (kb->vgroup[0] == 0 ||
+ m_mesh->dvert == NULL ||
+ (defindex = get_def_index(obj, kb->vgroup)) == -1) {
+ if (kb->weights) {
+ MEM_freeN(kb->weights);
+ kb->weights = NULL;
+ }
+ m_cacheWeightIndex[kbindex] = -1;
+ } else if (m_cacheWeightIndex[kbindex] != defindex) {
+ // a weight array is required but the cache is not matching
+ if (kb->weights) {
+ MEM_freeN(kb->weights);
+ kb->weights = NULL;
+ }
+
+ dvert= m_mesh->dvert;
+ totvert= m_mesh->totvert;
+
+ weights= (float*)MEM_callocN(totvert*sizeof(float), "weights");
+
+ for (i=0; i < totvert; i++, dvert++) {
+ for(j=0; j<dvert->totweight; j++) {
+ if (dvert->dw[j].def_nr == defindex) {
+ weights[i]= dvert->dw[j].weight;
+ break;
+ }
+ }
+ }
+ kb->weights = weights;
+ m_cacheWeightIndex[kbindex] = defindex;
+ }
}
-
}
-
diff --git a/source/gameengine/Converter/BL_SkinMeshObject.h b/source/gameengine/Converter/BL_SkinMeshObject.h
index 0ca7428c0f0..8544a2b958c 100644
--- a/source/gameengine/Converter/BL_SkinMeshObject.h
+++ b/source/gameengine/Converter/BL_SkinMeshObject.h
@@ -40,138 +40,20 @@
#include "BL_MeshDeformer.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-
-typedef vector<struct MVert*> BL_MVertArray;
-typedef vector<struct MDeformVert*> BL_DeformVertArray;
-typedef vector<class BL_TexVert> BL_VertexArray;
-
-
-typedef vector<vector<struct MDeformVert*>*> vecMDVertArray;
-typedef vector<vector<class BL_TexVert>*> vecBVertexArray;
-
-class BL_SkinArrayOptimizer : public KX_ArrayOptimizer
-{
-public:
- BL_SkinArrayOptimizer(int index)
- :KX_ArrayOptimizer (index) {};
- virtual ~BL_SkinArrayOptimizer(){
-
- for (vector<KX_IndexArray*>::iterator itv = m_MvertArrayCache1.begin();
- !(itv == m_MvertArrayCache1.end());itv++)
- {
- delete (*itv);
- }
- for (vector<BL_DeformVertArray*>::iterator itd = m_DvertArrayCache1.begin();
- !(itd == m_DvertArrayCache1.end());itd++)
- {
- delete (*itd);
- }
- for (vector<KX_IndexArray*>::iterator iti = m_DIndexArrayCache1.begin();
- !(iti == m_DIndexArrayCache1.end());iti++)
- {
- delete (*iti);
- }
-
- m_MvertArrayCache1.clear();
- m_DvertArrayCache1.clear();
- m_DIndexArrayCache1.clear();
- };
-
- vector<KX_IndexArray*> m_MvertArrayCache1;
- vector<BL_DeformVertArray*> m_DvertArrayCache1;
- vector<KX_IndexArray*> m_DIndexArrayCache1;
-
-};
-
class BL_SkinMeshObject : public RAS_MeshObject
{
-
-// enum { BUCKET_MAX_INDICES = 16384};//2048};//8192};
-// enum { BUCKET_MAX_TRIANGLES = 4096};
-
- KX_ArrayOptimizer* GetArrayOptimizer(RAS_IPolyMaterial* polymat)
- {
- KX_ArrayOptimizer** aop = (m_matVertexArrayS[*polymat]);
- if (aop)
- return *aop;
- int numelements = m_matVertexArrayS.size();
- m_sortedMaterials.push_back(polymat);
-
- BL_SkinArrayOptimizer* ao = new BL_SkinArrayOptimizer(numelements);
- m_matVertexArrayS.insert(*polymat,ao);
- return ao;
- }
-
protected:
-public:
- void Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec);
-// void Bucketize(double* oglmatrix,void* clientobj,bool useObjectColor,const MT_Vector4& rgbavec,class RAS_BucketManager* bucketmgr);
-
- int FindVertexArray(int numverts,RAS_IPolyMaterial* polymat);
- BL_SkinMeshObject(int lightlayer) : RAS_MeshObject (lightlayer)
- { m_class = 1;};
+ vector<int> m_cacheWeightIndex;
- virtual ~BL_SkinMeshObject(){
- };
+public:
+ BL_SkinMeshObject(Mesh* mesh, int lightlayer);
+ ~BL_SkinMeshObject();
- const vecIndexArrays& GetDIndexCache (RAS_IPolyMaterial* mat)
- {
- BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
- return ao->m_DIndexArrayCache1;
- }
- const vecMDVertArray& GetDVertCache (RAS_IPolyMaterial* mat)
- {
- BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
- return ao->m_DvertArrayCache1;
- }
- const vecIndexArrays& GetMVertCache (RAS_IPolyMaterial* mat)
- {
- BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
- return ao->m_MvertArrayCache1;
- }
+ void UpdateBuckets(void* clientobj, double* oglmatrix,
+ bool useObjectColor, const MT_Vector4& rgbavec, bool visible, bool culled);
- void AddPolygon(RAS_Polygon* poly);
- int FindOrAddDeform(unsigned int vtxarray, unsigned int mv, struct MDeformVert *dv, RAS_IPolyMaterial* mat);
- int FindOrAddVertex(int vtxarray,const MT_Point3& xyz,
- const MT_Point2& uv,
- const MT_Point2& uv2,
- const MT_Vector4& tangent,
- const unsigned int rgbacolor,
- const MT_Vector3& normal, int defnr, bool flat, RAS_IPolyMaterial* mat)
- {
- RAS_TexVert tempvert(xyz,uv,uv2, tangent,rgbacolor,normal,flat ? TV_CALCFACENORMAL : 0);
-
- // KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
- BL_SkinArrayOptimizer* ao = (BL_SkinArrayOptimizer*)GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
-
- int numverts = ao->m_VertexArrayCache1[vtxarray]->size();//m_VertexArrayCount[vtxarray];
-
- int index=-1;
-
- for (int i=0;i<numverts;i++)
- {
- const RAS_TexVert& vtx = (*ao->m_VertexArrayCache1[vtxarray])[i];
- if (tempvert.closeTo(&vtx))
- {
- index = i;
- break;
- }
-
- }
- if (index >= 0)
- return index;
-
- // no vertex found, add one
- ao->m_VertexArrayCache1[vtxarray]->push_back(tempvert);
- ao->m_DIndexArrayCache1[vtxarray]->push_back(defnr);
-
- return numverts;
-
-
- }
-
+ // for shape keys,
+ void CheckWeightCache(struct Object* obj);
};
#endif
diff --git a/source/gameengine/Converter/CMakeLists.txt b/source/gameengine/Converter/CMakeLists.txt
index 1b8aa73bf1f..a5219b9e759 100644
--- a/source/gameengine/Converter/CMakeLists.txt
+++ b/source/gameengine/Converter/CMakeLists.txt
@@ -65,6 +65,7 @@ SET(INC
../../../source/gameengine/Network/LoopBackNetwork
../../../source/blender/misc
../../../source/blender/blenloader
+ ../../../source/blender/gpu
../../../extern/bullet2/src
../../../extern/solid
${PYTHON_INC}
diff --git a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
index f58d60b026a..4d79febb7b4 100644
--- a/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
+++ b/source/gameengine/Converter/KX_BlenderScalarInterpolator.cpp
@@ -28,13 +28,10 @@
#include "KX_BlenderScalarInterpolator.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-extern "C" int IPO_GetChannels(struct Ipo *ipo, short *channels);
-extern "C" float IPO_GetFloatValue(struct Ipo *ipo, /*IPO_Channel*/ short channel, float ctime);
-
+extern "C" {
+#include "DNA_ipo_types.h"
+#include "BKE_ipo.h"
+}
static const int BL_MAX_CHANNELS = 32;
@@ -42,7 +39,7 @@ float BL_ScalarInterpolator::GetValue(float currentTime) const {
return IPO_GetFloatValue(m_blender_ipo, m_channel, currentTime);
}
-typedef short IPO_Channel;
+
BL_InterpolatorList::BL_InterpolatorList(struct Ipo *ipo) {
IPO_Channel channels[BL_MAX_CHANNELS];
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
index 067fce3eefe..3fcb4765c67 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.cpp
@@ -100,7 +100,8 @@ KX_BlenderSceneConverter::KX_BlenderSceneConverter(
m_sipo(sipo),
m_ketsjiEngine(engine),
m_alwaysUseExpandFraming(false),
- m_usemat(false)
+ m_usemat(false),
+ m_useglslmat(false)
{
m_newfilename = "";
}
@@ -120,29 +121,29 @@ KX_BlenderSceneConverter::~KX_BlenderSceneConverter()
delete (ipoList);
}
- vector<KX_WorldInfo*>::iterator itw = m_worldinfos.begin();
+ vector<pair<KX_Scene*,KX_WorldInfo*> >::iterator itw = m_worldinfos.begin();
while (itw != m_worldinfos.end()) {
- delete (*itw);
+ delete (*itw).second;
itw++;
}
- vector<RAS_IPolyMaterial*>::iterator itp = m_polymaterials.begin();
+ vector<pair<KX_Scene*,RAS_IPolyMaterial*> >::iterator itp = m_polymaterials.begin();
while (itp != m_polymaterials.end()) {
- delete (*itp);
+ delete (*itp).second;
itp++;
}
// delete after RAS_IPolyMaterial
- vector<BL_Material *>::iterator itmat = m_materials.begin();
+ vector<pair<KX_Scene*,BL_Material *> >::iterator itmat = m_materials.begin();
while (itmat != m_materials.end()) {
- delete (*itmat);
+ delete (*itmat).second;
itmat++;
}
- vector<RAS_MeshObject*>::iterator itm = m_meshobjects.begin();
+ vector<pair<KX_Scene*,RAS_MeshObject*> >::iterator itm = m_meshobjects.begin();
while (itm != m_meshobjects.end()) {
- delete (*itm);
+ delete (*itm).second;
itm++;
}
@@ -183,20 +184,21 @@ bool KX_BlenderSceneConverter::TryAndLoadNewFile()
return result;
}
-
+Scene *KX_BlenderSceneConverter::GetBlenderSceneForName(const STR_String& name)
+{
+ Scene *sce;
/**
* Find the specified scene by name, or the first
* scene if nothing matches (shouldn't happen).
*/
-static struct Scene *GetSceneForName2(struct Main *maggie, const STR_String& scenename) {
- Scene *sce;
- for (sce= (Scene*) maggie->scene.first; sce; sce= (Scene*) sce->id.next)
- if (scenename == (sce->id.name+2))
+ for (sce= (Scene*) m_maggie->scene.first; sce; sce= (Scene*) sce->id.next)
+ if (name == (sce->id.name+2))
return sce;
- return (Scene*) maggie->scene.first;
+ return (Scene*)m_maggie->scene.first;
+
}
#include "KX_PythonInit.h"
@@ -244,6 +246,11 @@ struct BlenderDebugDraw : public btIDebugDraw
{
return m_debugMode;
}
+ ///todo: find out if Blender can do this
+ virtual void draw3dText(const btVector3& location,const char* textString)
+ {
+
+ }
};
@@ -257,9 +264,12 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename,
class RAS_ICanvas* canvas)
{
//find out which physics engine
- Scene *blenderscene = GetSceneForName2(m_maggie, scenename);
+ Scene *blenderscene = GetBlenderSceneForName(scenename);
e_PhysicsEngine physics_engine = UseBullet;
+ // hook for registration function during conversion.
+ m_currentScene = destinationscene;
+ destinationscene->SetSceneConverter(this);
if (blenderscene)
{
@@ -357,21 +367,102 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename,
m_alwaysUseExpandFraming
);
+ //These lookup are not needed during game
m_map_blender_to_gameactuator.clear();
m_map_blender_to_gamecontroller.clear();
-
m_map_blender_to_gameobject.clear();
- m_map_mesh_to_gamemesh.clear();
- //don't clear it yet, it is needed for the baking physics into ipo animation
+ //Clearing this lookup table has the effect of disabling the cache of meshes
+ //between scenes, even if they are shared in the blend file.
+ //This cache mecanism is buggy so I leave it disable and the memory leak
+ //that would result from this is fixed in RemoveScene()
+ m_map_mesh_to_gamemesh.clear();
+ //Don't clear this lookup, it is needed for the baking physics into ipo animation
+ //To avoid it's infinite grows, object will be unregister when they are deleted
+ //see KX_Scene::NewRemoveObject
//m_map_gameobject_to_blender.clear();
}
+// This function removes all entities stored in the converter for that scene
+// It should be used instead of direct delete scene
+// Note that there was some provision for sharing entities (meshes...) between
+// scenes but that is now disabled so all scene will have their own copy
+// and we can delete them here. If the sharing is reactivated, change this code too..
+// (see KX_BlenderSceneConverter::ConvertScene)
+void KX_BlenderSceneConverter::RemoveScene(KX_Scene *scene)
+{
+ int i, size;
+ // delete the scene first as it will stop the use of entities
+ delete scene;
+ // delete the entities of this scene
+ vector<pair<KX_Scene*,KX_WorldInfo*> >::iterator worldit;
+ size = m_worldinfos.size();
+ for (i=0, worldit=m_worldinfos.begin(); i<size; ) {
+ if ((*worldit).first == scene) {
+ delete (*worldit).second;
+ *worldit = m_worldinfos.back();
+ m_worldinfos.pop_back();
+ size--;
+ } else {
+ i++;
+ worldit++;
+ }
+ }
+
+ vector<pair<KX_Scene*,RAS_IPolyMaterial*> >::iterator polymit;
+ size = m_polymaterials.size();
+ for (i=0, polymit=m_polymaterials.begin(); i<size; ) {
+ if ((*polymit).first == scene) {
+ delete (*polymit).second;
+ *polymit = m_polymaterials.back();
+ m_polymaterials.pop_back();
+ size--;
+ } else {
+ i++;
+ polymit++;
+ }
+ }
+
+ vector<pair<KX_Scene*,BL_Material*> >::iterator matit;
+ size = m_materials.size();
+ for (i=0, matit=m_materials.begin(); i<size; ) {
+ if ((*matit).first == scene) {
+ delete (*matit).second;
+ *matit = m_materials.back();
+ m_materials.pop_back();
+ size--;
+ } else {
+ i++;
+ matit++;
+ }
+ }
+
+ vector<pair<KX_Scene*,RAS_MeshObject*> >::iterator meshit;
+ size = m_meshobjects.size();
+ for (i=0, meshit=m_meshobjects.begin(); i<size; ) {
+ if ((*meshit).first == scene) {
+ delete (*meshit).second;
+ *meshit = m_meshobjects.back();
+ m_meshobjects.pop_back();
+ size--;
+ } else {
+ i++;
+ meshit++;
+ }
+ }
+}
// use blender materials
void KX_BlenderSceneConverter::SetMaterials(bool val)
{
m_usemat = val;
+ m_useglslmat = false;
+}
+
+void KX_BlenderSceneConverter::SetGLSLMaterials(bool val)
+{
+ m_usemat = val;
+ m_useglslmat = val;
}
bool KX_BlenderSceneConverter::GetMaterials()
@@ -379,10 +470,14 @@ bool KX_BlenderSceneConverter::GetMaterials()
return m_usemat;
}
+bool KX_BlenderSceneConverter::GetGLSLMaterials()
+{
+ return m_useglslmat;
+}
void KX_BlenderSceneConverter::RegisterBlenderMaterial(BL_Material *mat)
{
- m_materials.push_back(mat);
+ m_materials.push_back(pair<KX_Scene*,BL_Material *>(m_currentScene,mat));
}
@@ -403,6 +498,21 @@ void KX_BlenderSceneConverter::RegisterGameObject(
m_map_blender_to_gameobject.insert(CHashedPtr(for_blenderobject),gameobject);
}
+void KX_BlenderSceneConverter::UnregisterGameObject(
+ KX_GameObject *gameobject)
+{
+ CHashedPtr gptr(gameobject);
+ struct Object **bobp= m_map_gameobject_to_blender[gptr];
+ if (bobp) {
+ CHashedPtr bptr(*bobp);
+ KX_GameObject **gobp= m_map_blender_to_gameobject[bptr];
+ if (gobp && *gobp == gameobject)
+ // also maintain m_map_blender_to_gameobject if the gameobject
+ // being removed is matching the blender object
+ m_map_blender_to_gameobject.remove(bptr);
+ m_map_gameobject_to_blender.remove(gptr);
+ }
+}
KX_GameObject *KX_BlenderSceneConverter::FindGameObject(
@@ -430,7 +540,7 @@ void KX_BlenderSceneConverter::RegisterGameMesh(
struct Mesh *for_blendermesh)
{
m_map_mesh_to_gamemesh.insert(CHashedPtr(for_blendermesh),gamemesh);
- m_meshobjects.push_back(gamemesh);
+ m_meshobjects.push_back(pair<KX_Scene*,RAS_MeshObject*>(m_currentScene,gamemesh));
}
@@ -455,7 +565,7 @@ RAS_MeshObject *KX_BlenderSceneConverter::FindGameMesh(
void KX_BlenderSceneConverter::RegisterPolyMaterial(RAS_IPolyMaterial *polymat)
{
- m_polymaterials.push_back(polymat);
+ m_polymaterials.push_back(pair<KX_Scene*,RAS_IPolyMaterial*>(m_currentScene,polymat));
}
@@ -520,7 +630,7 @@ SCA_IController *KX_BlenderSceneConverter::FindGameController(
void KX_BlenderSceneConverter::RegisterWorldInfo(
KX_WorldInfo *worldinfo)
{
- m_worldinfos.push_back(worldinfo);
+ m_worldinfos.push_back(pair<KX_Scene*,KX_WorldInfo*>(m_currentScene,worldinfo));
}
/*
@@ -552,13 +662,13 @@ extern "C"
{
Ipo *add_ipo( char *name, int idcode );
char *getIpoCurveName( IpoCurve * icu );
- struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int);
+ struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int, short);
void testhandles_ipocurve(struct IpoCurve *icu);
+ void insert_vert_icu(struct IpoCurve *, float, float, short);
void Mat3ToEul(float tmat[][3], float *eul);
-
}
-IpoCurve* findIpoCurve(IpoCurve* first,char* searchName)
+IpoCurve* findIpoCurve(IpoCurve* first, const char* searchName)
{
IpoCurve* icu1;
for( icu1 = first; icu1; icu1 = icu1->next )
@@ -726,7 +836,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
if (gameObj->IsDynamic())
{
- KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
+ //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
Object* blenderObject = FindBlenderObject(gameObj);
if (blenderObject)
@@ -754,7 +864,7 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
- const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
+ //const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
const MT_Point3& position = gameObj->NodeGetWorldPosition();
Ipo* ipo = blenderObject->ipo;
@@ -765,27 +875,27 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
IpoCurve *icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX");
if (!icu1)
- icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X);
+ icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X, 1);
icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY");
if (!icu1)
- icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y);
+ icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y, 1);
icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ");
if (!icu1)
- icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z);
+ icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z, 1);
icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX");
if (!icu1)
- icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X);
+ icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X, 1);
icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY");
if (!icu1)
- icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y);
+ icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y, 1);
icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ");
if (!icu1)
- icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z);
+ icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z, 1);
@@ -882,7 +992,7 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo()
KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
if (gameObj->IsDynamic())
{
- KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
+ //KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
Object* blenderObject = FindBlenderObject(gameObj);
if (blenderObject)
@@ -910,8 +1020,8 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo()
- const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
- const MT_Point3& position = gameObj->NodeGetWorldPosition();
+ //const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
+ //const MT_Point3& position = gameObj->NodeGetWorldPosition();
Ipo* ipo = blenderObject->ipo;
if (ipo)
@@ -921,27 +1031,27 @@ void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo()
IpoCurve *icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX");
if (!icu1)
- icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X);
+ icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X, 1);
icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY");
if (!icu1)
- icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y);
+ icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y, 1);
icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ");
if (!icu1)
- icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z);
+ icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z, 1);
icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX");
if (!icu1)
- icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X);
+ icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X, 1);
icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY");
if (!icu1)
- icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y);
+ icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y, 1);
icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ");
if (!icu1)
- icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z);
+ icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z, 1);
diff --git a/source/gameengine/Converter/KX_BlenderSceneConverter.h b/source/gameengine/Converter/KX_BlenderSceneConverter.h
index 971b45fc786..2317e952a0a 100644
--- a/source/gameengine/Converter/KX_BlenderSceneConverter.h
+++ b/source/gameengine/Converter/KX_BlenderSceneConverter.h
@@ -45,13 +45,17 @@ class BL_Material;
struct IpoCurve;
struct Main;
struct SpaceIpo;
+struct Scene;
class KX_BlenderSceneConverter : public KX_ISceneConverter
{
- vector<KX_WorldInfo*> m_worldinfos;
- vector<RAS_IPolyMaterial*> m_polymaterials;
- vector<RAS_MeshObject*> m_meshobjects;
- vector<BL_Material *> m_materials;
+ // Use vector of pairs to allow removal of entities between scene switch
+ vector<pair<KX_Scene*,KX_WorldInfo*> > m_worldinfos;
+ vector<pair<KX_Scene*,RAS_IPolyMaterial*> > m_polymaterials;
+ vector<pair<KX_Scene*,RAS_MeshObject*> > m_meshobjects;
+ vector<pair<KX_Scene*,BL_Material *> > m_materials;
+ // Should also have a list of collision shapes.
+ // For the time being this is held in KX_Scene::m_shapes
GEN_Map<CHashedPtr,struct Object*> m_map_gameobject_to_blender;
GEN_Map<CHashedPtr,KX_GameObject*> m_map_blender_to_gameobject;
@@ -69,8 +73,10 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter
STR_String m_newfilename;
class KX_KetsjiEngine* m_ketsjiEngine;
+ class KX_Scene* m_currentScene; // Scene being converted
bool m_alwaysUseExpandFraming;
bool m_usemat;
+ bool m_useglslmat;
void localDel_ipoCurve ( IpoCurve * icu ,struct SpaceIpo* sipo);
// struct Ipo* findIpoForName(char* objName);
@@ -96,6 +102,7 @@ public:
class RAS_IRenderTools* rendertools,
class RAS_ICanvas* canvas
);
+ virtual void RemoveScene(class KX_Scene *scene);
void SetNewFileName(const STR_String& filename);
bool TryAndLoadNewFile();
@@ -103,6 +110,7 @@ public:
void SetAlwaysUseExpandFraming(bool to_what);
void RegisterGameObject(KX_GameObject *gameobject, struct Object *for_blenderobject);
+ void UnregisterGameObject(KX_GameObject *gameobject);
KX_GameObject *FindGameObject(struct Object *for_blenderobject);
struct Object *FindBlenderObject(KX_GameObject *for_gameobject);
@@ -140,6 +148,11 @@ public:
virtual void SetMaterials(bool val);
virtual bool GetMaterials();
+ // use blender glsl materials
+ virtual void SetGLSLMaterials(bool val);
+ virtual bool GetGLSLMaterials();
+
+ struct Scene* GetBlenderSceneForName(const STR_String& name);
};
#endif //__KX_BLENDERSCENECONVERTER_H
diff --git a/source/gameengine/Converter/KX_ConvertActuators.cpp b/source/gameengine/Converter/KX_ConvertActuators.cpp
index 02c07a8eb94..4f152acc918 100644
--- a/source/gameengine/Converter/KX_ConvertActuators.cpp
+++ b/source/gameengine/Converter/KX_ConvertActuators.cpp
@@ -34,6 +34,8 @@
#define BLENDER_HACK_DTIME 0.02
+#include "MEM_guardedalloc.h"
+
#include "KX_BlenderSceneConverter.h"
#include "KX_ConvertActuators.h"
@@ -42,7 +44,7 @@
#include "SCA_PropertyActuator.h"
#include "SCA_LogicManager.h"
#include "SCA_RandomActuator.h"
-
+#include "SCA_2DFilterActuator.h"
// Ketsji specific logicbricks
#include "KX_SceneActuator.h"
@@ -54,10 +56,13 @@
#include "KX_ConstraintActuator.h"
#include "KX_CameraActuator.h"
#include "KX_GameActuator.h"
+#include "KX_StateActuator.h"
#include "KX_VisibilityActuator.h"
#include "KX_SCA_AddObjectActuator.h"
#include "KX_SCA_EndObjectActuator.h"
#include "KX_SCA_ReplaceMeshActuator.h"
+#include "KX_ParentActuator.h"
+#include "KX_SCA_DynamicActuator.h"
#include "KX_Scene.h"
#include "KX_KetsjiEngine.h"
@@ -66,9 +71,11 @@
#include "KX_GameObject.h"
/* This little block needed for linking to Blender... */
-
+#include "BKE_text.h"
#include "BLI_blenlib.h"
+#define FILE_MAX 240 // repeated here to avoid dependency from BKE_utildefines.h
+
#include "KX_NetworkMessageActuator.h"
#ifdef WIN32
@@ -81,6 +88,7 @@
#include "DNA_actuator_types.h"
#include "DNA_packedFile_types.h"
#include "BL_ActionActuator.h"
+#include "BL_ShapeActionActuator.h"
/* end of blender include block */
#include "BL_BlenderDataConversion.h"
@@ -132,6 +140,7 @@ void BL_ConvertActuators(char* maggiename,
MT_Vector3 angvelvec ( KX_BLENDERTRUNC(obact->angularvelocity[0]),
KX_BLENDERTRUNC(obact->angularvelocity[1]),
KX_BLENDERTRUNC(obact->angularvelocity[2]));
+ short damping = obact->damping;
drotvec /= BLENDER_HACK_DTIME;
//drotvec /= BLENDER_HACK_DTIME;
@@ -152,7 +161,7 @@ void BL_ConvertActuators(char* maggiename,
bitLocalFlag.DRot = bool((obact->flag & ACT_DROT_LOCAL)!=0);
bitLocalFlag.LinearVelocity = bool((obact->flag & ACT_LIN_VEL_LOCAL)!=0);
bitLocalFlag.AngularVelocity = bool((obact->flag & ACT_ANG_VEL_LOCAL)!=0);
-
+ bitLocalFlag.ServoControl = bool(obact->type == ACT_OBJECT_SERVO);
bitLocalFlag.AddOrSetLinV = bool((obact->flag & ACT_ADD_LIN_VEL)!=0);
@@ -163,6 +172,7 @@ void BL_ConvertActuators(char* maggiename,
drotvec.getValue(),
linvelvec.getValue(),
angvelvec.getValue(),
+ damping,
bitLocalFlag
);
baseact = tmpbaseact;
@@ -173,16 +183,19 @@ void BL_ConvertActuators(char* maggiename,
if (blenderobject->type==OB_ARMATURE){
bActionActuator* actact = (bActionActuator*) bact->data;
STR_String propname = (actact->name ? actact->name : "");
+ STR_String propframe = (actact->frameProp ? actact->frameProp : "");
BL_ActionActuator* tmpbaseact = new BL_ActionActuator(
gameobj,
propname,
+ propframe,
actact->sta,
actact->end,
actact->act,
actact->type, // + 1, because Blender starts to count at zero,
actact->blendin,
actact->priority,
+ actact->end_reset,
actact->stridelength
// Ketsji at 1, because zero is reserved for "NoDef"
);
@@ -192,26 +205,55 @@ void BL_ConvertActuators(char* maggiename,
else
printf ("Discarded action actuator from non-armature object [%s]\n", blenderobject->id.name+2);
}
+ case ACT_SHAPEACTION:
+ {
+ if (blenderobject->type==OB_MESH){
+ bActionActuator* actact = (bActionActuator*) bact->data;
+ STR_String propname = (actact->name ? actact->name : "");
+ STR_String propframe = (actact->frameProp ? actact->frameProp : "");
+
+ BL_ShapeActionActuator* tmpbaseact = new BL_ShapeActionActuator(
+ gameobj,
+ propname,
+ propframe,
+ actact->sta,
+ actact->end,
+ actact->act,
+ actact->type, // + 1, because Blender starts to count at zero,
+ actact->blendin,
+ actact->priority,
+ actact->stridelength
+ // Ketsji at 1, because zero is reserved for "NoDef"
+ );
+ baseact= tmpbaseact;
+ break;
+ }
+ else
+ printf ("Discarded shape action actuator from non-mesh object [%s]\n", blenderobject->id.name+2);
+ }
case ACT_IPO:
{
bIpoActuator* ipoact = (bIpoActuator*) bact->data;
bool ipochild = (ipoact->flag & ACT_IPOCHILD) !=0;
- STR_String propname = ( ipoact->name ? ipoact->name : "");
+ STR_String propname = ipoact->name;
+ STR_String frameProp = ipoact->frameProp;
// first bit?
bool ipo_as_force = (ipoact->flag & ACT_IPOFORCE);
- bool force_local = (ipoact->flag & ACT_IPOFORCE_LOCAL);
+ bool local = (ipoact->flag & ACT_IPOLOCAL);
+ bool ipo_add = (ipoact->flag & ACT_IPOADD);
KX_IpoActuator* tmpbaseact = new KX_IpoActuator(
gameobj,
propname ,
+ frameProp,
ipoact->sta,
ipoact->end,
ipochild,
ipoact->type + 1, // + 1, because Blender starts to count at zero,
// Ketsji at 1, because zero is reserved for "NoDef"
ipo_as_force,
- force_local
- );
+ ipo_add,
+ local);
baseact = tmpbaseact;
break;
}
@@ -249,15 +291,19 @@ void BL_ConvertActuators(char* maggiename,
STR_String toPropName = (msgAct->toPropName
? (char*) msgAct->toPropName
: "");
- /**
- * Get the Message Subject to send.
+ /* BGE Wants "OB" prefix */
+ if (toPropName != "")
+ toPropName = "OB" + toPropName;
+
+ /**
+ * Get the Message Subject to send.
*/
STR_String subject = (msgAct->subject
? (char*) msgAct->subject
: "");
- /**
- * Get the bodyType
+ /**
+ * Get the bodyType
*/
int bodyType = msgAct->bodyType;
@@ -319,22 +365,26 @@ void BL_ConvertActuators(char* maggiename,
if (soundActuatorType != KX_SoundActuator::KX_SOUNDACT_NODEF)
{
- SND_SoundObject* sndobj = NULL;
+ SND_Scene* soundscene = scene->GetSoundScene();
+ STR_String samplename = "";
+ bool sampleisloaded = false;
- if (soundact->sound)
- {
- SND_Scene* soundscene = scene->GetSoundScene();
- STR_String samplename = soundact->sound->name;
+ if (soundact->sound) {
+ /* Need to convert the samplename into absolute path
+ * before checking if its loaded */
+ char fullpath[FILE_MAX];
- bool sampleisloaded = false;
+ /* dont modify soundact->sound->name, only change a copy */
+ BLI_strncpy(fullpath, soundact->sound->name, sizeof(fullpath));
+ BLI_convertstringcode(fullpath, maggiename);
+ samplename = fullpath;
/* let's see if the sample was already loaded */
if (soundscene->IsSampleLoaded(samplename))
{
sampleisloaded = true;
}
- else
- {
+ else {
/* if not, make it so */
PackedFile* pf = soundact->sound->newpackedfile;
@@ -347,21 +397,33 @@ void BL_ConvertActuators(char* maggiename,
/* or else load it from disk */
else
{
- /* but we need to convert the samplename into absolute pathname first */
- BLI_convertstringcode(soundact->sound->name, maggiename, 0);
- samplename = soundact->sound->name;
-
- /* and now we can load it */
- if (soundscene->LoadSample(samplename, NULL, 0) > -1)
+ if (soundscene->LoadSample(samplename, NULL, 0) > -1) {
sampleisloaded = true;
+ }
+ else {
+ std::cout << "WARNING: Sound actuator \"" << bact->name <<
+ "\" from object \"" << blenderobject->id.name+2 <<
+ "\" failed to load sample." << std::endl;
+ }
}
}
-
- if (sampleisloaded)
- {
- sndobj = new SND_SoundObject();
- sndobj->SetSampleName(samplename.Ptr());
- sndobj->SetObjectName(bact->name);
+ } else {
+ std::cout << "WARNING: Sound actuator \"" << bact->name <<
+ "\" from object \"" << blenderobject->id.name+2 <<
+ "\" has no sound datablock." << std::endl;
+ }
+
+ /* Note, allowing actuators for sounds that are not there was added since 2.47
+ * This is because python may expect the actuator and raise an exception if it dosnt find it
+ * better just to add a dummy sound actuator. */
+ SND_SoundObject* sndobj = NULL;
+ if (sampleisloaded)
+ {
+ /* setup the SND_SoundObject */
+ sndobj = new SND_SoundObject();
+ sndobj->SetSampleName(samplename.Ptr());
+ sndobj->SetObjectName(bact->name);
+ if (soundact->sound) {
sndobj->SetRollOffFactor(soundact->sound->attenuation);
sndobj->SetGain(soundact->sound->volume);
sndobj->SetPitch(exp((soundact->sound->pitch / 12.0) * log(2.0)));
@@ -374,8 +436,9 @@ void BL_ConvertActuators(char* maggiename,
else
sndobj->SetLoopMode(SND_LOOP_NORMAL);
}
- else
+ else {
sndobj->SetLoopMode(SND_LOOP_OFF);
+ }
if (soundact->sound->flags & SOUND_FLAGS_PRIORITY)
sndobj->SetHighPriority(true);
@@ -386,22 +449,30 @@ void BL_ConvertActuators(char* maggiename,
sndobj->Set3D(true);
else
sndobj->Set3D(false);
-
- KX_SoundActuator* tmpsoundact =
- new KX_SoundActuator(gameobj,
- sndobj,
- scene->GetSoundScene(), // needed for replication!
- soundActuatorType,
- startFrame,
- stopFrame);
-
- tmpsoundact->SetName(bact->name);
- baseact = tmpsoundact;
- soundscene->AddObject(sndobj);
- } else {
- std::cout << "WARNING: Sound actuator " << bact->name << " failed to load sample." << std::endl;
+ }
+ else {
+ /* dummy values for a NULL sound
+ * see editsound.c - defaults are unlikely to change soon */
+ sndobj->SetRollOffFactor(1.0);
+ sndobj->SetGain(1.0);
+ sndobj->SetPitch(1.0);
+ sndobj->SetLoopMode(SND_LOOP_OFF);
+ sndobj->SetHighPriority(false);
+ sndobj->Set3D(false);
}
}
+ KX_SoundActuator* tmpsoundact =
+ new KX_SoundActuator(gameobj,
+ sndobj,
+ scene->GetSoundScene(), // needed for replication!
+ soundActuatorType,
+ startFrame,
+ stopFrame);
+
+ tmpsoundact->SetName(bact->name);
+ baseact = tmpsoundact;
+ if (sndobj)
+ soundscene->AddObject(sndobj);
}
break;
}
@@ -467,7 +538,7 @@ void BL_ConvertActuators(char* maggiename,
case ACT_PROPERTY:
{
bPropertyActuator* propact = (bPropertyActuator*) bact->data;
- CValue* destinationObj = NULL;
+ SCA_IObject* destinationObj = NULL;
/*
here the destinationobject is searched. problem with multiple scenes: other scenes
@@ -503,14 +574,27 @@ void BL_ConvertActuators(char* maggiename,
// does the 'original' for replication exists, and
// is it in a non-active layer ?
- CValue* originalval = NULL;
- if (editobact->ob && !(editobact->ob->lay & activeLayerBitInfo))
- originalval = converter->FindGameObject(editobact->ob);
-
- MT_Vector3 linvelvec ( KX_BLENDERTRUNC(editobact->linVelocity[0]),
+ SCA_IObject* originalval = NULL;
+ if (editobact->ob)
+ {
+ if (editobact->ob->lay & activeLayerBitInfo)
+ {
+ fprintf(stderr, "Warning, object \"%s\" from AddObject actuator \"%s\" is not in a hidden layer.\n", objectname.Ptr(), uniquename.Ptr());
+ }
+ else {
+ originalval = converter->FindGameObject(editobact->ob);
+ }
+ }
+ MT_Vector3 linvelvec (
+ KX_BLENDERTRUNC(editobact->linVelocity[0]),
KX_BLENDERTRUNC(editobact->linVelocity[1]),
KX_BLENDERTRUNC(editobact->linVelocity[2]));
-
+
+ MT_Vector3 angvelvec (
+ KX_BLENDERTRUNC(editobact->angVelocity[0]),
+ KX_BLENDERTRUNC(editobact->angVelocity[1]),
+ KX_BLENDERTRUNC(editobact->angVelocity[2]));
+
KX_SCA_AddObjectActuator* tmpaddact =
new KX_SCA_AddObjectActuator(
gameobj,
@@ -518,7 +602,9 @@ void BL_ConvertActuators(char* maggiename,
editobact->time,
scene,
linvelvec.getValue(),
- editobact->localflag!=0
+ (editobact->localflag & ACT_EDOB_LOCAL_LINV)!=0,
+ angvelvec.getValue(),
+ (editobact->localflag & ACT_EDOB_LOCAL_ANGV)!=0
);
//editobact->ob to gameobj
@@ -569,6 +655,15 @@ void BL_ConvertActuators(char* maggiename,
blenderobject->upflag
);
baseact = tmptrackact;
+ break;
+ }
+ case ACT_EDOB_DYNAMICS:
+ {
+ KX_SCA_DynamicActuator* tmpdynact
+ = new KX_SCA_DynamicActuator(gameobj,
+ editobact->dyn_operation
+ );
+ baseact = tmpdynact;
}
}
break;
@@ -576,51 +671,141 @@ void BL_ConvertActuators(char* maggiename,
case ACT_CONSTRAINT:
{
float min = 0.0, max = 0.0;
+ char *prop = NULL;
KX_ConstraintActuator::KX_CONSTRAINTTYPE locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_NODEF;
bConstraintActuator *conact
= (bConstraintActuator*) bact->data;
/* convert settings... degrees in the ui become radians */
/* internally */
- switch (conact->flag) {
- case ACT_CONST_LOCX:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCX;
- min = conact->minloc[0];
- max = conact->maxloc[0];
- break;
- case ACT_CONST_LOCY:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCY;
- min = conact->minloc[1];
- max = conact->maxloc[1];
- break;
- case ACT_CONST_LOCZ:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCZ;
- min = conact->minloc[2];
- max = conact->maxloc[2];
- break;
- case ACT_CONST_ROTX:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTX;
- min = MT_2_PI * conact->minrot[0] / 360.0;
- max = MT_2_PI * conact->maxrot[0] / 360.0;
- break;
- case ACT_CONST_ROTY:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTY;
- min = MT_2_PI * conact->minrot[1] / 360.0;
- max = MT_2_PI * conact->maxrot[1] / 360.0;
- break;
- case ACT_CONST_ROTZ:
- locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTZ;
- min = MT_2_PI * conact->minrot[2] / 360.0;
- max = MT_2_PI * conact->maxrot[2] / 360.0;
- break;
- default:
- ; /* error */
+ if (conact->type == ACT_CONST_TYPE_ORI) {
+ min = (MT_2_PI * conact->minloc[0])/360.0;
+ max = (MT_2_PI * conact->maxloc[0])/360.0;
+ switch (conact->mode) {
+ case ACT_CONST_DIRPX:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIX;
+ break;
+ case ACT_CONST_DIRPY:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIY;
+ break;
+ case ACT_CONST_DIRPZ:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIZ;
+ break;
+ }
+ } else if (conact->type == ACT_CONST_TYPE_DIST) {
+ switch (conact->mode) {
+ case ACT_CONST_DIRPX:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPX;
+ min = conact->minloc[0];
+ max = conact->maxloc[0];
+ break;
+ case ACT_CONST_DIRPY:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPY;
+ min = conact->minloc[1];
+ max = conact->maxloc[1];
+ break;
+ case ACT_CONST_DIRPZ:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPZ;
+ min = conact->minloc[2];
+ max = conact->maxloc[2];
+ break;
+ case ACT_CONST_DIRNX:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNX;
+ min = conact->minloc[0];
+ max = conact->maxloc[0];
+ break;
+ case ACT_CONST_DIRNY:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNY;
+ min = conact->minloc[1];
+ max = conact->maxloc[1];
+ break;
+ case ACT_CONST_DIRNZ:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNZ;
+ min = conact->minloc[2];
+ max = conact->maxloc[2];
+ break;
+ }
+ prop = conact->matprop;
+ } else if (conact->type == ACT_CONST_TYPE_FH) {
+ switch (conact->mode) {
+ case ACT_CONST_DIRPX:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPX;
+ min = conact->minloc[0];
+ max = conact->maxloc[0];
+ break;
+ case ACT_CONST_DIRPY:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPY;
+ min = conact->minloc[1];
+ max = conact->maxloc[1];
+ break;
+ case ACT_CONST_DIRPZ:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHPZ;
+ min = conact->minloc[2];
+ max = conact->maxloc[2];
+ break;
+ case ACT_CONST_DIRNX:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNX;
+ min = conact->minloc[0];
+ max = conact->maxloc[0];
+ break;
+ case ACT_CONST_DIRNY:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNY;
+ min = conact->minloc[1];
+ max = conact->maxloc[1];
+ break;
+ case ACT_CONST_DIRNZ:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_FHNZ;
+ min = conact->minloc[2];
+ max = conact->maxloc[2];
+ break;
+ }
+ prop = conact->matprop;
+ } else {
+ switch (conact->flag) {
+ case ACT_CONST_LOCX:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCX;
+ min = conact->minloc[0];
+ max = conact->maxloc[0];
+ break;
+ case ACT_CONST_LOCY:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCY;
+ min = conact->minloc[1];
+ max = conact->maxloc[1];
+ break;
+ case ACT_CONST_LOCZ:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_LOCZ;
+ min = conact->minloc[2];
+ max = conact->maxloc[2];
+ break;
+ case ACT_CONST_ROTX:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTX;
+ min = MT_2_PI * conact->minrot[0] / 360.0;
+ max = MT_2_PI * conact->maxrot[0] / 360.0;
+ break;
+ case ACT_CONST_ROTY:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTY;
+ min = MT_2_PI * conact->minrot[1] / 360.0;
+ max = MT_2_PI * conact->maxrot[1] / 360.0;
+ break;
+ case ACT_CONST_ROTZ:
+ locrot = KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTZ;
+ min = MT_2_PI * conact->minrot[2] / 360.0;
+ max = MT_2_PI * conact->maxrot[2] / 360.0;
+ break;
+ default:
+ ; /* error */
+ }
}
KX_ConstraintActuator *tmpconact
= new KX_ConstraintActuator(gameobj,
- conact->damp,
- min,
- max,
- locrot);
+ conact->damp,
+ conact->rotdamp,
+ min,
+ max,
+ conact->maxrot,
+ locrot,
+ conact->time,
+ conact->flag,
+ prop);
baseact = tmpconact;
break;
}
@@ -678,15 +863,11 @@ void BL_ConvertActuators(char* maggiename,
break;
}
case ACT_SCENE_CAMERA:
+ mode = KX_SceneActuator::KX_SCENE_SET_CAMERA;
if (sceneact->camera)
{
- mode = KX_SceneActuator::KX_SCENE_SET_CAMERA;
cam = (KX_Camera*) converter->FindGameObject(sceneact->camera);
}
- else
- {
- // TODO:warn user
- }
break;
case ACT_SCENE_RESTART:
{
@@ -739,6 +920,16 @@ void BL_ConvertActuators(char* maggiename,
mode = KX_GameActuator::KX_GAME_QUIT;
break;
}
+ case ACT_GAME_SAVECFG:
+ {
+ mode = KX_GameActuator::KX_GAME_SAVECFG;
+ break;
+ }
+ case ACT_GAME_LOADCFG:
+ {
+ mode = KX_GameActuator::KX_GAME_LOADCFG;
+ break;
+ }
default:
; /* flag error */
}
@@ -825,15 +1016,129 @@ void BL_ConvertActuators(char* maggiename,
bVisibilityActuator *vis_act = (bVisibilityActuator *) bact->data;
KX_VisibilityActuator * tmp_vis_act = NULL;
bool v = ((vis_act->flag & ACT_VISIBILITY_INVISIBLE) != 0);
+ bool recursive = ((vis_act->flag & ACT_VISIBILITY_RECURSIVE) != 0);
- tmp_vis_act =
- new KX_VisibilityActuator(gameobj,
- !v);
+ tmp_vis_act = new KX_VisibilityActuator(gameobj, !v, recursive);
baseact = tmp_vis_act;
}
break;
+ case ACT_STATE:
+ {
+ bStateActuator *sta_act = (bStateActuator *) bact->data;
+ KX_StateActuator * tmp_sta_act = NULL;
+
+ tmp_sta_act =
+ new KX_StateActuator(gameobj, sta_act->type, sta_act->mask);
+
+ baseact = tmp_sta_act;
+ }
+ break;
+
+ case ACT_2DFILTER:
+ {
+ bTwoDFilterActuator *_2dfilter = (bTwoDFilterActuator*) bact->data;
+ SCA_2DFilterActuator *tmp = NULL;
+
+ RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode;
+ switch(_2dfilter->type)
+ {
+ case ACT_2DFILTER_MOTIONBLUR:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR;
+ break;
+ case ACT_2DFILTER_BLUR:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_BLUR;
+ break;
+ case ACT_2DFILTER_SHARPEN:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_SHARPEN;
+ break;
+ case ACT_2DFILTER_DILATION:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_DILATION;
+ break;
+ case ACT_2DFILTER_EROSION:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_EROSION;
+ break;
+ case ACT_2DFILTER_LAPLACIAN:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_LAPLACIAN;
+ break;
+ case ACT_2DFILTER_SOBEL:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_SOBEL;
+ break;
+ case ACT_2DFILTER_PREWITT:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_PREWITT;
+ break;
+ case ACT_2DFILTER_GRAYSCALE:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_GRAYSCALE;
+ break;
+ case ACT_2DFILTER_SEPIA:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_SEPIA;
+ break;
+ case ACT_2DFILTER_INVERT:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_INVERT;
+ break;
+ case ACT_2DFILTER_CUSTOMFILTER:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_CUSTOMFILTER;
+ break;
+ case ACT_2DFILTER_NOFILTER:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
+ break;
+ case ACT_2DFILTER_DISABLED:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_DISABLED;
+ break;
+ case ACT_2DFILTER_ENABLED:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_ENABLED;
+ break;
+ default:
+ filtermode = RAS_2DFilterManager::RAS_2DFILTER_NOFILTER;
+ break;
+ }
+
+ tmp = new SCA_2DFilterActuator(gameobj, filtermode, _2dfilter->flag,
+ _2dfilter->float_arg,_2dfilter->int_arg,ketsjiEngine->GetRasterizer(),rendertools);
+
+ if (_2dfilter->text)
+ {
+ char *buf;
+ // this is some blender specific code
+ buf = txt_to_buf(_2dfilter->text);
+ if (buf)
+ {
+ tmp->SetShaderText(STR_String(buf));
+ MEM_freeN(buf);
+ }
+ }
+
+ baseact = tmp;
+
+ }
+ break;
+ case ACT_PARENT:
+ {
+ bParentActuator *parAct = (bParentActuator *) bact->data;
+ int mode = KX_ParentActuator::KX_PARENT_NODEF;
+ KX_GameObject *tmpgob = NULL;
+
+ switch(parAct->type)
+ {
+ case ACT_PARENT_SET:
+ mode = KX_ParentActuator::KX_PARENT_SET;
+ tmpgob = converter->FindGameObject(parAct->ob);
+ break;
+ case ACT_PARENT_REMOVE:
+ mode = KX_ParentActuator::KX_PARENT_REMOVE;
+ tmpgob = NULL;
+ break;
+ }
+
+ KX_ParentActuator *tmpparact
+ = new KX_ParentActuator(gameobj,
+ mode,
+ tmpgob);
+ baseact = tmpparact;
+ break;
+ }
+
default:
; /* generate some error */
}
@@ -851,9 +1156,12 @@ void BL_ConvertActuators(char* maggiename,
gameobj->AddActuator(baseact);
converter->RegisterGameActuator(baseact, bact);
+ // done with baseact, release it
+ baseact->Release();
}
bact = bact->next;
}
}
+
diff --git a/source/gameengine/Converter/KX_ConvertControllers.cpp b/source/gameengine/Converter/KX_ConvertControllers.cpp
index a6ac2707db6..da490b4ee85 100644
--- a/source/gameengine/Converter/KX_ConvertControllers.cpp
+++ b/source/gameengine/Converter/KX_ConvertControllers.cpp
@@ -35,6 +35,10 @@
// Controller
#include "SCA_ANDController.h"
#include "SCA_ORController.h"
+#include "SCA_NANDController.h"
+#include "SCA_NORController.h"
+#include "SCA_XORController.h"
+#include "SCA_XNORController.h"
#include "SCA_PythonController.h"
#include "SCA_ExpressionController.h"
@@ -112,6 +116,30 @@ void BL_ConvertControllers(
LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
break;
}
+ case CONT_LOGIC_NAND:
+ {
+ gamecontroller = new SCA_NANDController(gameobj);
+ LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
+ break;
+ }
+ case CONT_LOGIC_NOR:
+ {
+ gamecontroller = new SCA_NORController(gameobj);
+ LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
+ break;
+ }
+ case CONT_LOGIC_XOR:
+ {
+ gamecontroller = new SCA_XORController(gameobj);
+ LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
+ break;
+ }
+ case CONT_LOGIC_XNOR:
+ {
+ gamecontroller = new SCA_XNORController(gameobj);
+ LinkControllerToActuators(gamecontroller,bcontr,logicmgr,converter);
+ break;
+ }
case CONT_EXPRESSION:
{
bExpressionCont* bexpcont = (bExpressionCont*) bcontr->data;
@@ -161,6 +189,7 @@ void BL_ConvertControllers(
if (gamecontroller)
{
gamecontroller->SetExecutePriority(executePriority++);
+ gamecontroller->SetState(bcontr->state_mask);
STR_String uniquename = bcontr->name;
uniquename += "#CONTR#";
uniqueint++;
@@ -171,6 +200,8 @@ void BL_ConvertControllers(
gameobj->AddController(gamecontroller);
converter->RegisterGameController(gamecontroller, bcontr);
+ //done with gamecontroller
+ gamecontroller->Release();
}
bcontr = bcontr->next;
diff --git a/source/gameengine/Converter/KX_ConvertProperties.cpp b/source/gameengine/Converter/KX_ConvertProperties.cpp
index 13fa5708e16..dfbc6f0c48d 100644
--- a/source/gameengine/Converter/KX_ConvertProperties.cpp
+++ b/source/gameengine/Converter/KX_ConvertProperties.cpp
@@ -102,8 +102,9 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan
// set a subproperty called 'timer' so that
// we can register the replica of this property
// at the time a game object is replicated (AddObjectActuator triggers this)
-
- timeval->SetProperty("timer",new CBoolValue(true));
+ CValue *bval = new CBoolValue(true);
+ timeval->SetProperty("timer",bval);
+ bval->Release();
if (isInActiveLayer)
{
timemgr->AddTimeProperty(timeval);
@@ -125,10 +126,16 @@ void BL_ConvertProperties(Object* object,KX_GameObject* gameobj,SCA_TimeEventMan
{
scene->AddDebugProperty(gameobj,STR_String(prop->name));
}
+ // done with propval, release it
+ propval->Release();
}
prop = prop->next;
}
-
-
+ // check if state needs to be debugged
+ if (object->scaflag & OB_DEBUGSTATE)
+ {
+ // reserve name for object state
+ scene->AddDebugProperty(gameobj,STR_String("__state__"));
+ }
}
diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp
index 1ac80df1ee7..4cf302b1f64 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.cpp
+++ b/source/gameengine/Converter/KX_ConvertSensors.cpp
@@ -65,6 +65,8 @@ probably misplaced */
#include "KX_MouseFocusSensor.h"
#include "SCA_JoystickSensor.h"
#include "KX_NetworkMessageSensor.h"
+#include "SCA_ActuatorSensor.h"
+#include "SCA_DelaySensor.h"
#include "SCA_PropertySensor.h"
@@ -91,6 +93,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
class KX_GameObject* gameobj,
SCA_LogicManager* logicmgr,
KX_Scene* kxscene,
+ KX_KetsjiEngine* kxengine,
SCA_IInputDevice* keydev,
int & executePriority,
int activeLayerBitInfo,
@@ -260,6 +263,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
bool neg_pulsemode = false;
int frequency = 0;
bool invert = false;
+ bool level = false;
while(sens)
{
@@ -272,7 +276,8 @@ void BL_ConvertSensors(struct Object* blenderobject,
frequency = sens->freq;
invert = !(sens->invert == 0);
-
+ level = !(sens->level == 0);
+
switch (sens->type)
{
case SENS_ALWAYS:
@@ -287,6 +292,22 @@ void BL_ConvertSensors(struct Object* blenderobject,
break;
}
+ case SENS_DELAY:
+ {
+ // we can reuse the Always event manager for the delay sensor
+ SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::ALWAYS_EVENTMGR);
+ if (eventmgr)
+ {
+ bDelaySensor* delaysensor = (bDelaySensor*)sens->data;
+ gamesensor = new SCA_DelaySensor(eventmgr,
+ gameobj,
+ delaysensor->delay,
+ delaysensor->duration,
+ (delaysensor->flag & SENS_DELAY_REPEAT) != 0);
+ }
+ break;
+ }
+
case SENS_COLLISION:
{
SCA_EventManager* eventmgr = logicmgr->FindEventManager(SCA_EventManager::TOUCH_EVENTMGR);
@@ -392,8 +413,9 @@ void BL_ConvertSensors(struct Object* blenderobject,
bool bFindMaterial = false;
PHY_IPhysicsController* physCtrl = kxscene->GetPhysicsEnvironment()->CreateSphereController(radius,pos);
- if (isInActiveLayer)
- kxscene->GetPhysicsEnvironment()->addSensor(physCtrl);
+ //will be done in KX_TouchEventManager::RegisterSensor()
+ //if (isInActiveLayer)
+ // kxscene->GetPhysicsEnvironment()->addSensor(physCtrl);
@@ -420,8 +442,8 @@ void BL_ConvertSensors(struct Object* blenderobject,
{
gamesensor = new SCA_KeyboardSensor(eventmgr,
gReverseKeyTranslateTable[blenderkeybdsensor->key],
- blenderkeybdsensor->qual,
- blenderkeybdsensor->qual2,
+ gReverseKeyTranslateTable[blenderkeybdsensor->qual],
+ gReverseKeyTranslateTable[blenderkeybdsensor->qual2],
(blenderkeybdsensor->type == SENS_ALL_KEYS),
blenderkeybdsensor->targetName,
blenderkeybdsensor->toggleName,
@@ -496,6 +518,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
trackfocus,
canvas,
kxscene,
+ kxengine,
gameobj);
}
} else {
@@ -544,6 +567,19 @@ void BL_ConvertSensors(struct Object* blenderobject,
break;
}
+ case SENS_ACTUATOR:
+ {
+ bActuatorSensor* blenderactsensor = (bActuatorSensor*) sens->data;
+ // we will reuse the property event manager, there is nothing special with this sensor
+ SCA_EventManager* eventmgr
+ = logicmgr->FindEventManager(SCA_EventManager::ACTUATOR_EVENTMGR);
+ if (eventmgr)
+ {
+ STR_String propname=blenderactsensor->name;
+ gamesensor = new SCA_ActuatorSensor(eventmgr,gameobj,propname);
+ }
+ break;
+ }
case SENS_RADAR:
{
@@ -608,6 +644,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
if (eventmgr)
{
bool bFindMaterial = (blenderraysensor->mode & SENS_COLLISION_MATERIAL);
+ bool bXRay = (blenderraysensor->mode & SENS_RAY_XRAY);
STR_String checkname = (bFindMaterial? blenderraysensor->matname : blenderraysensor->propname);
@@ -620,6 +657,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
gameobj,
checkname,
bFindMaterial,
+ bXRay,
distance,
axis,
kxscene);
@@ -656,7 +694,6 @@ void BL_ConvertSensors(struct Object* blenderobject,
int axis =0;
int axisf =0;
int button =0;
- int buttonf =0;
int hat =0;
int hatf =0;
int prec =0;
@@ -671,7 +708,6 @@ void BL_ConvertSensors(struct Object* blenderobject,
break;
case SENS_JOY_BUTTON:
button = bjoy->button;
- buttonf = bjoy->buttonf;
joysticktype = SCA_JoystickSensor::KX_JOYSENSORMODE_BUTTON;
break;
case SENS_JOY_HAT:
@@ -686,11 +722,13 @@ void BL_ConvertSensors(struct Object* blenderobject,
gamesensor = new SCA_JoystickSensor(
eventmgr,
gameobj,
+ bjoy->joyindex,
joysticktype,
axis,axisf,
prec,
- button,buttonf,
- hat,hatf);
+ button,
+ hat,hatf,
+ (bjoy->flag & SENS_JOY_ANY_EVENT));
}
else
{
@@ -719,25 +757,49 @@ void BL_ConvertSensors(struct Object* blenderobject,
neg_pulsemode,
frequency);
gamesensor->SetInvert(invert);
+ gamesensor->SetLevel(level);
gamesensor->SetName(STR_String(sens->name));
gameobj->AddSensor(gamesensor);
// only register to manager if it's in an active layer
-
- if (isInActiveLayer)
- gamesensor->RegisterToManager();
+ // Make registration dynamic: only when sensor is activated
+ //if (isInActiveLayer)
+ // gamesensor->RegisterToManager();
for (int i=0;i<sens->totlinks;i++)
{
bController* linkedcont = (bController*) sens->links[i];
- SCA_IController* gamecont = converter->FindGameController(linkedcont);
+ if (linkedcont) {
+ SCA_IController* gamecont = converter->FindGameController(linkedcont);
- if (gamecont) {
- logicmgr->RegisterToSensor(gamecont,gamesensor);
+ if (gamecont) {
+ logicmgr->RegisterToSensor(gamecont,gamesensor);
+ } else {
+ printf(
+ "Warning, sensor \"%s\" could not find its controller "
+ "(link %d of %d) from object \"%s\"\n"
+ "\tthere has been an error converting the blender controller for the game engine,"
+ "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2);
+ }
+ } else {
+ printf(
+ "Warning, sensor \"%s\" has lost a link to a controller "
+ "(link %d of %d) from object \"%s\"\n"
+ "\tpossible causes are partially appended objects or an error reading the file,"
+ "logic may be incorrect\n", sens->name, i+1, sens->totlinks, blenderobject->id.name+2);
}
}
+ // special case: Keyboard sensor with no link
+ // this combination is usually used for key logging.
+ if (sens->type == SENS_KEYBOARD && sens->totlinks == 0) {
+ // Force the registration so that the sensor runs
+ gamesensor->IncLink();
+ }
+
+ // done with gamesensor
+ gamesensor->Release();
}
sens=sens->next;
diff --git a/source/gameengine/Converter/KX_ConvertSensors.h b/source/gameengine/Converter/KX_ConvertSensors.h
index 73da51f47f0..b18ffc10a2a 100644
--- a/source/gameengine/Converter/KX_ConvertSensors.h
+++ b/source/gameengine/Converter/KX_ConvertSensors.h
@@ -33,6 +33,7 @@ void BL_ConvertSensors(struct Object* blenderobject,
class KX_GameObject* gameobj,
class SCA_LogicManager* logicmgr,
class KX_Scene* kxscene,
+ class KX_KetsjiEngine* kxengine,
class SCA_IInputDevice* keydev,
int & executePriority ,
int activeLayerBitInfo,
diff --git a/source/gameengine/Converter/KX_IpoConvert.cpp b/source/gameengine/Converter/KX_IpoConvert.cpp
index 4d1fb7323f3..ce004fa0504 100644
--- a/source/gameengine/Converter/KX_IpoConvert.cpp
+++ b/source/gameengine/Converter/KX_IpoConvert.cpp
@@ -36,6 +36,7 @@
#pragma warning (disable:4786)
#endif
+#include "BKE_material.h" /* give_current_material */
#include "KX_GameObject.h"
#include "KX_IpoConvert.h"
@@ -68,6 +69,8 @@
#include "SG_Node.h"
+#include "STR_HashedString.h"
+
static BL_InterpolatorList *GetIpoList(struct Ipo *for_ipo, KX_BlenderSceneConverter *converter) {
BL_InterpolatorList *ipoList= converter->FindInterpolatorList(for_ipo);
@@ -97,9 +100,9 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
ipocontr->GetIPOTransform().SetPosition(
MT_Point3(
- blenderobject->loc[0]+blenderobject->dloc[0],
- blenderobject->loc[1]+blenderobject->dloc[1],
- blenderobject->loc[2]+blenderobject->dloc[2]
+ blenderobject->loc[0]/*+blenderobject->dloc[0]*/,
+ blenderobject->loc[1]/*+blenderobject->dloc[1]*/,
+ blenderobject->loc[2]/*+blenderobject->dloc[2]*/
)
);
ipocontr->GetIPOTransform().SetEulerAngles(
@@ -131,7 +134,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetPosition()[0]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyPosition(true);
+ ipocontr->SetIPOChannelActive(OB_LOC_X, true);
}
@@ -142,7 +145,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetPosition()[1]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyPosition(true);
+ ipocontr->SetIPOChannelActive(OB_LOC_Y, true);
}
ipo = ipoList->GetScalarInterpolator(OB_LOC_Z);
@@ -152,7 +155,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetPosition()[2]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyPosition(true);
+ ipocontr->SetIPOChannelActive(OB_LOC_Z, true);
}
// Master the art of cut & paste programming...
@@ -164,7 +167,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetDeltaPosition()[0]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyPosition(true);
+ ipocontr->SetIPOChannelActive(OB_DLOC_X, true);
}
ipo = ipoList->GetScalarInterpolator(OB_DLOC_Y);
@@ -174,7 +177,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetDeltaPosition()[1]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyPosition(true);
+ ipocontr->SetIPOChannelActive(OB_DLOC_Y, true);
}
ipo = ipoList->GetScalarInterpolator(OB_DLOC_Z);
@@ -184,7 +187,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetDeltaPosition()[2]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyPosition(true);
+ ipocontr->SetIPOChannelActive(OB_DLOC_Z, true);
}
// Explore the finesse of reuse and slight modification
@@ -196,7 +199,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetEulerAngles()[0]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyOrientation(true);
+ ipocontr->SetIPOChannelActive(OB_ROT_X, true);
}
ipo = ipoList->GetScalarInterpolator(OB_ROT_Y);
if (ipo) {
@@ -205,7 +208,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetEulerAngles()[1]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyOrientation(true);
+ ipocontr->SetIPOChannelActive(OB_ROT_Y, true);
}
ipo = ipoList->GetScalarInterpolator(OB_ROT_Z);
if (ipo) {
@@ -214,7 +217,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetEulerAngles()[2]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyOrientation(true);
+ ipocontr->SetIPOChannelActive(OB_ROT_Z, true);
}
// Hmmm, the need for a macro comes to mind...
@@ -226,7 +229,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[0]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyOrientation(true);
+ ipocontr->SetIPOChannelActive(OB_DROT_X, true);
}
ipo = ipoList->GetScalarInterpolator(OB_DROT_Y);
if (ipo) {
@@ -235,7 +238,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[1]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyOrientation(true);
+ ipocontr->SetIPOChannelActive(OB_DROT_Y, true);
}
ipo = ipoList->GetScalarInterpolator(OB_DROT_Z);
if (ipo) {
@@ -244,7 +247,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetDeltaEulerAngles()[2]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyOrientation(true);
+ ipocontr->SetIPOChannelActive(OB_DROT_Z, true);
}
// Hang on, almost there...
@@ -256,7 +259,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetScaling()[0]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyScaling(true);
+ ipocontr->SetIPOChannelActive(OB_SIZE_X, true);
}
ipo = ipoList->GetScalarInterpolator(OB_SIZE_Y);
if (ipo) {
@@ -265,7 +268,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetScaling()[1]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyScaling(true);
+ ipocontr->SetIPOChannelActive(OB_SIZE_Y, true);
}
ipo = ipoList->GetScalarInterpolator(OB_SIZE_Z);
if (ipo) {
@@ -274,7 +277,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetScaling()[2]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyScaling(true);
+ ipocontr->SetIPOChannelActive(OB_SIZE_Z, true);
}
// The last few...
@@ -286,7 +289,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetDeltaScaling()[0]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyScaling(true);
+ ipocontr->SetIPOChannelActive(OB_DSIZE_X, true);
}
ipo = ipoList->GetScalarInterpolator(OB_DSIZE_Y);
if (ipo) {
@@ -295,7 +298,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetDeltaScaling()[1]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyScaling(true);
+ ipocontr->SetIPOChannelActive(OB_DSIZE_Y, true);
}
ipo = ipoList->GetScalarInterpolator(OB_DSIZE_Z);
if (ipo) {
@@ -304,7 +307,7 @@ void BL_ConvertIpos(struct Object* blenderobject,KX_GameObject* gameobj,KX_Blend
&(ipocontr->GetIPOTransform().GetDeltaScaling()[2]),
ipo);
ipocontr->AddInterpolator(interpolator);
- ipocontr->SetModifyScaling(true);
+ ipocontr->SetIPOChannelActive(OB_DSIZE_Z, true);
}
{
@@ -560,16 +563,15 @@ void BL_ConvertWorldIpos(struct World* blenderworld,KX_BlenderSceneConverter *co
}
}
-
-void BL_ConvertMaterialIpos(
- Material* blendermaterial,
+static void ConvertMaterialIpos(
+ Material* blendermaterial,
+ dword matname_hash,
KX_GameObject* gameobj,
KX_BlenderSceneConverter *converter
)
{
if (blendermaterial->ipo) {
-
- KX_MaterialIpoController* ipocontr = new KX_MaterialIpoController();
+ KX_MaterialIpoController* ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
@@ -596,7 +598,7 @@ void BL_ConvertMaterialIpos(
ipo = ipoList->GetScalarInterpolator(MA_COL_R);
if (ipo) {
if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController();
+ ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
@@ -610,7 +612,7 @@ void BL_ConvertMaterialIpos(
ipo = ipoList->GetScalarInterpolator(MA_COL_G);
if (ipo) {
if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController();
+ ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
@@ -624,7 +626,7 @@ void BL_ConvertMaterialIpos(
ipo = ipoList->GetScalarInterpolator(MA_COL_B);
if (ipo) {
if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController();
+ ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
@@ -638,7 +640,7 @@ void BL_ConvertMaterialIpos(
ipo = ipoList->GetScalarInterpolator(MA_ALPHA);
if (ipo) {
if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController();
+ ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
@@ -653,7 +655,7 @@ void BL_ConvertMaterialIpos(
ipo = ipoList->GetScalarInterpolator(MA_SPEC_R );
if (ipo) {
if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController();
+ ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
@@ -667,7 +669,7 @@ void BL_ConvertMaterialIpos(
ipo = ipoList->GetScalarInterpolator(MA_SPEC_G);
if (ipo) {
if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController();
+ ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
@@ -681,7 +683,7 @@ void BL_ConvertMaterialIpos(
ipo = ipoList->GetScalarInterpolator(MA_SPEC_B);
if (ipo) {
if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController();
+ ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
@@ -696,7 +698,7 @@ void BL_ConvertMaterialIpos(
ipo = ipoList->GetScalarInterpolator(MA_HARD);
if (ipo) {
if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController();
+ ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
@@ -710,7 +712,7 @@ void BL_ConvertMaterialIpos(
ipo = ipoList->GetScalarInterpolator(MA_SPEC);
if (ipo) {
if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController();
+ ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
@@ -725,7 +727,7 @@ void BL_ConvertMaterialIpos(
ipo = ipoList->GetScalarInterpolator(MA_REF);
if (ipo) {
if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController();
+ ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
@@ -739,7 +741,7 @@ void BL_ConvertMaterialIpos(
ipo = ipoList->GetScalarInterpolator(MA_EMIT);
if (ipo) {
if (!ipocontr) {
- ipocontr = new KX_MaterialIpoController();
+ ipocontr = new KX_MaterialIpoController(matname_hash);
gameobj->GetSGNode()->AddSGController(ipocontr);
ipocontr->SetObject(gameobj->GetSGNode());
}
@@ -752,3 +754,31 @@ void BL_ConvertMaterialIpos(
}
}
+void BL_ConvertMaterialIpos(
+ struct Object* blenderobject,
+ KX_GameObject* gameobj,
+ KX_BlenderSceneConverter *converter
+ )
+{
+ if (blenderobject->totcol==1)
+ {
+ Material *mat = give_current_material(blenderobject, 1);
+ // if there is only one material attached to the mesh then set material_index in BL_ConvertMaterialIpos to NULL
+ // --> this makes the UpdateMaterialData function in KX_GameObject.cpp use the old hack of using SetObjectColor
+ // because this yields a better performance as not all the vertex colors need to be edited
+ if(mat) ConvertMaterialIpos(mat, 0, gameobj, converter);
+ }
+ else
+ {
+ for (int material_index=1; material_index <= blenderobject->totcol; material_index++)
+ {
+ Material *mat = give_current_material(blenderobject, material_index);
+ STR_HashedString matname;
+ if(mat) {
+ matname= mat->id.name;
+ ConvertMaterialIpos(mat, matname.hash(), gameobj, converter);
+ }
+ }
+ }
+}
+
diff --git a/source/gameengine/Converter/KX_IpoConvert.h b/source/gameengine/Converter/KX_IpoConvert.h
index afcb1b22821..4ec9bd31062 100644
--- a/source/gameengine/Converter/KX_IpoConvert.h
+++ b/source/gameengine/Converter/KX_IpoConvert.h
@@ -46,7 +46,7 @@ void BL_ConvertCameraIpos(struct Camera* blendercamera,
class KX_GameObject* cameraobj,
class KX_BlenderSceneConverter *converter);
-void BL_ConvertMaterialIpos(struct Material* blendermaterial,
+void BL_ConvertMaterialIpos(struct Object* blenderobject,
class KX_GameObject* materialobj,
class KX_BlenderSceneConverter *converter);
diff --git a/source/gameengine/Converter/Makefile b/source/gameengine/Converter/Makefile
index 4a76b661d4f..938994e8b62 100644
--- a/source/gameengine/Converter/Makefile
+++ b/source/gameengine/Converter/Makefile
@@ -52,6 +52,7 @@ CPPFLAGS += -I../../blender/editors/include
CPPFLAGS += -I../../blender/blenlib
CPPFLAGS += -I../../blender/blenkernel
CPPFLAGS += -I../../blender/render/extern/include
+CPPFLAGS += -I../../blender/gpu
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
CPPFLAGS += -I../Expressions -I../Rasterizer -I../GameLogic
CPPFLAGS += -I../Ketsji -I../BlenderRoutines -I../SceneGraph
diff --git a/source/gameengine/Converter/SConscript b/source/gameengine/Converter/SConscript
index a63881f3ef0..434fad0f544 100644
--- a/source/gameengine/Converter/SConscript
+++ b/source/gameengine/Converter/SConscript
@@ -16,7 +16,7 @@ incs += ' #source/gameengine/Expressions #source/gameengine/Network #source/game
incs += ' #source/gameengine/Physics/common #source/gameengine/Physics/Bullet #source/gameengine/Physics/BlOde'
incs += ' #source/gameengine/Physics/Dummy #source/gameengine/Physics/Sumo'
incs += ' #source/gameengine/Physics/Sumo/Fuzzics/include #source/gameengine/Network/LoopBackNetwork'
-incs += ' #source/blender/misc #source/blender/blenloader'
+incs += ' #source/blender/misc #source/blender/blenloader #source/blender/gpu'
incs += ' #source/blender/windowmanager'
incs += ' ' + env['BF_PYTHON_INC']
diff --git a/source/gameengine/Expressions/Expression.cpp b/source/gameengine/Expressions/Expression.cpp
index 5c5e1abea34..f16f572c322 100644
--- a/source/gameengine/Expressions/Expression.cpp
+++ b/source/gameengine/Expressions/Expression.cpp
@@ -22,7 +22,9 @@
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
-
+#ifdef _DEBUG
+//int gRefCountExpr;
+#endif
CExpression::CExpression()// : m_cached_calculate(NULL)
{
m_refcount = 1;
diff --git a/source/gameengine/Expressions/InputParser.cpp b/source/gameengine/Expressions/InputParser.cpp
index 24033dd21a2..32a9de32e21 100644
--- a/source/gameengine/Expressions/InputParser.cpp
+++ b/source/gameengine/Expressions/InputParser.cpp
@@ -631,7 +631,8 @@ void CParser::SetContext(CValue* context)
PyObject* CParserPyMake(PyObject* ignored,PyObject* args)
{
char* txt;
- Py_Try(PyArg_ParseTuple(args,"s",&txt));
+ if (!PyArg_ParseTuple(args,"s",&txt))
+ return NULL;
CParser parser;
CExpression* expr = parser.ProcessText(txt);
CValue* val = expr->Calculate();
@@ -641,7 +642,7 @@ PyObject* CParserPyMake(PyObject* ignored,PyObject* args)
static PyMethodDef CParserMethods[] =
{
- { "calc", CParserPyMake , Py_NEWARGS},
+ { "calc", CParserPyMake , METH_VARARGS},
{ NULL,NULL} // Sentinel
};
diff --git a/source/gameengine/Expressions/ListValue.cpp b/source/gameengine/Expressions/ListValue.cpp
index bbf58a8a06e..9ffdbb1223c 100644
--- a/source/gameengine/Expressions/ListValue.cpp
+++ b/source/gameengine/Expressions/ListValue.cpp
@@ -43,7 +43,7 @@ PyObject* listvalue_buffer_item(PyObject* list,Py_ssize_t index)
return ((CListValue*) list)->GetValue(index)->AddRef();
}
- Py_Error(PyExc_IndexError, "Python ListIndex out of range");
+ PyErr_SetString(PyExc_IndexError, "Python ListIndex out of range");
return NULL;
}
@@ -130,9 +130,10 @@ listvalue_buffer_concat(PyObject * self, PyObject * other)
}
}
- if (error)
- Py_Error(PyExc_SystemError, "Python Error: couldn't add one or more items to a list");
-
+ if (error) {
+ PyErr_SetString(PyExc_SystemError, "Python Error: couldn't add one or more items to a list");
+ return NULL;
+ }
} else
{
@@ -155,8 +156,8 @@ listvalue_buffer_concat(PyObject * self, PyObject * other)
listval->Add(objval);
} else
{
- Py_Error(PyExc_SystemError, "Python Error: couldn't add item to a list");
- // bad luck
+ PyErr_SetString(PyExc_SystemError, "Python Error: couldn't add item to a list");
+ return NULL;
}
}
}
diff --git a/source/gameengine/Expressions/Makefile b/source/gameengine/Expressions/Makefile
index e9c02eedcf2..6736149bbcd 100644
--- a/source/gameengine/Expressions/Makefile
+++ b/source/gameengine/Expressions/Makefile
@@ -36,6 +36,7 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
+CPPFLAGS += -I../../blender/makesdna
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
diff --git a/source/gameengine/Expressions/PyObjectPlus.cpp b/source/gameengine/Expressions/PyObjectPlus.cpp
index aabcd6cb71d..1eca527151a 100644
--- a/source/gameengine/Expressions/PyObjectPlus.cpp
+++ b/source/gameengine/Expressions/PyObjectPlus.cpp
@@ -94,7 +94,7 @@ PyObjectPlus::PyObjectPlus(PyTypeObject *T) // constructor
* PyObjectPlus Methods -- Every class, even the abstract one should have a Methods
------------------------------*/
PyMethodDef PyObjectPlus::Methods[] = {
- {"isA", (PyCFunction) sPy_isA, Py_NEWARGS},
+ {"isA", (PyCFunction) sPy_isA, METH_VARARGS},
{NULL, NULL} /* Sentinel */
};
@@ -119,6 +119,7 @@ PyObject *PyObjectPlus::_getattr(const STR_String& attr)
int PyObjectPlus::_delattr(const STR_String& attr)
{
+ PyErr_SetString(PyExc_AttributeError, "attribute cant be deleted");
return 1;
}
@@ -126,7 +127,8 @@ int PyObjectPlus::_setattr(const STR_String& attr, PyObject *value)
{
//return PyObject::_setattr(attr,value);
//cerr << "Unknown attribute" << endl;
- return 1;
+ PyErr_SetString(PyExc_AttributeError, "attribute cant be set");
+ return 1;
}
/*------------------------------
@@ -134,7 +136,8 @@ int PyObjectPlus::_setattr(const STR_String& attr, PyObject *value)
------------------------------*/
PyObject *PyObjectPlus::_repr(void)
{
- Py_Error(PyExc_SystemError, "Representation not overridden by object.");
+ PyErr_SetString(PyExc_SystemError, "Representation not overridden by object.");
+ return NULL;
}
/*------------------------------
@@ -164,11 +167,12 @@ bool PyObjectPlus::isA(const char *mytypename) // check typename of each parent
PyObject *PyObjectPlus::Py_isA(PyObject *args) // Python wrapper for isA
{
char *mytypename;
- Py_Try(PyArg_ParseTuple(args, "s", &mytypename));
+ if (!PyArg_ParseTuple(args, "s", &mytypename))
+ return NULL;
if(isA(mytypename))
- {Py_INCREF(Py_True); return Py_True;}
+ Py_RETURN_TRUE;
else
- {Py_INCREF(Py_False); return Py_False;};
+ Py_RETURN_FALSE;
}
#endif //NO_EXP_PYTHON_EMBEDDING
diff --git a/source/gameengine/Expressions/PyObjectPlus.h b/source/gameengine/Expressions/PyObjectPlus.h
index de89ed9b5c8..3a054454a0b 100644
--- a/source/gameengine/Expressions/PyObjectPlus.h
+++ b/source/gameengine/Expressions/PyObjectPlus.h
@@ -43,25 +43,39 @@
* Python defines
------------------------------*/
+/*
+ Py_RETURN_NONE
+ Python 2.4 macro.
+ defined here until we switch to 2.4
+ also in api2_2x/gen_utils.h
+*/
+#ifndef Py_RETURN_NONE
+#define Py_RETURN_NONE return Py_BuildValue("O", Py_None)
+#endif
+#ifndef Py_RETURN_FALSE
+#define Py_RETURN_FALSE return PyBool_FromLong(0)
+#endif
+#ifndef Py_RETURN_TRUE
+#define Py_RETURN_TRUE return PyBool_FromLong(1)
+#endif
+
+/* for pre Py 2.5 */
+#if PY_VERSION_HEX < 0x02050000
+typedef int Py_ssize_t;
+#define PY_SSIZE_T_MAX INT_MAX
+#define PY_SSIZE_T_MIN INT_MIN
+#define PY_METHODCHAR char *
+#else
+/* Py 2.5 and later */
+#define intargfunc ssizeargfunc
+#define intintargfunc ssizessizeargfunc
+#define PY_METHODCHAR const char *
+#endif
+
// some basic python macros
-#define Py_NEWARGS 1
#define Py_Return { Py_INCREF(Py_None); return Py_None;}
-static inline PyObject* Py_Success(bool truth)
-{
- if (truth)
- {
- Py_INCREF(Py_True);
- return Py_True;
- }
- Py_INCREF(Py_False);
- return Py_False;
-}
-
-#define Py_Error(E, M) {PyErr_SetString(E, M); return NULL;}
-#define Py_Try(F) {if (!(F)) return NULL;}
-#define Py_Assert(A,E,M) {if (!(A)) {PyErr_SetString(E, M); return NULL;}}
-static inline void Py_Fatal(char *M) {
+static inline void Py_Fatal(const char *M) {
//cout << M << endl;
exit(-1);
};
@@ -76,18 +90,36 @@ static inline void Py_Fatal(char *M) {
virtual PyTypeObject *GetType(void) {return &Type;}; \
virtual PyParentObject *GetParents(void) {return Parents;}
+
// This defines the _getattr_up macro
// which allows attribute and method calls
// to be properly passed up the hierarchy.
#define _getattr_up(Parent) \
- PyObject *rvalue = Py_FindMethod(Methods, this, const_cast<char*>(attr.ReadPtr())); \
- if (rvalue == NULL) \
- { \
+ PyObject *rvalue = NULL; \
+ if (attr=="__methods__") { \
+ PyObject *_attr_string = NULL; \
+ PyMethodDef *meth = Methods; \
+ rvalue = Parent::_getattr(attr); \
+ if (rvalue==NULL) { \
+ PyErr_Clear(); \
+ rvalue = PyList_New(0); \
+ } \
+ if (meth) { \
+ for (; meth->ml_name != NULL; meth++) { \
+ _attr_string = PyString_FromString(meth->ml_name); \
+ PyList_Append(rvalue, _attr_string); \
+ Py_DECREF(_attr_string); \
+ } \
+ } \
+ } else { \
+ rvalue = Py_FindMethod(Methods, this, const_cast<char*>(attr.ReadPtr())); \
+ if (rvalue == NULL) { \
PyErr_Clear(); \
- return Parent::_getattr(attr); \
+ rvalue = Parent::_getattr(attr); \
} \
- else \
- return rvalue
+ } \
+ return rvalue; \
+
/**
* These macros are helpfull when embedding Python routines. The second
@@ -99,27 +131,73 @@ static inline void Py_Fatal(char *M) {
return ((class_name*) self)->Py##method_name(self, args, kwds); \
}; \
+#define KX_PYMETHOD_VARARGS(class_name, method_name) \
+ PyObject* Py##method_name(PyObject* self, PyObject* args); \
+ static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \
+ return ((class_name*) self)->Py##method_name(self, args); \
+ }; \
+
+#define KX_PYMETHOD_NOARGS(class_name, method_name) \
+ PyObject* Py##method_name(PyObject* self); \
+ static PyObject* sPy##method_name( PyObject* self) { \
+ return ((class_name*) self)->Py##method_name(self); \
+ }; \
+
+#define KX_PYMETHOD_O(class_name, method_name) \
+ PyObject* Py##method_name(PyObject* self, PyObject* value); \
+ static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
+ return ((class_name*) self)->Py##method_name(self, value); \
+ }; \
+
#define KX_PYMETHOD_DOC(class_name, method_name) \
PyObject* Py##method_name(PyObject* self, PyObject* args, PyObject* kwds); \
static PyObject* sPy##method_name( PyObject* self, PyObject* args, PyObject* kwds) { \
return ((class_name*) self)->Py##method_name(self, args, kwds); \
}; \
- static char method_name##_doc[]; \
+ static const char method_name##_doc[]; \
+
+#define KX_PYMETHOD_DOC_VARARGS(class_name, method_name) \
+ PyObject* Py##method_name(PyObject* self, PyObject* args); \
+ static PyObject* sPy##method_name( PyObject* self, PyObject* args) { \
+ return ((class_name*) self)->Py##method_name(self, args); \
+ }; \
+ static const char method_name##_doc[]; \
+
+#define KX_PYMETHOD_DOC_O(class_name, method_name) \
+ PyObject* Py##method_name(PyObject* self, PyObject* value); \
+ static PyObject* sPy##method_name( PyObject* self, PyObject* value) { \
+ return ((class_name*) self)->Py##method_name(self, value); \
+ }; \
+ static const char method_name##_doc[]; \
+
+#define KX_PYMETHOD_DOC_NOARGS(class_name, method_name) \
+ PyObject* Py##method_name(PyObject* self); \
+ static PyObject* sPy##method_name( PyObject* self) { \
+ return ((class_name*) self)->Py##method_name(self); \
+ }; \
+ static const char method_name##_doc[]; \
+
/* The line above should remain empty */
/**
* Method table macro (with doc)
*/
#define KX_PYMETHODTABLE(class_name, method_name) \
- {#method_name , (PyCFunction) class_name::sPy##method_name, METH_VARARGS, class_name::method_name##_doc}
+ {#method_name , (PyCFunction) class_name::sPy##method_name, METH_VARARGS, (PY_METHODCHAR)class_name::method_name##_doc}
+
+#define KX_PYMETHODTABLE_NOARG(class_name, method_name) \
+ {#method_name , (PyCFunction) class_name::sPy##method_name, METH_NOARGS, (PY_METHODCHAR)class_name::method_name##_doc}
/**
* Function implementation macro
*/
#define KX_PYMETHODDEF_DOC(class_name, method_name, doc_string) \
-char class_name::method_name##_doc[] = doc_string; \
+const char class_name::method_name##_doc[] = doc_string; \
PyObject* class_name::Py##method_name(PyObject*, PyObject* args, PyObject*)
+#define KX_PYMETHODDEF_DOC_NOARG(class_name, method_name, doc_string) \
+const char class_name::method_name##_doc[] = doc_string; \
+PyObject* class_name::Py##method_name(PyObject*)
/*------------------------------
* PyObjectPlus
diff --git a/source/gameengine/Expressions/Value.cpp b/source/gameengine/Expressions/Value.cpp
index 48898dfc1f5..7296dfbec10 100644
--- a/source/gameengine/Expressions/Value.cpp
+++ b/source/gameengine/Expressions/Value.cpp
@@ -158,18 +158,38 @@ PyParentObject CValue::Parents[] = {
};
PyMethodDef CValue::Methods[] = {
-// { "printHello", (PyCFunction) CValue::sPyPrintHello, Py_NEWARGS},
- { "getName", (PyCFunction) CValue::sPyGetName, Py_NEWARGS},
+// { "printHello", (PyCFunction) CValue::sPyPrintHello, METH_VARARGS},
+ { "getName", (PyCFunction) CValue::sPyGetName, METH_NOARGS},
{NULL,NULL} //Sentinel
};
-PyObject* CValue::PyGetName(PyObject* self,PyObject* args,PyObject* kwds)
+PyObject* CValue::PyGetName(PyObject* self)
{
- PyObject* pyname = PyString_FromString(this->GetName());
- return pyname;
+ return PyString_FromString(this->GetName());
}
+/*#define CVALUE_DEBUG*/
+#ifdef CVALUE_DEBUG
+int gRefCount;
+struct SmartCValueRef
+{
+ CValue *m_ref;
+ int m_count;
+ SmartCValueRef(CValue *ref)
+ {
+ m_ref = ref;
+ m_count = gRefCount++;
+ }
+};
+
+#include <vector>
+std::vector<SmartCValueRef> gRefList;
+#endif
+
+#ifdef _DEBUG
+//int gRefCountValue;
+#endif
CValue::CValue(PyTypeObject *T)
: PyObjectPlus(T),
@@ -186,6 +206,12 @@ effect: constucts a CValue
*/
{
//debug(gRefCountValue++) // debugging
+#ifdef _DEBUG
+ //gRefCountValue++;
+#ifdef CVALUE_DEBUG
+ gRefList.push_back(SmartCValueRef(this));
+#endif
+#endif
}
@@ -199,6 +225,18 @@ effect: deletes the object
ClearProperties();
assertd (m_refcount==0);
+#ifdef CVALUE_DEBUG
+ std::vector<SmartCValueRef>::iterator it;
+ for (it=gRefList.begin(); it!=gRefList.end(); it++)
+ {
+ if (it->m_ref == this)
+ {
+ *it = gRefList.back();
+ gRefList.pop_back();
+ break;
+ }
+ }
+#endif
}
@@ -293,7 +331,7 @@ void CValue::SetProperty(const STR_String & name,CValue* ioProperty)
}
// Add property at end of array
- (*m_pNamedPropertyArray)[name] = ioProperty;//->Add(ioProperty);
+ (*m_pNamedPropertyArray)[name] = ioProperty->AddRef();//->Add(ioProperty);
}
@@ -353,17 +391,40 @@ float CValue::GetPropertyNumber(const STR_String& inName,float defnumber)
bool CValue::RemoveProperty(const STR_String & inName)
{
// Check if there are properties at all which can be removed
- if (m_pNamedPropertyArray == NULL)
- return false;
-
- // Scan all properties, as soon as we find one with <inName> -> Remove it
-// CValue* val = (*m_pNamedPropertyArray)[inName];
- if (m_pNamedPropertyArray->erase(inName)) return true;
+ if (m_pNamedPropertyArray) {
+ CValue* val = GetProperty(inName);
+ if (NULL != val)
+ {
+ val->Release();
+ m_pNamedPropertyArray->erase(inName);
+ return true;
+ }
+ }
+ char err[128];
+ if (m_pNamedPropertyArray)
+ sprintf(err, "attribute \"%s\" dosnt exist", inName.ReadPtr());
+ else
+ sprintf(err, "attribute \"%s\" dosnt exist (no property array)", inName.ReadPtr());
+
+ PyErr_SetString(PyExc_AttributeError, err);
return false;
}
-
+//
+// Get Property Names
+//
+vector<STR_String> CValue::GetPropertyNames()
+{
+ vector<STR_String> result;
+ if(!m_pNamedPropertyArray) return result;
+ for ( std::map<STR_String,CValue*>::iterator it = m_pNamedPropertyArray->begin();
+ !(it == m_pNamedPropertyArray->end());it++)
+ {
+ result.push_back((*it).first);
+ }
+ return result;
+}
//
// Clear all properties
@@ -379,7 +440,7 @@ void CValue::ClearProperties()
!(it == m_pNamedPropertyArray->end());it++)
{
CValue* tmpval = (*it).second;
- STR_String name = (*it).first;
+ //STR_String name = (*it).first;
tmpval->Release();
}
@@ -469,19 +530,15 @@ void CValue::CloneProperties(CValue *replica)
for ( std::map<STR_String,CValue*>::iterator it = m_pNamedPropertyArray->begin();
!(it == m_pNamedPropertyArray->end());it++)
{
-
- replica->SetProperty((*it).first,(*it).second->GetReplica());
+ CValue *val = (*it).second->GetReplica();
+ replica->SetProperty((*it).first,val);
+ val->Release();
}
}
}
-
-
-
-
-
double* CValue::GetVector3(bool bGetTransformedVec)
{
assertd(false); // don;t get vector from me
@@ -489,10 +546,6 @@ double* CValue::GetVector3(bool bGetTransformedVec)
}
-
-
-
-
/*---------------------------------------------------------------------------------------------------------------------
Reference Counting
---------------------------------------------------------------------------------------------------------------------*/
@@ -504,6 +557,9 @@ CValue *CValue::AddRef()
// Increase global reference count, used to see at the end of the program
// if all CValue-derived classes have been dereferenced to 0
//debug(gRefCountValue++);
+#ifdef _DEBUG
+ //gRefCountValue++;
+#endif
m_refcount++;
return this;
}
@@ -518,7 +574,9 @@ int CValue::Release()
// Decrease global reference count, used to see at the end of the program
// if all CValue-derived classes have been dereferenced to 0
//debug(gRefCountValue--);
-
+#ifdef _DEBUG
+ //gRefCountValue--;
+#endif
// Decrease local reference count, if it reaches 0 the object should be freed
if (--m_refcount > 0)
{
@@ -546,6 +604,9 @@ void CValue::DisableRefCount()
m_refcount--;
//debug(gRefCountValue--);
+#ifdef _DEBUG
+ //gRefCountValue--;
+#endif
m_ValFlags.RefCountDisabled=true;
}
@@ -590,11 +651,14 @@ CValue* CValue::FindIdentifier(const STR_String& identifiername)
} else
{
result = GetProperty(identifiername);
+ if (result)
+ return result->AddRef();
+ }
+ if (!result)
+ {
+ // warning here !!!
+ result = new CErrorValue(identifiername+" not found");
}
- if (result)
- return result->AddRef();
- // warning here !!!
- result = new CErrorValue(identifiername+" not found");
return result;
}
@@ -604,7 +668,7 @@ CValue* CValue::FindIdentifier(const STR_String& identifiername)
static PyMethodDef CValueMethods[] =
{
- //{ "new", CValue::PyMake , Py_NEWARGS},
+ //{ "new", CValue::PyMake , METH_VARARGS},
{ NULL,NULL} // Sentinel
};
@@ -642,9 +706,7 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
CValue* vallie = NULL;
- PyTypeObject* type = pyobj->ob_type;
-
- if (type == &PyList_Type)
+ if (PyList_Check(pyobj))
{
CListValue* listval = new CListValue();
bool error = false;
@@ -674,26 +736,25 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
}
} else
- if (type == &PyFloat_Type)
+ if (PyFloat_Check(pyobj))
{
- float fl;
- PyArg_Parse(pyobj,"f",&fl);
- vallie = new CFloatValue(fl);
+ vallie = new CFloatValue( (float)PyFloat_AsDouble(pyobj) );
} else
- if (type==&PyInt_Type)
+ if (PyInt_Check(pyobj))
{
- int innie;
- PyArg_Parse(pyobj,"i",&innie);
- vallie = new CIntValue(innie);
+ vallie = new CIntValue( (int)PyInt_AS_LONG(pyobj) );
} else
-
- if (type==&PyString_Type)
+ if (PyString_Check(pyobj))
{
vallie = new CStringValue(PyString_AsString(pyobj),"");
} else
- if (type==&CValue::Type || type==&CListValue::Type)
+ if (pyobj->ob_type==&CValue::Type || pyobj->ob_type==&CListValue::Type)
{
vallie = ((CValue*) pyobj)->AddRef();
+ } else
+ {
+ /* return an error value from the caller */
+ PyErr_SetString(PyExc_TypeError, "This python value could not be assigned to a game engine property");
}
return vallie;
@@ -701,7 +762,8 @@ CValue* CValue::ConvertPythonToValue(PyObject* pyobj)
int CValue::_delattr(const STR_String& attr)
{
- RemoveProperty(attr);
+ if (!RemoveProperty(attr)) /* sets error */
+ return 1;
return 0;
}
@@ -717,21 +779,42 @@ int CValue::_setattr(const STR_String& attr,PyObject* pyobj)
oldprop->SetValue(vallie);
} else
{
- SetProperty(attr,vallie->AddRef());
+ SetProperty(attr,vallie);
}
vallie->Release();
+ } else
+ {
+ return 1; /* ConvertPythonToValue sets the error message */
}
//PyObjectPlus::_setattr(attr,value);
return 0;
};
+
+PyObject* CValue::ConvertKeysToPython( void )
+{
+ PyObject *pylist = PyList_New( 0 );
+ PyObject *pystr;
+
+ if (m_pNamedPropertyArray)
+ {
+ for ( std::map<STR_String,CValue*>::iterator it = m_pNamedPropertyArray->begin();
+ !(it == m_pNamedPropertyArray->end());it++)
+ {
+ pystr = PyString_FromString( (*it).first );
+ PyList_Append(pylist, pystr);
+ Py_DECREF( pystr );
+ }
+ }
+ return pylist;
+}
+
/*
PyObject* CValue::PyMake(PyObject* ignored,PyObject* args)
{
- //Py_Try(PyArg_ParseTuple(args,"s",&name));
- Py_INCREF(Py_None);
- return Py_None;//new CValue();
+ //if (!PyArg_ParseTuple(args,"s",&name)) return NULL;
+ Py_RETURN_NONE;//new CValue();
}
*/
diff --git a/source/gameengine/Expressions/Value.h b/source/gameengine/Expressions/Value.h
index ccb9c34749d..74fcdae5756 100644
--- a/source/gameengine/Expressions/Value.h
+++ b/source/gameengine/Expressions/Value.h
@@ -253,7 +253,9 @@ public:
virtual int _delattr(const STR_String& attr);
virtual int _setattr(const STR_String& attr,PyObject* value);
- KX_PYMETHOD(CValue,GetName);
+ virtual PyObject* ConvertKeysToPython( void );
+
+ KX_PYMETHOD_NOARGS(CValue,GetName);
#else
CValue();
@@ -284,6 +286,7 @@ public:
STR_String GetPropertyText(const STR_String & inName,const STR_String& deftext=""); // Get text description of property with name <inName>, returns an empty string if there is no property named <inName>
float GetPropertyNumber(const STR_String& inName,float defnumber);
virtual bool RemoveProperty(const STR_String & inName); // Remove the property named <inName>, returns true if the property was succesfully removed, false if property was not found or could not be removed
+ virtual vector<STR_String> GetPropertyNames();
virtual void ClearProperties(); // Clear all properties
virtual void SetPropertiesModified(bool inModified); // Set all properties' modified flag to <inModified>
diff --git a/source/gameengine/GameLogic/CMakeLists.txt b/source/gameengine/GameLogic/CMakeLists.txt
index 6af37b746da..a7519196d50 100644
--- a/source/gameengine/GameLogic/CMakeLists.txt
+++ b/source/gameengine/GameLogic/CMakeLists.txt
@@ -32,6 +32,7 @@ SET(INC
../../../intern/string
../../../source/gameengine/Expressions
../../../intern/moto/include
+ ../../../source/gameengine/Rasterizer
${PYTHON_INC}
${SDL_INC}
)
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
index aa5fc9eb8f3..e8e29fb2769 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.cpp
@@ -24,14 +24,18 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
+#ifndef DISABLE_SDL
#include <SDL.h>
+#endif
+
+#include <stdio.h>
#include "SCA_Joystick.h"
#include "SCA_JoystickPrivate.h"
-
-SCA_Joystick::SCA_Joystick()
+SCA_Joystick::SCA_Joystick(short int index)
:
+ m_joyindex(index),
m_axis10(0),
m_axis11(0),
m_axis20(0),
@@ -40,78 +44,100 @@ SCA_Joystick::SCA_Joystick()
m_buttonnum(-2),
m_hatdir(-2),
m_isinit(0),
- m_istrig(0)
+ m_istrig_axis(0),
+ m_istrig_button(0),
+ m_istrig_hat(0),
+ m_axismax(-1),
+ m_buttonmax(-1),
+ m_hatmax(-1)
{
+#ifndef DISABLE_SDL
m_private = new PrivateData();
+#endif
}
SCA_Joystick::~SCA_Joystick()
{
+#ifndef DISABLE_SDL
delete m_private;
+#endif
}
+SCA_Joystick *SCA_Joystick::m_instance[JOYINDEX_MAX];
+int SCA_Joystick::m_refCount = 0;
-bool SCA_Joystick::CreateJoystickDevice()
+SCA_Joystick *SCA_Joystick::GetInstance( short int joyindex )
{
- bool init = false;
- init = pCreateJoystickDevice();
- return init;
-}
-
+#ifdef DISABLE_SDL
+ return NULL;
+#else
+ if (joyindex < 0 || joyindex >= JOYINDEX_MAX) {
+ echo("Error-invalid joystick index: " << joyindex);
+ return NULL;
+ }
-void SCA_Joystick::DestroyJoystickDevice()
-{
- if(m_isinit)
- pDestroyJoystickDevice();
+ if (m_refCount == 0)
+ {
+ int i;
+ // do this once only
+ if(SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO ) == -1 ){
+ echo("Error-Initializing-SDL: " << SDL_GetError());
+ return NULL;
+ }
+ for (i=0; i<JOYINDEX_MAX; i++) {
+ m_instance[i] = new SCA_Joystick(i);
+ m_instance[i]->CreateJoystickDevice();
+ }
+ m_refCount = 1;
+ }
+ else
+ {
+ m_refCount++;
+ }
+ return m_instance[joyindex];
+#endif
}
-
-void SCA_Joystick::HandleEvents()
+void SCA_Joystick::ReleaseInstance()
{
- if(m_isinit)
+ if (--m_refCount == 0)
{
- if(SDL_PollEvent(&m_private->m_event))
- {
- switch(m_private->m_event.type)
- {
- case SDL_JOYAXISMOTION:
- HANDLE_AXISMOTION(OnAxisMotion);
- break;
- case SDL_JOYHATMOTION:
- HANDLE_HATMOTION(OnHatMotion);
- break;
- case SDL_JOYBUTTONUP:
- HANDLE_BUTTONUP(OnButtonUp);
- break;
- case SDL_JOYBUTTONDOWN:
- HANDLE_BUTTONDOWN(OnButtonDown);
- break;
- case SDL_JOYBALLMOTION:
- HANDLE_BALLMOTION(OnBallMotion);
- break;
- default:
- HANDLE_NOEVENT(OnNothing);
- break;
+#ifndef DISABLE_SDL
+ int i;
+ for (i=0; i<JOYINDEX_MAX; i++) {
+ if (m_instance[i]) {
+ m_instance[i]->DestroyJoystickDevice();
+ delete m_instance[i];
}
+ m_instance[i]= NULL;
}
+
+ SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO );
+#endif
}
}
-
void SCA_Joystick::cSetPrecision(int val)
{
m_prec = val;
}
+bool SCA_Joystick::aAnyAxisIsPositive(int axis)
+{
+ bool result;
+ int res = pAxisTest(axis);
+ res > m_prec? result = true: result = false;
+ return result;
+}
+
bool SCA_Joystick::aRightAxisIsPositive(int axis)
{
bool result;
int res = pGetAxis(axis,1);
res > m_prec? result = true: result = false;
- m_istrig = result;
return result;
}
@@ -121,7 +147,6 @@ bool SCA_Joystick::aUpAxisIsPositive(int axis)
bool result;
int res = pGetAxis(axis,0);
res < -m_prec? result = true : result = false;
- m_istrig = result;
return result;
}
@@ -131,7 +156,6 @@ bool SCA_Joystick::aLeftAxisIsPositive(int axis)
bool result;
int res = pGetAxis(axis,1);
res < -m_prec ? result = true : result = false;
- m_istrig = result;
return result;
}
@@ -141,26 +165,40 @@ bool SCA_Joystick::aDownAxisIsPositive(int axis)
bool result;
int res = pGetAxis(axis,0);
res > m_prec ? result = true:result = false;
- m_istrig = result;
return result;
}
+bool SCA_Joystick::aAnyButtonPressIsPositive(void)
+{
+ return (m_buttonnum==-2) ? false : true;
+}
+
+bool SCA_Joystick::aAnyButtonReleaseIsPositive(void)
+{
+ return (m_buttonnum==-2) ? true : false;
+}
bool SCA_Joystick::aButtonPressIsPositive(int button)
{
+#ifdef DISABLE_SDL
+ return false;
+#else
bool result;
SDL_JoystickGetButton(m_private->m_joystick, button)? result = true:result = false;
- m_istrig = result;
return result;
+#endif
}
bool SCA_Joystick::aButtonReleaseIsPositive(int button)
{
+#ifdef DISABLE_SDL
+ return false;
+#else
bool result;
SDL_JoystickGetButton(m_private->m_joystick, button)? result = false : result = true;
- m_istrig = result;
return result;
+#endif
}
@@ -169,27 +207,9 @@ bool SCA_Joystick::aHatIsPositive(int dir)
bool result;
int res = pGetHat(dir);
res == dir? result = true : result = false;
- m_istrig = result;
return result;
}
-
-int SCA_Joystick::pGetButtonPress(int button)
-{
- if(button == m_buttonnum)
- return m_buttonnum;
- return -2;
-}
-
-
-int SCA_Joystick::pGetButtonRelease(int button)
-{
- if(button == m_buttonnum)
- return m_buttonnum;
- return -2;
-}
-
-
int SCA_Joystick::pGetHat(int direction)
{
if(direction == m_hatdir){
@@ -198,174 +218,121 @@ int SCA_Joystick::pGetHat(int direction)
return 0;
}
-
-bool SCA_Joystick::GetJoyAxisMotion()
-{
- bool result = false;
- if(m_isinit){
- if(SDL_PollEvent(&m_private->m_event)){
- switch(m_private->m_event.type)
- {
- case SDL_JOYAXISMOTION:
- result = true;
- break;
- }
- }
- }
- return result;
-}
-
-
-bool SCA_Joystick::GetJoyButtonPress()
-{
- bool result = false;
- if(m_isinit){
- if(SDL_PollEvent(&m_private->m_event)){
- switch(m_private->m_event.type)
- {
- case SDL_JOYBUTTONDOWN:
- result = true;
- break;
- }
- }
- }
- return result;
-}
-
-
-bool SCA_Joystick::GetJoyButtonRelease()
-{
- bool result = false;
- if(m_isinit)
- {
- if(SDL_PollEvent(&m_private->m_event)){
- switch(m_private->m_event.type)
- {
- case SDL_JOYBUTTONUP:
- result = true;
- break;
- }
- }
- }
- return result;
-}
-
-
-bool SCA_Joystick::GetJoyHatMotion()
-{
- bool result = false;
- if(m_isinit){
- if(SDL_PollEvent(&m_private->m_event)){
- switch(m_private->m_event.type)
- {
- case SDL_JOYHATMOTION:
- result = true;
- break;
- }
- }
- }
- return 0;
-}
-
-
int SCA_Joystick::GetNumberOfAxes()
{
- int number;
- if(m_isinit){
- if(m_private->m_joystick){
- number = SDL_JoystickNumAxes(m_private->m_joystick);
- return number;
- }
- }
- return -1;
+ return m_axismax;
}
int SCA_Joystick::GetNumberOfButtons()
{
- int number;
- if(m_isinit){
- if(m_private->m_joystick){
- number = SDL_JoystickNumButtons(m_private->m_joystick);
- return number;
- }
- }
- return -1;
+ return m_buttonmax;
}
int SCA_Joystick::GetNumberOfHats()
{
- int number;
- if(m_isinit){
- if(m_private->m_joystick){
- number = SDL_JoystickNumHats(m_private->m_joystick);
- return number;
- }
- }
- return -1;
+ return m_hatmax;
}
-bool SCA_Joystick::pCreateJoystickDevice()
+bool SCA_Joystick::CreateJoystickDevice(void)
{
+#ifdef DISABLE_SDL
+ return false;
+#else
if(m_isinit == false){
- if(SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO ) == -1 ){
- echo("Error-Initializing-SDL: " << SDL_GetError());
- return false;
- }
- if(SDL_NumJoysticks() > 0){
- for(int i=0; i<SDL_NumJoysticks();i++){
- m_private->m_joystick = SDL_JoystickOpen(i);
- SDL_JoystickEventState(SDL_ENABLE);
- m_numjoys = i;
- }
- echo("Joystick-initialized");
- m_isinit = true;
- return true;
- }else{
- echo("Joystick-Error: " << SDL_NumJoysticks() << " avaiable joystick(s)");
+ if (m_joyindex>=SDL_NumJoysticks()) {
+ // don't print a message, because this is done anyway
+ //echo("Joystick-Error: " << SDL_NumJoysticks() << " avaiable joystick(s)");
return false;
}
+
+ m_private->m_joystick = SDL_JoystickOpen(m_joyindex);
+ SDL_JoystickEventState(SDL_ENABLE);
+ m_isinit = true;
+
+ echo("Joystick " << m_joyindex << " initialized");
+
+ /* must run after being initialized */
+ m_axismax = SDL_JoystickNumAxes(m_private->m_joystick);
+ m_buttonmax = SDL_JoystickNumButtons(m_private->m_joystick);
+ m_hatmax = SDL_JoystickNumHats(m_private->m_joystick);
}
- return false;
+ return true;
+#endif
}
-void SCA_Joystick::pDestroyJoystickDevice()
+void SCA_Joystick::DestroyJoystickDevice(void)
{
- echo("Closing-");
- for(int i=0; i<SDL_NumJoysticks(); i++){
- if(SDL_JoystickOpened(i)){
+#ifndef DISABLE_SDL
+ if (m_isinit){
+ if(SDL_JoystickOpened(m_joyindex)){
+ echo("Closing-joystick " << m_joyindex);
SDL_JoystickClose(m_private->m_joystick);
}
+ m_isinit = false;
}
- SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_VIDEO );
+#endif
}
+int SCA_Joystick::Connected(void)
+{
+#ifndef DISABLE_SDL
+ if (m_isinit && SDL_JoystickOpened(m_joyindex))
+ return 1;
+#endif
+ return 0;
+}
void SCA_Joystick::pFillAxes()
{
- if(GetNumberOfAxes() == 1){
+#ifndef DISABLE_SDL
+ if(m_axismax == 1){
m_axis10 = SDL_JoystickGetAxis(m_private->m_joystick, 0);
m_axis11 = SDL_JoystickGetAxis(m_private->m_joystick, 1);
- }else if(GetNumberOfAxes() > 1){
+ }else if(m_axismax > 1){
m_axis10 = SDL_JoystickGetAxis(m_private->m_joystick, 0);
m_axis11 = SDL_JoystickGetAxis(m_private->m_joystick, 1);
m_axis20 = SDL_JoystickGetAxis(m_private->m_joystick, 2);
m_axis21 = SDL_JoystickGetAxis(m_private->m_joystick, 3);
}else{
- m_axis10 = 0;m_axis11 = 0;
- m_axis20 = 0;m_axis21 = 0;
+ m_axis10 = m_axis11 = m_axis20 = m_axis21 = 0;
}
+#endif
}
int SCA_Joystick::pGetAxis(int axisnum, int udlr)
{
+#ifndef DISABLE_SDL
if(axisnum == 1 && udlr == 1)return m_axis10; //u/d
if(axisnum == 1 && udlr == 0)return m_axis11; //l/r
if(axisnum == 2 && udlr == 0)return m_axis20; //...
if(axisnum == 2 && udlr == 1)return m_axis21;
+#endif
+ return 0;
+}
+
+int SCA_Joystick::pAxisTest(int axisnum)
+{
+#ifndef DISABLE_SDL
+ short i1,i2;
+ if(axisnum == 1) {
+ i1 = m_axis10; i2 = m_axis11;
+ }
+ else if(axisnum == 2) {
+ i1 = m_axis20; i2 = m_axis21;
+ }
+ /* long winded way to do
+ * return MAX2(abs(i1), abs(i2))
+ * avoid abs from math.h */
+ if (i1 < 0) i1 = -i1;
+ if (i2 < 0) i2 = -i2;
+ if (i1 <i2) return i2;
+ else return i1;
+#else
return 0;
+#endif
}
diff --git a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
index a76edc73b44..8335d5538ad 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
+++ b/source/gameengine/GameLogic/Joystick/SCA_Joystick.h
@@ -1,304 +1,189 @@
/**
-
* ***** BEGIN GPL LICENSE BLOCK *****
-
*
-
* 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
-
* of the License, or (at your option) any later version.
-
-
-
-
*
-
* 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,
-
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
*
-
* 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): snailrose.
-
*
-
* ***** END GPL LICENSE BLOCK *****
-
*/
#ifndef _SCA_JOYSTICK_H_
-
#define _SCA_JOYSTICK_H_
-
-
#include "SCA_JoystickDefines.h"
-
-
-
-
+#ifndef DISABLE_SDL
+#include "SDL.h"
+#endif
/*
-
* Basic Joystick class
-
+ * I will make this class a singleton because there should be only one joystick
+ * even if there are more than one scene using it and count how many scene are using it.
+ * The underlying joystick should only be removed when the last scene is removed
*/
class SCA_Joystick
{
+ static SCA_Joystick *m_instance[JOYINDEX_MAX];
+ static int m_refCount;
class PrivateData;
-
+#ifndef DISABLE_SDL
PrivateData *m_private;
-
+#endif
int m_joyindex;
- /*!
-
- * the number of avail joysticks
-
- */
-
- int m_numjoys;
-
/*
-
*support for 2 axes
-
*/
int m_axis10,m_axis11;
-
int m_axis20,m_axis21;
- /*
-
+ /*
* Precision or range of the axes
-
*/
-
int m_prec;
/*
-
* multiple axis values stored here
-
*/
-
int m_axisnum;
-
int m_axisvalue;
/*
-
* max # of axes avail
-
*/
-
/*disabled
-
int m_axismax;
-
*/
/*
-
* button values stored here
-
*/
-
int m_buttonnum;
/*
-
* max # of buttons avail
-
*/
-
+
+ int m_axismax;
int m_buttonmax;
-
- /*
-
+ int m_hatmax;
+
+ /*
* hat values stored here
-
*/
-
int m_hatnum;
-
int m_hatdir;
/*
* max # of hats avail
-
disabled
-
int m_hatmax;
-
*/
-
/* is the joystick initialized ?*/
-
bool m_isinit;
+ /* is triggered for each event type */
+ bool m_istrig_axis;
+ bool m_istrig_button;
+ bool m_istrig_hat;
- /* is triggered */
-
- bool m_istrig;
-
+#ifndef DISABLE_SDL
/*
-
- * Open the joystick
-
+ * event callbacks
*/
-
- bool pCreateJoystickDevice(void);
-
+ void OnAxisMotion(SDL_Event *sdl_event);
+ void OnHatMotion(SDL_Event *sdl_event);
+ void OnButtonUp(SDL_Event *sdl_event);
+ void OnButtonDown(SDL_Event *sdl_event);
+ void OnNothing(SDL_Event *sdl_event);
+ void OnBallMotion(SDL_Event *sdl_event){}
+#endif
/*
-
- * Close the joystick
-
+ * Open the joystick
*/
-
- void pDestroyJoystickDevice(void);
-
-
+ bool CreateJoystickDevice(void);
/*
-
- * event callbacks
-
+ * Close the joystick
*/
-
- void OnAxisMotion(void);
-
- void OnHatMotion(void);
-
- void OnButtonUp(void);
-
- void OnButtonDown(void);
-
- void OnNothing(void);
-
- void OnBallMotion(void){}
+ void DestroyJoystickDevice(void);
/*
-
* fills the axis mnember values
-
*/
-
void pFillAxes(void);
-
-
-
void pFillButtons(void);
/*
-
* returns m_axis10,m_axis11...
-
*/
- int pGetAxis(int axisnum, int udlr);
-
+ int pAxisTest(int axisnum);
/*
-
- * gets the current button
-
- */
-
- int pGetButtonPress(int button);
-
- /*
-
- * returns if no button is pressed
-
+ * returns m_axis10,m_axis11...
*/
-
- int pGetButtonRelease(int button);
+ int pGetAxis(int axisnum, int udlr);
/*
-
* gets the current hat direction
-
*/
-
int pGetHat(int direction);
-
-
-public:
-
- SCA_Joystick();
+ SCA_Joystick(short int index);
~SCA_Joystick();
-
+public:
- bool CreateJoystickDevice(void);
-
- void DestroyJoystickDevice(void);
-
- void HandleEvents();
+ static SCA_Joystick *GetInstance( short int joyindex );
+ static void HandleEvents( void );
+ void ReleaseInstance();
+
/*
-
*/
-
+ bool aAnyAxisIsPositive(int axis);
bool aUpAxisIsPositive(int axis);
-
bool aDownAxisIsPositive(int axis);
-
bool aLeftAxisIsPositive(int axis);
-
bool aRightAxisIsPositive(int axis);
+ bool aAnyButtonPressIsPositive(void);
+ bool aAnyButtonReleaseIsPositive(void);
bool aButtonPressIsPositive(int button);
-
bool aButtonReleaseIsPositive(int button);
-
bool aHatIsPositive(int dir);
/*
-
* precision is default '3200' which is overridden by input
-
*/
void cSetPrecision(int val);
-
-
int GetAxis10(void){
return m_axis10;
@@ -306,80 +191,57 @@ public:
}
int GetAxis11(void){
-
return m_axis11;
-
}
int GetAxis20(void){
-
return m_axis20;
-
}
int GetAxis21(void){
-
return m_axis21;
-
}
int GetButton(void){
-
return m_buttonnum;
-
}
int GetHat(void){
-
return m_hatdir;
-
}
int GetThreshold(void){
-
return m_prec;
-
}
- bool IsTrig(void){
-
- return m_istrig;
-
+ bool IsTrigAxis(void){
+ return m_istrig_axis;
}
-
+ bool IsTrigButton(void){
+ return m_istrig_button;
+ }
+
+ bool IsTrigHat(void){
+ return m_istrig_hat;
+ }
/*
-
- * returns true if an event is being processed
-
- */
-
- bool GetJoyAxisMotion(void);
-
- bool GetJoyButtonPress(void);
-
- bool GetJoyButtonRelease(void);
-
- bool GetJoyHatMotion(void);
-
- /*
-
* returns the # of...
-
*/
int GetNumberOfAxes(void);
-
int GetNumberOfButtons(void);
-
int GetNumberOfHats(void);
-
-
+ /*
+ * Test if the joystick is connected
+ */
+ int Connected(void);
};
-
-
+#ifndef DISABLE_SDL
+void Joystick_HandleEvents( void );
+#endif
#endif
diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h b/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h
index 15a421188b9..73ffe1406d9 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h
+++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickDefines.h
@@ -38,12 +38,6 @@
#define echo(x) std::cout << x << std::endl;
#endif
-/* function callbacks */
-#define HANDLE_AXISMOTION(fn) ((fn)(), 0L)
-#define HANDLE_HATMOTION(fn) ((fn)(), 0L)
-#define HANDLE_BUTTONUP(fn) ((fn)(), 0L)
-#define HANDLE_BUTTONDOWN(fn) ((fn)(), 0L)
-#define HANDLE_BALLMOTION(fn) ((fn)(), 0L)
-#define HANDLE_NOEVENT(fn) ((fn)(), 0L)
+#define JOYINDEX_MAX 8
#endif
diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
index ab523470e21..73ca288861d 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
+++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickEvents.cpp
@@ -24,47 +24,100 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
+#ifndef DISABLE_SDL
#include <SDL.h>
+#endif
+
#include "SCA_Joystick.h"
#include "SCA_JoystickPrivate.h"
-
-void SCA_Joystick::OnAxisMotion(void)
+#ifndef DISABLE_SDL
+void SCA_Joystick::OnAxisMotion(SDL_Event* sdl_event)
{
pFillAxes();
- m_axisnum = m_private->m_event.jaxis.axis;
- m_axisvalue = m_private->m_event.jaxis.value;
- m_istrig = 1;
+ m_axisnum = sdl_event->jaxis.axis;
+ m_axisvalue = sdl_event->jaxis.value;
+ m_istrig_axis = 1;
}
-void SCA_Joystick::OnHatMotion(void)
+void SCA_Joystick::OnHatMotion(SDL_Event* sdl_event)
{
- m_hatdir = m_private->m_event.jhat.value;
- m_hatnum = m_private->m_event.jhat.hat;
- m_istrig = 1;
+ m_hatdir = sdl_event->jhat.value;
+ m_hatnum = sdl_event->jhat.hat;
+ m_istrig_hat = 1;
}
-
-void SCA_Joystick::OnButtonUp(void)
+void SCA_Joystick::OnButtonUp(SDL_Event* sdl_event)
{
+ m_istrig_button = 1;
+
+ /* this is needed for the "all events" option
+ * so we know if there are no buttons pressed */
+ int i;
+ for (i=0; i<m_buttonmax; i++) {
+ if (SDL_JoystickGetButton(m_private->m_joystick, i)) {
+ m_buttonnum = i;
+ return;
+ }
+ }
m_buttonnum = -2;
}
-void SCA_Joystick::OnButtonDown(void)
+void SCA_Joystick::OnButtonDown(SDL_Event* sdl_event)
{
- m_buttonmax = GetNumberOfButtons();
- if(m_private->m_event.jbutton.button >= 1 || m_private->m_event.jbutton.button <= m_buttonmax)
+ if(sdl_event->jbutton.button >= 0 || sdl_event->jbutton.button <= m_buttonmax)
{
- m_istrig = 1;
- m_buttonnum = m_private->m_event.jbutton.button;
+ m_istrig_button = 1;
+ m_buttonnum = sdl_event->jbutton.button;
}
}
-void SCA_Joystick::OnNothing(void)
+void SCA_Joystick::OnNothing(SDL_Event* sdl_event)
{
- m_istrig = 0;
+ m_istrig_axis = m_istrig_button = m_istrig_hat = 0;
+}
+
+/* only handle events for 1 joystick */
+
+void SCA_Joystick::HandleEvents(void)
+{
+ SDL_Event sdl_event;
+
+ int i;
+ for (i=0; i<JOYINDEX_MAX; i++) {
+ if(SCA_Joystick::m_instance[i])
+ SCA_Joystick::m_instance[i]->OnNothing(&sdl_event);
+ }
+
+ if(SDL_PollEvent(&sdl_event))
+ {
+ /* Note! m_instance[sdl_event.jaxis.which]
+ * will segfault if over JOYINDEX_MAX, not too nice but what are the chances? */
+ switch(sdl_event.type)
+ {
+ case SDL_JOYAXISMOTION:
+ SCA_Joystick::m_instance[sdl_event.jaxis.which]->OnAxisMotion(&sdl_event);
+ break;
+ case SDL_JOYHATMOTION:
+ SCA_Joystick::m_instance[sdl_event.jhat.which]->OnHatMotion(&sdl_event);
+ break;
+ case SDL_JOYBUTTONUP:
+ SCA_Joystick::m_instance[sdl_event.jbutton.which]->OnButtonUp(&sdl_event);
+ break;
+ case SDL_JOYBUTTONDOWN:
+ SCA_Joystick::m_instance[sdl_event.jbutton.which]->OnButtonDown(&sdl_event);
+ break;
+ case SDL_JOYBALLMOTION:
+ SCA_Joystick::m_instance[sdl_event.jball.which]->OnBallMotion(&sdl_event);
+ break;
+ default:
+ printf("SCA_Joystick::HandleEvents, Unknown SDL event, this should not happen\n");
+ break;
+ }
+ }
}
+#endif
diff --git a/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h b/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h
index 23fad3cd55d..acbbcae9cd7 100644
--- a/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h
+++ b/source/gameengine/GameLogic/Joystick/SCA_JoystickPrivate.h
@@ -29,14 +29,11 @@
#define __SCA_JOYSTICKPRIVATE_H__
#include "SCA_Joystick.h"
+#ifndef DISABLE_SDL
class SCA_Joystick::PrivateData
{
public:
/*
- * SDL events structure
- */
- SDL_Event m_event;
- /*
* The Joystick
*/
SDL_Joystick* m_joystick;
@@ -47,3 +44,5 @@ public:
}
};
#endif
+
+#endif
diff --git a/source/gameengine/GameLogic/Makefile b/source/gameengine/GameLogic/Makefile
index bf4cb5afea7..355ece6e8bd 100644
--- a/source/gameengine/GameLogic/Makefile
+++ b/source/gameengine/GameLogic/Makefile
@@ -39,8 +39,10 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
CPPFLAGS += -I../Expressions
+CPPFLAGS += -I../Rasterizer
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
+CPPFLAGS += -I../../blender/makesdna
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
CPPFLAGS += $(NAN_SDLCFLAGS)
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
new file mode 100644
index 00000000000..9ec4ea00337
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.cpp
@@ -0,0 +1,118 @@
+#include "SCA_IActuator.h"
+
+#include "SCA_2DFilterActuator.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <iostream>
+
+SCA_2DFilterActuator::~SCA_2DFilterActuator()
+{
+}
+
+SCA_2DFilterActuator::SCA_2DFilterActuator(
+ SCA_IObject *gameobj,
+ RAS_2DFilterManager::RAS_2DFILTER_MODE type,
+ short flag,
+ float float_arg,
+ int int_arg,
+ RAS_IRasterizer* rasterizer,
+ RAS_IRenderTools* rendertools,
+ PyTypeObject* T)
+ : SCA_IActuator(gameobj, T),
+ m_type(type),
+ m_flag(flag),
+ m_float_arg(float_arg),
+ m_int_arg(int_arg),
+ m_rasterizer(rasterizer),
+ m_rendertools(rendertools)
+{
+ m_gameObj = NULL;
+ if(gameobj){
+ m_propNames = gameobj->GetPropertyNames();
+ m_gameObj = gameobj;
+ }
+}
+
+void SCA_2DFilterActuator::SetShaderText(STR_String text)
+{
+ m_shaderText = text;
+}
+
+
+
+CValue* SCA_2DFilterActuator::GetReplica()
+{
+ SCA_2DFilterActuator* replica = new SCA_2DFilterActuator(*this);
+ replica->ProcessReplica();
+ CValue::AddDataToReplica(replica);
+
+ return replica;
+}
+
+
+bool SCA_2DFilterActuator::Update()
+{
+ bool bNegativeEvent = IsNegativeEvent();
+ RemoveAllEvents();
+
+
+ if (bNegativeEvent)
+ return false; // do nothing on negative events
+
+ if( m_type == RAS_2DFilterManager::RAS_2DFILTER_MOTIONBLUR )
+ {
+ if(!m_flag)
+ m_rasterizer->EnableMotionBlur(m_float_arg);
+ else
+ m_rasterizer->DisableMotionBlur();
+
+ return false;
+ }
+ else if(m_type < RAS_2DFilterManager::RAS_2DFILTER_NUMBER_OF_FILTERS)
+ {
+ m_rendertools->Update2DFilter(m_propNames, m_gameObj, m_type, m_int_arg, m_shaderText);
+ }
+ return true;
+}
+
+
+PyTypeObject SCA_2DFilterActuator::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "SCA_2DFilterActuator",
+ sizeof(SCA_2DFilterActuator),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0,
+ __repr,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+
+PyParentObject SCA_2DFilterActuator::Parents[] = {
+ &SCA_2DFilterActuator::Type,
+ &SCA_IActuator::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+
+PyMethodDef SCA_2DFilterActuator::Methods[] = {
+ /* add python functions to deal with m_msg... */
+ {NULL,NULL}
+};
+
+
+PyObject* SCA_2DFilterActuator::_getattr(const STR_String& attr) {
+ _getattr_up(SCA_IActuator);
+}
diff --git a/source/gameengine/GameLogic/SCA_2DFilterActuator.h b/source/gameengine/GameLogic/SCA_2DFilterActuator.h
new file mode 100644
index 00000000000..7ec07cf5b19
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_2DFilterActuator.h
@@ -0,0 +1,44 @@
+#ifndef __SCA_2DFILETRACTUATOR_H__
+#define __SCA_2DFILETRACTUATOR_H__
+
+#include "RAS_IRasterizer.h"
+#include "RAS_IRenderTools.h"
+#include "SCA_IActuator.h"
+
+class SCA_2DFilterActuator : public SCA_IActuator
+{
+ Py_Header;
+
+private:
+ vector<STR_String> m_propNames;
+ void * m_gameObj;
+ RAS_2DFilterManager::RAS_2DFILTER_MODE m_type;
+ short m_flag;
+ float m_float_arg;
+ int m_int_arg;
+ STR_String m_shaderText;
+ RAS_IRasterizer* m_rasterizer;
+ RAS_IRenderTools* m_rendertools;
+
+public:
+
+ SCA_2DFilterActuator(
+ class SCA_IObject* gameobj,
+ RAS_2DFilterManager::RAS_2DFILTER_MODE type,
+ short flag,
+ float float_arg,
+ int int_arg,
+ RAS_IRasterizer* rasterizer,
+ RAS_IRenderTools* rendertools,
+ PyTypeObject* T=&Type
+ );
+
+ void SetShaderText(STR_String text);
+ virtual ~SCA_2DFilterActuator();
+ virtual bool Update();
+
+ virtual CValue* GetReplica();
+ virtual PyObject* _getattr(const STR_String& attr);
+
+};
+#endif
diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp b/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp
new file mode 100644
index 00000000000..768a3a45937
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_ActuatorEventManager.cpp
@@ -0,0 +1,67 @@
+/**
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "SCA_ISensor.h"
+#include "SCA_ActuatorEventManager.h"
+#include "SCA_ActuatorSensor.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+SCA_ActuatorEventManager::SCA_ActuatorEventManager(class SCA_LogicManager* logicmgr)
+ : SCA_EventManager(ACTUATOR_EVENTMGR),
+ m_logicmgr(logicmgr)
+{
+}
+
+
+
+SCA_ActuatorEventManager::~SCA_ActuatorEventManager()
+{
+
+}
+
+void SCA_ActuatorEventManager::NextFrame()
+{
+ // check for changed actuator
+ for (set<SCA_ISensor*>::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++)
+ {
+ (*it)->Activate(m_logicmgr,NULL);
+ }
+}
+
+void SCA_ActuatorEventManager::UpdateFrame()
+{
+ // update the state of actuator before executing them
+ for (set<SCA_ISensor*>::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++)
+ {
+ ((SCA_ActuatorSensor*)(*it))->Update();
+ }
+} \ No newline at end of file
diff --git a/source/gameengine/GameLogic/SCA_ActuatorEventManager.h b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h
new file mode 100644
index 00000000000..a7d61627c23
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_ActuatorEventManager.h
@@ -0,0 +1,51 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef __KX_ACTUATOREVENTMANAGER
+#define __KX_ACTUATOREVENTMANAGER
+
+#include "SCA_EventManager.h"
+
+#include <vector>
+
+using namespace std;
+
+class SCA_ActuatorEventManager : public SCA_EventManager
+{
+ class SCA_LogicManager* m_logicmgr;
+
+public:
+ SCA_ActuatorEventManager(class SCA_LogicManager* logicmgr);
+ virtual ~SCA_ActuatorEventManager();
+ virtual void NextFrame();
+ virtual void UpdateFrame();
+ //SCA_LogicManager* GetLogicManager() { return m_logicmgr;}
+};
+
+#endif //__KX_ACTUATOREVENTMANAGER
+
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
new file mode 100644
index 00000000000..7c37b237d60
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.cpp
@@ -0,0 +1,196 @@
+/**
+ * Actuator sensor
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <iostream>
+#include "SCA_ActuatorSensor.h"
+#include "SCA_EventManager.h"
+#include "SCA_LogicManager.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+SCA_ActuatorSensor::SCA_ActuatorSensor(SCA_EventManager* eventmgr,
+ SCA_IObject* gameobj,
+ const STR_String& actname,
+ PyTypeObject* T )
+ : SCA_ISensor(gameobj,eventmgr,T),
+ m_checkactname(actname)
+{
+ m_actuator = GetParent()->FindActuator(m_checkactname);
+ Init();
+}
+
+void SCA_ActuatorSensor::Init()
+{
+ m_lastresult = m_invert?true:false;
+ m_midresult = m_lastresult;
+ m_reset = true;
+}
+
+CValue* SCA_ActuatorSensor::GetReplica()
+{
+ SCA_ActuatorSensor* replica = new SCA_ActuatorSensor(*this);
+ // m_range_expr must be recalculated on replica!
+ CValue::AddDataToReplica(replica);
+ replica->Init();
+
+ return replica;
+}
+
+void SCA_ActuatorSensor::ReParent(SCA_IObject* parent)
+{
+ m_actuator = parent->FindActuator(m_checkactname);
+ SCA_ISensor::ReParent(parent);
+}
+
+bool SCA_ActuatorSensor::IsPositiveTrigger()
+{
+ bool result = m_lastresult;
+ if (m_invert)
+ result = !result;
+
+ return result;
+}
+
+
+
+SCA_ActuatorSensor::~SCA_ActuatorSensor()
+{
+}
+
+
+
+bool SCA_ActuatorSensor::Evaluate(CValue* event)
+{
+ if (m_actuator)
+ {
+ bool result = m_actuator->IsActive();
+ bool reset = m_reset && m_level;
+
+ m_reset = false;
+ if (m_lastresult != result || m_midresult != result)
+ {
+ m_lastresult = m_midresult = result;
+ return true;
+ }
+ return (reset) ? true : false;
+ }
+ return false;
+}
+
+void SCA_ActuatorSensor::Update()
+{
+ if (m_actuator)
+ {
+ m_midresult = m_actuator->IsActive() && !m_actuator->IsNegativeEvent();
+ }
+}
+
+
+/* ------------------------------------------------------------------------- */
+/* Python functions */
+/* ------------------------------------------------------------------------- */
+
+/* Integration hooks ------------------------------------------------------- */
+PyTypeObject SCA_ActuatorSensor::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "SCA_ActuatorSensor",
+ sizeof(SCA_ActuatorSensor),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject SCA_ActuatorSensor::Parents[] = {
+ &SCA_ActuatorSensor::Type,
+ &SCA_ISensor::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+PyMethodDef SCA_ActuatorSensor::Methods[] = {
+ {"getActuator", (PyCFunction) SCA_ActuatorSensor::sPyGetActuator, METH_NOARGS, (PY_METHODCHAR)GetActuator_doc},
+ {"setActuator", (PyCFunction) SCA_ActuatorSensor::sPySetActuator, METH_VARARGS, (PY_METHODCHAR)SetActuator_doc},
+ {NULL,NULL} //Sentinel
+};
+
+PyObject* SCA_ActuatorSensor::_getattr(const STR_String& attr) {
+ _getattr_up(SCA_ISensor); /* implicit return! */
+}
+
+/* 3. getActuator */
+const char SCA_ActuatorSensor::GetActuator_doc[] =
+"getActuator()\n"
+"\tReturn the Actuator with which the sensor operates.\n";
+PyObject* SCA_ActuatorSensor::PyGetActuator(PyObject* self)
+{
+ return PyString_FromString(m_checkactname);
+}
+
+/* 4. setActuator */
+const char SCA_ActuatorSensor::SetActuator_doc[] =
+"setActuator(name)\n"
+"\t- name: string\n"
+"\tSets the Actuator with which to operate. If there is no Actuator\n"
+"\tof this name, the call is ignored.\n";
+PyObject* SCA_ActuatorSensor::PySetActuator(PyObject* self, PyObject* args, PyObject* kwds)
+{
+ /* We should query whether the name exists. Or should we create a prop */
+ /* on the fly? */
+ char *actNameArg = NULL;
+
+ if (!PyArg_ParseTuple(args, "s", &actNameArg)) {
+ return NULL;
+ }
+
+ SCA_IActuator* act = GetParent()->FindActuator(STR_String(actNameArg));
+ if (act) {
+ m_checkactname = actNameArg;
+ m_actuator = act;
+ } else {
+ ; /* error: bad actuator name */
+ }
+ Py_Return;
+}
+
+/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ActuatorSensor.h b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
new file mode 100644
index 00000000000..a71145f6852
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_ActuatorSensor.h
@@ -0,0 +1,74 @@
+/**
+ * Actuator sensor
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __KX_ACTUATORSENSOR
+#define __KX_ACTUATORSENSOR
+
+#include "SCA_ISensor.h"
+#include "SCA_IActuator.h"
+
+class SCA_ActuatorSensor : public SCA_ISensor
+{
+ Py_Header;
+ STR_String m_checkactname;
+ bool m_lastresult;
+ bool m_midresult;
+ protected:
+ SCA_IActuator* m_actuator;
+public:
+ SCA_ActuatorSensor(class SCA_EventManager* eventmgr,
+ SCA_IObject* gameobj,
+ const STR_String& actname,
+ PyTypeObject* T=&Type );
+
+ virtual ~SCA_ActuatorSensor();
+ virtual CValue* GetReplica();
+ virtual void Init();
+ virtual bool Evaluate(CValue* event);
+ virtual bool IsPositiveTrigger();
+ virtual void ReParent(SCA_IObject* parent);
+ void Update();
+
+ /* --------------------------------------------------------------------- */
+ /* Python interface ---------------------------------------------------- */
+ /* --------------------------------------------------------------------- */
+
+ virtual PyObject* _getattr(const STR_String& attr);
+
+ /* 3. setProperty */
+ KX_PYMETHOD_DOC(SCA_ActuatorSensor,SetActuator);
+ /* 4. getProperty */
+ KX_PYMETHOD_DOC_NOARGS(SCA_ActuatorSensor,GetActuator);
+
+};
+
+#endif
+
diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp b/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
index ab3bc2cc4ee..4cd2dfba994 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.cpp
@@ -51,16 +51,9 @@ SCA_AlwaysEventManager::SCA_AlwaysEventManager(class SCA_LogicManager* logicmgr)
void SCA_AlwaysEventManager::NextFrame()
{
- for (vector<class SCA_ISensor*>::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++)
+ for (set<class SCA_ISensor*>::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++)
{
- SCA_ISensor* sensor = *i;
- sensor->Activate(m_logicmgr, NULL);
+ (*i)->Activate(m_logicmgr, NULL);
}
}
-
-
-void SCA_AlwaysEventManager::RegisterSensor(SCA_ISensor* sensor)
-{
- m_sensors.push_back(sensor);
-}
diff --git a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h
index 28c71512875..a619eecddd4 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysEventManager.h
+++ b/source/gameengine/GameLogic/SCA_AlwaysEventManager.h
@@ -39,7 +39,6 @@ class SCA_AlwaysEventManager : public SCA_EventManager
public:
SCA_AlwaysEventManager(class SCA_LogicManager* logicmgr);
virtual void NextFrame();
- virtual void RegisterSensor(SCA_ISensor* sensor);
};
diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
index 67df5d091ab..f9fbf2387c4 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.cpp
@@ -53,10 +53,13 @@ SCA_AlwaysSensor::SCA_AlwaysSensor(class SCA_EventManager* eventmgr,
: SCA_ISensor(gameobj,eventmgr, T)
{
//SetDrawColor(255,0,0);
- m_alwaysresult = true;
+ Init();
}
-
+void SCA_AlwaysSensor::Init()
+{
+ m_alwaysresult = true;
+}
SCA_AlwaysSensor::~SCA_AlwaysSensor()
{
diff --git a/source/gameengine/GameLogic/SCA_AlwaysSensor.h b/source/gameengine/GameLogic/SCA_AlwaysSensor.h
index 474ed025432..8bf2a8aa98e 100644
--- a/source/gameengine/GameLogic/SCA_AlwaysSensor.h
+++ b/source/gameengine/GameLogic/SCA_AlwaysSensor.h
@@ -45,6 +45,8 @@ public:
virtual CValue* GetReplica();
virtual bool Evaluate(CValue* event);
virtual bool IsPositiveTrigger();
+ virtual void Init();
+
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.cpp b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
new file mode 100644
index 00000000000..f15d4c7249f
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.cpp
@@ -0,0 +1,257 @@
+/**
+ * Delay trigger
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef WIN32
+// 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
+
+#include "SCA_DelaySensor.h"
+#include "SCA_LogicManager.h"
+#include "SCA_EventManager.h"
+
+/* ------------------------------------------------------------------------- */
+/* Native functions */
+/* ------------------------------------------------------------------------- */
+
+SCA_DelaySensor::SCA_DelaySensor(class SCA_EventManager* eventmgr,
+ SCA_IObject* gameobj,
+ int delay,
+ int duration,
+ bool repeat,
+ PyTypeObject* T)
+ : SCA_ISensor(gameobj,eventmgr, T),
+ m_delay(delay),
+ m_duration(duration),
+ m_repeat(repeat)
+{
+ Init();
+}
+
+void SCA_DelaySensor::Init()
+{
+ m_lastResult = false;
+ m_frameCount = -1;
+ m_reset = true;
+}
+
+SCA_DelaySensor::~SCA_DelaySensor()
+{
+ /* intentionally empty */
+}
+
+CValue* SCA_DelaySensor::GetReplica()
+{
+ CValue* replica = new SCA_DelaySensor(*this);
+ // this will copy properties and so on...
+ CValue::AddDataToReplica(replica);
+
+ return replica;
+}
+
+
+
+bool SCA_DelaySensor::IsPositiveTrigger()
+{
+ return (m_invert ? !m_lastResult : m_lastResult);
+}
+
+bool SCA_DelaySensor::Evaluate(CValue* event)
+{
+ bool trigger = false;
+ bool result;
+
+ if (m_frameCount==-1) {
+ // this is needed to ensure ON trigger in case delay==0
+ // and avoid spurious OFF trigger when duration==0
+ m_lastResult = false;
+ m_frameCount = 0;
+ }
+
+ if (m_frameCount<m_delay) {
+ m_frameCount++;
+ result = false;
+ } else if (m_duration > 0) {
+ if (m_frameCount < m_delay+m_duration) {
+ m_frameCount++;
+ result = true;
+ } else {
+ result = false;
+ if (m_repeat)
+ m_frameCount = -1;
+ }
+ } else {
+ result = true;
+ if (m_repeat)
+ m_frameCount = -1;
+ }
+ if ((m_reset && m_level) || result != m_lastResult)
+ trigger = true;
+ m_reset = false;
+ m_lastResult = result;
+ return trigger;
+}
+
+/* ------------------------------------------------------------------------- */
+/* Python functions */
+/* ------------------------------------------------------------------------- */
+
+/* Integration hooks ------------------------------------------------------- */
+PyTypeObject SCA_DelaySensor::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "SCA_DelaySensor",
+ sizeof(SCA_DelaySensor),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject SCA_DelaySensor::Parents[] = {
+ &SCA_DelaySensor::Type,
+ &SCA_ISensor::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+PyMethodDef SCA_DelaySensor::Methods[] = {
+ /* setProperty */
+ {"setDelay", (PyCFunction) SCA_DelaySensor::sPySetDelay, METH_VARARGS, (PY_METHODCHAR)SetDelay_doc},
+ {"setDuration", (PyCFunction) SCA_DelaySensor::sPySetDuration, METH_VARARGS, (PY_METHODCHAR)SetDuration_doc},
+ {"setRepeat", (PyCFunction) SCA_DelaySensor::sPySetRepeat, METH_VARARGS, (PY_METHODCHAR)SetRepeat_doc},
+ /* getProperty */
+ {"getDelay", (PyCFunction) SCA_DelaySensor::sPyGetDelay, METH_NOARGS, (PY_METHODCHAR)GetDelay_doc},
+ {"getDuration", (PyCFunction) SCA_DelaySensor::sPyGetDuration, METH_NOARGS, (PY_METHODCHAR)GetDuration_doc},
+ {"getRepeat", (PyCFunction) SCA_DelaySensor::sPyGetRepeat, METH_NOARGS, (PY_METHODCHAR)GetRepeat_doc},
+ {NULL,NULL} //Sentinel
+};
+
+PyObject* SCA_DelaySensor::_getattr(const STR_String& attr) {
+ _getattr_up(SCA_ISensor);
+}
+
+const char SCA_DelaySensor::SetDelay_doc[] =
+"setDelay(delay)\n"
+"\t- delay: length of the initial OFF period as number of frame\n"
+"\t 0 for immediate trigger\n"
+"\tSet the initial delay before the positive trigger\n";
+PyObject* SCA_DelaySensor::PySetDelay(PyObject* self, PyObject* args, PyObject* kwds)
+{
+ int delay;
+
+ if(!PyArg_ParseTuple(args, "i", &delay)) {
+ return NULL;
+ }
+ if (delay < 0) {
+ PyErr_SetString(PyExc_ValueError, "Delay cannot be negative");
+ return NULL;
+ }
+ m_delay = delay;
+ Py_Return;
+}
+
+const char SCA_DelaySensor::SetDuration_doc[] =
+"setDuration(duration)\n"
+"\t- duration: length of the ON period in number of frame after the initial off period\n"
+"\t 0 for no ON period\n"
+"\tSet the duration of the ON pulse after initial delay.\n"
+"\tIf > 0, a negative trigger is fired at the end of the ON pulse.\n";
+PyObject* SCA_DelaySensor::PySetDuration(PyObject* self, PyObject* args, PyObject* kwds)
+{
+ int duration;
+
+ if(!PyArg_ParseTuple(args, "i", &duration)) {
+ return NULL;
+ }
+ if (duration < 0) {
+ PyErr_SetString(PyExc_ValueError, "Duration cannot be negative");
+ return NULL;
+ }
+ m_duration = duration;
+ Py_Return;
+}
+
+const char SCA_DelaySensor::SetRepeat_doc[] =
+"setRepeat(repeat)\n"
+"\t- repeat: 1 if the initial OFF-ON cycle should be repeated indefinately\n"
+"\t 0 if the initial OFF-ON cycle should run only once\n"
+"\tSet the sensor repeat mode\n";
+PyObject* SCA_DelaySensor::PySetRepeat(PyObject* self, PyObject* args, PyObject* kwds)
+{
+ int repeat;
+
+ if(!PyArg_ParseTuple(args, "i", &repeat)) {
+ return NULL;
+ }
+ m_repeat = (repeat != 0);
+ Py_Return;
+}
+
+const char SCA_DelaySensor::GetDelay_doc[] =
+"getDelay()\n"
+"\tReturn the delay parameter value\n";
+PyObject* SCA_DelaySensor::PyGetDelay(PyObject* self)
+{
+ return PyInt_FromLong(m_delay);
+}
+
+const char SCA_DelaySensor::GetDuration_doc[] =
+"getDuration()\n"
+"\tReturn the duration parameter value\n";
+PyObject* SCA_DelaySensor::PyGetDuration(PyObject* self)
+{
+ return PyInt_FromLong(m_duration);
+}
+
+const char SCA_DelaySensor::GetRepeat_doc[] =
+"getRepeat()\n"
+"\tReturn the repeat parameter value\n";
+PyObject* SCA_DelaySensor::PyGetRepeat(PyObject* self)
+{
+ return BoolToPyArg(m_repeat);
+}
+
+/* eof */
diff --git a/source/gameengine/GameLogic/SCA_DelaySensor.h b/source/gameengine/GameLogic/SCA_DelaySensor.h
new file mode 100644
index 00000000000..a997fabe3cd
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_DelaySensor.h
@@ -0,0 +1,77 @@
+/**
+ * SCA_DelaySensor.h
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __KX_DELAYSENSOR
+#define __KX_DELAYSENSOR
+#include "SCA_ISensor.h"
+
+class SCA_DelaySensor : public SCA_ISensor
+{
+ Py_Header;
+ bool m_lastResult;
+ bool m_repeat;
+ int m_delay;
+ int m_duration;
+ int m_frameCount;
+
+public:
+ SCA_DelaySensor(class SCA_EventManager* eventmgr,
+ SCA_IObject* gameobj,
+ int delay,
+ int duration,
+ bool repeat,
+ PyTypeObject* T =&Type);
+ virtual ~SCA_DelaySensor();
+ virtual CValue* GetReplica();
+ virtual bool Evaluate(CValue* event);
+ virtual bool IsPositiveTrigger();
+ virtual void Init();
+
+
+ /* --------------------------------------------------------------------- */
+ /* Python interface ---------------------------------------------------- */
+ /* --------------------------------------------------------------------- */
+
+ virtual PyObject* _getattr(const STR_String& attr);
+
+ /* setProperty */
+ KX_PYMETHOD_DOC(SCA_DelaySensor,SetDelay);
+ KX_PYMETHOD_DOC(SCA_DelaySensor,SetDuration);
+ KX_PYMETHOD_DOC(SCA_DelaySensor,SetRepeat);
+ /* getProperty */
+ KX_PYMETHOD_DOC_NOARGS(SCA_DelaySensor,GetDelay);
+ KX_PYMETHOD_DOC_NOARGS(SCA_DelaySensor,GetDuration);
+ KX_PYMETHOD_DOC_NOARGS(SCA_DelaySensor,GetRepeat);
+
+};
+
+#endif //__KX_ALWAYSSENSOR
+
diff --git a/source/gameengine/GameLogic/SCA_EventManager.cpp b/source/gameengine/GameLogic/SCA_EventManager.cpp
index 1ca88182ddc..e4fd0379597 100644
--- a/source/gameengine/GameLogic/SCA_EventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_EventManager.cpp
@@ -45,17 +45,14 @@ SCA_EventManager::~SCA_EventManager()
{
}
-
+void SCA_EventManager::RegisterSensor(class SCA_ISensor* sensor)
+{
+ m_sensors.insert(sensor);
+}
void SCA_EventManager::RemoveSensor(class SCA_ISensor* sensor)
{
- std::vector<SCA_ISensor*>::iterator i =
- std::find(m_sensors.begin(), m_sensors.end(), sensor);
- if (!(i == m_sensors.end()))
- {
- std::swap(*i, m_sensors.back());
- m_sensors.pop_back();
- }
+ m_sensors.erase(sensor);
}
void SCA_EventManager::NextFrame(double curtime, double fixedtime)
@@ -72,7 +69,9 @@ void SCA_EventManager::EndFrame()
{
}
-
+void SCA_EventManager::UpdateFrame()
+{
+}
int SCA_EventManager::GetType()
{
diff --git a/source/gameengine/GameLogic/SCA_EventManager.h b/source/gameengine/GameLogic/SCA_EventManager.h
index 89731497f6f..9dbb5a6d24f 100644
--- a/source/gameengine/GameLogic/SCA_EventManager.h
+++ b/source/gameengine/GameLogic/SCA_EventManager.h
@@ -30,12 +30,14 @@
#define __KX_EVENTMANAGER
#include <vector>
+#include <set>
#include <algorithm>
class SCA_EventManager
{
protected:
- std::vector <class SCA_ISensor*> m_sensors;
+ // use a set to speed-up insertion/removal
+ std::set <class SCA_ISensor*> m_sensors;
public:
enum EVENT_MANAGER_TYPE {
@@ -49,7 +51,8 @@ public:
RAY_EVENTMGR,
RADAR_EVENTMGR,
NETWORK_EVENTMGR,
- JOY_EVENTMGR
+ JOY_EVENTMGR,
+ ACTUATOR_EVENTMGR
};
SCA_EventManager(EVENT_MANAGER_TYPE mgrtype);
@@ -58,8 +61,9 @@ public:
virtual void RemoveSensor(class SCA_ISensor* sensor);
virtual void NextFrame(double curtime, double fixedtime);
virtual void NextFrame();
+ virtual void UpdateFrame();
virtual void EndFrame();
- virtual void RegisterSensor(class SCA_ISensor* sensor)=0;
+ virtual void RegisterSensor(class SCA_ISensor* sensor);
int GetType();
protected:
diff --git a/source/gameengine/GameLogic/SCA_IActuator.cpp b/source/gameengine/GameLogic/SCA_IActuator.cpp
index 568d0eb4a89..eeca2d7b44c 100644
--- a/source/gameengine/GameLogic/SCA_IActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_IActuator.cpp
@@ -36,6 +36,7 @@ using namespace std;
SCA_IActuator::SCA_IActuator(SCA_IObject* gameobj,
PyTypeObject* T) :
+ m_links(0),
SCA_ILogicBrick(gameobj,T)
{
// nothing to do
@@ -109,3 +110,12 @@ SCA_IActuator::~SCA_IActuator()
RemoveAllEvents();
}
+void SCA_IActuator::DecLink()
+{
+ m_links--;
+ if (m_links < 0)
+ {
+ printf("Warning: actuator %s has negative m_links: %d\n", m_name.Ptr(), m_links);
+ m_links = 0;
+ }
+}
diff --git a/source/gameengine/GameLogic/SCA_IActuator.h b/source/gameengine/GameLogic/SCA_IActuator.h
index bff32dcebaa..7ffb21b5490 100644
--- a/source/gameengine/GameLogic/SCA_IActuator.h
+++ b/source/gameengine/GameLogic/SCA_IActuator.h
@@ -34,8 +34,11 @@
class SCA_IActuator : public SCA_ILogicBrick
{
+ friend class SCA_LogicManager;
protected:
std::vector<CValue*> m_events;
+ int m_links; // number of active links to controllers
+ // when 0, the actuator is automatically stopped
void RemoveAllEvents();
public:
@@ -47,6 +50,15 @@ public:
PyTypeObject* T =&Type);
/**
+ * UnlinkObject(...)
+ * Certain actuator use gameobject pointers (like TractTo actuator)
+ * This function can be called when an object is removed to make
+ * sure that the actuator will not use it anymore.
+ */
+
+ virtual bool UnlinkObject(SCA_IObject* clientobj) { return false; }
+
+ /**
* Update(...)
* Update the actuator based upon the events received since
* the last call to Update, the current time and deltatime the
@@ -74,6 +86,11 @@ public:
*/
bool IsNegativeEvent() const;
virtual ~SCA_IActuator();
+
+ void ClrLink() { m_links=0; }
+ void IncLink() { m_links++; }
+ void DecLink();
+ bool IsNoLink() const { return !m_links; }
};
#endif //__KX_IACTUATOR
diff --git a/source/gameengine/GameLogic/SCA_IController.cpp b/source/gameengine/GameLogic/SCA_IController.cpp
index 5cb62678c6b..0bd20117f31 100644
--- a/source/gameengine/GameLogic/SCA_IController.cpp
+++ b/source/gameengine/GameLogic/SCA_IController.cpp
@@ -29,6 +29,7 @@
#include "SCA_IController.h"
#include "SCA_LogicManager.h"
#include "SCA_IActuator.h"
+#include "SCA_ISensor.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -37,6 +38,7 @@
SCA_IController::SCA_IController(SCA_IObject* gameobj,
PyTypeObject* T)
:
+ m_statemask(0),
SCA_ILogicBrick(gameobj,T)
{
}
@@ -45,6 +47,7 @@ SCA_IController::SCA_IController(SCA_IObject* gameobj,
SCA_IController::~SCA_IController()
{
+ UnlinkAllActuators();
}
@@ -65,6 +68,14 @@ const std::vector<class SCA_IActuator*>& SCA_IController::GetLinkedActuators()
void SCA_IController::UnlinkAllSensors()
{
+ if (IsActive())
+ {
+ std::vector<class SCA_ISensor*>::iterator sensit;
+ for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit)
+ {
+ (*sensit)->DecLink();
+ }
+ }
m_linkedsensors.clear();
}
@@ -72,6 +83,14 @@ void SCA_IController::UnlinkAllSensors()
void SCA_IController::UnlinkAllActuators()
{
+ if (IsActive())
+ {
+ std::vector<class SCA_IActuator*>::iterator actit;
+ for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit)
+ {
+ (*actit)->DecLink();
+ }
+ }
m_linkedactuators.clear();
}
@@ -95,26 +114,96 @@ void SCA_IController::Trigger(SCA_LogicManager* logicmgr)
void SCA_IController::LinkToActuator(SCA_IActuator* actua)
{
m_linkedactuators.push_back(actua);
+ if (IsActive())
+ {
+ actua->IncLink();
+ }
}
void SCA_IController::UnlinkActuator(class SCA_IActuator* actua)
{
std::vector<class SCA_IActuator*>::iterator actit;
- std::vector<class SCA_IActuator*>::iterator actfound = m_linkedactuators.end();
for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit)
{
if ((*actit) == actua)
- actfound = actit;
+ {
+ break;
+ }
}
- if (!(actfound==m_linkedactuators.end()))
+ if (!(actit==m_linkedactuators.end()))
{
- m_linkedactuators.erase(actfound);
+ if (IsActive())
+ {
+ (*actit)->DecLink();
+ }
+ m_linkedactuators.erase(actit);
}
-
}
void SCA_IController::LinkToSensor(SCA_ISensor* sensor)
{
m_linkedsensors.push_back(sensor);
+ if (IsActive())
+ {
+ sensor->IncLink();
+ }
+}
+
+void SCA_IController::UnlinkSensor(class SCA_ISensor* sensor)
+{
+ std::vector<class SCA_ISensor*>::iterator sensit;
+ for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit)
+ {
+ if ((*sensit) == sensor)
+ {
+ break;
+ }
+
+ }
+ if (!(sensit==m_linkedsensors.end()))
+ {
+ if (IsActive())
+ {
+ (*sensit)->DecLink();
+ }
+ m_linkedsensors.erase(sensit);
+ }
}
+
+void SCA_IController::ApplyState(unsigned int state)
+{
+ std::vector<class SCA_IActuator*>::iterator actit;
+ std::vector<class SCA_ISensor*>::iterator sensit;
+
+ if (m_statemask & state)
+ {
+ if (!IsActive())
+ {
+ // reactive the controller, all the links to actuator are valid again
+ for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit)
+ {
+ (*actit)->IncLink();
+ }
+ for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit)
+ {
+ (*sensit)->IncLink();
+ // remember that this controller just activated that sensor
+ (*sensit)->AddNewController(this);
+ }
+ SetActive(true);
+ }
+ } else if (IsActive())
+ {
+ for (actit = m_linkedactuators.begin();!(actit==m_linkedactuators.end());++actit)
+ {
+ (*actit)->DecLink();
+ }
+ for (sensit = m_linkedsensors.begin();!(sensit==m_linkedsensors.end());++sensit)
+ {
+ (*sensit)->DecLink();
+ }
+ SetActive(false);
+ }
+}
+
diff --git a/source/gameengine/GameLogic/SCA_IController.h b/source/gameengine/GameLogic/SCA_IController.h
index 79e956dec4e..f67c0942eb4 100644
--- a/source/gameengine/GameLogic/SCA_IController.h
+++ b/source/gameengine/GameLogic/SCA_IController.h
@@ -36,6 +36,7 @@ class SCA_IController : public SCA_ILogicBrick
protected:
std::vector<class SCA_ISensor*> m_linkedsensors;
std::vector<class SCA_IActuator*> m_linkedactuators;
+ unsigned int m_statemask;
public:
SCA_IController(SCA_IObject* gameobj,PyTypeObject* T);
virtual ~SCA_IController();
@@ -47,6 +48,9 @@ public:
void UnlinkAllSensors();
void UnlinkAllActuators();
void UnlinkActuator(class SCA_IActuator* actua);
+ void UnlinkSensor(class SCA_ISensor* sensor);
+ void SetState(unsigned int state) { m_statemask = state; }
+ void ApplyState(unsigned int state);
};
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
index 8423d06dfcd..abd049e9d64 100644
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
+++ b/source/gameengine/GameLogic/SCA_ILogicBrick.cpp
@@ -27,6 +27,7 @@
*/
#include "SCA_ILogicBrick.h"
+#include "PyObjectPlus.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -82,7 +83,10 @@ void SCA_ILogicBrick::ReParent(SCA_IObject* parent)
m_gameobj = parent;
}
-
+void SCA_ILogicBrick::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
+{
+ // nothing to do
+}
CValue* SCA_ILogicBrick::Calc(VALUE_OPERATOR op, CValue *val)
{
@@ -242,8 +246,8 @@ PyParentObject SCA_ILogicBrick::Parents[] = {
PyMethodDef SCA_ILogicBrick::Methods[] = {
- {"getOwner", (PyCFunction) SCA_ILogicBrick::sPyGetOwner, METH_VARARGS},
- {"getExecutePriority", (PyCFunction) SCA_ILogicBrick::sPySetExecutePriority, METH_VARARGS},
+ {"getOwner", (PyCFunction) SCA_ILogicBrick::sPyGetOwner, METH_NOARGS},
+ {"getExecutePriority", (PyCFunction) SCA_ILogicBrick::sPySetExecutePriority, METH_NOARGS},
{"setExecutePriority", (PyCFunction) SCA_ILogicBrick::sPySetExecutePriority, METH_VARARGS},
{NULL,NULL} //Sentinel
};
@@ -258,9 +262,7 @@ SCA_ILogicBrick::_getattr(const STR_String& attr)
-PyObject* SCA_ILogicBrick::PyGetOwner(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* SCA_ILogicBrick::PyGetOwner(PyObject* self)
{
CValue* parent = GetParent();
if (parent)
@@ -270,8 +272,7 @@ PyObject* SCA_ILogicBrick::PyGetOwner(PyObject* self,
}
printf("ERROR: Python scriptblock without owner\n");
- Py_INCREF(Py_None);
- return Py_None;//Int_FromLong(IsPositiveTrigger());
+ Py_RETURN_NONE; //Int_FromLong(IsPositiveTrigger());
}
@@ -294,9 +295,7 @@ PyObject* SCA_ILogicBrick::PySetExecutePriority(PyObject* self,
-PyObject* SCA_ILogicBrick::PyGetExecutePriority(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* SCA_ILogicBrick::PyGetExecutePriority(PyObject* self)
{
return PyInt_FromLong(m_Execute_Ueber_Priority);
}
diff --git a/source/gameengine/GameLogic/SCA_ILogicBrick.h b/source/gameengine/GameLogic/SCA_ILogicBrick.h
index f359ee0911b..c28711ac0f6 100644
--- a/source/gameengine/GameLogic/SCA_ILogicBrick.h
+++ b/source/gameengine/GameLogic/SCA_ILogicBrick.h
@@ -32,6 +32,8 @@
#include "Value.h"
#include "SCA_IObject.h"
#include "BoolValue.h"
+#include "GEN_Map.h"
+#include "GEN_HashedPtr.h"
class SCA_ILogicBrick : public CValue
{
@@ -59,6 +61,7 @@ public:
SCA_IObject* GetParent();
virtual void ReParent(SCA_IObject* parent);
+ virtual void Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map);
// act as a BoolValue (with value IsPositiveTrigger)
virtual CValue* Calc(VALUE_OPERATOR op, CValue *val);
@@ -82,9 +85,9 @@ public:
// python methods
- KX_PYMETHOD(SCA_ILogicBrick,GetOwner);
+ KX_PYMETHOD_NOARGS(SCA_ILogicBrick,GetOwner);
KX_PYMETHOD(SCA_ILogicBrick,SetExecutePriority);
- KX_PYMETHOD(SCA_ILogicBrick,GetExecutePriority);
+ KX_PYMETHOD_NOARGS(SCA_ILogicBrick,GetExecutePriority);
enum KX_BOOL_TYPE {
KX_BOOL_NODEF = 0,
diff --git a/source/gameengine/GameLogic/SCA_IObject.cpp b/source/gameengine/GameLogic/SCA_IObject.cpp
index 0d315a55f43..b0f8decee26 100644
--- a/source/gameengine/GameLogic/SCA_IObject.cpp
+++ b/source/gameengine/GameLogic/SCA_IObject.cpp
@@ -40,7 +40,7 @@
MT_Point3 SCA_IObject::m_sDummy=MT_Point3(0,0,0);
-SCA_IObject::SCA_IObject(PyTypeObject* T): CValue(T)
+SCA_IObject::SCA_IObject(PyTypeObject* T): m_initState(0), m_state(0), CValue(T)
{
m_suspended = false;
}
@@ -52,7 +52,9 @@ SCA_IObject::~SCA_IObject()
SCA_SensorList::iterator its;
for (its = m_sensors.begin(); !(its == m_sensors.end()); ++its)
{
- ((CValue*)(*its))->Release();
+ //Use Delete for sensor to ensure proper cleaning
+ (*its)->Delete();
+ //((CValue*)(*its))->Release();
}
SCA_ControllerList::iterator itc;
for (itc = m_controllers.begin(); !(itc == m_controllers.end()); ++itc)
@@ -60,6 +62,10 @@ SCA_IObject::~SCA_IObject()
((CValue*)(*itc))->Release();
}
SCA_ActuatorList::iterator ita;
+ for (ita = m_registeredActuators.begin(); !(ita==m_registeredActuators.end()); ++ita)
+ {
+ (*ita)->UnlinkObject(this);
+ }
for (ita = m_actuators.begin(); !(ita==m_actuators.end()); ++ita)
{
((CValue*)(*ita))->Release();
@@ -96,6 +102,7 @@ SCA_ActuatorList& SCA_IObject::GetActuators()
void SCA_IObject::AddSensor(SCA_ISensor* act)
{
+ act->AddRef();
m_sensors.push_back(act);
}
@@ -103,6 +110,7 @@ void SCA_IObject::AddSensor(SCA_ISensor* act)
void SCA_IObject::AddController(SCA_IController* act)
{
+ act->AddRef();
m_controllers.push_back(act);
}
@@ -110,10 +118,28 @@ void SCA_IObject::AddController(SCA_IController* act)
void SCA_IObject::AddActuator(SCA_IActuator* act)
{
+ act->AddRef();
m_actuators.push_back(act);
}
+void SCA_IObject::RegisterActuator(SCA_IActuator* act)
+{
+ // don't increase ref count, it would create dead lock
+ m_registeredActuators.push_back(act);
+}
+void SCA_IObject::UnregisterActuator(SCA_IActuator* act)
+{
+ SCA_ActuatorList::iterator ita;
+ for (ita = m_registeredActuators.begin(); ita != m_registeredActuators.end(); ita++)
+ {
+ if ((*ita) == act) {
+ (*ita) = m_registeredActuators.back();
+ m_registeredActuators.pop_back();
+ break;
+ }
+ }
+}
void SCA_IObject::SetIgnoreActivityCulling(bool b)
{
@@ -131,15 +157,17 @@ bool SCA_IObject::GetIgnoreActivityCulling()
void SCA_IObject::ReParentLogic()
{
- SCA_SensorList& oldsensors = GetSensors();
-
- int sen = 0;
- SCA_SensorList::iterator its;
- for (its = oldsensors.begin(); !(its==oldsensors.end()); ++its)
+ SCA_ActuatorList& oldactuators = GetActuators();
+ int act = 0;
+ SCA_ActuatorList::iterator ita;
+ for (ita = oldactuators.begin(); !(ita==oldactuators.end()); ++ita)
{
- SCA_ISensor* newsensor = (SCA_ISensor*)(*its)->GetReplica();
- newsensor->ReParent(this);
- oldsensors[sen++] = newsensor;
+ SCA_IActuator* newactuator = (SCA_IActuator*) (*ita)->GetReplica();
+ newactuator->ReParent(this);
+ // actuators are initially not connected to any controller
+ newactuator->SetActive(false);
+ newactuator->ClrLink();
+ oldactuators[act++] = newactuator;
}
SCA_ControllerList& oldcontrollers = GetControllers();
@@ -149,20 +177,26 @@ void SCA_IObject::ReParentLogic()
{
SCA_IController* newcontroller = (SCA_IController*)(*itc)->GetReplica();
newcontroller->ReParent(this);
+ newcontroller->SetActive(false);
oldcontrollers[con++]=newcontroller;
}
- SCA_ActuatorList& oldactuators = GetActuators();
-
- int act = 0;
- SCA_ActuatorList::iterator ita;
- for (ita = oldactuators.begin(); !(ita==oldactuators.end()); ++ita)
+ // convert sensors last so that actuators are already available for Actuator sensor
+ SCA_SensorList& oldsensors = GetSensors();
+ int sen = 0;
+ SCA_SensorList::iterator its;
+ for (its = oldsensors.begin(); !(its==oldsensors.end()); ++its)
{
- SCA_IActuator* newactuator = (SCA_IActuator*) (*ita)->GetReplica();
- newactuator->ReParent(this);
- newactuator->SetActive(false);
- oldactuators[act++] = newactuator;
+ SCA_ISensor* newsensor = (SCA_ISensor*)(*its)->GetReplica();
+ newsensor->ReParent(this);
+ newsensor->SetActive(false);
+ // sensors are initially not connected to any controller
+ newsensor->ClrLink();
+ oldsensors[sen++] = newsensor;
}
+
+ // a new object cannot be client of any actuator
+ m_registeredActuators.clear();
}
@@ -272,7 +306,7 @@ const MT_Point3& SCA_IObject::ConvertPythonPylist(PyObject* pylist)
}
#endif
-void SCA_IObject::Suspend(void)
+void SCA_IObject::Suspend()
{
if ((!m_ignore_activity_culling)
&& (!m_suspended)) {
@@ -301,6 +335,36 @@ void SCA_IObject::Resume(void)
}
}
+void SCA_IObject::SetState(unsigned int state)
+{
+ unsigned int tmpstate;
+ SCA_ControllerList::iterator contit;
+
+ // we will update the state in two steps:
+ // 1) set the new state bits that are 1
+ // 2) clr the new state bits that are 0
+ // This to ensure continuity if a sensor is attached to two states
+ // that are switching state: no need to deactive and reactive the sensor
+
+ tmpstate = m_state | state;
+ if (tmpstate != m_state)
+ {
+ // update the status of the controllers
+ for (contit = m_controllers.begin(); contit != m_controllers.end(); contit++)
+ {
+ (*contit)->ApplyState(tmpstate);
+ }
+ }
+ m_state = state;
+ if (m_state != tmpstate)
+ {
+ for (contit = m_controllers.begin(); contit != m_controllers.end(); contit++)
+ {
+ (*contit)->ApplyState(m_state);
+ }
+ }
+}
+
/* ------------------------------------------------------------------------- */
diff --git a/source/gameengine/GameLogic/SCA_IObject.h b/source/gameengine/GameLogic/SCA_IObject.h
index 8f3e25afa03..38a7ed29dca 100644
--- a/source/gameengine/GameLogic/SCA_IObject.h
+++ b/source/gameengine/GameLogic/SCA_IObject.h
@@ -55,6 +55,7 @@ protected:
SCA_SensorList m_sensors;
SCA_ControllerList m_controllers;
SCA_ActuatorList m_actuators;
+ SCA_ActuatorList m_registeredActuators; // actuators that use a pointer to this object
static class MT_Point3 m_sDummy;
/**
@@ -66,7 +67,17 @@ protected:
* Ignore updates?
*/
bool m_suspended;
-
+
+ /**
+ * init state of object (used when object is created)
+ */
+ unsigned int m_initState;
+
+ /**
+ * current state = bit mask of state that are active
+ */
+ unsigned int m_state;
+
public:
SCA_IObject(PyTypeObject* T=&Type);
@@ -79,6 +90,8 @@ public:
void AddSensor(SCA_ISensor* act);
void AddController(SCA_IController* act);
void AddActuator(SCA_IActuator* act);
+ void RegisterActuator(SCA_IActuator* act);
+ void UnregisterActuator(SCA_IActuator* act);
SCA_ISensor* FindSensor(const STR_String& sensorname);
SCA_IActuator* FindActuator(const STR_String& actuatorname);
@@ -108,7 +121,27 @@ public:
* Resume progress
*/
void Resume(void);
-
+
+ /**
+ * Set init state
+ */
+ void SetInitState(unsigned int initState) { m_initState = initState; }
+
+ /**
+ * initialize the state when object is created
+ */
+ void ResetState(void) { SetState(m_initState); }
+
+ /**
+ * Set the object state
+ */
+ void SetState(unsigned int state);
+
+ /**
+ * Get the object state
+ */
+ unsigned int GetState(void) { return m_state; }
+
// const class MT_Point3& ConvertPythonPylist(PyObject* pylist);
// here come the python forwarded methods
@@ -117,7 +150,7 @@ public:
virtual int GetGameObjectType() {return -1;}
typedef enum ObjectTypes {
- OBJ_ARMATURE=0
+ OBJ_ARMATURE=0,
}ObjectTypes;
};
diff --git a/source/gameengine/GameLogic/SCA_IScene.cpp b/source/gameengine/GameLogic/SCA_IScene.cpp
index 5e4e1cdcf92..9fbeb706910 100644
--- a/source/gameengine/GameLogic/SCA_IScene.cpp
+++ b/source/gameengine/GameLogic/SCA_IScene.cpp
@@ -27,25 +27,40 @@
*/
#include "SCA_IScene.h"
+#include "Value.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-SCA_IScene::SCA_IScene()
+SCA_DebugProp::SCA_DebugProp(): m_obj(NULL)
{
}
+SCA_DebugProp::~SCA_DebugProp()
+{
+ if (m_obj)
+ m_obj->Release();
+}
+SCA_IScene::SCA_IScene()
+{
+}
-SCA_IScene::~SCA_IScene()
+void SCA_IScene::RemoveAllDebugProperties()
{
- // release debugprop list
for (std::vector<SCA_DebugProp*>::iterator it = m_debugList.begin();
!(it==m_debugList.end());it++)
{
delete (*it);
}
+ m_debugList.clear();
+}
+
+
+SCA_IScene::~SCA_IScene()
+{
+ RemoveAllDebugProperties();
}
@@ -61,6 +76,7 @@ void SCA_IScene::AddDebugProperty(class CValue* debugprop,
{
SCA_DebugProp* dprop = new SCA_DebugProp();
dprop->m_obj = debugprop;
+ debugprop->AddRef();
dprop->m_name = name;
m_debugList.push_back(dprop);
}
diff --git a/source/gameengine/GameLogic/SCA_IScene.h b/source/gameengine/GameLogic/SCA_IScene.h
index 145d8a98512..d18778a37c2 100644
--- a/source/gameengine/GameLogic/SCA_IScene.h
+++ b/source/gameengine/GameLogic/SCA_IScene.h
@@ -37,6 +37,8 @@ struct SCA_DebugProp
{
class CValue* m_obj;
STR_String m_name;
+ SCA_DebugProp();
+ ~SCA_DebugProp();
};
class SCA_IScene
@@ -57,6 +59,7 @@ public:
std::vector<SCA_DebugProp*>& GetDebugProperties();
void AddDebugProperty(class CValue* debugprop,
const STR_String &name);
+ void RemoveAllDebugProperties();
};
#endif //__KX_ISCENE_H
diff --git a/source/gameengine/GameLogic/SCA_ISensor.cpp b/source/gameengine/GameLogic/SCA_ISensor.cpp
index 9fdee0c19da..b10ac676464 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.cpp
+++ b/source/gameengine/GameLogic/SCA_ISensor.cpp
@@ -32,6 +32,8 @@
#include "SCA_ISensor.h"
#include "SCA_EventManager.h"
#include "SCA_LogicManager.h"
+// needed for IsTriggered()
+#include "SCA_PythonController.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -41,7 +43,8 @@
void SCA_ISensor::ReParent(SCA_IObject* parent)
{
SCA_ILogicBrick::ReParent(parent);
- m_eventmgr->RegisterSensor(this);
+ // will be done when the sensor is activated
+ //m_eventmgr->RegisterSensor(this);
this->SetActive(false);
}
@@ -52,8 +55,11 @@ SCA_ISensor::SCA_ISensor(SCA_IObject* gameobj,
SCA_ILogicBrick(gameobj,T),
m_triggered(false)
{
+ m_links = 0;
m_suspended = false;
m_invert = false;
+ m_level = false;
+ m_reset = false;
m_pos_ticks = 0;
m_neg_ticks = 0;
m_pos_pulsemode = false;
@@ -94,6 +100,10 @@ void SCA_ISensor::SetInvert(bool inv) {
m_invert = inv;
}
+void SCA_ISensor::SetLevel(bool lvl) {
+ m_level = lvl;
+}
+
float SCA_ISensor::GetNumber() {
return IsPositiveTrigger();
@@ -111,6 +121,24 @@ void SCA_ISensor::Resume() {
m_suspended = false;
}
+void SCA_ISensor::Init() {
+ printf("Sensor %s has no init function, please report this bug to Blender.org\n", m_name.Ptr());
+}
+
+void SCA_ISensor::DecLink() {
+ m_links--;
+ if (m_links < 0)
+ {
+ printf("Warning: sensor %s has negative m_links: %d\n", m_name.Ptr(), m_links);
+ m_links = 0;
+ }
+ if (!m_links)
+ {
+ // sensor is detached from all controllers, remove it from manager
+ UnregisterToManager();
+ }
+}
+
/* python integration */
PyTypeObject SCA_ISensor::Type = {
@@ -140,23 +168,31 @@ PyParentObject SCA_ISensor::Parents[] = {
};
PyMethodDef SCA_ISensor::Methods[] = {
{"isPositive", (PyCFunction) SCA_ISensor::sPyIsPositive,
- METH_VARARGS, IsPositive_doc},
+ METH_NOARGS, (PY_METHODCHAR)IsPositive_doc},
+ {"isTriggered", (PyCFunction) SCA_ISensor::sPyIsTriggered,
+ METH_VARARGS, (PY_METHODCHAR)IsTriggered_doc},
{"getUsePosPulseMode", (PyCFunction) SCA_ISensor::sPyGetUsePosPulseMode,
- METH_VARARGS, GetUsePosPulseMode_doc},
+ METH_NOARGS, (PY_METHODCHAR)GetUsePosPulseMode_doc},
{"setUsePosPulseMode", (PyCFunction) SCA_ISensor::sPySetUsePosPulseMode,
- METH_VARARGS, SetUsePosPulseMode_doc},
+ METH_VARARGS, (PY_METHODCHAR)SetUsePosPulseMode_doc},
{"getFrequency", (PyCFunction) SCA_ISensor::sPyGetFrequency,
- METH_VARARGS, GetFrequency_doc},
+ METH_NOARGS, (PY_METHODCHAR)GetFrequency_doc},
{"setFrequency", (PyCFunction) SCA_ISensor::sPySetFrequency,
- METH_VARARGS, SetFrequency_doc},
+ METH_VARARGS, (PY_METHODCHAR)SetFrequency_doc},
{"getUseNegPulseMode", (PyCFunction) SCA_ISensor::sPyGetUseNegPulseMode,
- METH_VARARGS, GetUseNegPulseMode_doc},
+ METH_NOARGS, (PY_METHODCHAR)GetUseNegPulseMode_doc},
{"setUseNegPulseMode", (PyCFunction) SCA_ISensor::sPySetUseNegPulseMode,
- METH_VARARGS, SetUseNegPulseMode_doc},
+ METH_VARARGS, (PY_METHODCHAR)SetUseNegPulseMode_doc},
{"getInvert", (PyCFunction) SCA_ISensor::sPyGetInvert,
- METH_VARARGS, GetInvert_doc},
+ METH_NOARGS, (PY_METHODCHAR)GetInvert_doc},
{"setInvert", (PyCFunction) SCA_ISensor::sPySetInvert,
- METH_VARARGS, SetInvert_doc},
+ METH_VARARGS, (PY_METHODCHAR)SetInvert_doc},
+ {"getLevel", (PyCFunction) SCA_ISensor::sPyGetLevel,
+ METH_NOARGS, (PY_METHODCHAR)GetLevel_doc},
+ {"setLevel", (PyCFunction) SCA_ISensor::sPySetLevel,
+ METH_VARARGS, (PY_METHODCHAR)SetLevel_doc},
+ {"reset", (PyCFunction) SCA_ISensor::sPyReset,
+ METH_NOARGS, (PY_METHODCHAR)Reset_doc},
{NULL,NULL} //Sentinel
};
@@ -170,17 +206,29 @@ SCA_ISensor::_getattr(const STR_String& attr)
void SCA_ISensor::RegisterToManager()
{
+ // sensor is just activated, initialize it
+ Init();
+ m_newControllers.erase(m_newControllers.begin(), m_newControllers.end());
m_eventmgr->RegisterSensor(this);
}
+void SCA_ISensor::UnregisterToManager()
+{
+ m_eventmgr->RemoveSensor(this);
+}
+
void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr, CValue* event)
{
// calculate if a __triggering__ is wanted
- if (!m_suspended) {
+ // don't evaluate a sensor that is not connected to any controller
+ if (m_links && !m_suspended) {
bool result = this->Evaluate(event);
if (result) {
logicmgr->AddActivatedSensor(this);
+ // reset these counters so that pulse are synchronized with transition
+ m_pos_ticks = 0;
+ m_neg_ticks = 0;
} else
{
/* First, the pulsing behaviour, if pulse mode is
@@ -209,26 +257,54 @@ void SCA_ISensor::Activate(class SCA_LogicManager* logicmgr, CValue* event)
}
}
}
+ if (!m_newControllers.empty())
+ {
+ if (!IsActive() && m_level)
+ {
+ // This level sensor is connected to at least one controller that was just made
+ // active but it did not generate an event yet, do it now to those controllers only
+ for (std::vector<SCA_IController*>::iterator ci=m_newControllers.begin();
+ ci != m_newControllers.end(); ci++)
+ {
+ logicmgr->AddTriggeredController(*ci, this);
+ }
+ }
+ // clear the list. Instead of using clear, which also release the memory,
+ // use erase, which keeps the memory available for next time.
+ m_newControllers.erase(m_newControllers.begin(), m_newControllers.end());
+ }
}
}
/* Python functions: */
-char SCA_ISensor::IsPositive_doc[] =
+const char SCA_ISensor::IsPositive_doc[] =
"isPositive()\n"
-"\tReturns whether the sensor is registered a positive event.\n";
-PyObject* SCA_ISensor::PyIsPositive(PyObject* self, PyObject* args, PyObject* kwds)
+"\tReturns whether the sensor is in an active state.\n";
+PyObject* SCA_ISensor::PyIsPositive(PyObject* self)
{
int retval = IsPositiveTrigger();
return PyInt_FromLong(retval);
}
+const char SCA_ISensor::IsTriggered_doc[] =
+"isTriggered()\n"
+"\tReturns whether the sensor has triggered the current controller.\n";
+PyObject* SCA_ISensor::PyIsTriggered(PyObject* self)
+{
+ // check with the current controller
+ int retval = 0;
+ if (SCA_PythonController::m_sCurrentController)
+ retval = SCA_PythonController::m_sCurrentController->IsTriggered(this);
+ return PyInt_FromLong(retval);
+}
+
/**
* getUsePulseMode: getter for the pulse mode (KX_TRUE = on)
*/
-char SCA_ISensor::GetUsePosPulseMode_doc[] =
+const char SCA_ISensor::GetUsePosPulseMode_doc[] =
"getUsePosPulseMode()\n"
"\tReturns whether positive pulse mode is active.\n";
-PyObject* SCA_ISensor::PyGetUsePosPulseMode(PyObject* self, PyObject* args, PyObject* kwds)
+PyObject* SCA_ISensor::PyGetUsePosPulseMode(PyObject* self)
{
return BoolToPyArg(m_pos_pulsemode);
}
@@ -236,7 +312,7 @@ PyObject* SCA_ISensor::PyGetUsePosPulseMode(PyObject* self, PyObject* args, PyOb
/**
* setUsePulseMode: setter for the pulse mode (KX_TRUE = on)
*/
-char SCA_ISensor::SetUsePosPulseMode_doc[] =
+const char SCA_ISensor::SetUsePosPulseMode_doc[] =
"setUsePosPulseMode(pulse?)\n"
"\t - pulse? : Pulse when a positive event occurs?\n"
"\t (KX_TRUE, KX_FALSE)\n"
@@ -252,10 +328,10 @@ PyObject* SCA_ISensor::PySetUsePosPulseMode(PyObject* self, PyObject* args, PyOb
/**
* getFrequency: getter for the pulse mode interval
*/
-char SCA_ISensor::GetFrequency_doc[] =
+const char SCA_ISensor::GetFrequency_doc[] =
"getFrequency()\n"
"\tReturns the frequency of the updates in pulse mode.\n" ;
-PyObject* SCA_ISensor::PyGetFrequency(PyObject* self, PyObject* args, PyObject* kwds)
+PyObject* SCA_ISensor::PyGetFrequency(PyObject* self)
{
return PyInt_FromLong(m_pulse_frequency);
}
@@ -263,7 +339,7 @@ PyObject* SCA_ISensor::PyGetFrequency(PyObject* self, PyObject* args, PyObject*
/**
* setFrequency: setter for the pulse mode (KX_TRUE = on)
*/
-char SCA_ISensor::SetFrequency_doc[] =
+const char SCA_ISensor::SetFrequency_doc[] =
"setFrequency(pulse_frequency)\n"
"\t- pulse_frequency: The frequency of the updates in pulse mode (integer)"
"\tSet the frequency of the updates in pulse mode.\n"
@@ -287,15 +363,15 @@ PyObject* SCA_ISensor::PySetFrequency(PyObject* self, PyObject* args, PyObject*
}
-char SCA_ISensor::GetInvert_doc[] =
+const char SCA_ISensor::GetInvert_doc[] =
"getInvert()\n"
"\tReturns whether or not pulses from this sensor are inverted.\n" ;
-PyObject* SCA_ISensor::PyGetInvert(PyObject* self, PyObject* args, PyObject* kwds)
+PyObject* SCA_ISensor::PyGetInvert(PyObject* self)
{
return BoolToPyArg(m_invert);
}
-char SCA_ISensor::SetInvert_doc[] =
+const char SCA_ISensor::SetInvert_doc[] =
"setInvert(invert?)\n"
"\t- invert?: Invert the event-values? (KX_TRUE, KX_FALSE)\n"
"\tSet whether to invert pulses.\n";
@@ -307,15 +383,39 @@ PyObject* SCA_ISensor::PySetInvert(PyObject* self, PyObject* args, PyObject* kwd
Py_Return;
}
-char SCA_ISensor::GetUseNegPulseMode_doc[] =
+const char SCA_ISensor::GetLevel_doc[] =
+"getLevel()\n"
+"\tReturns whether this sensor is a level detector or a edge detector.\n"
+"\tIt makes a difference only in case of logic state transition (state actuator).\n"
+"\tA level detector will immediately generate a pulse, negative or positive\n"
+"\tdepending on the sensor condition, as soon as the state is activated.\n"
+"\tA edge detector will wait for a state change before generating a pulse.\n";
+PyObject* SCA_ISensor::PyGetLevel(PyObject* self)
+{
+ return BoolToPyArg(m_level);
+}
+
+const char SCA_ISensor::SetLevel_doc[] =
+"setLevel(level?)\n"
+"\t- level?: Detect level instead of edge? (KX_TRUE, KX_FALSE)\n"
+"\tSet whether to detect level or edge transition when entering a state.\n";
+PyObject* SCA_ISensor::PySetLevel(PyObject* self, PyObject* args, PyObject* kwds)
+{
+ int pyarg = 0;
+ if(!PyArg_ParseTuple(args, "i", &pyarg)) { return NULL; }
+ m_level = PyArgToBool(pyarg);
+ Py_Return;
+}
+
+const char SCA_ISensor::GetUseNegPulseMode_doc[] =
"getUseNegPulseMode()\n"
"\tReturns whether negative pulse mode is active.\n";
-PyObject* SCA_ISensor::PyGetUseNegPulseMode(PyObject* self, PyObject* args, PyObject* kwds)
+PyObject* SCA_ISensor::PyGetUseNegPulseMode(PyObject* self)
{
return BoolToPyArg(m_neg_pulsemode);
}
-char SCA_ISensor::SetUseNegPulseMode_doc[] =
+const char SCA_ISensor::SetUseNegPulseMode_doc[] =
"setUseNegPulseMode(pulse?)\n"
"\t - pulse? : Pulse when a negative event occurs?\n"
"\t (KX_TRUE, KX_FALSE)\n"
@@ -328,4 +428,15 @@ PyObject* SCA_ISensor::PySetUseNegPulseMode(PyObject* self, PyObject* args, PyOb
Py_Return;
}
+const char SCA_ISensor::Reset_doc[] =
+"reset()\n"
+"\tReset sensor internal state, effect depends on the type of sensor and settings.\n"
+"\tThe sensor is put in its initial state as if it was just activated.\n";
+PyObject* SCA_ISensor::PyReset(PyObject* self)
+{
+ Init();
+ Py_Return;
+}
+
+
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_ISensor.h b/source/gameengine/GameLogic/SCA_ISensor.h
index 000a4951e0f..d1872009291 100644
--- a/source/gameengine/GameLogic/SCA_ISensor.h
+++ b/source/gameengine/GameLogic/SCA_ISensor.h
@@ -34,6 +34,8 @@
#include "SCA_ILogicBrick.h"
+#include <vector>
+
/**
* Interface Class for all logic Sensors. Implements
* pulsemode,pulsefrequency */
@@ -61,12 +63,21 @@ class SCA_ISensor : public SCA_ILogicBrick
/** invert the output signal*/
bool m_invert;
+ /** detect level instead of edge*/
+ bool m_level;
+
+ /** sensor has been reset */
+ bool m_reset;
+
/** Sensor must ignore updates? */
bool m_suspended;
- /** Pass the activation on to the logic manager.*/
- void SignalActivation(class SCA_LogicManager* logicmgr);
-
+ /** number of connections to controller */
+ int m_links;
+
+ /** list of controllers that have just activated this sensor because of a state change */
+ std::vector<class SCA_IController*> m_newControllers;
+
public:
SCA_ISensor(SCA_IObject* gameobj,
class SCA_EventManager* eventmgr,
@@ -81,6 +92,7 @@ public:
void Activate(class SCA_LogicManager* logicmgr,CValue* event);
virtual bool Evaluate(CValue* event) = 0;
virtual bool IsPositiveTrigger();
+ virtual void Init();
virtual PyObject* _getattr(const STR_String& attr);
virtual CValue* GetReplica()=0;
@@ -94,10 +106,19 @@ public:
bool negmode,
int freq);
+ /** Release sensor
+ * For property sensor, it is used to release the pre-calculated expression
+ * so that self references are removed before the sensor itself is released
+ */
+ virtual void Delete() { Release(); }
/** Set inversion of pulses on or off. */
void SetInvert(bool inv);
+ /** set the level detection on or off */
+ void SetLevel(bool lvl);
+
+ virtual void RegisterToManager();
+ virtual void UnregisterToManager();
- void RegisterToManager();
virtual float GetNumber();
/** Stop sensing for a while. */
@@ -109,16 +130,30 @@ public:
/** Resume sensing. */
void Resume();
+ void AddNewController(class SCA_IController* controller)
+ { m_newControllers.push_back(controller); }
+ void ClrLink()
+ { m_links = 0; }
+ void IncLink()
+ { if (!m_links++) RegisterToManager(); }
+ void DecLink();
+ bool IsNoLink() const
+ { return !m_links; }
+
/* Python functions: */
- KX_PYMETHOD_DOC(SCA_ISensor,IsPositive);
- KX_PYMETHOD_DOC(SCA_ISensor,GetUsePosPulseMode);
+ KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsPositive);
+ KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,IsTriggered);
+ KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetUsePosPulseMode);
KX_PYMETHOD_DOC(SCA_ISensor,SetUsePosPulseMode);
- KX_PYMETHOD_DOC(SCA_ISensor,GetFrequency);
+ KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetFrequency);
KX_PYMETHOD_DOC(SCA_ISensor,SetFrequency);
- KX_PYMETHOD_DOC(SCA_ISensor,GetUseNegPulseMode);
+ KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetUseNegPulseMode);
KX_PYMETHOD_DOC(SCA_ISensor,SetUseNegPulseMode);
- KX_PYMETHOD_DOC(SCA_ISensor,GetInvert);
+ KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetInvert);
KX_PYMETHOD_DOC(SCA_ISensor,SetInvert);
+ KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,GetLevel);
+ KX_PYMETHOD_DOC(SCA_ISensor,SetLevel);
+ KX_PYMETHOD_DOC_NOARGS(SCA_ISensor,Reset);
};
diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.cpp b/source/gameengine/GameLogic/SCA_JoystickManager.cpp
index a095ad2a594..f3ce549a637 100644
--- a/source/gameengine/GameLogic/SCA_JoystickManager.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickManager.cpp
@@ -40,42 +40,49 @@ SCA_JoystickManager::SCA_JoystickManager(class SCA_LogicManager* logicmgr)
: SCA_EventManager(JOY_EVENTMGR),
m_logicmgr(logicmgr)
{
- m_joystick = new SCA_Joystick();
- m_joystick->CreateJoystickDevice();
+ int i;
+ for (i=0; i<JOYINDEX_MAX; i++) {
+ m_joystick[i] = SCA_Joystick::GetInstance( i );
+ }
}
SCA_JoystickManager::~SCA_JoystickManager()
{
- m_joystick->DestroyJoystickDevice();
- delete m_joystick;
+ int i;
+ for (i=0; i<JOYINDEX_MAX; i++) {
+ if(m_joystick[i])
+ m_joystick[i]->ReleaseInstance();
+ }
}
void SCA_JoystickManager::NextFrame(double curtime,double deltatime)
{
- for (unsigned int i = 0; i < m_sensors.size(); i++)
- {
- SCA_JoystickSensor* joysensor = (SCA_JoystickSensor*) m_sensors[i];
- if(!joysensor->IsSuspended())
+ if (m_sensors.size()==0) {
+ return;
+ }
+ else {
+ set<SCA_ISensor*>::iterator it;
+#ifndef DISABLE_SDL
+ SCA_Joystick::HandleEvents(); /* Handle all SDL Joystick events */
+#endif
+ for (it = m_sensors.begin(); it != m_sensors.end(); it++)
{
- m_joystick->HandleEvents();
- joysensor->Activate(m_logicmgr, NULL);
+ SCA_JoystickSensor* joysensor = (SCA_JoystickSensor*)(*it);
+ if(!joysensor->IsSuspended())
+ {
+ joysensor->Activate(m_logicmgr, NULL);
+ }
}
}
}
-void SCA_JoystickManager::RegisterSensor(SCA_ISensor* sensor)
-{
- m_sensors.push_back(sensor);
-}
-
-
-SCA_Joystick *SCA_JoystickManager::GetJoystickDevice()
+SCA_Joystick *SCA_JoystickManager::GetJoystickDevice( short int joyindex)
{
/*
*Return the instance of SCA_Joystick for use
*/
- return m_joystick;
+ return m_joystick[joyindex];
}
diff --git a/source/gameengine/GameLogic/SCA_JoystickManager.h b/source/gameengine/GameLogic/SCA_JoystickManager.h
index 3c4df64677e..d3a7ac95bea 100644
--- a/source/gameengine/GameLogic/SCA_JoystickManager.h
+++ b/source/gameengine/GameLogic/SCA_JoystickManager.h
@@ -40,13 +40,12 @@ class SCA_JoystickManager : public SCA_EventManager
/**
* SDL Joystick Class Instance
*/
- SCA_Joystick *m_joystick;
+ SCA_Joystick *m_joystick[JOYINDEX_MAX];
public:
SCA_JoystickManager(class SCA_LogicManager* logicmgr);
virtual ~SCA_JoystickManager();
virtual void NextFrame(double curtime,double deltatime);
- virtual void RegisterSensor(SCA_ISensor* sensor);
- SCA_Joystick* GetJoystickDevice(void);
+ SCA_Joystick* GetJoystickDevice(short int joyindex);
};
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
index b0e7fee130d..8b96840b149 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.cpp
@@ -30,8 +30,11 @@
#include "SCA_EventManager.h"
#include "SCA_LogicManager.h"
+#include "PyObjectPlus.h"
+
#include <iostream>
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -39,34 +42,41 @@
SCA_JoystickSensor::SCA_JoystickSensor(class SCA_JoystickManager* eventmgr,
SCA_IObject* gameobj,
+ short int joyindex,
short int joymode,
int axis, int axisf,int prec,
- int button, int buttonf,
- int hat, int hatf,
+ int button,
+ int hat, int hatf, bool allevents,
PyTypeObject* T )
:SCA_ISensor(gameobj,eventmgr,T),
m_pJoystickMgr(eventmgr),
m_axis(axis),
m_axisf(axisf),
m_button(button),
- m_buttonf(buttonf),
m_hat(hat),
m_hatf(hatf),
m_precision(prec),
- m_joymode(joymode)
+ m_joymode(joymode),
+ m_joyindex(joyindex),
+ m_bAllEvents(allevents)
{
/*
std::cout << " axis " << m_axis << std::endl;
std::cout << " axis flag " << m_axisf << std::endl;
std::cout << " precision " << m_precision << std::endl;
std::cout << " button " << m_button << std::endl;
-std::cout << " button flag "<< m_buttonf << std::endl;
std::cout << " hat " << m_hat << std::endl;
std::cout << " hat flag " << m_hatf << std::endl;
*/
- m_istrig=0;
+ Init();
}
+void SCA_JoystickSensor::Init()
+{
+ m_istrig=(m_invert)?1:0;
+ m_istrig_prev=0;
+ m_reset = true;
+}
SCA_JoystickSensor::~SCA_JoystickSensor()
{
@@ -75,9 +85,10 @@ SCA_JoystickSensor::~SCA_JoystickSensor()
CValue* SCA_JoystickSensor::GetReplica()
{
- CValue* replica = new SCA_JoystickSensor(*this);
+ SCA_JoystickSensor* replica = new SCA_JoystickSensor(*this);
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
+ replica->Init();
return replica;
}
@@ -93,9 +104,14 @@ bool SCA_JoystickSensor::IsPositiveTrigger()
bool SCA_JoystickSensor::Evaluate(CValue* event)
{
- SCA_Joystick *js = m_pJoystickMgr->GetJoystickDevice();
+ SCA_Joystick *js = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
bool result = false;
+ bool reset = m_reset && m_level;
+ if(js==NULL) /* no joystick - dont do anything */
+ return false;
+
+ m_reset = false;
switch(m_joymode)
{
case KX_JOYSENSORMODE_AXIS:
@@ -107,10 +123,25 @@ bool SCA_JoystickSensor::Evaluate(CValue* event)
m_axisf == 3 == down
numberof== m_axis -- max 2
*/
+
+ if (!js->IsTrigAxis() && !reset) /* No events from SDL? - dont bother */
+ return false;
+
js->cSetPrecision(m_precision);
- if(m_axisf == 1){
+ if (m_bAllEvents) {
+ if(js->aAnyAxisIsPositive(m_axis)){
+ m_istrig = 1;
+ result = true;
+ }else{
+ if(m_istrig){
+ m_istrig = 0;
+ result = true;
+ }
+ }
+ }
+ else if(m_axisf == 1){
if(js->aUpAxisIsPositive(m_axis)){
- m_istrig =1;
+ m_istrig = 1;
result = true;
}else{
if(m_istrig){
@@ -119,7 +150,7 @@ bool SCA_JoystickSensor::Evaluate(CValue* event)
}
}
}
- if(m_axisf == 3){
+ else if(m_axisf == 3){
if(js->aDownAxisIsPositive(m_axis)){
m_istrig = 1;
result = true;
@@ -130,7 +161,7 @@ bool SCA_JoystickSensor::Evaluate(CValue* event)
}
}
}
- if(m_axisf == 2){
+ else if(m_axisf == 2){
if(js->aLeftAxisIsPositive(m_axis)){
m_istrig = 1;
result = true;
@@ -141,7 +172,7 @@ bool SCA_JoystickSensor::Evaluate(CValue* event)
}
}
}
- if(m_axisf == 0){
+ else if(m_axisf == 0){
if(js->aRightAxisIsPositive(m_axis)){
m_istrig = 1;
result = true;
@@ -157,32 +188,20 @@ bool SCA_JoystickSensor::Evaluate(CValue* event)
case KX_JOYSENSORMODE_BUTTON:
{
/* what is what!
- pressed = m_buttonf == 0
- released = m_buttonf == 1
m_button = the actual button in question
*/
- if(m_buttonf == 0){
- if(js->aButtonPressIsPositive(m_button)){
- m_istrig = 1;
+ if (!js->IsTrigButton() && !reset) /* No events from SDL? - dont bother */
+ return false;
+
+ if(( m_bAllEvents && js->aAnyButtonPressIsPositive()) || (!m_bAllEvents && js->aButtonPressIsPositive(m_button))) {
+ m_istrig = 1;
+ result = true;
+ }else {
+ if(m_istrig){
+ m_istrig = 0;
result = true;
- }else {
- if(m_istrig){
- m_istrig = 0;
- result = true;
- }
}
}
- if(m_buttonf == 1){
- if(js->aButtonReleaseIsPositive(m_button)){
- m_istrig = 1;
- result = true;
- }else {
- if(m_istrig){
- m_istrig = 0;
- result = true;
- }
- }
- }
break;
}
case KX_JOYSENSORMODE_HAT:
@@ -191,6 +210,10 @@ bool SCA_JoystickSensor::Evaluate(CValue* event)
numberof = m_hat -- max 2
direction= m_hatf -- max 12
*/
+
+ if (!js->IsTrigHat() && !reset) /* No events from SDL? - dont bother */
+ return false;
+
if(m_hat == 1){
if(js->aHatIsPositive(m_hatf)){
m_istrig = 1;
@@ -213,19 +236,6 @@ bool SCA_JoystickSensor::Evaluate(CValue* event)
}
}
}
- /*
- if(m_hat == 3){
- if(js->aHatIsPositive(m_hatf)){
- m_istrig = 1;
- result = true;
- }else{
- if(m_istrig){
- m_istrig = 0;
- result = true;
- }
- }
- }
- */
break;
}
/* test for ball anyone ?*/
@@ -233,9 +243,20 @@ bool SCA_JoystickSensor::Evaluate(CValue* event)
printf("Error invalid switch statement\n");
break;
}
- if(!js->IsTrig()){
- m_istrig = 0;
+
+ /* if not all events are enabled, only send a positive pulse when
+ * the button state changes */
+ if (!m_bAllEvents) {
+ if (m_istrig_prev == m_istrig) {
+ result = false;
+ } else {
+ m_istrig_prev = m_istrig;
+ }
}
+
+ if (reset)
+ result = true;
+
return result;
}
@@ -283,18 +304,22 @@ PyParentObject SCA_JoystickSensor::Parents[] = {
PyMethodDef SCA_JoystickSensor::Methods[] = {
- {"getAxis", (PyCFunction) SCA_JoystickSensor::sPyGetAxis, METH_NOARGS, GetAxis_doc},
- {"setAxis", (PyCFunction) SCA_JoystickSensor::sPySetAxis, METH_VARARGS, SetAxis_doc},
- {"getAxisValue", (PyCFunction) SCA_JoystickSensor::sPyGetRealAxis, METH_NOARGS, GetRealAxis_doc},
- {"getThreshold", (PyCFunction) SCA_JoystickSensor::sPyGetThreshold, METH_NOARGS, GetThreshold_doc},
- {"setThreshold", (PyCFunction) SCA_JoystickSensor::sPySetThreshold, METH_VARARGS, SetThreshold_doc},
- {"getButton", (PyCFunction) SCA_JoystickSensor::sPyGetButton, METH_NOARGS, GetButton_doc},
- {"setButton", (PyCFunction) SCA_JoystickSensor::sPySetButton, METH_VARARGS, SetButton_doc},
- {"getHat", (PyCFunction) SCA_JoystickSensor::sPyGetHat, METH_NOARGS, GetHat_doc},
- {"setHat", (PyCFunction) SCA_JoystickSensor::sPySetHat, METH_VARARGS, SetHat_doc},
- {"getNumAxes", (PyCFunction) SCA_JoystickSensor::sPyNumberOfAxes, METH_NOARGS, NumberOfAxes_doc},
- {"getNumButtons",(PyCFunction) SCA_JoystickSensor::sPyNumberOfButtons,METH_NOARGS, NumberOfButtons_doc},
- {"getNumHats", (PyCFunction) SCA_JoystickSensor::sPyNumberOfHats, METH_NOARGS, NumberOfHats_doc},
+ {"getIndex", (PyCFunction) SCA_JoystickSensor::sPyGetIndex, METH_NOARGS, (PY_METHODCHAR)GetIndex_doc},
+ {"setIndex", (PyCFunction) SCA_JoystickSensor::sPySetIndex, METH_O, (PY_METHODCHAR)SetIndex_doc},
+ {"getAxis", (PyCFunction) SCA_JoystickSensor::sPyGetAxis, METH_NOARGS, (PY_METHODCHAR)GetAxis_doc},
+ {"setAxis", (PyCFunction) SCA_JoystickSensor::sPySetAxis, METH_VARARGS, (PY_METHODCHAR)SetAxis_doc},
+ {"getAxisValue", (PyCFunction) SCA_JoystickSensor::sPyGetAxisValue, METH_NOARGS, (PY_METHODCHAR)GetAxisValue_doc},
+ {"getThreshold", (PyCFunction) SCA_JoystickSensor::sPyGetThreshold, METH_NOARGS, (PY_METHODCHAR)GetThreshold_doc},
+ {"setThreshold", (PyCFunction) SCA_JoystickSensor::sPySetThreshold, METH_VARARGS, (PY_METHODCHAR)SetThreshold_doc},
+ {"getButton", (PyCFunction) SCA_JoystickSensor::sPyGetButton, METH_NOARGS, (PY_METHODCHAR)GetButton_doc},
+ {"setButton", (PyCFunction) SCA_JoystickSensor::sPySetButton, METH_O, (PY_METHODCHAR)SetButton_doc},
+ {"getButtonValue",(PyCFunction) SCA_JoystickSensor::sPyGetButtonValue, METH_NOARGS,(PY_METHODCHAR)GetButtonValue_doc},
+ {"getHat", (PyCFunction) SCA_JoystickSensor::sPyGetHat, METH_NOARGS, (PY_METHODCHAR)GetHat_doc},
+ {"setHat", (PyCFunction) SCA_JoystickSensor::sPySetHat, METH_VARARGS, (PY_METHODCHAR)SetHat_doc},
+ {"getNumAxes", (PyCFunction) SCA_JoystickSensor::sPyNumberOfAxes, METH_NOARGS, (PY_METHODCHAR)NumberOfAxes_doc},
+ {"getNumButtons",(PyCFunction) SCA_JoystickSensor::sPyNumberOfButtons,METH_NOARGS, (PY_METHODCHAR)NumberOfButtons_doc},
+ {"getNumHats", (PyCFunction) SCA_JoystickSensor::sPyNumberOfHats, METH_NOARGS, (PY_METHODCHAR)NumberOfHats_doc},
+ {"isConnected", (PyCFunction) SCA_JoystickSensor::sPyConnected, METH_NOARGS, (PY_METHODCHAR)Connected_doc},
{NULL,NULL} //Sentinel
};
@@ -304,24 +329,44 @@ PyObject* SCA_JoystickSensor::_getattr(const STR_String& attr) {
}
+/* get index ---------------------------------------------------------- */
+const char SCA_JoystickSensor::GetIndex_doc[] =
+"getIndex\n"
+"\tReturns the joystick index to use.\n";
+PyObject* SCA_JoystickSensor::PyGetIndex( PyObject* self ) {
+ return PyInt_FromLong(m_joyindex);
+}
+
+
+/* set index ---------------------------------------------------------- */
+const char SCA_JoystickSensor::SetIndex_doc[] =
+"setIndex\n"
+"\tSets the joystick index to use.\n";
+PyObject* SCA_JoystickSensor::PySetIndex( PyObject* self, PyObject* value ) {
+ int index = PyInt_AsLong( value ); /* -1 on error, will raise an error in this case */
+ if (index < 0 || index >= JOYINDEX_MAX) {
+ PyErr_SetString(PyExc_ValueError, "joystick index out of range or not an int");
+ return NULL;
+ }
+
+ m_joyindex = index;
+ Py_RETURN_NONE;
+}
+
/* get axis ---------------------------------------------------------- */
-char SCA_JoystickSensor::GetAxis_doc[] =
+const char SCA_JoystickSensor::GetAxis_doc[] =
"getAxis\n"
-"\tReturns the current state of the axis.\n";
-PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+"\tReturns the current axis this sensor reacts to.\n";
+PyObject* SCA_JoystickSensor::PyGetAxis( PyObject* self) {
return Py_BuildValue("[ii]",m_axis, m_axisf);
}
/* set axis ---------------------------------------------------------- */
-char SCA_JoystickSensor::SetAxis_doc[] =
+const char SCA_JoystickSensor::SetAxis_doc[] =
"setAxis\n"
-"\tSets the current state of the axis.\n";
-PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+"\tSets the current axis this sensor reacts to.\n";
+PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self, PyObject* args ) {
int axis,axisflag;
if(!PyArg_ParseTuple(args, "ii", &axis, &axisflag)){
@@ -329,145 +374,145 @@ PyObject* SCA_JoystickSensor::PySetAxis( PyObject* self,
}
m_axis = axis;
m_axisf = axisflag;
- Py_Return;
+ Py_RETURN_NONE;
}
/* get axis value ----------------------------------------------------- */
-char SCA_JoystickSensor::GetRealAxis_doc[] =
+const char SCA_JoystickSensor::GetAxisValue_doc[] =
"getAxisValue\n"
-"\tReturns a list of the values for each axis .\n";
-PyObject* SCA_JoystickSensor::PyGetRealAxis( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- int a,b,c,d;
- SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice();
- a = joy->GetAxis10();
- b = joy->GetAxis11();
- c = joy->GetAxis20();
- d = joy->GetAxis21();
- return Py_BuildValue("[iiii]",a,b,c,d);
+"\tReturns a list of the values for the current state of each axis.\n";
+PyObject* SCA_JoystickSensor::PyGetAxisValue( PyObject* self) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ if(joy)
+ return Py_BuildValue("[iiii]", joy->GetAxis10(), joy->GetAxis11(), joy->GetAxis20(), joy->GetAxis21());
+ else
+ return Py_BuildValue("[iiii]", 0, 0, 0, 0);
}
/* get threshold ----------------------------------------------------- */
-char SCA_JoystickSensor::GetThreshold_doc[] =
+const char SCA_JoystickSensor::GetThreshold_doc[] =
"getThreshold\n"
"\tReturns the threshold of the axis.\n";
-PyObject* SCA_JoystickSensor::PyGetThreshold( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- return Py_BuildValue("i", m_precision);
+PyObject* SCA_JoystickSensor::PyGetThreshold( PyObject* self) {
+ return PyInt_FromLong(m_precision);
}
/* set threshold ----------------------------------------------------- */
-char SCA_JoystickSensor::SetThreshold_doc[] =
+const char SCA_JoystickSensor::SetThreshold_doc[] =
"setThreshold\n"
"\tSets the threshold of the axis.\n";
-PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* SCA_JoystickSensor::PySetThreshold( PyObject* self, PyObject* args ) {
int thresh;
if(!PyArg_ParseTuple(args, "i", &thresh)){
return NULL;
}
m_precision = thresh;
- Py_Return;
+ Py_RETURN_NONE;
}
-
/* get button -------------------------------------------------------- */
-char SCA_JoystickSensor::GetButton_doc[] =
+const char SCA_JoystickSensor::GetButton_doc[] =
"getButton\n"
-"\tReturns the currently pressed button.\n";
-PyObject* SCA_JoystickSensor::PyGetButton( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- return Py_BuildValue("[ii]",m_button, m_buttonf);
+"\tReturns the current button this sensor is checking.\n";
+PyObject* SCA_JoystickSensor::PyGetButton( PyObject* self) {
+ return PyInt_FromLong(m_button);
}
-
/* set button -------------------------------------------------------- */
-char SCA_JoystickSensor::SetButton_doc[] =
+const char SCA_JoystickSensor::SetButton_doc[] =
"setButton\n"
"\tSets the button the sensor reacts to.\n";
-PyObject* SCA_JoystickSensor::PySetButton( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- int button,buttonflag;
- if(!PyArg_ParseTuple(args, "ii", &button, &buttonflag)){
+PyObject* SCA_JoystickSensor::PySetButton( PyObject* self, PyObject* value ) {
+ int button = PyInt_AsLong(value);
+ if(button==-1 && PyErr_Occurred()) {
+ PyErr_SetString(PyExc_ValueError, "expected an int");
return NULL;
}
m_button = button;
- m_buttonf = buttonflag;
- Py_Return;
+ Py_RETURN_NONE;
}
+/* get button value -------------------------------------------------- */
+const char SCA_JoystickSensor::GetButtonValue_doc[] =
+"getButtonValue\n"
+"\tReturns a list containing the indicies of the current pressed state of each button.\n";
+PyObject* SCA_JoystickSensor::PyGetButtonValue( PyObject* self) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ PyObject *ls = PyList_New(0);
+ PyObject *value;
+ int i;
+
+ if(joy) {
+ for (i=0; i < joy->GetNumberOfButtons(); i++) {
+ if (joy->aButtonPressIsPositive(i)) {
+ value = PyInt_FromLong(i);
+ PyList_Append(ls, value);
+ Py_DECREF(value);
+ }
+ }
+ }
+ return ls;
+}
/* get hat ----------------------------------------------------------- */
-char SCA_JoystickSensor::GetHat_doc[] =
+const char SCA_JoystickSensor::GetHat_doc[] =
"getHat\n"
"\tReturns the current direction of the hat.\n";
-PyObject* SCA_JoystickSensor::PyGetHat( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* SCA_JoystickSensor::PyGetHat( PyObject* self ) {
return Py_BuildValue("[ii]",m_hat, m_hatf);
}
/* set hat ----------------------------------------------------------- */
-char SCA_JoystickSensor::SetHat_doc[] =
+const char SCA_JoystickSensor::SetHat_doc[] =
"setHat\n"
"\tSets the hat the sensor reacts to.\n";
-PyObject* SCA_JoystickSensor::PySetHat( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* SCA_JoystickSensor::PySetHat( PyObject* self, PyObject* args ) {
int hat,hatflag;
if(!PyArg_ParseTuple(args, "ii", &hat, &hatflag)){
return NULL;
}
m_hat = hat;
m_hatf = hatflag;
- Py_Return;
+ Py_RETURN_NONE;
}
/* get # of ----------------------------------------------------- */
-char SCA_JoystickSensor::NumberOfAxes_doc[] =
+const char SCA_JoystickSensor::NumberOfAxes_doc[] =
"getNumAxes\n"
"\tReturns the number of axes .\n";
-PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- int num;
- SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice();
- num = joy->GetNumberOfAxes();
- return Py_BuildValue("i",num);
+PyObject* SCA_JoystickSensor::PyNumberOfAxes( PyObject* self ) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ // when the joystick is null their is 0 exis still. dumb but scripters should use isConnected()
+ return PyInt_FromLong( joy ? joy->GetNumberOfAxes() : 0 );
}
-char SCA_JoystickSensor::NumberOfButtons_doc[] =
+const char SCA_JoystickSensor::NumberOfButtons_doc[] =
"getNumButtons\n"
"\tReturns the number of buttons .\n";
-PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- int num;
- SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice();
- num = joy->GetNumberOfButtons();
- return Py_BuildValue("i",num);
+PyObject* SCA_JoystickSensor::PyNumberOfButtons( PyObject* self ) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ return PyInt_FromLong( joy ? joy->GetNumberOfButtons() : 0 );
}
-char SCA_JoystickSensor::NumberOfHats_doc[] =
+const char SCA_JoystickSensor::NumberOfHats_doc[] =
"getNumHats\n"
"\tReturns the number of hats .\n";
-PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- int num;
- SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice();
- num = joy->GetNumberOfHats();
- return Py_BuildValue("i",num);
+PyObject* SCA_JoystickSensor::PyNumberOfHats( PyObject* self ) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ return PyInt_FromLong( joy ? joy->GetNumberOfHats() : 0 );
+}
+
+const char SCA_JoystickSensor::Connected_doc[] =
+"getConnected\n"
+"\tReturns True if a joystick is connected at this joysticks index.\n";
+PyObject* SCA_JoystickSensor::PyConnected( PyObject* self ) {
+ SCA_Joystick *joy = m_pJoystickMgr->GetJoystickDevice(m_joyindex);
+ return PyBool_FromLong( joy ? joy->Connected() : 0 );
}
diff --git a/source/gameengine/GameLogic/SCA_JoystickSensor.h b/source/gameengine/GameLogic/SCA_JoystickSensor.h
index 2fbe1edf1e7..d316ad1119c 100644
--- a/source/gameengine/GameLogic/SCA_JoystickSensor.h
+++ b/source/gameengine/GameLogic/SCA_JoystickSensor.h
@@ -69,9 +69,24 @@ class SCA_JoystickSensor :public SCA_ISensor
*/
bool m_istrig;
/**
+ * Last trigger state for this sensors joystick,
+ * Otherwise it will trigger all the time
+ * this is used to see if the trigger state changes.
+ */
+ bool m_istrig_prev;
+ /**
* The mode to determine axis,button or hat
*/
short int m_joymode;
+ /**
+ * Select which joystick to use
+ */
+ short int m_joyindex;
+
+ /**
+ * Detect all events for the currently selected type
+ */
+ bool m_bAllEvents;
enum KX_JOYSENSORMODE {
KX_JOYSENSORMODE_NODEF = 0,
@@ -85,39 +100,50 @@ class SCA_JoystickSensor :public SCA_ISensor
public:
SCA_JoystickSensor(class SCA_JoystickManager* eventmgr,
SCA_IObject* gameobj,
+ short int joyindex,
short int joymode,
int axis, int axisf,int prec,
- int button, int buttonf,
- int hat, int hatf,
+ int button,
+ int hat, int hatf, bool allevents,
PyTypeObject* T=&Type );
virtual ~SCA_JoystickSensor();
virtual CValue* GetReplica();
virtual bool Evaluate(CValue* event);
virtual bool IsPositiveTrigger();
+ virtual void Init();
+ short int GetJoyIndex(void){
+ return m_joyindex;
+ }
+
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
/* --------------------------------------------------------------------- */
virtual PyObject* _getattr(const STR_String& attr);
+ /* Joystick Index */
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetIndex);
+ KX_PYMETHOD_DOC_O(SCA_JoystickSensor,SetIndex);
/* Axes*/
- KX_PYMETHOD_DOC(SCA_JoystickSensor,GetAxis);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,SetAxis);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,GetRealAxis);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,GetThreshold);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,SetThreshold);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetAxis);
+ KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetAxis);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetAxisValue);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetThreshold);
+ KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetThreshold);
/* Buttons */
- KX_PYMETHOD_DOC(SCA_JoystickSensor,GetButton);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,SetButton);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButton);
+ KX_PYMETHOD_DOC_O(SCA_JoystickSensor,SetButton);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetButtonValue);
/* Hats */
- KX_PYMETHOD_DOC(SCA_JoystickSensor,GetHat);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,SetHat);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,GetHat);
+ KX_PYMETHOD_DOC_VARARGS(SCA_JoystickSensor,SetHat);
/* number of */
- KX_PYMETHOD_DOC(SCA_JoystickSensor,NumberOfAxes);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,NumberOfButtons);
- KX_PYMETHOD_DOC(SCA_JoystickSensor,NumberOfHats);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfAxes);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfButtons);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,NumberOfHats);
+ KX_PYMETHOD_DOC_NOARGS(SCA_JoystickSensor,Connected);
};
diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp b/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
index 259b06134d7..6a96442b124 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardManager.cpp
@@ -62,23 +62,14 @@ void SCA_KeyboardManager::NextFrame()
{
//const SCA_InputEvent& event = GetEventValue(SCA_IInputDevice::KX_EnumInputs inputcode)=0;
// cerr << "SCA_KeyboardManager::NextFrame"<< endl;
- for (unsigned int i=0;i<m_sensors.size();i++)
+ set<SCA_ISensor*>::iterator it;
+ for (it=m_sensors.begin(); it != m_sensors.end(); it++)
{
- SCA_KeyboardSensor* keysensor = (SCA_KeyboardSensor*)m_sensors[i];
- keysensor->Activate(m_logicmanager,NULL);
+ (*it)->Activate(m_logicmanager,NULL);
}
}
-
-
-void SCA_KeyboardManager::RegisterSensor(SCA_ISensor* keysensor)
-{
- m_sensors.push_back(keysensor);
-}
-
-
-
bool SCA_KeyboardManager::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)
{
return false;
diff --git a/source/gameengine/GameLogic/SCA_KeyboardManager.h b/source/gameengine/GameLogic/SCA_KeyboardManager.h
index b4a50f56025..8f3cc0ab715 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardManager.h
+++ b/source/gameengine/GameLogic/SCA_KeyboardManager.h
@@ -55,7 +55,6 @@ public:
bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode);
virtual void NextFrame();
- virtual void RegisterSensor(class SCA_ISensor* sensor);
SCA_IInputDevice* GetInputDevice();
};
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
index f7bec628991..fa39a13679f 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.cpp
@@ -62,7 +62,7 @@ SCA_KeyboardSensor::SCA_KeyboardSensor(SCA_KeyboardManager* keybdmgr,
if (hotkey == SCA_IInputDevice::KX_ESCKEY)
keybdmgr->GetInputDevice()->HookEscape();
// SetDrawColor(0xff0000ff);
- m_val=0;
+ Init();
}
@@ -71,14 +71,22 @@ SCA_KeyboardSensor::~SCA_KeyboardSensor()
{
}
-
+void SCA_KeyboardSensor::Init()
+{
+ // this function is used when the sensor is disconnected from all controllers
+ // by the state engine. It reinitializes the sensor as if it was just created.
+ // However, if the target key is pressed when the sensor is reactivated, it
+ // will not generated an event (see remark in Evaluate()).
+ m_val = (m_invert)?1:0;
+ m_reset = true;
+}
CValue* SCA_KeyboardSensor::GetReplica()
{
- CValue* replica = new SCA_KeyboardSensor(*this);
+ SCA_KeyboardSensor* replica = new SCA_KeyboardSensor(*this);
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
-
+ replica->Init();
return replica;
}
@@ -113,8 +121,12 @@ bool SCA_KeyboardSensor::TriggerOnAllKeys()
bool SCA_KeyboardSensor::Evaluate(CValue* eventval)
{
bool result = false;
- SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
+ bool reset = m_reset && m_level;
+ bool qual = true;
+ bool qual_change = false;
+ short int m_val_orig = m_val;
+ SCA_IInputDevice* inputdev = m_pKeyboardMgr->GetInputDevice();
// cerr << "SCA_KeyboardSensor::Eval event, sensing for "<< m_hotkey << " at device " << inputdev << "\n";
/* See if we need to do logging: togPropState exists and is
@@ -127,24 +139,29 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval)
LogKeystrokes();
}
-
+ m_reset = false;
/* Now see whether events must be bounced. */
if (m_bAllKeys)
{
bool justactivated = false;
bool justreleased = false;
+ bool active = false;
for (int i=SCA_IInputDevice::KX_BEGINKEY ; i< SCA_IInputDevice::KX_ENDKEY;i++)
{
const SCA_InputEvent & inevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) i);
- if (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED)
- {
+ switch (inevent.m_status)
+ {
+ case SCA_InputEvent::KX_JUSTACTIVATED:
justactivated = true;
- }
- if (inevent.m_status == SCA_InputEvent::KX_JUSTRELEASED)
- {
+ break;
+ case SCA_InputEvent::KX_JUSTRELEASED:
justreleased = true;
+ break;
+ case SCA_InputEvent::KX_ACTIVE:
+ active = true;
+ break;
}
}
@@ -156,8 +173,27 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval)
{
if (justreleased)
{
- m_val=0;
+ m_val=(active)?1:0;
result = true;
+ } else
+ {
+ if (active)
+ {
+ if (m_val == 0)
+ {
+ m_val = 1;
+ if (m_level) {
+ result = true;
+ }
+ }
+ } else
+ {
+ if (m_val == 1)
+ {
+ m_val = 0;
+ result = true;
+ }
+ }
}
}
@@ -170,9 +206,52 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval)
(SCA_IInputDevice::KX_EnumInputs) m_hotkey);
// cerr << "======= SCA_KeyboardSensor::Evaluate:: status: " << inevent.m_status << endl;
-
+
+
+ /* Check qualifier keys
+ * - see if the qualifiers we request are pressed - 'qual' true/false
+ * - see if the qualifiers we request changed their state - 'qual_change' true/false
+ */
+ if (m_qual > 0) {
+ const SCA_InputEvent & qualevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) m_qual);
+ switch(qualevent.m_status) {
+ case SCA_InputEvent::KX_NO_INPUTSTATUS:
+ qual = false;
+ break;
+ case SCA_InputEvent::KX_JUSTRELEASED:
+ qual_change = true;
+ qual = false;
+ break;
+ case SCA_InputEvent::KX_JUSTACTIVATED:
+ qual_change = true;
+ }
+ }
+ if (m_qual2 > 0 && qual==true) {
+ const SCA_InputEvent & qualevent = inputdev->GetEventValue((SCA_IInputDevice::KX_EnumInputs) m_qual2);
+ /* copy of above */
+ switch(qualevent.m_status) {
+ case SCA_InputEvent::KX_NO_INPUTSTATUS:
+ qual = false;
+ break;
+ case SCA_InputEvent::KX_JUSTRELEASED:
+ qual_change = true;
+ qual = false;
+ break;
+ case SCA_InputEvent::KX_JUSTACTIVATED:
+ qual_change = true;
+ }
+ }
+ /* done reading qualifiers */
+
if (inevent.m_status == SCA_InputEvent::KX_NO_INPUTSTATUS)
{
+ if (m_val == 1)
+ {
+ // this situation may occur after a scene suspend: the keyboard release
+ // event was not captured, produce now the event off
+ m_val = 0;
+ result = true;
+ }
} else
{
if (inevent.m_status == SCA_InputEvent::KX_JUSTACTIVATED)
@@ -185,11 +264,52 @@ bool SCA_KeyboardSensor::Evaluate(CValue* eventval)
{
m_val = 0;
result = true;
+ } else
+ {
+ if (inevent.m_status == SCA_InputEvent::KX_ACTIVE)
+ {
+ if (m_val == 0)
+ {
+ m_val = 1;
+ if (m_level)
+ {
+ result = true;
+ }
+ }
+ }
}
}
}
+
+ /* Modify the key state based on qual(s)
+ * Tested carefuly. dont touch unless your really sure.
+ * note, this will only change the results if key modifiers are set.
+ *
+ * When all modifiers and keys are positive
+ * - pulse true
+ *
+ * When ANY of the modifiers or main key become inactive,
+ * - pulse false
+ */
+ if (qual==false) { /* one of the qualifiers are not pressed */
+ if (m_val_orig && qual_change) { /* we were originally enabled, but a qualifier changed */
+ result = true;
+ } else {
+ result = false;
+ }
+ m_val = 0; /* since one of the qualifiers is not on, set the state to false */
+ } else { /* we done have any qualifiers or they are all pressed */
+ if (m_val && qual_change) { /* the main key state is true and our qualifier just changed */
+ result = true;
+ }
+ }
+ /* done with key quals */
+
}
-
+
+ if (reset)
+ // force an event
+ result = true;
return result;
}
@@ -209,6 +329,7 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex)
newprop.SetLength(oldlength - 1);
CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
GetParent()->SetProperty(m_targetprop, newstringprop);
+ newstringprop->Release();
}
} else {
/* append */
@@ -216,6 +337,7 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex)
STR_String newprop = tprop->GetText() + pchar;
CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
GetParent()->SetProperty(m_targetprop, newstringprop);
+ newstringprop->Release();
}
} else {
if (!IsDelete(keyIndex)) {
@@ -224,6 +346,7 @@ void SCA_KeyboardSensor::AddToTargetProp(int keyIndex)
STR_String newprop = pchar;
CStringValue * newstringprop = new CStringValue(newprop, m_targetprop);
GetParent()->SetProperty(m_targetprop, newstringprop);
+ newstringprop->Release();
}
}
}
@@ -448,12 +571,12 @@ PyObject* SCA_KeyboardSensor::sPySetAllMode(PyObject* self,
PyObject* kwds)
{
// printf("sPyIsPositive\n");
- return ((SCA_KeyboardSensor*) self)->PyIsPositive(self, args, kwds);
+ return ((SCA_KeyboardSensor*) self)->PyIsPositive(self);
}
/** 1. GetKey : check which key this sensor looks at */
-char SCA_KeyboardSensor::GetKey_doc[] =
+const char SCA_KeyboardSensor::GetKey_doc[] =
"getKey()\n"
"\tReturn the code of the key this sensor is listening to.\n" ;
PyObject* SCA_KeyboardSensor::PyGetKey(PyObject* self, PyObject* args, PyObject* kwds)
@@ -462,7 +585,7 @@ PyObject* SCA_KeyboardSensor::PyGetKey(PyObject* self, PyObject* args, PyObject*
}
/** 2. SetKey: change the key to look at */
-char SCA_KeyboardSensor::SetKey_doc[] =
+const char SCA_KeyboardSensor::SetKey_doc[] =
"setKey(keycode)\n"
"\t- keycode: any code from GameKeys\n"
"\tSet the key this sensor should listen to.\n" ;
@@ -482,7 +605,7 @@ PyObject* SCA_KeyboardSensor::PySetKey(PyObject* self, PyObject* args, PyObject*
}
/** 3. GetHold1 : set the first bucky bit */
-char SCA_KeyboardSensor::GetHold1_doc[] =
+const char SCA_KeyboardSensor::GetHold1_doc[] =
"getHold1()\n"
"\tReturn the code of the first key modifier to the key this \n"
"\tsensor is listening to.\n" ;
@@ -492,7 +615,7 @@ PyObject* SCA_KeyboardSensor::PyGetHold1(PyObject* self, PyObject* args, PyObjec
}
/** 4. SetHold1: change the first bucky bit */
-char SCA_KeyboardSensor::SetHold1_doc[] =
+const char SCA_KeyboardSensor::SetHold1_doc[] =
"setHold1(keycode)\n"
"\t- keycode: any code from GameKeys\n"
"\tSet the first modifier to the key this sensor should listen to.\n" ;
@@ -512,7 +635,7 @@ PyObject* SCA_KeyboardSensor::PySetHold1(PyObject* self, PyObject* args, PyObjec
}
/** 5. GetHold2 : get the second bucky bit */
-char SCA_KeyboardSensor::GetHold2_doc[] =
+const char SCA_KeyboardSensor::GetHold2_doc[] =
"getHold2()\n"
"\tReturn the code of the second key modifier to the key this \n"
"\tsensor is listening to.\n" ;
@@ -522,7 +645,7 @@ PyObject* SCA_KeyboardSensor::PyGetHold2(PyObject* self, PyObject* args, PyObjec
}
/** 6. SetHold2: change the second bucky bit */
-char SCA_KeyboardSensor::SetHold2_doc[] =
+const char SCA_KeyboardSensor::SetHold2_doc[] =
"setHold2(keycode)\n"
"\t- keycode: any code from GameKeys\n"
"\tSet the first modifier to the key this sensor should listen to.\n" ;
@@ -542,7 +665,7 @@ PyObject* SCA_KeyboardSensor::PySetHold2(PyObject* self, PyObject* args, PyObjec
}
-char SCA_KeyboardSensor::GetPressedKeys_doc[] =
+const char SCA_KeyboardSensor::GetPressedKeys_doc[] =
"getPressedKeys()\n"
"\tGet a list of pressed keys that have either been pressed, or just released this frame.\n" ;
@@ -582,7 +705,7 @@ PyObject* SCA_KeyboardSensor::PyGetPressedKeys(PyObject* self, PyObject* args, P
-char SCA_KeyboardSensor::GetCurrentlyPressedKeys_doc[] =
+const char SCA_KeyboardSensor::GetCurrentlyPressedKeys_doc[] =
"getCurrentlyPressedKeys()\n"
"\tGet a list of keys that are currently pressed.\n" ;
@@ -653,17 +776,17 @@ PyParentObject SCA_KeyboardSensor::Parents[] = {
};
PyMethodDef SCA_KeyboardSensor::Methods[] = {
- {"getKey", (PyCFunction) SCA_KeyboardSensor::sPyGetKey, METH_VARARGS, GetKey_doc},
- {"setKey", (PyCFunction) SCA_KeyboardSensor::sPySetKey, METH_VARARGS, SetKey_doc},
- {"getHold1", (PyCFunction) SCA_KeyboardSensor::sPyGetHold1, METH_VARARGS, GetHold1_doc},
- {"setHold1", (PyCFunction) SCA_KeyboardSensor::sPySetHold1, METH_VARARGS, SetHold1_doc},
- {"getHold2", (PyCFunction) SCA_KeyboardSensor::sPyGetHold2, METH_VARARGS, GetHold2_doc},
- {"setHold2", (PyCFunction) SCA_KeyboardSensor::sPySetHold2, METH_VARARGS, SetHold2_doc},
-// {"getUseAllKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetUseAllKeys, METH_VARARGS, GetUseAllKeys_doc},
-// {"setUseAllKeys", (PyCFunction) SCA_KeyboardSensor::sPySetUseAllKeys, METH_VARARGS, SetUseAllKeys_doc},
- {"getPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetPressedKeys, METH_VARARGS, GetPressedKeys_doc},
- {"getCurrentlyPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetCurrentlyPressedKeys, METH_VARARGS, GetCurrentlyPressedKeys_doc},
-// {"getKeyEvents", (PyCFunction) SCA_KeyboardSensor::sPyGetKeyEvents, METH_VARARGS, GetKeyEvents_doc},
+ {"getKey", (PyCFunction) SCA_KeyboardSensor::sPyGetKey, METH_VARARGS, (PY_METHODCHAR)GetKey_doc},
+ {"setKey", (PyCFunction) SCA_KeyboardSensor::sPySetKey, METH_VARARGS, (PY_METHODCHAR)SetKey_doc},
+ {"getHold1", (PyCFunction) SCA_KeyboardSensor::sPyGetHold1, METH_VARARGS, (PY_METHODCHAR)GetHold1_doc},
+ {"setHold1", (PyCFunction) SCA_KeyboardSensor::sPySetHold1, METH_VARARGS, (PY_METHODCHAR)SetHold1_doc},
+ {"getHold2", (PyCFunction) SCA_KeyboardSensor::sPyGetHold2, METH_VARARGS, (PY_METHODCHAR)GetHold2_doc},
+ {"setHold2", (PyCFunction) SCA_KeyboardSensor::sPySetHold2, METH_VARARGS, (PY_METHODCHAR)SetHold2_doc},
+// {"getUseAllKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetUseAllKeys, METH_VARARGS, (PY_METHODCHAR)GetUseAllKeys_doc},
+// {"setUseAllKeys", (PyCFunction) SCA_KeyboardSensor::sPySetUseAllKeys, METH_VARARGS, (PY_METHODCHAR)SetUseAllKeys_doc},
+ {"getPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetPressedKeys, METH_VARARGS, (PY_METHODCHAR)GetPressedKeys_doc},
+ {"getCurrentlyPressedKeys", (PyCFunction) SCA_KeyboardSensor::sPyGetCurrentlyPressedKeys, METH_VARARGS, (PY_METHODCHAR)GetCurrentlyPressedKeys_doc},
+// {"getKeyEvents", (PyCFunction) SCA_KeyboardSensor::sPyGetKeyEvents, METH_VARARGS, (PY_METHODCHAR)GetKeyEvents_doc},
{NULL,NULL} //Sentinel
};
diff --git a/source/gameengine/GameLogic/SCA_KeyboardSensor.h b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
index e87eddecd32..b86f6931d27 100644
--- a/source/gameengine/GameLogic/SCA_KeyboardSensor.h
+++ b/source/gameengine/GameLogic/SCA_KeyboardSensor.h
@@ -114,6 +114,8 @@ public:
PyTypeObject* T=&Type );
virtual ~SCA_KeyboardSensor();
virtual CValue* GetReplica();
+ virtual void Init();
+
short int GetHotkey();
virtual bool Evaluate(CValue* event);
diff --git a/source/gameengine/GameLogic/SCA_LogicManager.cpp b/source/gameengine/GameLogic/SCA_LogicManager.cpp
index 9c9c7dadc52..b584b37180f 100644
--- a/source/gameengine/GameLogic/SCA_LogicManager.cpp
+++ b/source/gameengine/GameLogic/SCA_LogicManager.cpp
@@ -33,6 +33,7 @@
#include "SCA_IController.h"
#include "SCA_IActuator.h"
#include "SCA_EventManager.h"
+#include "SCA_PythonController.h"
#include <set>
#ifdef HAVE_CONFIG_H
@@ -48,6 +49,10 @@ SCA_LogicManager::SCA_LogicManager()
SCA_LogicManager::~SCA_LogicManager()
{
+ /* AddRef() is not used when the objects are added to m_mapStringToGameObjects
+ so Release() should not be used either. The memory leak big is fixed
+ in BL_ConvertBlenderObjects()
+
int numgameobj = m_mapStringToGameObjects.size();
for (int i = 0; i < numgameobj; i++)
{
@@ -55,8 +60,9 @@ SCA_LogicManager::~SCA_LogicManager()
assert(gameobjptr);
if (gameobjptr)
(*gameobjptr)->Release();
-
+
}
+ */
/*for (int i=0;i<m_sensorcontrollermap.size();i++)
{
vector<SCA_IController*>* controllerarray = *(m_sensorcontrollermap[i]);
@@ -69,6 +75,8 @@ SCA_LogicManager::~SCA_LogicManager()
}
m_eventmanagers.clear();
m_sensorcontrollermapje.clear();
+ m_removedActuators.clear();
+ m_activeActuators.clear();
}
@@ -120,12 +128,17 @@ void SCA_LogicManager::RegisterGameMeshName(const STR_String& gamemeshname, void
-void SCA_LogicManager::RegisterGameObj(CValue* gameobj, void* blendobj)
+void SCA_LogicManager::RegisterGameObj(void* blendobj, CValue* gameobj)
{
- m_map_gameobj_to_blendobj.insert(CHashedPtr(gameobj), blendobj);
+ m_map_blendobj_to_gameobj.insert(CHashedPtr(blendobj), gameobj);
}
-
+void SCA_LogicManager::UnregisterGameObj(void* blendobj, CValue* gameobj)
+{
+ void **obp = m_map_blendobj_to_gameobj[CHashedPtr(blendobj)];
+ if (obp && (CValue*)(*obp) == gameobj)
+ m_map_blendobj_to_gameobj.remove(CHashedPtr(blendobj));
+}
CValue* SCA_LogicManager::GetGameObjectByName(const STR_String& gameobjname)
{
@@ -139,10 +152,10 @@ CValue* SCA_LogicManager::GetGameObjectByName(const STR_String& gameobjname)
}
-void* SCA_LogicManager::FindBlendObjByGameObj(CValue* gameobject)
+CValue* SCA_LogicManager::FindGameObjByBlendObj(void* blendobj)
{
- void **obp= m_map_gameobj_to_blendobj[CHashedPtr(gameobject)];
- return obp?*obp:NULL;
+ void **obp= m_map_blendobj_to_gameobj[CHashedPtr(blendobj)];
+ return obp?(CValue*)(*obp):NULL;
}
@@ -158,15 +171,25 @@ void* SCA_LogicManager::FindBlendObjByGameMeshName(const STR_String& gamemeshnam
void SCA_LogicManager::RemoveSensor(SCA_ISensor* sensor)
{
- m_sensorcontrollermapje.erase(sensor);
-
- for (vector<SCA_EventManager*>::const_iterator ie=m_eventmanagers.begin();
- !(ie==m_eventmanagers.end());ie++)
+ controllerlist contlist = m_sensorcontrollermapje[sensor];
+ for (controllerlist::const_iterator c= contlist.begin();!(c==contlist.end());c++)
{
- (*ie)->RemoveSensor(sensor);
+ (*c)->UnlinkSensor(sensor);
}
+ m_sensorcontrollermapje.erase(sensor);
+ sensor->UnregisterToManager();
}
+void SCA_LogicManager::RemoveController(SCA_IController* controller)
+{
+ controller->UnlinkAllSensors();
+ controller->UnlinkAllActuators();
+ std::map<SCA_ISensor*,controllerlist>::iterator sit;
+ for (sit = m_sensorcontrollermapje.begin();!(sit==m_sensorcontrollermapje.end());++sit)
+ {
+ (*sit).second.remove(controller);
+ }
+}
void SCA_LogicManager::RemoveDestroyedActuator(SCA_IActuator* actuator)
@@ -210,8 +233,6 @@ void SCA_LogicManager::BeginFrame(double curtime, double fixedtime)
// for this frame, look up for activated sensors, and build the collection of triggered controllers
// int numsensors = this->m_activatedsensors.size(); /*unused*/
- set<SmartControllerPtr> triggeredControllerSet;
-
for (vector<SCA_ISensor*>::const_iterator is=m_activatedsensors.begin();
!(is==m_activatedsensors.end());is++)
{
@@ -221,19 +242,29 @@ void SCA_LogicManager::BeginFrame(double curtime, double fixedtime)
!(c==contlist.end());c++)
{
SCA_IController* contr = *c;//controllerarray->at(c);
- triggeredControllerSet.insert(SmartControllerPtr(contr,0));
+ if (contr->IsActive())
+ {
+ m_triggeredControllerSet.insert(SmartControllerPtr(contr,0));
+ // So that the controller knows which sensor has activited it.
+ // Only needed for the python controller though.
+ if (contr->GetType() == &SCA_PythonController::Type)
+ {
+ SCA_PythonController* pythonController = (SCA_PythonController*)contr;
+ pythonController->AddTriggeredSensor(sensor);
+ }
+ }
}
//sensor->SetActive(false);
}
// int numtriggered = triggeredControllerSet.size(); /*unused*/
- for (set<SmartControllerPtr>::iterator tit=triggeredControllerSet.begin();
- !(tit==triggeredControllerSet.end());tit++)
+ for (set<SmartControllerPtr>::iterator tit=m_triggeredControllerSet.begin();
+ !(tit==m_triggeredControllerSet.end());tit++)
{
(*tit)->Trigger(this);
}
- triggeredControllerSet.clear();
+ m_triggeredControllerSet.clear();
}
@@ -248,6 +279,10 @@ void SCA_LogicManager::UpdateFrame(double curtime, bool frame)
}
m_removedActuators.clear();
+ // About to run actuators, but before update the sensors for those which depends on actuators
+ for (vector<SCA_EventManager*>::const_iterator ie=m_eventmanagers.begin(); !(ie==m_eventmanagers.end()); ie++)
+ (*ie)->UpdateFrame();
+
for (set<SmartActuatorPtr>::iterator ia = m_activeActuators.begin();!(ia==m_activeActuators.end());ia++)
{
//SCA_IActuator* actua = *ia;
@@ -258,6 +293,16 @@ void SCA_LogicManager::UpdateFrame(double curtime, bool frame)
(*ia)->SetActive(false);
//m_activeactuators.pop_back();
+ } else if ((*ia)->IsNoLink())
+ {
+ // This actuator has no more links but it still active
+ // make sure it will get a negative event on next frame to stop it
+ // Do this check after Update() rather than before to make sure
+ // that all the actuators that are activated at same time than a state
+ // actuator have a chance to execute.
+ CValue* event = new CBoolValue(false);
+ (*ia)->RemoveAllEvents();
+ (*ia)->AddEvent(event);
}
}
@@ -345,6 +390,17 @@ void SCA_LogicManager::AddActivatedSensor(SCA_ISensor* sensor)
}
}
+void SCA_LogicManager::AddTriggeredController(SCA_IController* controller, SCA_ISensor* sensor)
+{
+ m_triggeredControllerSet.insert(SmartControllerPtr(controller,0));
+ // so that the controller knows which sensor has activited it
+ // only needed for python controller
+ if (controller->GetType() == &SCA_PythonController::Type)
+ {
+ SCA_PythonController* pythonController = (SCA_PythonController*)controller;
+ pythonController->AddTriggeredSensor(sensor);
+ }
+}
void SCA_LogicManager::AddActiveActuator(SCA_IActuator* actua,CValue* event)
diff --git a/source/gameengine/GameLogic/SCA_LogicManager.h b/source/gameengine/GameLogic/SCA_LogicManager.h
index 39d8b865977..50383879d8f 100644
--- a/source/gameengine/GameLogic/SCA_LogicManager.h
+++ b/source/gameengine/GameLogic/SCA_LogicManager.h
@@ -99,6 +99,7 @@ class SCA_LogicManager
vector<class SCA_ISensor*> m_activatedsensors;
set<class SmartActuatorPtr> m_activeActuators;
+ set<class SmartControllerPtr> m_triggeredControllerSet;
map<SCA_ISensor*,controllerlist > m_sensorcontrollermapje;
@@ -109,7 +110,7 @@ class SCA_LogicManager
GEN_Map<STR_HashedString,void*> m_mapStringToActions;
GEN_Map<STR_HashedString,void*> m_map_gamemeshname_to_blendobj;
- GEN_Map<CHashedPtr,void*> m_map_gameobj_to_blendobj;
+ GEN_Map<CHashedPtr,void*> m_map_blendobj_to_gameobj;
vector<SmartActuatorPtr> m_removedActuators;
public:
@@ -127,6 +128,7 @@ public:
void EndFrame();
void AddActivatedSensor(SCA_ISensor* sensor);
void AddActiveActuator(SCA_IActuator* sensor,class CValue* event);
+ void AddTriggeredController(SCA_IController* controller, SCA_ISensor* sensor);
SCA_EventManager* FindEventManager(int eventmgrtype);
void RemoveGameObject(const STR_String& gameobjname);
@@ -152,8 +154,9 @@ public:
void RegisterGameMeshName(const STR_String& gamemeshname, void* blendobj);
void* FindBlendObjByGameMeshName(const STR_String& gamemeshname);
- void RegisterGameObj(CValue* gameobj, void* blendobj);
- void* FindBlendObjByGameObj(CValue* gameobj);
+ void RegisterGameObj(void* blendobj, CValue* gameobj);
+ void UnregisterGameObj(void* blendobj, CValue* gameobj);
+ CValue* FindGameObjByBlendObj(void* blendobj);
};
#endif //__KX_LOGICMANAGER
diff --git a/source/gameengine/GameLogic/SCA_MouseManager.cpp b/source/gameengine/GameLogic/SCA_MouseManager.cpp
index b4251d8ab53..ca875dad07c 100644
--- a/source/gameengine/GameLogic/SCA_MouseManager.cpp
+++ b/source/gameengine/GameLogic/SCA_MouseManager.cpp
@@ -75,9 +75,10 @@ void SCA_MouseManager::NextFrame()
{
if (m_mousedevice)
{
- for (unsigned int i = 0; i < m_sensors.size(); i++)
+ set<SCA_ISensor*>::iterator it;
+ for (it=m_sensors.begin(); it!=m_sensors.end(); it++)
{
- SCA_MouseSensor* mousesensor = (SCA_MouseSensor*) m_sensors[i];
+ SCA_MouseSensor* mousesensor = (SCA_MouseSensor*)(*it);
// (0,0) is the Upper Left corner in our local window
// coordinates
if (!mousesensor->IsSuspended())
@@ -98,15 +99,6 @@ void SCA_MouseManager::NextFrame()
}
}
-
-
-void SCA_MouseManager::RegisterSensor(SCA_ISensor* keysensor)
-{
- m_sensors.push_back(keysensor);
-}
-
-
-
bool SCA_MouseManager::IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)
{
/* We should guard for non-mouse events maybe? A rather silly side */
diff --git a/source/gameengine/GameLogic/SCA_MouseManager.h b/source/gameengine/GameLogic/SCA_MouseManager.h
index bc8254486ad..efa4c639ce7 100644
--- a/source/gameengine/GameLogic/SCA_MouseManager.h
+++ b/source/gameengine/GameLogic/SCA_MouseManager.h
@@ -62,7 +62,6 @@ public:
*/
bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode);
virtual void NextFrame();
- virtual void RegisterSensor(class SCA_ISensor* sensor);
SCA_IInputDevice* GetInputDevice();
};
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.cpp b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
index a91cf3e0439..d4952ce4777 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.cpp
@@ -58,7 +58,6 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr,
{
m_mousemode = mousemode;
m_triggermode = true;
- m_val = 0; /* stores the latest attribute */
switch (m_mousemode) {
case KX_MOUSESENSORMODE_LEFTBUTTON:
@@ -79,7 +78,13 @@ SCA_MouseSensor::SCA_MouseSensor(SCA_MouseManager* eventmgr,
default:
; /* ignore, no hotkey */
}
+ Init();
+}
+void SCA_MouseSensor::Init()
+{
+ m_val = (m_invert)?1:0; /* stores the latest attribute */
+ m_reset = true;
}
SCA_MouseSensor::~SCA_MouseSensor()
@@ -91,9 +96,10 @@ SCA_MouseSensor::~SCA_MouseSensor()
CValue* SCA_MouseSensor::GetReplica()
{
- CValue* replica = new SCA_MouseSensor(*this);
+ SCA_MouseSensor* replica = new SCA_MouseSensor(*this);
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
+ replica->Init();
return replica;
}
@@ -128,6 +134,7 @@ SCA_IInputDevice::KX_EnumInputs SCA_MouseSensor::GetHotKey()
bool SCA_MouseSensor::Evaluate(CValue* event)
{
bool result = false;
+ bool reset = m_reset && m_level;
SCA_IInputDevice* mousedev = m_pMouseMgr->GetInputDevice();
@@ -139,7 +146,7 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
/* both MOUSEX and MOUSEY. Treat all of these as key-presses. */
/* So, treat KX_MOUSESENSORMODE_POSITION as */
/* KX_MOUSESENSORMODE_POSITIONX || KX_MOUSESENSORMODE_POSITIONY */
-
+ m_reset = false;
switch (m_mousemode) {
case KX_MOUSESENSORMODE_LEFTBUTTON:
case KX_MOUSESENSORMODE_MIDDLEBUTTON:
@@ -158,6 +165,26 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
{
m_val = 0;
result = true;
+ } else
+ {
+ if (event.m_status == SCA_InputEvent::KX_ACTIVE)
+ {
+ if (m_val == 0)
+ {
+ m_val = 1;
+ if (m_level)
+ {
+ result = true;
+ }
+ }
+ } else
+ {
+ if (m_val == 1)
+ {
+ m_val = 0;
+ result = true;
+ }
+ }
}
}
break;
@@ -183,6 +210,13 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
{
m_val = 0;
result = true;
+ } else
+ {
+ if (m_val == 1)
+ {
+ m_val = 0;
+ result = true;
+ }
}
}
break;
@@ -191,6 +225,9 @@ bool SCA_MouseSensor::Evaluate(CValue* event)
; /* error */
}
+ if (reset)
+ // force an event
+ result = true;
return result;
}
@@ -246,8 +283,8 @@ PyParentObject SCA_MouseSensor::Parents[] = {
};
PyMethodDef SCA_MouseSensor::Methods[] = {
- {"getXPosition", (PyCFunction) SCA_MouseSensor::sPyGetXPosition, METH_VARARGS, GetXPosition_doc},
- {"getYPosition", (PyCFunction) SCA_MouseSensor::sPyGetYPosition, METH_VARARGS, GetYPosition_doc},
+ {"getXPosition", (PyCFunction) SCA_MouseSensor::sPyGetXPosition, METH_VARARGS, (PY_METHODCHAR)GetXPosition_doc},
+ {"getYPosition", (PyCFunction) SCA_MouseSensor::sPyGetYPosition, METH_VARARGS, (PY_METHODCHAR)GetYPosition_doc},
{NULL,NULL} //Sentinel
};
@@ -256,7 +293,7 @@ PyObject* SCA_MouseSensor::_getattr(const STR_String& attr) {
}
/* get x position ---------------------------------------------------------- */
-char SCA_MouseSensor::GetXPosition_doc[] =
+const char SCA_MouseSensor::GetXPosition_doc[] =
"getXPosition\n"
"\tReturns the x-coordinate of the mouse sensor, in frame coordinates.\n"
"\tThe lower-left corner is the origin. The coordinate is given in\n"
@@ -268,7 +305,7 @@ PyObject* SCA_MouseSensor::PyGetXPosition(PyObject* self,
}
/* get y position ---------------------------------------------------------- */
-char SCA_MouseSensor::GetYPosition_doc[] =
+const char SCA_MouseSensor::GetYPosition_doc[] =
"getYPosition\n"
"\tReturns the y-coordinate of the mouse sensor, in frame coordinates.\n"
"\tThe lower-left corner is the origin. The coordinate is given in\n"
diff --git a/source/gameengine/GameLogic/SCA_MouseSensor.h b/source/gameengine/GameLogic/SCA_MouseSensor.h
index 86c9d96a800..26a1c5e3fd2 100644
--- a/source/gameengine/GameLogic/SCA_MouseSensor.h
+++ b/source/gameengine/GameLogic/SCA_MouseSensor.h
@@ -96,7 +96,7 @@ class SCA_MouseSensor : public SCA_ISensor
virtual ~SCA_MouseSensor();
virtual CValue* GetReplica();
virtual bool Evaluate(CValue* event);
-
+ virtual void Init();
virtual bool IsPositiveTrigger();
short int GetModeKey();
SCA_IInputDevice::KX_EnumInputs GetHotKey();
diff --git a/source/gameengine/GameLogic/SCA_NANDController.cpp b/source/gameengine/GameLogic/SCA_NANDController.cpp
new file mode 100644
index 00000000000..5b869ee8298
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_NANDController.cpp
@@ -0,0 +1,144 @@
+/**
+ * 'Nand' together all inputs
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "SCA_NANDController.h"
+#include "SCA_ISensor.h"
+#include "SCA_LogicManager.h"
+#include "BoolValue.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* ------------------------------------------------------------------------- */
+/* Native functions */
+/* ------------------------------------------------------------------------- */
+
+SCA_NANDController::SCA_NANDController(SCA_IObject* gameobj,
+ PyTypeObject* T)
+ :
+ SCA_IController(gameobj,T)
+{
+}
+
+
+
+SCA_NANDController::~SCA_NANDController()
+{
+}
+
+
+
+void SCA_NANDController::Trigger(SCA_LogicManager* logicmgr)
+{
+
+ bool sensorresult = false;
+
+ for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
+ !(is==m_linkedsensors.end());is++)
+ {
+ SCA_ISensor* sensor = *is;
+ if (!sensor->IsPositiveTrigger())
+ {
+ sensorresult = true;
+ break;
+ }
+ }
+
+ CValue* newevent = new CBoolValue(sensorresult);
+
+ for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
+ !(i==m_linkedactuators.end());i++)
+ {
+ SCA_IActuator* actua = *i;//m_linkedactuators.at(i);
+ logicmgr->AddActiveActuator(actua,newevent);
+ }
+
+ // every actuator that needs the event, has a it's own reference to it now so
+ // release it (so to be clear: if there is no actuator, it's deleted right now)
+ newevent->Release();
+
+}
+
+
+
+CValue* SCA_NANDController::GetReplica()
+{
+ CValue* replica = new SCA_NANDController(*this);
+ // this will copy properties and so on...
+ CValue::AddDataToReplica(replica);
+
+ return replica;
+}
+
+
+
+/* ------------------------------------------------------------------------- */
+/* Python functions */
+/* ------------------------------------------------------------------------- */
+
+/* Integration hooks ------------------------------------------------------- */
+PyTypeObject SCA_NANDController::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "SCA_NANDController",
+ sizeof(SCA_NANDController),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject SCA_NANDController::Parents[] = {
+ &SCA_NANDController::Type,
+ &SCA_IController::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+PyMethodDef SCA_NANDController::Methods[] = {
+ {NULL,NULL} //Sentinel
+};
+
+PyObject* SCA_NANDController::_getattr(const STR_String& attr) {
+ _getattr_up(SCA_IController);
+}
+
+/* eof */
diff --git a/source/gameengine/GameLogic/SCA_NANDController.h b/source/gameengine/GameLogic/SCA_NANDController.h
new file mode 100644
index 00000000000..1193ff64f07
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_NANDController.h
@@ -0,0 +1,56 @@
+/**
+ * SCA_NANDController.h
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __KX_NANDCONTROLLER
+#define __KX_NANDCONTROLLER
+
+#include "SCA_IController.h"
+
+class SCA_NANDController : public SCA_IController
+{
+ Py_Header;
+ //virtual void Trigger(class SCA_LogicManager* logicmgr);
+public:
+ SCA_NANDController(SCA_IObject* gameobj,PyTypeObject* T=&Type);
+ virtual ~SCA_NANDController();
+ virtual CValue* GetReplica();
+ virtual void Trigger(SCA_LogicManager* logicmgr);
+
+ /* --------------------------------------------------------------------- */
+ /* Python interface ---------------------------------------------------- */
+ /* --------------------------------------------------------------------- */
+
+ virtual PyObject* _getattr(const STR_String& attr);
+
+};
+
+#endif //__KX_NANDCONTROLLER
+
diff --git a/source/gameengine/GameLogic/SCA_NORController.cpp b/source/gameengine/GameLogic/SCA_NORController.cpp
new file mode 100644
index 00000000000..2866dec0b74
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_NORController.cpp
@@ -0,0 +1,144 @@
+/**
+ * 'Nor' together all inputs
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "SCA_NORController.h"
+#include "SCA_ISensor.h"
+#include "SCA_LogicManager.h"
+#include "BoolValue.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* ------------------------------------------------------------------------- */
+/* Native functions */
+/* ------------------------------------------------------------------------- */
+
+SCA_NORController::SCA_NORController(SCA_IObject* gameobj,
+ PyTypeObject* T)
+ :
+ SCA_IController(gameobj,T)
+{
+}
+
+
+
+SCA_NORController::~SCA_NORController()
+{
+}
+
+
+
+void SCA_NORController::Trigger(SCA_LogicManager* logicmgr)
+{
+
+ bool sensorresult = true;
+
+ for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
+ !(is==m_linkedsensors.end());is++)
+ {
+ SCA_ISensor* sensor = *is;
+ if (sensor->IsPositiveTrigger())
+ {
+ sensorresult = false;
+ break;
+ }
+ }
+
+ CValue* newevent = new CBoolValue(sensorresult);
+
+ for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
+ !(i==m_linkedactuators.end());i++)
+ {
+ SCA_IActuator* actua = *i;//m_linkedactuators.at(i);
+ logicmgr->AddActiveActuator(actua,newevent);
+ }
+
+ // every actuator that needs the event, has a it's own reference to it now so
+ // release it (so to be clear: if there is no actuator, it's deleted right now)
+ newevent->Release();
+
+}
+
+
+
+CValue* SCA_NORController::GetReplica()
+{
+ CValue* replica = new SCA_NORController(*this);
+ // this will copy properties and so on...
+ CValue::AddDataToReplica(replica);
+
+ return replica;
+}
+
+
+
+/* ------------------------------------------------------------------------- */
+/* Python functions */
+/* ------------------------------------------------------------------------- */
+
+/* Integration hooks ------------------------------------------------------- */
+PyTypeObject SCA_NORController::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "SCA_NORController",
+ sizeof(SCA_NORController),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject SCA_NORController::Parents[] = {
+ &SCA_NORController::Type,
+ &SCA_IController::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+PyMethodDef SCA_NORController::Methods[] = {
+ {NULL,NULL} //Sentinel
+};
+
+PyObject* SCA_NORController::_getattr(const STR_String& attr) {
+ _getattr_up(SCA_IController);
+}
+
+/* eof */
diff --git a/source/gameengine/GameLogic/SCA_NORController.h b/source/gameengine/GameLogic/SCA_NORController.h
new file mode 100644
index 00000000000..aab59e3d46c
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_NORController.h
@@ -0,0 +1,56 @@
+/**
+ * SCA_NORController.h
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __KX_NORCONTROLLER
+#define __KX_NORCONTROLLER
+
+#include "SCA_IController.h"
+
+class SCA_NORController : public SCA_IController
+{
+ Py_Header;
+ //virtual void Trigger(class SCA_LogicManager* logicmgr);
+public:
+ SCA_NORController(SCA_IObject* gameobj,PyTypeObject* T=&Type);
+ virtual ~SCA_NORController();
+ virtual CValue* GetReplica();
+ virtual void Trigger(SCA_LogicManager* logicmgr);
+
+ /* --------------------------------------------------------------------- */
+ /* Python interface ---------------------------------------------------- */
+ /* --------------------------------------------------------------------- */
+
+ virtual PyObject* _getattr(const STR_String& attr);
+
+};
+
+#endif //__KX_NORCONTROLLER
+
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
index 1ee32e64b6c..3b541e87f02 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.cpp
@@ -42,17 +42,23 @@
/* Native functions */
/* ------------------------------------------------------------------------- */
-SCA_PropertyActuator::SCA_PropertyActuator(SCA_IObject* gameobj,CValue* sourceObj,const STR_String& propname,const STR_String& expr,int acttype,PyTypeObject* T )
+SCA_PropertyActuator::SCA_PropertyActuator(SCA_IObject* gameobj,SCA_IObject* sourceObj,const STR_String& propname,const STR_String& expr,int acttype,PyTypeObject* T )
: SCA_IActuator(gameobj,T),
m_type(acttype),
m_propname(propname),
m_exprtxt(expr),
m_sourceObj(sourceObj)
{
+ // protect ourselves against someone else deleting the source object
+ // don't protect against ourselves: it would create a dead lock
+ if (m_sourceObj)
+ m_sourceObj->RegisterActuator(this);
}
SCA_PropertyActuator::~SCA_PropertyActuator()
{
+ if (m_sourceObj)
+ m_sourceObj->UnregisterActuator(this);
}
bool SCA_PropertyActuator::Update()
@@ -87,12 +93,11 @@ bool SCA_PropertyActuator::Update()
if (oldprop)
{
oldprop->SetValue(newval);
- newval->Release();
} else
{
propowner->SetProperty(m_propname,newval);
}
-
+ newval->Release();
break;
}
case KX_ACT_PROP_ADD:
@@ -120,9 +125,11 @@ bool SCA_PropertyActuator::Update()
CValue* copyprop = m_sourceObj->GetProperty(m_exprtxt);
if (copyprop)
{
+ CValue *val = copyprop->GetReplica();
GetParent()->SetProperty(
m_propname,
- copyprop->GetReplica());
+ val);
+ val->Release();
}
}
@@ -173,7 +180,36 @@ GetReplica() {
};
+void SCA_PropertyActuator::ProcessReplica()
+{
+ // no need to check for self reference like in the constructor:
+ // the replica will always have a different parent
+ if (m_sourceObj)
+ m_sourceObj->RegisterActuator(this);
+ SCA_IActuator::ProcessReplica();
+}
+bool SCA_PropertyActuator::UnlinkObject(SCA_IObject* clientobj)
+{
+ if (clientobj == m_sourceObj)
+ {
+ // this object is being deleted, we cannot continue to track it.
+ m_sourceObj = NULL;
+ return true;
+ }
+ return false;
+}
+
+void SCA_PropertyActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
+{
+ void **h_obj = (*obj_map)[m_sourceObj];
+ if (h_obj) {
+ if (m_sourceObj)
+ m_sourceObj->UnregisterActuator(this);
+ m_sourceObj = (SCA_IObject*)(*h_obj);
+ m_sourceObj->RegisterActuator(this);
+ }
+}
/* ------------------------------------------------------------------------- */
@@ -209,10 +245,10 @@ PyParentObject SCA_PropertyActuator::Parents[] = {
};
PyMethodDef SCA_PropertyActuator::Methods[] = {
- {"setProperty", (PyCFunction) SCA_PropertyActuator::sPySetProperty, METH_VARARGS, SetProperty_doc},
- {"getProperty", (PyCFunction) SCA_PropertyActuator::sPyGetProperty, METH_VARARGS, GetProperty_doc},
- {"setValue", (PyCFunction) SCA_PropertyActuator::sPySetValue, METH_VARARGS, SetValue_doc},
- {"getValue", (PyCFunction) SCA_PropertyActuator::sPyGetValue, METH_VARARGS, GetValue_doc},
+ {"setProperty", (PyCFunction) SCA_PropertyActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
+ {"getProperty", (PyCFunction) SCA_PropertyActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
+ {"setValue", (PyCFunction) SCA_PropertyActuator::sPySetValue, METH_VARARGS, (PY_METHODCHAR)SetValue_doc},
+ {"getValue", (PyCFunction) SCA_PropertyActuator::sPyGetValue, METH_VARARGS, (PY_METHODCHAR)GetValue_doc},
{NULL,NULL} //Sentinel
};
@@ -221,7 +257,7 @@ PyObject* SCA_PropertyActuator::_getattr(const STR_String& attr) {
}
/* 1. setProperty */
-char SCA_PropertyActuator::SetProperty_doc[] =
+const char SCA_PropertyActuator::SetProperty_doc[] =
"setProperty(name)\n"
"\t- name: string\n"
"\tSet the property on which to operate. If there is no property\n"
@@ -236,17 +272,18 @@ PyObject* SCA_PropertyActuator::PySetProperty(PyObject* self, PyObject* args, Py
CValue* prop = GetParent()->FindIdentifier(nameArg);
- if (prop) {
+ if (!prop->IsError()) {
m_propname = nameArg;
} else {
; /* not found ... */
}
+ prop->Release();
Py_Return;
}
/* 2. getProperty */
-char SCA_PropertyActuator::GetProperty_doc[] =
+const char SCA_PropertyActuator::GetProperty_doc[] =
"getProperty(name)\n"
"\tReturn the property on which the actuator operates.\n";
PyObject* SCA_PropertyActuator::PyGetProperty(PyObject* self, PyObject* args, PyObject* kwds)
@@ -255,7 +292,7 @@ PyObject* SCA_PropertyActuator::PyGetProperty(PyObject* self, PyObject* args, Py
}
/* 3. setValue */
-char SCA_PropertyActuator::SetValue_doc[] =
+const char SCA_PropertyActuator::SetValue_doc[] =
"setValue(value)\n"
"\t- value: string\n"
"\tSet the value with which the actuator operates. If the value\n"
@@ -274,7 +311,7 @@ PyObject* SCA_PropertyActuator::PySetValue(PyObject* self, PyObject* args, PyObj
}
/* 4. getValue */
-char SCA_PropertyActuator::GetValue_doc[] =
+const char SCA_PropertyActuator::GetValue_doc[] =
"getValue()\n"
"\tReturns the value with which the actuator operates.\n";
PyObject* SCA_PropertyActuator::PyGetValue(PyObject* self, PyObject* args, PyObject* kwds)
diff --git a/source/gameengine/GameLogic/SCA_PropertyActuator.h b/source/gameengine/GameLogic/SCA_PropertyActuator.h
index 05a7cfbc501..1e435684572 100644
--- a/source/gameengine/GameLogic/SCA_PropertyActuator.h
+++ b/source/gameengine/GameLogic/SCA_PropertyActuator.h
@@ -52,7 +52,7 @@ class SCA_PropertyActuator : public SCA_IActuator
int m_type;
STR_String m_propname;
STR_String m_exprtxt;
- CValue* m_sourceObj; // for copy property actuator
+ SCA_IObject* m_sourceObj; // for copy property actuator
public:
@@ -60,7 +60,7 @@ public:
SCA_PropertyActuator(
SCA_IObject* gameobj,
- CValue* sourceObj,
+ SCA_IObject* sourceObj,
const STR_String& propname,
const STR_String& expr,
int acttype,
@@ -74,6 +74,10 @@ public:
GetReplica(
);
+ virtual void ProcessReplica();
+ virtual bool UnlinkObject(SCA_IObject* clientobj);
+ virtual void Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map);
+
virtual bool
Update();
diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp b/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
index fc56d101728..e5e3f9cced5 100644
--- a/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.cpp
@@ -47,19 +47,10 @@ SCA_PropertyEventManager::~SCA_PropertyEventManager()
}
-
-
-void SCA_PropertyEventManager::RegisterSensor(SCA_ISensor* sensor)
-{
- m_sensors.push_back(sensor);
-}
-
-
-
void SCA_PropertyEventManager::NextFrame()
{
// check for changed properties
- for (vector<SCA_ISensor*>::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++)
+ for (set<SCA_ISensor*>::const_iterator it = m_sensors.begin();!(it==m_sensors.end());it++)
{
(*it)->Activate(m_logicmgr,NULL);
}
diff --git a/source/gameengine/GameLogic/SCA_PropertyEventManager.h b/source/gameengine/GameLogic/SCA_PropertyEventManager.h
index aaa303a52c8..f166065b198 100644
--- a/source/gameengine/GameLogic/SCA_PropertyEventManager.h
+++ b/source/gameengine/GameLogic/SCA_PropertyEventManager.h
@@ -43,7 +43,6 @@ public:
SCA_PropertyEventManager(class SCA_LogicManager* logicmgr);
virtual ~SCA_PropertyEventManager();
virtual void NextFrame();
- virtual void RegisterSensor(SCA_ISensor* sensor);
//SCA_LogicManager* GetLogicManager() { return m_logicmgr;}
};
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.cpp b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
index 21ec6d39c08..64e3d49c6cb 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.cpp
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.cpp
@@ -54,47 +54,65 @@ SCA_PropertySensor::SCA_PropertySensor(SCA_EventManager* eventmgr,
m_checkpropval(propval),
m_checkpropmaxval(propmaxval),
m_checkpropname(propname),
- m_lastresult(false),
m_range_expr(NULL)
{
- m_recentresult=false;
//CParser pars;
//pars.SetContext(this->AddRef());
//CValue* resultval = m_rightexpr->Calculate();
CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname);
- if (orgprop)
+ if (!orgprop->IsError())
{
m_previoustext = orgprop->GetText();
- orgprop->Release();
}
+ orgprop->Release();
if (m_checktype==KX_PROPSENSOR_INTERVAL)
{
PrecalculateRangeExpression();
}
+ Init();
+}
+void SCA_PropertySensor::Init()
+{
+ m_recentresult = false;
+ m_lastresult = m_invert?true:false;
+ m_reset = true;
}
void SCA_PropertySensor::PrecalculateRangeExpression()
{
CParser pars;
+ //The context is needed to retrieve the property at runtime but it creates
+ //loop of references
pars.SetContext(this->AddRef());
STR_String checkstr = "(" + m_checkpropval + " <= "
+ m_checkpropname + ") && ( "
+ m_checkpropname + " <= "
- + m_checkpropmaxval;
+ + m_checkpropmaxval + ")";
m_range_expr = pars.ProcessText(checkstr);
}
-
+// Forced deletion of precalculated range expression to break reference loop
+// Use this function when you know that you won't use the sensor anymore
+void SCA_PropertySensor::Delete()
+{
+ if (m_range_expr)
+ {
+ m_range_expr->Release();
+ m_range_expr = NULL;
+ }
+ Release();
+}
CValue* SCA_PropertySensor::GetReplica()
{
SCA_PropertySensor* replica = new SCA_PropertySensor(*this);
// m_range_expr must be recalculated on replica!
CValue::AddDataToReplica(replica);
+ replica->Init();
replica->m_range_expr = NULL;
if (replica->m_checktype==KX_PROPSENSOR_INTERVAL)
@@ -137,14 +155,15 @@ SCA_PropertySensor::~SCA_PropertySensor()
bool SCA_PropertySensor::Evaluate(CValue* event)
{
bool result = CheckPropertyCondition();
+ bool reset = m_reset && m_level;
+ m_reset = false;
if (m_lastresult!=result)
{
m_lastresult = result;
return true;
}
-
- return false;
+ return (reset) ? true : false;
}
@@ -161,7 +180,7 @@ bool SCA_PropertySensor::CheckPropertyCondition()
case KX_PROPSENSOR_EQUAL:
{
CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname);
- if (orgprop)
+ if (!orgprop->IsError())
{
STR_String testprop = orgprop->GetText();
// Force strings to upper case, to avoid confusion in
@@ -174,9 +193,8 @@ bool SCA_PropertySensor::CheckPropertyCondition()
} else {
result = (orgprop->GetText() == m_checkpropval);
}
- orgprop->Release();
-
}
+ orgprop->Release();
if (reverse)
result = !result;
@@ -241,15 +259,15 @@ bool SCA_PropertySensor::CheckPropertyCondition()
{
CValue* orgprop = GetParent()->FindIdentifier(m_checkpropname);
- if (orgprop)
+ if (!orgprop->IsError())
{
if (m_previoustext != orgprop->GetText())
{
m_previoustext = orgprop->GetText();
result = true;
}
- orgprop->Release();
}
+ orgprop->Release();
//cout << " \nSens:Prop:changed!"; /* need implementation here!!! */
break;
@@ -315,12 +333,12 @@ PyParentObject SCA_PropertySensor::Parents[] = {
};
PyMethodDef SCA_PropertySensor::Methods[] = {
- {"getType", (PyCFunction) SCA_PropertySensor::sPyGetType, METH_VARARGS, GetType_doc},
- {"setType", (PyCFunction) SCA_PropertySensor::sPySetType, METH_VARARGS, SetType_doc},
- {"getProperty", (PyCFunction) SCA_PropertySensor::sPyGetProperty, METH_VARARGS, GetProperty_doc},
- {"setProperty", (PyCFunction) SCA_PropertySensor::sPySetProperty, METH_VARARGS, SetProperty_doc},
- {"getValue", (PyCFunction) SCA_PropertySensor::sPyGetValue, METH_VARARGS, GetValue_doc},
- {"setValue", (PyCFunction) SCA_PropertySensor::sPySetValue, METH_VARARGS, SetValue_doc},
+ {"getType", (PyCFunction) SCA_PropertySensor::sPyGetType, METH_VARARGS, (PY_METHODCHAR)GetType_doc},
+ {"setType", (PyCFunction) SCA_PropertySensor::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc},
+ {"getProperty", (PyCFunction) SCA_PropertySensor::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
+ {"setProperty", (PyCFunction) SCA_PropertySensor::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
+ {"getValue", (PyCFunction) SCA_PropertySensor::sPyGetValue, METH_VARARGS, (PY_METHODCHAR)GetValue_doc},
+ {"setValue", (PyCFunction) SCA_PropertySensor::sPySetValue, METH_VARARGS, (PY_METHODCHAR)SetValue_doc},
{NULL,NULL} //Sentinel
};
@@ -329,7 +347,7 @@ PyObject* SCA_PropertySensor::_getattr(const STR_String& attr) {
}
/* 1. getType */
-char SCA_PropertySensor::GetType_doc[] =
+const char SCA_PropertySensor::GetType_doc[] =
"getType()\n"
"\tReturns the type of check this sensor performs.\n";
PyObject* SCA_PropertySensor::PyGetType(PyObject* self, PyObject* args, PyObject* kwds)
@@ -338,7 +356,7 @@ PyObject* SCA_PropertySensor::PyGetType(PyObject* self, PyObject* args, PyObject
}
/* 2. setType */
-char SCA_PropertySensor::SetType_doc[] =
+const char SCA_PropertySensor::SetType_doc[] =
"setType(type)\n"
"\t- type: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,\n"
"\t KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED,\n"
@@ -361,7 +379,7 @@ PyObject* SCA_PropertySensor::PySetType(PyObject* self, PyObject* args, PyObject
}
/* 3. getProperty */
-char SCA_PropertySensor::GetProperty_doc[] =
+const char SCA_PropertySensor::GetProperty_doc[] =
"getProperty()\n"
"\tReturn the property with which the sensor operates.\n";
PyObject* SCA_PropertySensor::PyGetProperty(PyObject* self, PyObject* args, PyObject* kwds)
@@ -370,7 +388,7 @@ PyObject* SCA_PropertySensor::PyGetProperty(PyObject* self, PyObject* args, PyOb
}
/* 4. setProperty */
-char SCA_PropertySensor::SetProperty_doc[] =
+const char SCA_PropertySensor::SetProperty_doc[] =
"setProperty(name)\n"
"\t- name: string\n"
"\tSets the property with which to operate. If there is no property\n"
@@ -385,17 +403,18 @@ PyObject* SCA_PropertySensor::PySetProperty(PyObject* self, PyObject* args, PyOb
return NULL;
}
- if (FindIdentifier(STR_String(propNameArg))) {
+ CValue *prop = FindIdentifier(STR_String(propNameArg));
+ if (!prop->IsError()) {
m_checkpropname = propNameArg;
} else {
; /* error: bad property name */
}
-
+ prop->Release();
Py_Return;
}
/* 5. getValue */
-char SCA_PropertySensor::GetValue_doc[] =
+const char SCA_PropertySensor::GetValue_doc[] =
"getValue()\n"
"\tReturns the value with which the sensor operates.\n";
PyObject* SCA_PropertySensor::PyGetValue(PyObject* self, PyObject* args, PyObject* kwds)
@@ -404,7 +423,7 @@ PyObject* SCA_PropertySensor::PyGetValue(PyObject* self, PyObject* args, PyObjec
}
/* 6. setValue */
-char SCA_PropertySensor::SetValue_doc[] =
+const char SCA_PropertySensor::SetValue_doc[] =
"setValue(value)\n"
"\t- value: string\n"
"\tSet the value with which the sensor operates. If the value\n"
diff --git a/source/gameengine/GameLogic/SCA_PropertySensor.h b/source/gameengine/GameLogic/SCA_PropertySensor.h
index e1e27684ecc..6871cb3afdc 100644
--- a/source/gameengine/GameLogic/SCA_PropertySensor.h
+++ b/source/gameengine/GameLogic/SCA_PropertySensor.h
@@ -74,8 +74,10 @@ public:
KX_PROPSENSOR_TYPE checktype,
PyTypeObject* T=&Type );
+ virtual void Delete();
virtual ~SCA_PropertySensor();
virtual CValue* GetReplica();
+ virtual void Init();
void PrecalculateRangeExpression();
bool CheckPropertyCondition();
diff --git a/source/gameengine/GameLogic/SCA_PythonController.cpp b/source/gameengine/GameLogic/SCA_PythonController.cpp
index 44cdc0a7de5..c354ab39747 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.cpp
+++ b/source/gameengine/GameLogic/SCA_PythonController.cpp
@@ -33,8 +33,11 @@
#include "SCA_LogicManager.h"
#include "SCA_ISensor.h"
#include "SCA_IActuator.h"
+#include "PyObjectPlus.h"
#include "compile.h"
#include "eval.h"
+#include <algorithm>
+
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -116,7 +119,7 @@ CValue* SCA_PythonController::GetReplica()
void SCA_PythonController::SetScriptText(const STR_String& text)
{
- m_scriptText = "import GameLogic\n" + text;
+ m_scriptText = text;
m_bModified = true;
}
@@ -139,28 +142,33 @@ void SCA_PythonController::SetDictionary(PyObject* pythondictionary)
m_pythondictionary = PyDict_Copy(pythondictionary); /* new reference */
}
+int SCA_PythonController::IsTriggered(class SCA_ISensor* sensor)
+{
+ if (std::find(m_triggeredSensors.begin(), m_triggeredSensors.end(), sensor) !=
+ m_triggeredSensors.end())
+ return 1;
+ return 0;
+}
+
#if 0
-static char* sPyGetCurrentController__doc__;
+static const char* sPyGetCurrentController__doc__;
#endif
-PyObject* SCA_PythonController::sPyGetCurrentController(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* SCA_PythonController::sPyGetCurrentController(PyObject* self)
{
m_sCurrentController->AddRef();
return m_sCurrentController;
}
#if 0
-static char* sPyAddActiveActuator__doc__;
+static const char* sPyAddActiveActuator__doc__;
#endif
PyObject* SCA_PythonController::sPyAddActiveActuator(
PyObject* self,
- PyObject* args,
- PyObject* kwds)
+ PyObject* args)
{
PyObject* ob1;
@@ -187,14 +195,13 @@ PyObject* SCA_PythonController::sPyAddActiveActuator(
m_sCurrentLogicManager->AddActiveActuator((SCA_IActuator*)act,boolval);
boolval->Release();
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
-char* SCA_PythonController::sPyGetCurrentController__doc__ = "getCurrentController()";
-char* SCA_PythonController::sPyAddActiveActuator__doc__= "addActiveActuator(actuator,bool)";
-char SCA_PythonController::GetActuators_doc[] = "getActuator";
+const char* SCA_PythonController::sPyGetCurrentController__doc__ = "getCurrentController()";
+const char* SCA_PythonController::sPyAddActiveActuator__doc__= "addActiveActuator(actuator,bool)";
+const char SCA_PythonController::GetActuators_doc[] = "getActuator";
PyTypeObject SCA_PythonController::Type = {
PyObject_HEAD_INIT(&PyType_Type)
@@ -222,16 +229,13 @@ PyParentObject SCA_PythonController::Parents[] = {
NULL
};
PyMethodDef SCA_PythonController::Methods[] = {
- {"getActuators", (PyCFunction) SCA_PythonController::sPyGetActuators,
- METH_VARARGS, SCA_PythonController::GetActuators_doc},
- {"getActuator", (PyCFunction) SCA_PythonController::sPyGetActuator,
- METH_VARARGS, SCA_PythonController::GetActuator_doc},
- {"getSensors", (PyCFunction) SCA_PythonController::sPyGetSensors,
- METH_VARARGS, SCA_PythonController::GetSensors_doc},
- {"getSensor", (PyCFunction) SCA_PythonController::sPyGetSensor,
- METH_VARARGS, SCA_PythonController::GetSensor_doc},
- {"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_VARARGS},
- {"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_VARARGS},
+ {"getActuators", (PyCFunction) SCA_PythonController::sPyGetActuators, METH_NOARGS, (PY_METHODCHAR)SCA_PythonController::GetActuators_doc},
+ {"getActuator", (PyCFunction) SCA_PythonController::sPyGetActuator, METH_O, (PY_METHODCHAR)SCA_PythonController::GetActuator_doc},
+ {"getSensors", (PyCFunction) SCA_PythonController::sPyGetSensors, METH_NOARGS, (PY_METHODCHAR)SCA_PythonController::GetSensors_doc},
+ {"getSensor", (PyCFunction) SCA_PythonController::sPyGetSensor, METH_O, (PY_METHODCHAR)SCA_PythonController::GetSensor_doc},
+ {"getScript", (PyCFunction) SCA_PythonController::sPyGetScript, METH_NOARGS},
+ {"setScript", (PyCFunction) SCA_PythonController::sPySetScript, METH_O},
+ {"getState", (PyCFunction) SCA_PythonController::sPyGetState, METH_NOARGS},
{NULL,NULL} //Sentinel
};
@@ -255,9 +259,17 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
{
// didn't compile, so instead of compile, complain
// something is wrong, tell the user what went wrong
- printf("PYTHON SCRIPT ERROR:\n");
+ printf("Python compile error from controller \"%s\": \n", GetName().Ptr());
//PyRun_SimpleString(m_scriptText.Ptr());
PyErr_Print();
+
+ /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
+ * their user count. Not to mention holding references to wrapped data.
+ * This is especially bad when the PyObject for the wrapped data is free'd, after blender
+ * has alredy dealocated the pointer */
+ PySys_SetObject( "last_traceback", Py_None);
+ PyErr_Clear(); /* just to be sure */
+
return;
}
m_bModified=false;
@@ -280,43 +292,36 @@ void SCA_PythonController::Trigger(SCA_LogicManager* logicmgr)
* break it by hand, then DECREF (which in this case
* should always ensure excdict is cleared).
*/
-/* PyObject *excdict= myPyDict_Copy(m_pythondictionary);
- struct _object* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
- excdict,
- excdict
- );
- PyDict_Clear(excdict);
- Py_DECREF(excdict);*/
-
-#if 1
PyObject *excdict= PyDict_Copy(m_pythondictionary);
PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
- excdict,
- excdict
- );
- PyDict_Clear(excdict);
- Py_DECREF(excdict);
-#else
-
- PyObject* resultobj = PyEval_EvalCode((PyCodeObject*)m_bytecode,
- m_pythondictionary,
- m_pythondictionary
- );
-
-#endif
+ excdict, excdict);
if (resultobj)
{
Py_DECREF(resultobj);
- } else
+ }
+ else
{
// something is wrong, tell the user what went wrong
- printf("PYTHON SCRIPT ERROR:\n");
+ printf("Python script error from controller \"%s\": \n", GetName().Ptr());
PyErr_Print();
+
+ /* Added in 2.48a, the last_traceback can reference Objects for example, increasing
+ * their user count. Not to mention holding references to wrapped data.
+ * This is especially bad when the PyObject for the wrapped data is free'd, after blender
+ * has alredy dealocated the pointer */
+ PySys_SetObject( "last_traceback", Py_None);
+ PyErr_Clear(); /* just to be sure */
+
//PyRun_SimpleString(m_scriptText.Ptr());
}
+ // clear after PyErrPrint - seems it can be using
+ // something in this dictionary and crash?
+ PyDict_Clear(excdict);
+ Py_DECREF(excdict);
+ m_triggeredSensors.erase(m_triggeredSensors.begin(), m_triggeredSensors.end());
m_sCurrentController = NULL;
}
@@ -329,30 +334,26 @@ PyObject* SCA_PythonController::_getattr(const STR_String& attr)
-PyObject* SCA_PythonController::PyGetActuators(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* SCA_PythonController::PyGetActuators(PyObject* self)
{
PyObject* resultlist = PyList_New(m_linkedactuators.size());
for (unsigned int index=0;index<m_linkedactuators.size();index++)
{
- PyList_SetItem(resultlist,index,m_linkedactuators[index]->AddRef());
+ PyList_SET_ITEM(resultlist,index,m_linkedactuators[index]->AddRef());
}
return resultlist;
}
-char SCA_PythonController::GetSensor_doc[] =
+const char SCA_PythonController::GetSensor_doc[] =
"GetSensor (char sensorname) return linked sensor that is named [sensorname]\n";
PyObject*
-SCA_PythonController::PyGetSensor(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+SCA_PythonController::PyGetSensor(PyObject* self, PyObject* value)
{
- char *scriptArg;
-
- if (!PyArg_ParseTuple(args, "s", &scriptArg)) {
+ char *scriptArg = PyString_AsString(value);
+ if (scriptArg==NULL) {
+ PyErr_SetString(PyExc_TypeError, "expected a string (sensor name)");
return NULL;
}
@@ -365,24 +366,24 @@ SCA_PythonController::PyGetSensor(PyObject* self,
return sensor->AddRef();
}
}
-
- PyErr_SetString(PyExc_AttributeError, "Unable to find requested sensor");
+
+ char emsg[96];
+ PyOS_snprintf( emsg, sizeof( emsg ), "Unable to find requested sensor \"%s\"", scriptArg );
+ PyErr_SetString(PyExc_AttributeError, emsg);
return NULL;
}
-char SCA_PythonController::GetActuator_doc[] =
+const char SCA_PythonController::GetActuator_doc[] =
"GetActuator (char sensorname) return linked actuator that is named [actuatorname]\n";
PyObject*
-SCA_PythonController::PyGetActuator(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+SCA_PythonController::PyGetActuator(PyObject* self, PyObject* value)
{
- char *scriptArg;
-
- if (!PyArg_ParseTuple(args, "s", &scriptArg)) {
+ char *scriptArg = PyString_AsString(value);
+ if (scriptArg==NULL) {
+ PyErr_SetString(PyExc_TypeError, "expected a string (actuator name)");
return NULL;
}
@@ -395,42 +396,39 @@ SCA_PythonController::PyGetActuator(PyObject* self,
return actua->AddRef();
}
}
-
- PyErr_SetString(PyExc_AttributeError, "Unable to find requested actuator");
+
+ char emsg[96];
+ PyOS_snprintf( emsg, sizeof( emsg ), "Unable to find requested actuator \"%s\"", scriptArg );
+ PyErr_SetString(PyExc_AttributeError, emsg);
return NULL;
}
-char SCA_PythonController::GetSensors_doc[] = "getSensors returns a list of all attached sensors";
+const char SCA_PythonController::GetSensors_doc[] = "getSensors returns a list of all attached sensors";
PyObject*
-SCA_PythonController::PyGetSensors(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+SCA_PythonController::PyGetSensors(PyObject* self)
{
PyObject* resultlist = PyList_New(m_linkedsensors.size());
for (unsigned int index=0;index<m_linkedsensors.size();index++)
{
- PyList_SetItem(resultlist,index,m_linkedsensors[index]->AddRef());
+ PyList_SET_ITEM(resultlist,index,m_linkedsensors[index]->AddRef());
}
return resultlist;
}
/* 1. getScript */
-PyObject* SCA_PythonController::PyGetScript(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* SCA_PythonController::PyGetScript(PyObject* self)
{
return PyString_FromString(m_scriptText);
}
/* 2. setScript */
-PyObject* SCA_PythonController::PySetScript(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* SCA_PythonController::PySetScript(PyObject* self, PyObject* value)
{
- char *scriptArg;
- if (!PyArg_ParseTuple(args, "s", &scriptArg)) {
+ char *scriptArg = PyString_AsString(value);
+ if (scriptArg==NULL) {
+ PyErr_SetString(PyExc_TypeError, "expected a string (script name)");
return NULL;
}
@@ -439,7 +437,13 @@ PyObject* SCA_PythonController::PySetScript(PyObject* self,
this->SetScriptText(scriptArg);
- Py_Return;
+ Py_RETURN_NONE;
+}
+
+/* 1. getScript */
+PyObject* SCA_PythonController::PyGetState(PyObject* self)
+{
+ return PyInt_FromLong(m_statemask);
}
/* eof */
diff --git a/source/gameengine/GameLogic/SCA_PythonController.h b/source/gameengine/GameLogic/SCA_PythonController.h
index 63975234da9..d9b2e242bea 100644
--- a/source/gameengine/GameLogic/SCA_PythonController.h
+++ b/source/gameengine/GameLogic/SCA_PythonController.h
@@ -36,6 +36,8 @@
#include "SCA_LogicManager.h"
#include "BoolValue.h"
+#include <vector>
+
class SCA_IObject;
class SCA_PythonController : public SCA_IController
{
@@ -47,6 +49,7 @@ class SCA_PythonController : public SCA_IController
STR_String m_scriptText;
STR_String m_scriptName;
PyObject* m_pythondictionary;
+ std::vector<class SCA_ISensor*> m_triggeredSensors;
public:
static SCA_PythonController* m_sCurrentController; // protected !!!
@@ -64,23 +67,24 @@ class SCA_PythonController : public SCA_IController
void SetScriptText(const STR_String& text);
void SetScriptName(const STR_String& name);
void SetDictionary(PyObject* pythondictionary);
+ void AddTriggeredSensor(class SCA_ISensor* sensor)
+ { m_triggeredSensors.push_back(sensor); }
+ int IsTriggered(class SCA_ISensor* sensor);
- static char* sPyGetCurrentController__doc__;
- static PyObject* sPyGetCurrentController(PyObject* self,
- PyObject* args,
- PyObject* kwds);
- static char* sPyAddActiveActuator__doc__;
+ static const char* sPyGetCurrentController__doc__;
+ static PyObject* sPyGetCurrentController(PyObject* self);
+ static const char* sPyAddActiveActuator__doc__;
static PyObject* sPyAddActiveActuator(PyObject* self,
- PyObject* args,
- PyObject* kwds);
+ PyObject* args);
virtual PyObject* _getattr(const STR_String& attr);
- KX_PYMETHOD_DOC(SCA_PythonController,GetSensors);
- KX_PYMETHOD_DOC(SCA_PythonController,GetSensor);
- KX_PYMETHOD_DOC(SCA_PythonController,GetActuator);
- KX_PYMETHOD_DOC(SCA_PythonController,GetActuators);
- KX_PYMETHOD(SCA_PythonController,SetScript);
- KX_PYMETHOD(SCA_PythonController,GetScript);
+ KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetSensors);
+ KX_PYMETHOD_DOC_NOARGS(SCA_PythonController,GetActuators);
+ KX_PYMETHOD_DOC_O(SCA_PythonController,GetSensor);
+ KX_PYMETHOD_DOC_O(SCA_PythonController,GetActuator);
+ KX_PYMETHOD_O(SCA_PythonController,SetScript);
+ KX_PYMETHOD_NOARGS(SCA_PythonController,GetScript);
+ KX_PYMETHOD_NOARGS(SCA_PythonController,GetState);
};
diff --git a/source/gameengine/GameLogic/SCA_RandomActuator.cpp b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
index 60570f7c19c..7b50a483cd8 100644
--- a/source/gameengine/GameLogic/SCA_RandomActuator.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomActuator.cpp
@@ -58,6 +58,7 @@ SCA_RandomActuator::SCA_RandomActuator(SCA_IObject *gameobj,
m_parameter2(para2),
m_distribution(mode)
{
+ // m_base is never deleted, probably a memory leak!
m_base = new SCA_RandomNumberGenerator(seed);
m_counter = 0;
enforceConstraints();
@@ -75,6 +76,7 @@ SCA_RandomActuator::~SCA_RandomActuator()
CValue* SCA_RandomActuator::GetReplica()
{
SCA_RandomActuator* replica = new SCA_RandomActuator(*this);
+ // replication just copy the m_base pointer => common random generator
replica->ProcessReplica();
CValue::AddDataToReplica(replica);
@@ -337,23 +339,23 @@ PyParentObject SCA_RandomActuator::Parents[] = {
};
PyMethodDef SCA_RandomActuator::Methods[] = {
- {"setSeed", (PyCFunction) SCA_RandomActuator::sPySetSeed, METH_VARARGS, SetSeed_doc},
- {"getSeed", (PyCFunction) SCA_RandomActuator::sPyGetSeed, METH_VARARGS, GetSeed_doc},
- {"getPara1", (PyCFunction) SCA_RandomActuator::sPyGetPara1, METH_VARARGS, GetPara1_doc},
- {"getPara2", (PyCFunction) SCA_RandomActuator::sPyGetPara2, METH_VARARGS, GetPara2_doc},
- {"getDistribution", (PyCFunction) SCA_RandomActuator::sPyGetDistribution, METH_VARARGS, GetDistribution_doc},
- {"setProperty", (PyCFunction) SCA_RandomActuator::sPySetProperty, METH_VARARGS, SetProperty_doc},
- {"getProperty", (PyCFunction) SCA_RandomActuator::sPyGetProperty, METH_VARARGS, GetProperty_doc},
- {"setBoolConst", (PyCFunction) SCA_RandomActuator::sPySetBoolConst, METH_VARARGS, SetBoolConst_doc},
- {"setBoolUniform", (PyCFunction) SCA_RandomActuator::sPySetBoolUniform, METH_VARARGS, SetBoolUniform_doc},
- {"setBoolBernouilli",(PyCFunction) SCA_RandomActuator::sPySetBoolBernouilli, METH_VARARGS, SetBoolBernouilli_doc},
- {"setIntConst", (PyCFunction) SCA_RandomActuator::sPySetIntConst, METH_VARARGS, SetIntConst_doc},
- {"setIntUniform", (PyCFunction) SCA_RandomActuator::sPySetIntUniform, METH_VARARGS, SetIntUniform_doc},
- {"setIntPoisson", (PyCFunction) SCA_RandomActuator::sPySetIntPoisson, METH_VARARGS, SetIntPoisson_doc},
- {"setFloatConst", (PyCFunction) SCA_RandomActuator::sPySetFloatConst, METH_VARARGS, SetFloatConst_doc},
- {"setFloatUniform", (PyCFunction) SCA_RandomActuator::sPySetFloatUniform, METH_VARARGS, SetFloatUniform_doc},
- {"setFloatNormal", (PyCFunction) SCA_RandomActuator::sPySetFloatNormal, METH_VARARGS, SetFloatNormal_doc},
- {"setFloatNegativeExponential", (PyCFunction) SCA_RandomActuator::sPySetFloatNegativeExponential, METH_VARARGS, SetFloatNegativeExponential_doc},
+ {"setSeed", (PyCFunction) SCA_RandomActuator::sPySetSeed, METH_VARARGS, (PY_METHODCHAR)SetSeed_doc},
+ {"getSeed", (PyCFunction) SCA_RandomActuator::sPyGetSeed, METH_VARARGS, (PY_METHODCHAR)GetSeed_doc},
+ {"getPara1", (PyCFunction) SCA_RandomActuator::sPyGetPara1, METH_VARARGS, (PY_METHODCHAR)GetPara1_doc},
+ {"getPara2", (PyCFunction) SCA_RandomActuator::sPyGetPara2, METH_VARARGS, (PY_METHODCHAR)GetPara2_doc},
+ {"getDistribution", (PyCFunction) SCA_RandomActuator::sPyGetDistribution, METH_VARARGS, (PY_METHODCHAR)GetDistribution_doc},
+ {"setProperty", (PyCFunction) SCA_RandomActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
+ {"getProperty", (PyCFunction) SCA_RandomActuator::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
+ {"setBoolConst", (PyCFunction) SCA_RandomActuator::sPySetBoolConst, METH_VARARGS, (PY_METHODCHAR)SetBoolConst_doc},
+ {"setBoolUniform", (PyCFunction) SCA_RandomActuator::sPySetBoolUniform, METH_VARARGS, (PY_METHODCHAR)SetBoolUniform_doc},
+ {"setBoolBernouilli",(PyCFunction) SCA_RandomActuator::sPySetBoolBernouilli, METH_VARARGS, (PY_METHODCHAR)SetBoolBernouilli_doc},
+ {"setIntConst", (PyCFunction) SCA_RandomActuator::sPySetIntConst, METH_VARARGS, (PY_METHODCHAR)SetIntConst_doc},
+ {"setIntUniform", (PyCFunction) SCA_RandomActuator::sPySetIntUniform, METH_VARARGS, (PY_METHODCHAR)SetIntUniform_doc},
+ {"setIntPoisson", (PyCFunction) SCA_RandomActuator::sPySetIntPoisson, METH_VARARGS, (PY_METHODCHAR)SetIntPoisson_doc},
+ {"setFloatConst", (PyCFunction) SCA_RandomActuator::sPySetFloatConst, METH_VARARGS, (PY_METHODCHAR)SetFloatConst_doc},
+ {"setFloatUniform", (PyCFunction) SCA_RandomActuator::sPySetFloatUniform, METH_VARARGS, (PY_METHODCHAR)SetFloatUniform_doc},
+ {"setFloatNormal", (PyCFunction) SCA_RandomActuator::sPySetFloatNormal, METH_VARARGS, (PY_METHODCHAR)SetFloatNormal_doc},
+ {"setFloatNegativeExponential", (PyCFunction) SCA_RandomActuator::sPySetFloatNegativeExponential, METH_VARARGS, (PY_METHODCHAR)SetFloatNegativeExponential_doc},
{NULL,NULL} //Sentinel
};
@@ -362,7 +364,7 @@ PyObject* SCA_RandomActuator::_getattr(const STR_String& attr) {
}
/* 1. setSeed */
-char SCA_RandomActuator::SetSeed_doc[] =
+const char SCA_RandomActuator::SetSeed_doc[] =
"setSeed(seed)\n"
"\t- seed: integer\n"
"\tSet the initial seed of the generator. Equal seeds produce\n"
@@ -379,7 +381,7 @@ PyObject* SCA_RandomActuator::PySetSeed(PyObject* self, PyObject* args, PyObject
Py_Return;
}
/* 2. getSeed */
-char SCA_RandomActuator::GetSeed_doc[] =
+const char SCA_RandomActuator::GetSeed_doc[] =
"getSeed()\n"
"\tReturns the initial seed of the generator. Equal seeds produce\n"
"\tequal series.\n";
@@ -388,7 +390,7 @@ PyObject* SCA_RandomActuator::PyGetSeed(PyObject* self, PyObject* args, PyObject
}
/* 4. getPara1 */
-char SCA_RandomActuator::GetPara1_doc[] =
+const char SCA_RandomActuator::GetPara1_doc[] =
"getPara1()\n"
"\tReturns the first parameter of the active distribution. Refer\n"
"\tto the documentation of the generator types for the meaning\n"
@@ -398,7 +400,7 @@ PyObject* SCA_RandomActuator::PyGetPara1(PyObject* self, PyObject* args, PyObjec
}
/* 6. getPara2 */
-char SCA_RandomActuator::GetPara2_doc[] =
+const char SCA_RandomActuator::GetPara2_doc[] =
"getPara2()\n"
"\tReturns the first parameter of the active distribution. Refer\n"
"\tto the documentation of the generator types for the meaning\n"
@@ -408,7 +410,7 @@ PyObject* SCA_RandomActuator::PyGetPara2(PyObject* self, PyObject* args, PyObjec
}
/* 8. getDistribution */
-char SCA_RandomActuator::GetDistribution_doc[] =
+const char SCA_RandomActuator::GetDistribution_doc[] =
"getDistribution()\n"
"\tReturns the type of the active distribution.\n";
PyObject* SCA_RandomActuator::PyGetDistribution(PyObject* self, PyObject* args, PyObject* kwds) {
@@ -416,7 +418,7 @@ PyObject* SCA_RandomActuator::PyGetDistribution(PyObject* self, PyObject* args,
}
/* 9. setProperty */
-char SCA_RandomActuator::SetProperty_doc[] =
+const char SCA_RandomActuator::SetProperty_doc[] =
"setProperty(name)\n"
"\t- name: string\n"
"\tSet the property to which the random value is assigned. If the \n"
@@ -429,17 +431,17 @@ PyObject* SCA_RandomActuator::PySetProperty(PyObject* self, PyObject* args, PyOb
CValue* prop = GetParent()->FindIdentifier(nameArg);
- if (prop) {
+ if (!prop->IsError()) {
m_propname = nameArg;
- prop->Release();
} else {
; /* not found ... */
}
+ prop->Release();
Py_Return;
}
/* 10. getProperty */
-char SCA_RandomActuator::GetProperty_doc[] =
+const char SCA_RandomActuator::GetProperty_doc[] =
"getProperty(name)\n"
"\tReturn the property to which the random value is assigned. If the \n"
"\tgenerator and property types do not match, the assignment is ignored.\n";
@@ -448,7 +450,7 @@ PyObject* SCA_RandomActuator::PyGetProperty(PyObject* self, PyObject* args, PyOb
}
/* 11. setBoolConst */
-char SCA_RandomActuator::SetBoolConst_doc[] =
+const char SCA_RandomActuator::SetBoolConst_doc[] =
"setBoolConst(value)\n"
"\t- value: 0 or 1\n"
"\tSet this generator to produce a constant boolean value.\n";
@@ -468,7 +470,7 @@ PyObject* SCA_RandomActuator::PySetBoolConst(PyObject* self,
Py_Return;
}
/* 12. setBoolUniform, */
-char SCA_RandomActuator::SetBoolUniform_doc[] =
+const char SCA_RandomActuator::SetBoolUniform_doc[] =
"setBoolUniform()\n"
"\tSet this generator to produce true and false, each with 50%% chance of occuring\n";
PyObject* SCA_RandomActuator::PySetBoolUniform(PyObject* self,
@@ -480,7 +482,7 @@ PyObject* SCA_RandomActuator::PySetBoolUniform(PyObject* self,
Py_Return;
}
/* 13. setBoolBernouilli, */
-char SCA_RandomActuator::SetBoolBernouilli_doc[] =
+const char SCA_RandomActuator::SetBoolBernouilli_doc[] =
"setBoolBernouilli(value)\n"
"\t- value: a float between 0 and 1\n"
"\tReturn false value * 100%% of the time.\n";
@@ -498,7 +500,7 @@ PyObject* SCA_RandomActuator::PySetBoolBernouilli(PyObject* self,
Py_Return;
}
/* 14. setIntConst,*/
-char SCA_RandomActuator::SetIntConst_doc[] =
+const char SCA_RandomActuator::SetIntConst_doc[] =
"setIntConst(value)\n"
"\t- value: integer\n"
"\tAlways return value\n";
@@ -516,7 +518,7 @@ PyObject* SCA_RandomActuator::PySetIntConst(PyObject* self,
Py_Return;
}
/* 15. setIntUniform,*/
-char SCA_RandomActuator::SetIntUniform_doc[] =
+const char SCA_RandomActuator::SetIntUniform_doc[] =
"setIntUniform(lower_bound, upper_bound)\n"
"\t- lower_bound: integer\n"
"\t- upper_bound: integer\n"
@@ -537,7 +539,7 @@ PyObject* SCA_RandomActuator::PySetIntUniform(PyObject* self,
Py_Return;
}
/* 16. setIntPoisson, */
-char SCA_RandomActuator::SetIntPoisson_doc[] =
+const char SCA_RandomActuator::SetIntPoisson_doc[] =
"setIntPoisson(value)\n"
"\t- value: float\n"
"\tReturn a Poisson-distributed number. This performs a series\n"
@@ -557,7 +559,7 @@ PyObject* SCA_RandomActuator::PySetIntPoisson(PyObject* self,
Py_Return;
}
/* 17. setFloatConst,*/
-char SCA_RandomActuator::SetFloatConst_doc[] =
+const char SCA_RandomActuator::SetFloatConst_doc[] =
"setFloatConst(value)\n"
"\t- value: float\n"
"\tAlways return value\n";
@@ -575,7 +577,7 @@ PyObject* SCA_RandomActuator::PySetFloatConst(PyObject* self,
Py_Return;
}
/* 18. setFloatUniform, */
-char SCA_RandomActuator::SetFloatUniform_doc[] =
+const char SCA_RandomActuator::SetFloatUniform_doc[] =
"setFloatUniform(lower_bound, upper_bound)\n"
"\t- lower_bound: float\n"
"\t- upper_bound: float\n"
@@ -596,7 +598,7 @@ PyObject* SCA_RandomActuator::PySetFloatUniform(PyObject* self,
Py_Return;
}
/* 19. setFloatNormal, */
-char SCA_RandomActuator::SetFloatNormal_doc[] =
+const char SCA_RandomActuator::SetFloatNormal_doc[] =
"setFloatNormal(mean, standard_deviation)\n"
"\t- mean: float\n"
"\t- standard_deviation: float\n"
@@ -617,7 +619,7 @@ PyObject* SCA_RandomActuator::PySetFloatNormal(PyObject* self,
Py_Return;
}
/* 20. setFloatNegativeExponential, */
-char SCA_RandomActuator::SetFloatNegativeExponential_doc[] =
+const char SCA_RandomActuator::SetFloatNegativeExponential_doc[] =
"setFloatNegativeExponential(half_life)\n"
"\t- half_life: float\n"
"\tReturn negative-exponentially distributed numbers. The half-life 'time'\n"
diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp b/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
index 02020a52a17..156478d866d 100644
--- a/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomEventManager.cpp
@@ -50,16 +50,9 @@ SCA_RandomEventManager::SCA_RandomEventManager(class SCA_LogicManager* logicmgr)
void SCA_RandomEventManager::NextFrame()
{
- for (vector<class SCA_ISensor*>::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++)
+ for (set<class SCA_ISensor*>::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++)
{
- SCA_ISensor *sensor = *i;
- sensor->Activate(m_logicmgr, NULL);
+ (*i)->Activate(m_logicmgr, NULL);
}
}
-
-
-void SCA_RandomEventManager::RegisterSensor(SCA_ISensor* sensor)
-{
- m_sensors.push_back(sensor);
-};
diff --git a/source/gameengine/GameLogic/SCA_RandomEventManager.h b/source/gameengine/GameLogic/SCA_RandomEventManager.h
index 8c75ef665fa..79138c23c62 100644
--- a/source/gameengine/GameLogic/SCA_RandomEventManager.h
+++ b/source/gameengine/GameLogic/SCA_RandomEventManager.h
@@ -45,7 +45,6 @@ public:
SCA_RandomEventManager(class SCA_LogicManager* logicmgr);
virtual void NextFrame();
- virtual void RegisterSensor(SCA_ISensor* sensor);
};
#endif //__KX_RANDOMEVENTMGR
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.cpp b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
index 540a5865537..202fd6382e6 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.cpp
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.cpp
@@ -50,12 +50,9 @@ SCA_RandomSensor::SCA_RandomSensor(SCA_EventManager* eventmgr,
PyTypeObject* T)
: SCA_ISensor(gameobj,eventmgr, T)
{
- m_iteration = 0;
- m_lastdraw = false;
-
+ // m_basegenerator is never deleted => memory leak
m_basegenerator = new SCA_RandomNumberGenerator(startseed);
- m_currentDraw = m_basegenerator->Draw();
- RegisterToManager();
+ Init();
}
@@ -65,11 +62,19 @@ SCA_RandomSensor::~SCA_RandomSensor()
/* Nothing to be done here. */
}
+void SCA_RandomSensor::Init()
+{
+ m_iteration = 0;
+ m_interval = 0;
+ m_lastdraw = false;
+ m_currentDraw = m_basegenerator->Draw();
+}
CValue* SCA_RandomSensor::GetReplica()
{
CValue* replica = new SCA_RandomSensor(*this);
+ // replication copies m_basegenerator pointer => share same generator
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
@@ -95,20 +100,25 @@ bool SCA_RandomSensor::Evaluate(CValue* event)
/* this is a reasonable way of generating bools. Check Knuth. */
/* Furthermore, we only draw each <delay>-eth frame. */
- bool drawResult = false;
-
- if (m_iteration > 31) {
- m_currentDraw = m_basegenerator->Draw();
- drawResult = (m_currentDraw & 0x1) == 0;
- m_iteration = 1;
- } else {
- drawResult = ((m_currentDraw >> m_iteration) & 0x1) == 0;
- m_iteration++;
+ bool evaluateResult = false;
+
+ if (++m_interval > m_pulse_frequency) {
+ bool drawResult = false;
+ m_interval = 0;
+ if (m_iteration > 31) {
+ m_currentDraw = m_basegenerator->Draw();
+ drawResult = (m_currentDraw & 0x1) == 0;
+ m_iteration = 1;
+ } else {
+ drawResult = ((m_currentDraw >> m_iteration) & 0x1) == 0;
+ m_iteration++;
+ }
+ evaluateResult = drawResult != m_lastdraw;
+ m_lastdraw = drawResult;
}
/* now pass this result to some controller */
- m_lastdraw = drawResult;
- return drawResult;
+ return evaluateResult;
}
/* ------------------------------------------------------------------------- */
@@ -144,9 +154,9 @@ PyParentObject SCA_RandomSensor::Parents[] = {
};
PyMethodDef SCA_RandomSensor::Methods[] = {
- {"setSeed", (PyCFunction) SCA_RandomSensor::sPySetSeed, METH_VARARGS, SetSeed_doc},
- {"getSeed", (PyCFunction) SCA_RandomSensor::sPyGetSeed, METH_VARARGS, GetSeed_doc},
- {"getLastDraw", (PyCFunction) SCA_RandomSensor::sPyGetLastDraw, METH_VARARGS, GetLastDraw_doc},
+ {"setSeed", (PyCFunction) SCA_RandomSensor::sPySetSeed, METH_VARARGS, (PY_METHODCHAR)SetSeed_doc},
+ {"getSeed", (PyCFunction) SCA_RandomSensor::sPyGetSeed, METH_VARARGS, (PY_METHODCHAR)GetSeed_doc},
+ {"getLastDraw", (PyCFunction) SCA_RandomSensor::sPyGetLastDraw, METH_VARARGS, (PY_METHODCHAR)GetLastDraw_doc},
{NULL,NULL} //Sentinel
};
@@ -155,7 +165,7 @@ PyObject* SCA_RandomSensor::_getattr(const STR_String& attr) {
}
/* 1. setSeed */
-char SCA_RandomSensor::SetSeed_doc[] =
+const char SCA_RandomSensor::SetSeed_doc[] =
"setSeed(seed)\n"
"\t- seed: integer\n"
"\tSet the initial seed of the generator. Equal seeds produce\n"
@@ -173,7 +183,7 @@ PyObject* SCA_RandomSensor::PySetSeed(PyObject* self, PyObject* args, PyObject*
}
/* 2. getSeed */
-char SCA_RandomSensor::GetSeed_doc[] =
+const char SCA_RandomSensor::GetSeed_doc[] =
"getSeed()\n"
"\tReturns the initial seed of the generator. Equal seeds produce\n"
"\tequal series.\n";
@@ -182,7 +192,7 @@ PyObject* SCA_RandomSensor::PyGetSeed(PyObject* self, PyObject* args, PyObject*
}
/* 3. getLastDraw */
-char SCA_RandomSensor::GetLastDraw_doc[] =
+const char SCA_RandomSensor::GetLastDraw_doc[] =
"getLastDraw()\n"
"\tReturn the last value that was drawn.\n";
PyObject* SCA_RandomSensor::PyGetLastDraw(PyObject* self, PyObject* args, PyObject* kwds) {
diff --git a/source/gameengine/GameLogic/SCA_RandomSensor.h b/source/gameengine/GameLogic/SCA_RandomSensor.h
index 729df9b2a62..d29bfb6837a 100644
--- a/source/gameengine/GameLogic/SCA_RandomSensor.h
+++ b/source/gameengine/GameLogic/SCA_RandomSensor.h
@@ -42,6 +42,7 @@ class SCA_RandomSensor : public SCA_ISensor
unsigned int m_currentDraw;
int m_iteration;
+ int m_interval;
SCA_RandomNumberGenerator *m_basegenerator;
bool m_lastdraw;
public:
@@ -53,6 +54,7 @@ public:
virtual CValue* GetReplica();
virtual bool Evaluate(CValue* event);
virtual bool IsPositiveTrigger();
+ virtual void Init();
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
index 643f1247a52..b7fadd3d62c 100644
--- a/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
+++ b/source/gameengine/GameLogic/SCA_TimeEventManager.cpp
@@ -65,6 +65,11 @@ void SCA_TimeEventManager::RegisterSensor(SCA_ISensor* sensor)
// not yet
}
+void SCA_TimeEventManager::RemoveSensor(SCA_ISensor* sensor)
+{
+ // empty
+}
+
void SCA_TimeEventManager::NextFrame(double curtime, double fixedtime)
diff --git a/source/gameengine/GameLogic/SCA_TimeEventManager.h b/source/gameengine/GameLogic/SCA_TimeEventManager.h
index 2fd39661a2d..bd57e12eb44 100644
--- a/source/gameengine/GameLogic/SCA_TimeEventManager.h
+++ b/source/gameengine/GameLogic/SCA_TimeEventManager.h
@@ -45,6 +45,7 @@ public:
virtual void NextFrame(double curtime, double fixedtime);
virtual void RegisterSensor(class SCA_ISensor* sensor);
+ virtual void RemoveSensor(class SCA_ISensor* sensor);
void AddTimeProperty(CValue* timeval);
void RemoveTimeProperty(CValue* timeval);
};
diff --git a/source/gameengine/GameLogic/SCA_XNORController.cpp b/source/gameengine/GameLogic/SCA_XNORController.cpp
new file mode 100644
index 00000000000..3ef7c07fe0a
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_XNORController.cpp
@@ -0,0 +1,148 @@
+/**
+ * 'Xnor' together all inputs
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "SCA_XNORController.h"
+#include "SCA_ISensor.h"
+#include "SCA_LogicManager.h"
+#include "BoolValue.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* ------------------------------------------------------------------------- */
+/* Native functions */
+/* ------------------------------------------------------------------------- */
+
+SCA_XNORController::SCA_XNORController(SCA_IObject* gameobj,
+ PyTypeObject* T)
+ :
+ SCA_IController(gameobj,T)
+{
+}
+
+
+
+SCA_XNORController::~SCA_XNORController()
+{
+}
+
+
+
+void SCA_XNORController::Trigger(SCA_LogicManager* logicmgr)
+{
+
+ bool sensorresult = true;
+
+ for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
+ !(is==m_linkedsensors.end());is++)
+ {
+ SCA_ISensor* sensor = *is;
+ if (sensor->IsPositiveTrigger())
+ {
+ if (sensorresult == false)
+ {
+ sensorresult = true;
+ break;
+ }
+ sensorresult = false;
+ }
+ }
+
+ CValue* newevent = new CBoolValue(sensorresult);
+
+ for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
+ !(i==m_linkedactuators.end());i++)
+ {
+ SCA_IActuator* actua = *i;//m_linkedactuators.at(i);
+ logicmgr->AddActiveActuator(actua,newevent);
+ }
+
+ // every actuator that needs the event, has a it's own reference to it now so
+ // release it (so to be clear: if there is no actuator, it's deleted right now)
+ newevent->Release();
+
+}
+
+
+
+CValue* SCA_XNORController::GetReplica()
+{
+ CValue* replica = new SCA_XNORController(*this);
+ // this will copy properties and so on...
+ CValue::AddDataToReplica(replica);
+
+ return replica;
+}
+
+
+
+/* ------------------------------------------------------------------------- */
+/* Python functions */
+/* ------------------------------------------------------------------------- */
+
+/* Integration hooks ------------------------------------------------------- */
+PyTypeObject SCA_XNORController::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "SCA_XNORController",
+ sizeof(SCA_XNORController),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject SCA_XNORController::Parents[] = {
+ &SCA_XNORController::Type,
+ &SCA_IController::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+PyMethodDef SCA_XNORController::Methods[] = {
+ {NULL,NULL} //Sentinel
+};
+
+PyObject* SCA_XNORController::_getattr(const STR_String& attr) {
+ _getattr_up(SCA_IController);
+}
+
+/* eof */
diff --git a/source/gameengine/GameLogic/SCA_XNORController.h b/source/gameengine/GameLogic/SCA_XNORController.h
new file mode 100644
index 00000000000..4b1eaee95d8
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_XNORController.h
@@ -0,0 +1,56 @@
+/**
+ * SCA_XNORController.h
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __KX_XNORCONTROLLER
+#define __KX_XNORCONTROLLER
+
+#include "SCA_IController.h"
+
+class SCA_XNORController : public SCA_IController
+{
+ Py_Header;
+ //virtual void Trigger(class SCA_LogicManager* logicmgr);
+public:
+ SCA_XNORController(SCA_IObject* gameobj,PyTypeObject* T=&Type);
+ virtual ~SCA_XNORController();
+ virtual CValue* GetReplica();
+ virtual void Trigger(SCA_LogicManager* logicmgr);
+
+ /* --------------------------------------------------------------------- */
+ /* Python interface ---------------------------------------------------- */
+ /* --------------------------------------------------------------------- */
+
+ virtual PyObject* _getattr(const STR_String& attr);
+
+};
+
+#endif //__KX_XNORCONTROLLER
+
diff --git a/source/gameengine/GameLogic/SCA_XORController.cpp b/source/gameengine/GameLogic/SCA_XORController.cpp
new file mode 100644
index 00000000000..6499c62f5f2
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_XORController.cpp
@@ -0,0 +1,148 @@
+/**
+ * 'Xor' together all inputs
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "SCA_XORController.h"
+#include "SCA_ISensor.h"
+#include "SCA_LogicManager.h"
+#include "BoolValue.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* ------------------------------------------------------------------------- */
+/* Native functions */
+/* ------------------------------------------------------------------------- */
+
+SCA_XORController::SCA_XORController(SCA_IObject* gameobj,
+ PyTypeObject* T)
+ :
+ SCA_IController(gameobj,T)
+{
+}
+
+
+
+SCA_XORController::~SCA_XORController()
+{
+}
+
+
+
+void SCA_XORController::Trigger(SCA_LogicManager* logicmgr)
+{
+
+ bool sensorresult = false;
+
+ for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
+ !(is==m_linkedsensors.end());is++)
+ {
+ SCA_ISensor* sensor = *is;
+ if (sensor->IsPositiveTrigger())
+ {
+ if (sensorresult == true)
+ {
+ sensorresult = false;
+ break;
+ }
+ sensorresult = true;
+ }
+ }
+
+ CValue* newevent = new CBoolValue(sensorresult);
+
+ for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
+ !(i==m_linkedactuators.end());i++)
+ {
+ SCA_IActuator* actua = *i;//m_linkedactuators.at(i);
+ logicmgr->AddActiveActuator(actua,newevent);
+ }
+
+ // every actuator that needs the event, has a it's own reference to it now so
+ // release it (so to be clear: if there is no actuator, it's deleted right now)
+ newevent->Release();
+
+}
+
+
+
+CValue* SCA_XORController::GetReplica()
+{
+ CValue* replica = new SCA_XORController(*this);
+ // this will copy properties and so on...
+ CValue::AddDataToReplica(replica);
+
+ return replica;
+}
+
+
+
+/* ------------------------------------------------------------------------- */
+/* Python functions */
+/* ------------------------------------------------------------------------- */
+
+/* Integration hooks ------------------------------------------------------- */
+PyTypeObject SCA_XORController::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "SCA_XORController",
+ sizeof(SCA_XORController),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject SCA_XORController::Parents[] = {
+ &SCA_XORController::Type,
+ &SCA_IController::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+PyMethodDef SCA_XORController::Methods[] = {
+ {NULL,NULL} //Sentinel
+};
+
+PyObject* SCA_XORController::_getattr(const STR_String& attr) {
+ _getattr_up(SCA_IController);
+}
+
+/* eof */
diff --git a/source/gameengine/GameLogic/SCA_XORController.h b/source/gameengine/GameLogic/SCA_XORController.h
new file mode 100644
index 00000000000..f50cd33c125
--- /dev/null
+++ b/source/gameengine/GameLogic/SCA_XORController.h
@@ -0,0 +1,56 @@
+/**
+ * SCA_XORController.h
+ *
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __KX_XORCONTROLLER
+#define __KX_XORCONTROLLER
+
+#include "SCA_IController.h"
+
+class SCA_XORController : public SCA_IController
+{
+ Py_Header;
+ //virtual void Trigger(class SCA_LogicManager* logicmgr);
+public:
+ SCA_XORController(SCA_IObject* gameobj,PyTypeObject* T=&Type);
+ virtual ~SCA_XORController();
+ virtual CValue* GetReplica();
+ virtual void Trigger(SCA_LogicManager* logicmgr);
+
+ /* --------------------------------------------------------------------- */
+ /* Python interface ---------------------------------------------------- */
+ /* --------------------------------------------------------------------- */
+
+ virtual PyObject* _getattr(const STR_String& attr);
+
+};
+
+#endif //__KX_XORCONTROLLER
+
diff --git a/source/gameengine/GameLogic/SConscript b/source/gameengine/GameLogic/SConscript
index 38064733b73..ee0e638af60 100644
--- a/source/gameengine/GameLogic/SConscript
+++ b/source/gameengine/GameLogic/SConscript
@@ -5,8 +5,16 @@ sources = env.Glob('*.cpp') + env.Glob('Joystick/*.cpp')
incs = '. #/source/kernel/gen_system #/intern/string'
incs += ' #/source/gameengine/Expressions #/intern/moto/include'
+incs += ' #/source/gameengine/Rasterizer'
incs += ' ' + env['BF_PYTHON_INC']
-incs += ' ' + env['BF_SDL_INC']
-env.BlenderLib ( 'bf_logic', sources, Split(incs), [], libtype=['game','player'], priority=[30, 100] )
+
+defs = ''
+
+if env['WITH_BF_SDL']:
+ incs += ' ' + env['BF_SDL_INC']
+else:
+ defs += ' DISABLE_SDL'
+
+env.BlenderLib ( 'bf_logic', sources, Split(incs), Split(defs), libtype=['game','player'], priority=[30, 100] )
diff --git a/source/gameengine/GamePlayer/CMakeLists.txt b/source/gameengine/GamePlayer/CMakeLists.txt
index ff1040bfb40..fc5912155cf 100644
--- a/source/gameengine/GamePlayer/CMakeLists.txt
+++ b/source/gameengine/GamePlayer/CMakeLists.txt
@@ -25,3 +25,7 @@
# ***** END GPL LICENSE BLOCK *****
SUBDIRS(common ghost)
+
+IF(WITH_WEBPLUGIN)
+ SUBDIRS(xembed)
+ENDIF(WITH_WEBPLUGIN)
diff --git a/source/gameengine/GamePlayer/Makefile b/source/gameengine/GamePlayer/Makefile
index 747a82fc333..c4f78f23117 100644
--- a/source/gameengine/GamePlayer/Makefile
+++ b/source/gameengine/GamePlayer/Makefile
@@ -34,7 +34,7 @@ SOURCEDIR = source/gameengine/GamePlayer
DIR = $(OCGDIR)/gameengine/GamePlayer
DIRS = common ghost
-ifneq ($(NAN_NO_PLUGIN),true)
+ifeq ($(WITH_BF_WEBPLUGIN),true)
ifeq ($(OS),$(findstring $(OS), "freebsd irix windows"))
ifneq ($(FREE_WINDOWS),true)
DIRS += netscape
diff --git a/source/gameengine/GamePlayer/SConscript b/source/gameengine/GamePlayer/SConscript
index df6d26e5d16..0b140bba8e7 100644
--- a/source/gameengine/GamePlayer/SConscript
+++ b/source/gameengine/GamePlayer/SConscript
@@ -1,3 +1,3 @@
#!/usr/bin/python
SConscript(['common/SConscript',
- 'ghost/SConscript'])
+ 'ghost/SConscript'])
diff --git a/source/gameengine/GamePlayer/common/CMakeLists.txt b/source/gameengine/GamePlayer/common/CMakeLists.txt
index 29cdcd640f5..0c6c4179e2d 100644
--- a/source/gameengine/GamePlayer/common/CMakeLists.txt
+++ b/source/gameengine/GamePlayer/common/CMakeLists.txt
@@ -30,7 +30,6 @@ SET(SRC
GPC_Engine.cpp
GPC_KeyboardDevice.cpp
GPC_MouseDevice.cpp
- GPC_PolygonMaterial.cpp
GPC_RawImage.cpp
GPC_RawLoadDotBlendArray.cpp
GPC_RawLogoArrays.cpp
@@ -69,6 +68,8 @@ SET(INC
../../../../source/gameengine/GamePlayer/ghost
../../../../source/blender/misc
../../../../source/blender/blenloader
+ ../../../../source/blender/gpu
+ ../../../../extern/glew/include
${PYTHON_INC}
${SOLID_INC}
${PNG_INC}
diff --git a/source/gameengine/GamePlayer/common/GPC_Canvas.h b/source/gameengine/GamePlayer/common/GPC_Canvas.h
index bd66c865988..87719041f65 100644
--- a/source/gameengine/GamePlayer/common/GPC_Canvas.h
+++ b/source/gameengine/GamePlayer/common/GPC_Canvas.h
@@ -33,18 +33,12 @@
#include "RAS_ICanvas.h"
#include "RAS_Rect.h"
-#if defined(WIN32) || defined(__APPLE__)
- #ifdef WIN32
- #pragma warning (disable:4786) // suppress stl-MSVC debug info warning
- #include <windows.h>
- #include <GL/gl.h>
- #else // WIN32
- // __APPLE__ is defined
- #include <AGL/gl.h>
- #endif // WIN32
-#else //defined(WIN32) || defined(__APPLE__)
- #include <GL/gl.h>
-#endif //defined(WIN32) || defined(__APPLE__)
+#ifdef WIN32
+ #pragma warning (disable:4786) // suppress stl-MSVC debug info warning
+ #include <windows.h>
+#endif // WIN32
+
+#include "GL/glew.h"
#include <map>
@@ -136,6 +130,12 @@ public:
) {
return m_displayarea;
};
+
+ RAS_Rect &
+ GetWindowArea(
+ ) {
+ return m_displayarea;
+ }
void
BeginFrame(
diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
index c5064c86b5a..474df9276a7 100644
--- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.cpp
@@ -29,6 +29,8 @@
#include "GPC_KeyboardDevice.h"
+#include <cstdlib>
+
/**
* NextFrame toggles currentTable with previousTable,
* and copies relevant event information from previous to current table
diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
index aa2bfefb603..891589dd118 100644
--- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
+++ b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h
@@ -55,9 +55,9 @@ protected:
* System dependent keyboard codes are stored as ints.
*/
std::map<int, KX_EnumInputs> m_reverseKeyTranslateTable;
- bool m_hookesc;
public:
+ bool m_hookesc;
GPC_KeyboardDevice()
: m_hookesc(false)
{
diff --git a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp
index 46fe24d8b87..b1e2b5af0e6 100644
--- a/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_PolygonMaterial.cpp
@@ -31,23 +31,7 @@
#include <config.h>
#endif
-#ifdef WIN32
-#include <windows.h>
-#endif // WIN32
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#include <OpenGL/glu.h>
-#else
-#include <GL/gl.h>
-#if defined(__sun__) && !defined(__sparc__)
-#include <mesa/glu.h>
-#else
-#include <GL/glu.h>
-#endif
-#endif
-
-
+#include "GL/glew.h"
#include "GPC_PolygonMaterial.h"
#include "MT_Vector3.h"
@@ -88,7 +72,6 @@ static int fDoMipMap = 1;
static int fLinearMipMap=1;
static int fAlphamode= -1;
-using namespace bgl;
/* (n&(n-1)) zeros the least significant bit of n */
static int is_pow2(int num) {
return ((num)&(num-1))==0;
@@ -154,16 +137,23 @@ int set_tpage(MTFace *tface)
fAlphamode= tface->transp;
if(fAlphamode) {
- glEnable(GL_BLEND);
-
if(fAlphamode==TF_ADD) {
+ glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
+ glDisable ( GL_ALPHA_TEST );
/* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
}
else if(fAlphamode==TF_ALPHA) {
+ glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glDisable ( GL_ALPHA_TEST );
/* glBlendEquationEXT(GL_FUNC_ADD_EXT); */
}
+ else if (fAlphamode==TF_CLIP){
+ glDisable(GL_BLEND);
+ glEnable ( GL_ALPHA_TEST );
+ glAlphaFunc(GL_GREATER, 0.5f);
+ }
/* else { */
/* glBlendFunc(GL_ONE, GL_ONE); */
/* glBlendEquationEXT(GL_FUNC_REVERSE_SUBTRACT_EXT); */
diff --git a/source/gameengine/GamePlayer/common/GPC_RawImage.cpp b/source/gameengine/GamePlayer/common/GPC_RawImage.cpp
index a9cfb0a9366..e6e97cbdfd3 100644
--- a/source/gameengine/GamePlayer/common/GPC_RawImage.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_RawImage.cpp
@@ -45,7 +45,7 @@ GPC_RawImage::GPC_RawImage()
bool GPC_RawImage::Load(
- char *srcName,
+ const char *srcName,
int destWidth, int destHeight,
TImageAlignment alignment, int offsetX, int offsetY)
{
diff --git a/source/gameengine/GamePlayer/common/GPC_RawImage.h b/source/gameengine/GamePlayer/common/GPC_RawImage.h
index 17c00d2fcc3..49a3043bffc 100644
--- a/source/gameengine/GamePlayer/common/GPC_RawImage.h
+++ b/source/gameengine/GamePlayer/common/GPC_RawImage.h
@@ -61,7 +61,7 @@ public:
* @param offsetX Amount of horzontal offset applied to the resource image.
* @param offsetY Amount of vertical offset applied to the resource image.
*/
- virtual bool Load(char *srcName,
+ virtual bool Load(const char *srcName,
int destWidth, int destHeight,
TImageAlignment alignment = alignTopLeft,
int offsetX = 0, int offsetY = 0);
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
index 5912a8a10fc..78d8eaf2aa3 100644
--- a/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
+++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.cpp
@@ -27,22 +27,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#include <assert.h>
-
-#ifdef WIN32
-#pragma warning (disable : 4786)
-#include <windows.h>
-#endif
-
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#else
-#include <GL/gl.h>
-#endif
-#include <iostream>
-
-#include "GPC_RenderTools.h"
+#include "GL/glew.h"
#include "RAS_IRenderTools.h"
#include "RAS_IRasterizer.h"
@@ -50,122 +35,248 @@
#include "RAS_ICanvas.h"
#include "RAS_GLExtensionManager.h"
-// next two includes/dependencies come from the shadow feature
-// it needs the gameobject and the sumo physics scene for a raycast
#include "KX_GameObject.h"
-
-#include "GPC_PolygonMaterial.h"
#include "KX_PolygonMaterial.h"
-#include "Value.h"
+#include "KX_BlenderMaterial.h"
+#include "KX_RayCast.h"
+#include "KX_IPhysicsController.h"
+
+#include "PHY_IPhysicsEnvironment.h"
-//#include "KX_BlenderGL.h" // for text printing
-//#include "KX_BlenderClientObject.h"
#include "STR_String.h"
-#include "RAS_BucketManager.h" // for polymaterial (needed for textprinting)
-
-
-// Blender includes
-/* This list includes only data type definitions */
-#include "DNA_object_types.h"
-#include "DNA_material_types.h"
-#include "DNA_image_types.h"
-#include "DNA_lamp_types.h"
-#include "DNA_group_types.h"
-#include "DNA_scene_types.h"
-#include "DNA_camera_types.h"
-#include "DNA_property_types.h"
-#include "DNA_text_types.h"
-#include "DNA_sensor_types.h"
-#include "DNA_controller_types.h"
-#include "DNA_actuator_types.h"
-#include "DNA_mesh_types.h"
-#include "DNA_meshdata_types.h"
-#include "DNA_view3d_types.h"
-#include "DNA_world_types.h"
-
-#include "BKE_global.h"
-#include "BKE_image.h"
-#include "BKE_bmfont.h"
+
+#include "GPU_draw.h"
+
+#include "BKE_bmfont.h" // for text printing
#include "BKE_bmfont_types.h"
-#include "BKE_main.h"
-#include "IMB_imbuf_types.h"
-// End of Blender includes
+#include "GPC_RenderTools.h"
-#include "KX_Scene.h"
-#include "KX_RayCast.h"
-#include "KX_IPhysicsController.h"
-#include "PHY_IPhysicsEnvironment.h"
-#include "KX_BlenderMaterial.h"
+unsigned int GPC_RenderTools::m_numgllights;
GPC_RenderTools::GPC_RenderTools()
{
m_font = BMF_GetFont(BMF_kHelvetica10);
+
glGetIntegerv(GL_MAX_LIGHTS, (GLint*) &m_numgllights);
if (m_numgllights < 8)
m_numgllights = 8;
}
-
GPC_RenderTools::~GPC_RenderTools()
{
}
+void GPC_RenderTools::BeginFrame(RAS_IRasterizer* rasty)
+{
+ m_clientobject = NULL;
+ m_lastlightlayer = -1;
+ m_lastlighting = false;
+ DisableOpenGLLights();
+}
void GPC_RenderTools::EndFrame(RAS_IRasterizer* rasty)
{
}
+/* ProcessLighting performs lighting on objects. the layer is a bitfield that
+ * contains layer information. There are 20 'official' layers in blender. A
+ * light is applied on an object only when they are in the same layer. OpenGL
+ * has a maximum of 8 lights (simultaneous), so 20 * 8 lights are possible in
+ * a scene. */
-void GPC_RenderTools::BeginFrame(RAS_IRasterizer* rasty)
+void GPC_RenderTools::ProcessLighting(int layer, const MT_Transform& viewmat)
{
- m_clientobject=NULL;
- m_modified=true;
- DisableOpenGLLights();
+ if(m_lastlightlayer == layer)
+ return;
-}
+ m_lastlightlayer = layer;
-int GPC_RenderTools::ProcessLighting(int layer)
-{
- int result = false;
+ bool enable = false;
- if (layer < 0)
- {
- DisableOpenGLLights();
- result = false;
- } else
+ if (layer >= 0)
{
if (m_clientobject)
- {
- if (applyLights(layer))
- {
- EnableOpenGLLights();
- result = true;
- } else
- {
- DisableOpenGLLights();
- result = false;
- }
+ {
+ if (layer == RAS_LIGHT_OBJECT_LAYER)
+ layer = static_cast<KX_GameObject*>(m_clientobject)->GetLayer();
+
+ enable = applyLights(layer, viewmat);
}
}
- return result;
+
+ if(enable)
+ EnableOpenGLLights();
+ else
+ DisableOpenGLLights();
}
void GPC_RenderTools::EnableOpenGLLights()
{
+ if(m_lastlighting == true)
+ return;
+
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
- glColorMaterial(GL_FRONT_AND_BACK,GL_DIFFUSE);
- if (bgl::QueryExtension(bgl::_GL_EXT_separate_specular_color) || bgl::QueryVersion(1, 2))
+
+ glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, true);
+ if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2)
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
+
+ m_lastlighting = true;
+}
+
+void GPC_RenderTools::DisableOpenGLLights()
+{
+ if(m_lastlighting == false)
+ return;
+
+ glDisable(GL_LIGHTING);
+ glDisable(GL_COLOR_MATERIAL);
+
+ m_lastlighting = false;
+}
+
+
+void GPC_RenderTools::SetClientObject(RAS_IRasterizer *rasty, void* obj)
+{
+ if (m_clientobject != obj)
+ {
+ bool ccw = (obj == NULL || !((KX_GameObject*)obj)->IsNegativeScaling());
+ rasty->SetFrontFace(ccw);
+
+ m_clientobject = obj;
+ }
+}
+
+bool GPC_RenderTools::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data)
+{
+ double* const oglmatrix = (double* const) data;
+ MT_Point3 resultpoint(result->m_hitPoint);
+ MT_Vector3 resultnormal(result->m_hitNormal);
+ MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
+ MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized();
+ left = (dir.cross(resultnormal)).safe_normalized();
+ // for the up vector, we take the 'resultnormal' returned by the physics
+
+ double maat[16]={
+ left[0], left[1], left[2], 0,
+ dir[0], dir[1], dir[2], 0,
+ resultnormal[0],resultnormal[1],resultnormal[2], 0,
+ 0, 0, 0, 1};
+ glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]);
+ //glMultMatrixd(oglmatrix);
+ glMultMatrixd(maat);
+ return true;
+}
+
+void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode )
+{
+ /* FIXME:
+ blender: intern/moto/include/MT_Vector3.inl:42: MT_Vector3 operator/(const
+ MT_Vector3&, double): Assertion `!MT_fuzzyZero(s)' failed.
+
+ Program received signal SIGABRT, Aborted.
+ [Switching to Thread 16384 (LWP 1519)]
+ 0x40477571 in kill () from /lib/libc.so.6
+ (gdb) bt
+ #7 0x08334368 in MT_Vector3::normalized() const ()
+ #8 0x0833e6ec in GPC_RenderTools::applyTransform(RAS_IRasterizer*, double*, int) ()
+ */
+
+ if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED ||
+ objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED)
+ {
+ // rotate the billboard/halo
+ //page 360/361 3D Game Engine Design, David Eberly for a discussion
+ // on screen aligned and axis aligned billboards
+ // assumed is that the preprocessor transformed all billboard polygons
+ // so that their normal points into the positive x direction (1.0 , 0.0 , 0.0)
+ // when new parenting for objects is done, this rotation
+ // will be moved into the object
+
+ MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]);
+ MT_Point3 campos = rasty->GetCameraPosition();
+ MT_Vector3 dir = (campos - objpos).safe_normalized();
+ MT_Vector3 up(0,0,1.0);
+
+ KX_GameObject* gameobj = (KX_GameObject*) this->m_clientobject;
+ // get scaling of halo object
+ MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale();
+
+ bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned
+ if (screenaligned)
+ {
+ up = (up - up.dot(dir) * dir).safe_normalized();
+ } else
+ {
+ dir = (dir - up.dot(dir)*up).safe_normalized();
+ }
+
+ MT_Vector3 left = dir.normalized();
+ dir = (left.cross(up)).normalized();
+
+ // we have calculated the row vectors, now we keep
+ // local scaling into account:
+
+ left *= size[0];
+ dir *= size[1];
+ up *= size[2];
+ double maat[16]={
+ left[0], left[1],left[2], 0,
+ dir[0], dir[1],dir[2],0,
+ up[0],up[1],up[2],0,
+ 0,0,0,1};
+ glTranslated(objpos[0],objpos[1],objpos[2]);
+ glMultMatrixd(maat);
+
+ } else
+ {
+ if (objectdrawmode & RAS_IPolyMaterial::SHADOW)
+ {
+ // shadow must be cast to the ground, physics system needed here!
+ MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
+ KX_GameObject *gameobj = (KX_GameObject*) this->m_clientobject;
+ MT_Vector3 direction = MT_Vector3(0,0,-1);
+
+ direction.normalize();
+ direction *= 100000;
+
+ MT_Point3 topoint = frompoint + direction;
+
+ KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo;
+ PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment();
+ KX_IPhysicsController* physics_controller = gameobj->GetPhysicsController();
+
+ KX_GameObject *parent = gameobj->GetParent();
+ if (!physics_controller && parent)
+ physics_controller = parent->GetPhysicsController();
+ if (parent)
+ parent->Release();
+
+ KX_RayCast::Callback<GPC_RenderTools> callback(this, physics_controller, oglmatrix);
+ if (!KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback))
+ {
+ // couldn't find something to cast the shadow on...
+ glMultMatrixd(oglmatrix);
+ }
+ } else
+ {
+
+ // 'normal' object
+ glMultMatrixd(oglmatrix);
+ }
+ }
}
-void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco,
- int yco,
- int width,
- int height)
+
+void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode,
+ const char* text,
+ int xco,
+ int yco,
+ int width,
+ int height)
{
STR_String tmpstr(text);
int lines;
@@ -238,21 +349,19 @@ void GPC_RenderTools::RenderText2D(RAS_TEXT_RENDER_MODE mode,
glDisable(GL_LIGHTING);
}
-/**
- * Copied from KX_BlenderRenderTools.cpp in KX_blenderhook
- * Renders text into a (series of) polygon(s), using a texture font,
- * Each character consists of one polygon (one quad or two triangles)
- */
+/* Render Text renders text into a (series of) polygon, using a texture font,
+ * Each character consists of one polygon (one quad or two triangles) */
+
void GPC_RenderTools::RenderText(
int mode,
RAS_IPolyMaterial* polymat,
- float v1[3], float v2[3], float v3[3], float v4[3])
+ float v1[3], float v2[3], float v3[3], float v4[3], int glattrib)
{
STR_String mytext = ((CValue*)m_clientobject)->GetPropertyText("Text");
const unsigned int flag = polymat->GetFlag();
struct MTFace* tface = 0;
- unsigned int* col = 0;
+ unsigned int *col = 0;
if(flag & RAS_BLENDERMAT) {
KX_BlenderMaterial *bl_mat = static_cast<KX_BlenderMaterial*>(polymat);
@@ -263,110 +372,29 @@ void GPC_RenderTools::RenderText(
tface = blenderpoly->GetMTFace();
col = blenderpoly->GetMCol();
}
-
- BL_RenderText(mode, mytext, mytext.Length(), tface, col, v1, v2, v3, v4);
+
+ GPU_render_text(tface, mode, mytext, mytext.Length(), col, v1, v2, v3, v4, glattrib);
}
-
-/**
- * Copied from KX_BlenderGL.cpp in KX_blenderhook
- */
-void GPC_RenderTools::BL_RenderText(
- int mode,
- const char* textstr,
- int textlen,
- struct MTFace* tface,
- unsigned int* col,
- float v1[3],float v2[3],float v3[3],float v4[3])
+void GPC_RenderTools::PushMatrix()
{
- struct Image* ima;
-
- if (mode & TF_BMFONT) {
- //char string[MAX_PROPSTRING];
-// float tmat[4][4];
- int characters, index, character;
- float centerx, centery, sizex, sizey, transx, transy, movex, movey, advance;
-
-// bProperty *prop;
-
- // string = "Frank van Beek";
-
- characters = textlen;
-
- ima = (struct Image*) tface->tpage;
- if (ima == NULL) {
- characters = 0;
- }
-
- if(!col) glColor3f(1.0f, 1.0f, 1.0f);
-
- glPushMatrix();
- for (index = 0; index < characters; index++) {
- // lets calculate offset stuff
- character = textstr[index];
-
- // space starts at offset 1
- // character = character - ' ' + 1;
-
- matrixGlyph((ImBuf *)ima->ibufs.first, character, & centerx, &centery, &sizex, &sizey, &transx, &transy, &movex, &movey, &advance);
-
- glBegin(GL_POLYGON);
- // printf(" %c %f %f %f %f\n", character, tface->uv[0][0], tface->uv[0][1], );
- // glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy);
- glTexCoord2f((tface->uv[0][0] - centerx) * sizex + transx, (tface->uv[0][1] - centery) * sizey + transy);
-
- if(col) BL_spack(col[0]);
- // glVertex3fv(v1);
- glVertex3f(sizex * v1[0] + movex, sizey * v1[1] + movey, v1[2]);
-
- glTexCoord2f((tface->uv[1][0] - centerx) * sizex + transx, (tface->uv[1][1] - centery) * sizey + transy);
- if(col) BL_spack(col[1]);
- // glVertex3fv(v2);
- glVertex3f(sizex * v2[0] + movex, sizey * v2[1] + movey, v2[2]);
-
- glTexCoord2f((tface->uv[2][0] - centerx) * sizex + transx, (tface->uv[2][1] - centery) * sizey + transy);
- if(col) BL_spack(col[2]);
- // glVertex3fv(v3);
- glVertex3f(sizex * v3[0] + movex, sizey * v3[1] + movey, v3[2]);
-
- if(v4) {
- // glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, 1.0 - (1.0 - tface->uv[3][1]) * sizey - transy);
- glTexCoord2f((tface->uv[3][0] - centerx) * sizex + transx, (tface->uv[3][1] - centery) * sizey + transy);
- if(col) BL_spack(col[3]);
- // glVertex3fv(v4);
- glVertex3f(sizex * v4[0] + movex, sizey * v4[1] + movey, v4[2]);
- }
- glEnd();
-
- glTranslatef(advance, 0.0, 0.0);
- }
- glPopMatrix();
-
- }
+ glPushMatrix();
}
-
-RAS_IPolyMaterial* GPC_RenderTools::CreateBlenderPolyMaterial(
- const STR_String &texname,
- bool ba,const STR_String& matname,int tile,int tilexrep,int tileyrep,int mode,bool transparant, bool zsort,
- int lightlayer,bool bIsTriangle,void* clientobject,void* tface)
+void GPC_RenderTools::PopMatrix()
{
- assert(!"Deprecated");
-/* return new GPC_PolygonMaterial(texname, ba,matname,tile,tilexrep,tileyrep,
- mode,transparant,zsort,lightlayer,bIsTriangle,clientobject,tface);
- */
- return NULL;
+ glPopMatrix();
}
-int GPC_RenderTools::applyLights(int objectlayer)
+int GPC_RenderTools::applyLights(int objectlayer, const MT_Transform& viewmat)
{
-// taken from blender source, incompatibility between Blender Object / GameObject
-
- int count;
+ // taken from blender source, incompatibility between Blender Object / GameObject
+ float glviewmat[16];
+ unsigned int count;
float vec[4];
-
+
vec[3]= 1.0;
for(count=0; count<m_numgllights; count++)
@@ -375,23 +403,20 @@ int GPC_RenderTools::applyLights(int objectlayer)
//std::vector<struct RAS_LightObject*> m_lights;
std::vector<struct RAS_LightObject*>::iterator lit = m_lights.begin();
+ viewmat.getValue(glviewmat);
+ glPushMatrix();
+ glLoadMatrixf(glviewmat);
for (lit = m_lights.begin(), count = 0; !(lit==m_lights.end()) && count < m_numgllights; ++lit)
{
RAS_LightObject* lightdata = (*lit);
if (lightdata->m_layer & objectlayer)
{
-
- glPushMatrix();
- glLoadMatrixf(m_viewmat);
-
-
vec[0] = (*(lightdata->m_worldmatrix))(0,3);
vec[1] = (*(lightdata->m_worldmatrix))(1,3);
vec[2] = (*(lightdata->m_worldmatrix))(2,3);
vec[3] = 1;
-
if(lightdata->m_type==RAS_LightObject::LIGHT_SUN) {
vec[0] = (*(lightdata->m_worldmatrix))(0,2);
@@ -447,126 +472,16 @@ int GPC_RenderTools::applyLights(int objectlayer)
}
glLightfv((GLenum)(GL_LIGHT0+count), GL_SPECULAR, vec);
glEnable((GLenum)(GL_LIGHT0+count));
-
- count++;
- glPopMatrix();
+ count++;
}
}
+ glPopMatrix();
return count;
}
-bool GPC_RenderTools::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data)
-{
- double* const oglmatrix = (double* const) data;
- MT_Point3 resultpoint(hit_point);
- MT_Vector3 resultnormal(hit_normal);
- MT_Vector3 left(oglmatrix[0],oglmatrix[1],oglmatrix[2]);
- MT_Vector3 dir = -(left.cross(resultnormal)).safe_normalized();
- left = (dir.cross(resultnormal)).safe_normalized();
- // for the up vector, we take the 'resultnormal' returned by the physics
-
- double maat[16]={
- left[0], left[1], left[2], 0,
- dir[0], dir[1], dir[2], 0,
- resultnormal[0],resultnormal[1],resultnormal[2], 0,
- 0, 0, 0, 1};
- glTranslated(resultpoint[0],resultpoint[1],resultpoint[2]);
- //glMultMatrixd(oglmatrix);
- glMultMatrixd(maat);
- return true;
-}
-
-void GPC_RenderTools::applyTransform(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode )
-{
- if (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED ||
- objectdrawmode & RAS_IPolyMaterial::BILLBOARD_AXISALIGNED)
- {
- // rotate the billboard/halo
- //page 360/361 3D Game Engine Design, David Eberly for a discussion
- // on screen aligned and axis aligned billboards
- // assumed is that the preprocessor transformed all billboard polygons
- // so that their normal points into the positive x direction (1.0 , 0.0 , 0.0)
- // when new parenting for objects is done, this rotation
- // will be moved into the object
-
- MT_Point3 objpos (oglmatrix[12],oglmatrix[13],oglmatrix[14]);
- MT_Point3 campos = rasty->GetCameraPosition();
- MT_Vector3 dir = (campos - objpos).safe_normalized();
- MT_Vector3 up(0,0,1.0);
-
- KX_GameObject* gameobj = (KX_GameObject*) this->m_clientobject;
- // get scaling of halo object
- MT_Vector3 size = gameobj->GetSGNode()->GetLocalScale();
-
- bool screenaligned = (objectdrawmode & RAS_IPolyMaterial::BILLBOARD_SCREENALIGNED)!=0;//false; //either screen or axisaligned
- if (screenaligned)
- {
- up = (up - up.dot(dir) * dir).safe_normalized();
- } else
- {
- dir = (dir - up.dot(dir)*up).safe_normalized();
- }
-
- MT_Vector3 left = dir.normalized();
- dir = (left.cross(up)).normalized();
-
- // we have calculated the row vectors, now we keep
- // local scaling into account:
-
- left *= size[0];
- dir *= size[1];
- up *= size[2];
- double maat[16]={
- left[0], left[1],left[2], 0,
- dir[0], dir[1],dir[2],0,
- up[0],up[1],up[2],0,
- 0,0,0,1};
- glTranslated(objpos[0],objpos[1],objpos[2]);
- glMultMatrixd(maat);
-
- } else
- {
- if (objectdrawmode & RAS_IPolyMaterial::SHADOW)
- {
- // shadow must be cast to the ground, physics system needed here!
- MT_Point3 frompoint(oglmatrix[12],oglmatrix[13],oglmatrix[14]);
- KX_GameObject *gameobj = (KX_GameObject*) this->m_clientobject;
- MT_Vector3 direction = MT_Vector3(0,0,-1);
-
- direction.normalize();
- direction *= 100000;
-
- MT_Point3 topoint = frompoint + direction;
-
- KX_Scene* kxscene = (KX_Scene*) m_auxilaryClientInfo;
- PHY_IPhysicsEnvironment* physics_environment = kxscene->GetPhysicsEnvironment();
- KX_IPhysicsController* physics_controller = gameobj->GetPhysicsController();
-
- KX_GameObject *parent = gameobj->GetParent();
- if (!physics_controller && parent)
- physics_controller = parent->GetPhysicsController();
- if (parent)
- parent->Release();
-
- MT_Point3 resultpoint;
- MT_Vector3 resultnormal;
- if (!KX_RayCast::RayTest(physics_controller, physics_environment, frompoint, topoint, resultpoint, resultnormal, KX_RayCast::Callback<GPC_RenderTools>(this, oglmatrix)))
- {
- // couldn't find something to cast the shadow on...
- glMultMatrixd(oglmatrix);
- }
- } else
- {
-
- // 'normal' object
- glMultMatrixd(oglmatrix);
- }
- }
-}
-
void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer)
{
int state = rasterizer->GetMotionBlurState();
@@ -590,4 +505,13 @@ void GPC_RenderTools::MotionBlur(RAS_IRasterizer* rasterizer)
}
}
-unsigned int GPC_RenderTools::m_numgllights;
+void GPC_RenderTools::Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)
+{
+ m_filtermanager.EnableFilter(propNames, gameObj, filtermode, pass, text);
+}
+
+void GPC_RenderTools::Render2DFilters(RAS_ICanvas* canvas)
+{
+ m_filtermanager.RenderFilters(canvas);
+}
+
diff --git a/source/gameengine/GamePlayer/common/GPC_RenderTools.h b/source/gameengine/GamePlayer/common/GPC_RenderTools.h
index f62aafff7c2..382956e73ea 100644
--- a/source/gameengine/GamePlayer/common/GPC_RenderTools.h
+++ b/source/gameengine/GamePlayer/common/GPC_RenderTools.h
@@ -30,146 +30,79 @@
#ifndef __GPC_RENDERTOOLS_H
#define __GPC_RENDERTOOLS_H
-#if defined(WIN32) || defined(__APPLE__)
- #ifdef WIN32
- #include <windows.h>
- #include <GL/gl.h>
- #else // WIN32
- // __APPLE__ is defined
- #include <AGL/gl.h>
- #endif // WIN32
-#else //defined(WIN32) || defined(__APPLE__)
- #include <GL/gl.h>
-#endif //defined(WIN32) || defined(__APPLE__)
-
+#ifdef WIN32
+// don't show stl-warnings
+#pragma warning (disable:4786)
+#include <windows.h>
+#endif // WIN32
#include "RAS_IRenderTools.h"
#include "BMF_Api.h"
struct KX_ClientObjectInfo;
+class KX_RayCast;
+/* BlenderRenderTools are a set of tools to apply 2D/3D graphics effects, which
+ * are not part of the (polygon) Rasterizer. Effects like 2D text, 3D (polygon)
+ * text, lighting.
+ *
+ * Most of this code is duplicated in KX_BlenderRenderTools, so this should be
+ * moved to some common location to avoid duplication. */
class GPC_RenderTools : public RAS_IRenderTools
{
+ int m_lastlightlayer;
+ bool m_lastlighting;
+ static unsigned int m_numgllights;
+
+ BMF_Font* m_font;
+
public:
- GPC_RenderTools();
- virtual ~GPC_RenderTools();
-
- virtual void EndFrame(RAS_IRasterizer* rasty);
- virtual void BeginFrame(RAS_IRasterizer* rasty);
-
- void DisableOpenGLLights()
- {
- glDisable(GL_LIGHTING);
- glDisable(GL_COLOR_MATERIAL);
- }
-
- void EnableOpenGLLights();
-
- int ProcessLighting(int layer);
-
- void Perspective(int a, int width, int height, float mat[4][4], float viewmat[4][4])
- {
- if(a== 0)
- {
- glMatrixMode(GL_PROJECTION);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- }
- else
- {
- if(a== 1)
- {
- glMatrixMode(GL_PROJECTION);
- glMatrixMode(GL_MODELVIEW);
- }
- }
- }
-
- /**
- * @attention mode is ignored here
- */
- virtual void RenderText2D(
- RAS_TEXT_RENDER_MODE mode,
- const char* text,
- int xco,
- int yco,
- int width,
- int height);
-
- /**
- * Renders text into a (series of) polygon(s), using a texture font,
- * Each character consists of one polygon (one quad or two triangles)
- */
- virtual void RenderText(
- int mode,
- RAS_IPolyMaterial* polymat,
- float v1[3],
- float v2[3],
- float v3[3],
- float v4[3]);
-
- void Render(RAS_IRasterizer* rasty,double* oglmatrix,int objectdrawmode)
- {
- glPopMatrix();
- glPushMatrix();
- glMultMatrixd(oglmatrix);
- }
-
- void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode);
-
- virtual void PushMatrix()
- {
- glPushMatrix();
- }
-
- virtual void PopMatrix()
- {
- glPopMatrix();
- }
-
- virtual class RAS_IPolyMaterial* CreateBlenderPolyMaterial(
- const STR_String &texname,
- bool ba,
- const STR_String& matname,
- int tile,
- int tilexrep,int tileyrep,
- int mode,
- bool transparant,
- bool zsort,
- int lightlayer,
- bool bIsTriangle,
- void* clientobject,
- void* tface);
-
- int applyLights(int objectlayer);
-
- bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data);
+ GPC_RenderTools();
+ virtual ~GPC_RenderTools();
+
+ void EndFrame(RAS_IRasterizer* rasty);
+ void BeginFrame(RAS_IRasterizer* rasty);
+
+ void EnableOpenGLLights();
+ void DisableOpenGLLights();
+ void ProcessLighting(int layer, const MT_Transform& viewmat);
+
+ /* @attention mode is ignored here */
+ void RenderText2D(RAS_TEXT_RENDER_MODE mode,
+ const char* text,
+ int xco,
+ int yco,
+ int width,
+ int height);
+ void RenderText(int mode,
+ class RAS_IPolyMaterial* polymat,
+ float v1[3],
+ float v2[3],
+ float v3[3],
+ float v4[3],
+ int glattrib);
+
+ void applyTransform(RAS_IRasterizer* rasty, double* oglmatrix, int objectdrawmode);
+ int applyLights(int objectlayer, const MT_Transform& viewmat);
+
+ void PushMatrix();
+ void PopMatrix();
+
+ bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
+ bool NeedRayCast(KX_ClientObjectInfo* client) { return true; }
virtual void MotionBlur(RAS_IRasterizer* rasterizer);
-protected:
- /**
- * Copied from KX_BlenderGL.cpp in KX_blenderhook
- */
- void BL_RenderText(
- int mode,
- const char* textstr,
- int textlen,
- struct MTFace* tface,
- unsigned int* col,
- float v1[3],float v2[3],float v3[3],float v4[3]);
- void BL_spack(unsigned int ucol)
- {
- char *cp = (char *)&ucol;
- glColor3ub(cp[3], cp[2], cp[1]);
- }
+ virtual void Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text);
- BMF_Font* m_font;
- static unsigned int m_numgllights;
+ virtual void Render2DFilters(RAS_ICanvas* canvas);
+
+ virtual void SetClientObject(RAS_IRasterizer *rasty, void* obj);
};
#endif // __GPC_RENDERTOOLS_H
+
diff --git a/source/gameengine/GamePlayer/common/Makefile b/source/gameengine/GamePlayer/common/Makefile
index b4800878704..6a12e659be6 100644
--- a/source/gameengine/GamePlayer/common/Makefile
+++ b/source/gameengine/GamePlayer/common/Makefile
@@ -35,6 +35,7 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
+CPPFLAGS += -I$(NAN_GLEW)/include
CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I../../../blender/blenkernel
@@ -42,6 +43,7 @@ CPPFLAGS += -I../../../blender/blenloader
CPPFLAGS += -I../../../blender/blenlib
CPPFLAGS += -I../../../blender/imbuf
CPPFLAGS += -I../../../blender/makesdna
+CPPFLAGS += -I../../../blender/gpu
CPPFLAGS += -I../../../kernel/gen_system
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
@@ -60,6 +62,7 @@ CPPFLAGS += -I../../../gameengine/Converter
CPPFLAGS += -I../../../gameengine/Expressions
CPPFLAGS += -I../../../gameengine/GameLogic
CPPFLAGS += -I../../../gameengine/Converter
+CPPFLAGS += -I../../../gameengine/BlenderRoutines
CPPFLAGS += -I../../../gameengine/Ketsji
CPPFLAGS += -I../../../gameengine/Ketsji/KXNetwork
CPPFLAGS += -I../../../gameengine/Network
diff --git a/source/gameengine/GamePlayer/common/SConscript b/source/gameengine/GamePlayer/common/SConscript
index b6e373b4f92..30f20a670d3 100644
--- a/source/gameengine/GamePlayer/common/SConscript
+++ b/source/gameengine/GamePlayer/common/SConscript
@@ -4,60 +4,62 @@ Import ('env')
source_files = ['bmfont.cpp',
- 'GPC_Canvas.cpp',
- 'GPC_Engine.cpp',
- 'GPC_KeyboardDevice.cpp',
- 'GPC_MouseDevice.cpp',
- 'GPC_PolygonMaterial.cpp',
- 'GPC_RawImage.cpp',
- 'GPC_RawLoadDotBlendArray.cpp',
- 'GPC_RawLogoArrays.cpp',
- 'GPC_RenderTools.cpp',
- 'GPC_System.cpp']
+ 'GPC_Canvas.cpp',
+ 'GPC_Engine.cpp',
+ 'GPC_KeyboardDevice.cpp',
+ 'GPC_MouseDevice.cpp',
+ 'GPC_RawImage.cpp',
+ 'GPC_RawLoadDotBlendArray.cpp',
+ 'GPC_RawLogoArrays.cpp',
+ 'GPC_RenderTools.cpp',
+ 'GPC_System.cpp']
incs = ['.',
- '#intern/string',
- '#intern/ghost',
- '#intern/guardedalloc',
- '#intern/bmfont',
- '#intern/moto/include',
- '#intern/SoundSystem',
- '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer',
- '#source/kernel/gen_system',
- '#source/kernel/gen_messaging',
- '#source/gameengine/Converter',
- '#source/blender/imbuf',
- '#source/gameengine/Ketsji',
- '#source/blender/blenlib',
- '#source/blender/blenkernel',
- '#source/blender',
- '#source/blender/editors/include',
- '#source/blender/makesdna',
- '#source/gameengine/Rasterizer',
- '#source/gameengine/GameLogic',
- '#source/gameengine/Expressions',
- '#source/gameengine/Network',
- '#source/gameengine/SceneGraph',
- '#source/gameengine/Physics/common',
- '#source/gameengine/Physics/Sumo',
- '#source/gameengine/Physics/Sumo/Fuzzics/include',
- '#source/gameengine/Network/LoopBackNetwork',
- '#source/gameengine/GamePlayer/ghost',
- '#source/blender/misc',
- '#source/blender/blenloader']
-
+ '#intern/string',
+ '#intern/ghost',
+ '#intern/guardedalloc',
+ '#intern/bmfont',
+ '#intern/moto/include',
+ '#intern/SoundSystem',
+ '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer',
+ '#source/kernel/gen_system',
+ '#source/kernel/gen_messaging',
+ '#source/gameengine/Converter',
+ '#source/blender/imbuf',
+ '#source/gameengine/Ketsji',
+ '#source/blender/blenlib',
+ '#source/blender/blenkernel',
+ '#source/blender',
+ '#source/blender/include',
+ '#source/blender/makesdna',
+ '#source/gameengine/BlenderRoutines',
+ '#source/gameengine/Rasterizer',
+ '#source/gameengine/GameLogic',
+ '#source/gameengine/Expressions',
+ '#source/gameengine/Network',
+ '#source/gameengine/SceneGraph',
+ '#source/gameengine/Physics/common',
+ '#source/gameengine/Physics/Sumo',
+ '#source/gameengine/Physics/Sumo/Fuzzics/include',
+ '#source/gameengine/Network/LoopBackNetwork',
+ '#source/gameengine/GamePlayer/ghost',
+ '#source/blender/misc',
+ '#source/blender/blenloader',
+ '#source/blender/gpu',
+ '#extern/glew/include']
+
#This is all plugin stuff!
#if sys.platform=='win32':
# source_files += ['windows/GPW_Canvas.cpp',
-# 'windows/GPW_Engine.cpp',
-# 'windows/GPW_KeyboardDevice.cpp',
-# 'windows/GPW_System.cpp']
+# 'windows/GPW_Engine.cpp',
+# 'windows/GPW_KeyboardDevice.cpp',
+# 'windows/GPW_System.cpp']
# gp_common_env.Append ( CPPPATH = ['windows'])
#elif sys.platform=='linux2' or sys.platform=='linux-i386':
# source_files += ['unix/GPU_Canvas.cpp',
-# 'unix/GPU_Engine.cpp',
-# 'unix/GPU_KeyboardDevice.cpp',
-# 'unix/GPU_System.cpp']
+# 'unix/GPU_Engine.cpp',
+# 'unix/GPU_KeyboardDevice.cpp',
+# 'unix/GPU_System.cpp']
# gp_common_env.Append ( CPPPATH = ['unix'])
incs += Split(env['BF_PYTHON_INC'])
@@ -67,6 +69,6 @@ incs += Split(env['BF_ZLIB_INC'])
cflags=[]
if env['OURPLATFORM']=='win32-vc':
- cflags = ['/GR']
+ cflags = ['/GR']
env.BlenderLib (libname='gp_common', sources=source_files, includes=incs, defines = [], libtype='player', priority=5, compileflags=cflags)
diff --git a/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h b/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h
index fee729a84ac..e5ed7f39811 100644
--- a/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h
+++ b/source/gameengine/GamePlayer/common/unix/GPU_PolygonMaterial.h
@@ -37,9 +37,9 @@ class GPU_PolygonMaterial : public BP_PolygonMaterial
public:
GPUPolygonMaterial(const STR_String& texname, bool ba,const STR_String& matname,
int tile, int tileXrep, int tileYrep, int mode, int transparant,
- int lightlayer,bool bIsTriangle,void* clientobject,void* tpage) :
+ int lightlayer,,void* tpage) :
BP_PolygonMaterial(texname, ba,matname, tile, tileXrep, tileYrep,
- mode, transparant, lightlayer, bIsTriangle, clientobject),
+ mode, transparant, lightlayer),
m_tface(tpage)
{
}
diff --git a/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h b/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h
index bb1abd71505..bf8cb720811 100644
--- a/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h
+++ b/source/gameengine/GamePlayer/common/windows/GPW_Canvas.h
@@ -36,7 +36,7 @@
#include <iostream>
#include <windows.h>
-#include <gl/gl.h>
+//#include <gl/gl.h>
#include "GPC_Canvas.h"
diff --git a/source/gameengine/GamePlayer/ghost/CMakeLists.txt b/source/gameengine/GamePlayer/ghost/CMakeLists.txt
index 3d17cd2cfdd..5e0ca93ac06 100644
--- a/source/gameengine/GamePlayer/ghost/CMakeLists.txt
+++ b/source/gameengine/GamePlayer/ghost/CMakeLists.txt
@@ -64,7 +64,9 @@ SET(INC
../../../../source/gameengine/GamePlayer/common
../../../../source/blender/misc
../../../../source/blender/blenloader
+ ../../../../source/blender/gpu
../../../../extern/solid
+ ../../../../extern/glew/include
${PYTHON_INC}
)
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
index 020798d5f24..aa5e5835cdc 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp
@@ -37,23 +37,14 @@
#include <windows.h>
#endif
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#include <OpenGL/glu.h>
-#else
-#include <GL/gl.h>
-#if defined(__sun__) && !defined(__sparc__)
-#include <mesa/glu.h>
-#else
-#include <GL/glu.h>
-#endif
-#endif
+#include "GL/glew.h"
+#include "GPU_extensions.h"
#include "GPG_Application.h"
#include <iostream>
#include <MT_assert.h>
+#include <stdlib.h>
/**********************************
* Begin Blender include block
@@ -66,6 +57,8 @@ extern "C"
#include "BLO_readfile.h"
#include "BKE_global.h"
#include "BKE_main.h"
+#include "IMB_imbuf.h"
+#include "DNA_scene_types.h"
#ifdef __cplusplus
}
#endif // __cplusplus
@@ -107,15 +100,15 @@ extern "C"
#include "GHOST_IWindow.h"
#include "GHOST_Rect.h"
-
static void frameTimerProc(GHOST_ITimerTask* task, GHOST_TUns64 time);
static GHOST_ISystem* fSystem = 0;
static const int kTimerFreq = 10;
-GPG_Application::GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR_String startSceneName)
- : m_startSceneName(startSceneName),
- m_maggie(maggie),
+GPG_Application::GPG_Application(GHOST_ISystem* system)
+ : m_startSceneName(""),
+ m_startScene(0),
+ m_maggie(0),
m_exitRequested(0),
m_system(system),
m_mainWindow(0),
@@ -123,6 +116,7 @@ GPG_Application::GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR
m_cursor(GHOST_kStandardCursorFirstCursor),
m_engineInitialized(0),
m_engineRunning(0),
+ m_isEmbedded(false),
m_ketsjiengine(0),
m_kxsystem(0),
m_keyboard(0),
@@ -133,7 +127,10 @@ GPG_Application::GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR
m_sceneconverter(0),
m_networkdevice(0),
m_audiodevice(0),
- m_blendermat(0)
+ m_blendermat(0),
+ m_blenderglslmat(0),
+ m_pyGlobalDictString(0),
+ m_pyGlobalDictString_Length(0)
{
fSystem = system;
}
@@ -142,21 +139,28 @@ GPG_Application::GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR
GPG_Application::~GPG_Application(void)
{
+ if(m_pyGlobalDictString) {
+ delete [] m_pyGlobalDictString;
+ m_pyGlobalDictString = 0;
+ m_pyGlobalDictString_Length = 0;
+ }
+
exitEngine();
fSystem->disposeWindow(m_mainWindow);
}
-bool GPG_Application::SetGameEngineData(struct Main* maggie, STR_String startSceneName)
+bool GPG_Application::SetGameEngineData(struct Main* maggie, Scene *scene)
{
bool result = false;
- if (maggie != NULL && startSceneName != "")
+ if (maggie != NULL && scene != NULL)
{
- G.scene = (Scene*)maggie->scene.first;
+ G.scene = scene;
m_maggie = maggie;
- m_startSceneName = startSceneName;
+ m_startSceneName = scene->id.name+2;
+ m_startScene = scene;
result = true;
}
@@ -328,6 +332,26 @@ bool GPG_Application::startWindow(STR_String& title,
return success;
}
+bool GPG_Application::startEmbeddedWindow(STR_String& title,
+ const GHOST_TEmbedderWindowID parentWindow,
+ const bool stereoVisual,
+ const int stereoMode) {
+
+ m_mainWindow = fSystem->createWindow(title, 0, 0, 0, 0, GHOST_kWindowStateNormal,
+ GHOST_kDrawingContextTypeOpenGL, stereoVisual, parentWindow);
+
+ if (!m_mainWindow) {
+ printf("error: could not create main window\n");
+ exit(-1);
+ }
+ m_isEmbedded = true;
+
+ bool success = initEngine(m_mainWindow, stereoMode);
+ if (success) {
+ success = startEngine();
+ }
+ return success;
+}
bool GPG_Application::startFullScreen(
@@ -486,7 +510,8 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
{
if (!m_engineInitialized)
{
- bgl::InitExtensions(1);
+ GPU_extensions_init();
+ bgl::InitExtensions(true);
// get and set the preferences
SYS_SystemHandle syshandle = SYS_GetSystem();
@@ -504,25 +529,16 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
bool fixed_framerate= (SYS_GetCommandLineInt(syshandle, "fixed_framerate", fixedFr) != 0);
bool frameRate = (SYS_GetCommandLineInt(syshandle, "show_framerate", 0) != 0);
- bool useVertexArrays = SYS_GetCommandLineInt(syshandle,"vertexarrays",1) != 0;
- bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DIAPLAY_LISTS) != 0);
-#ifdef GL_ARB_multitexture
- int gameflag =(G.fileflags & G_FILE_GAME_MAT);
- // ----------------------------------
- if(bgl::RAS_EXT_support._ARB_multitexture && bgl::QueryVersion(1, 1)) {
- m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", gameflag) != 0);
- int unitmax=0;
- glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&unitmax);
- bgl::max_texture_units = MAXTEX>unitmax?unitmax:MAXTEX;
- //std::cout << "using(" << bgl::max_texture_units << ") of(" << unitmax << ") texture units." << std::endl;
- } else {
- bgl::max_texture_units = 0;
- }
-#else
- m_blendermat=0;
-#endif//GL_ARB_multitexture
- // ----------------------------------
-
+ bool useLists = (SYS_GetCommandLineInt(syshandle, "displaylists", G.fileflags & G_FILE_DISPLAY_LISTS) != 0);
+
+ if(GLEW_ARB_multitexture && GLEW_VERSION_1_1)
+ m_blendermat = (SYS_GetCommandLineInt(syshandle, "blender_material", 1) != 0);
+
+ if(GPU_extensions_minimum_support())
+ m_blenderglslmat = (SYS_GetCommandLineInt(syshandle, "blender_glsl_material", 1) != 0);
+ else if(G.fileflags & G_FILE_GAME_MAT_GLSL)
+ m_blendermat = false;
+
// create the canvas, rasterizer and rendertools
m_canvas = new GPG_Canvas(window);
if (!m_canvas)
@@ -533,12 +549,17 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode)
if (!m_rendertools)
goto initFailed;
- if(useLists)
- m_rasterizer = new RAS_ListRasterizer(m_canvas);
- else if (useVertexArrays && bgl::QueryVersion(1, 1))
+ if(useLists) {
+ if(GLEW_VERSION_1_1)
+ m_rasterizer = new RAS_ListRasterizer(m_canvas, true);
+ else
+ m_rasterizer = new RAS_ListRasterizer(m_canvas);
+ }
+ else if (GLEW_VERSION_1_1)
m_rasterizer = new RAS_VAOpenGLRasterizer(m_canvas);
else
m_rasterizer = new RAS_OpenGLRasterizer(m_canvas);
+
m_rasterizer->SetStereoMode((RAS_IRasterizer::StereoMode) stereoMode);
if (!m_rasterizer)
goto initFailed;
@@ -640,31 +661,37 @@ bool GPG_Application::startEngine(void)
{
STR_String startscenename = m_startSceneName.Ptr();
m_ketsjiengine->SetSceneConverter(m_sceneconverter);
-
+
// if (always_use_expand_framing)
// sceneconverter->SetAlwaysUseExpandFraming(true);
- if(m_blendermat)
+ if(m_blendermat && (G.fileflags & G_FILE_GAME_MAT))
m_sceneconverter->SetMaterials(true);
+ if(m_blenderglslmat && (G.fileflags & G_FILE_GAME_MAT_GLSL))
+ m_sceneconverter->SetGLSLMaterials(true);
KX_Scene* startscene = new KX_Scene(m_keyboard,
m_mouse,
m_networkdevice,
m_audiodevice,
- startscenename);
+ startscenename,
+ m_startScene);
// some python things
PyObject* dictionaryobject = initGamePlayerPythonScripting("Ketsji", psl_Lowest);
m_ketsjiengine->SetPythonDictionary(dictionaryobject);
initRasterizer(m_rasterizer, m_canvas);
- PyObject *gameLogic = initGameLogic(startscene);
+ PyObject *gameLogic = initGameLogic(m_ketsjiengine, startscene);
+ PyDict_SetItemString(dictionaryobject, "GameLogic", gameLogic); // Same as importing the module
initGameKeys();
initPythonConstraintBinding();
+ initMathutils();
+ initVideoTexture();
-
-
-
-
+ // Set the GameLogic.globalDict from marshal'd data, so we can
+ // load new blend files and keep data in GameLogic.globalDict
+ loadGamePythonConfig(m_pyGlobalDictString, m_pyGlobalDictString_Length);
+
m_sceneconverter->ConvertScene(
startscenename,
startscene,
@@ -682,6 +709,11 @@ bool GPG_Application::startEngine(void)
m_ketsjiengine->StartEngine(true);
m_engineRunning = true;
+ // Set the animation playback rate for ipo's and actions
+ // the framerate below should patch with FPS macro defined in blendef.h
+ // Could be in StartEngine set the framerate, we need the scene to do this
+ m_ketsjiengine->SetAnimFrameRate( (((double) G.scene->r.frs_sec) / G.scene->r.frs_sec_base) );
+
}
if (!m_engineRunning)
@@ -695,6 +727,16 @@ bool GPG_Application::startEngine(void)
void GPG_Application::stopEngine()
{
+ // GameLogic.globalDict gets converted into a buffer, and sorted in
+ // m_pyGlobalDictString so we can restore after python has stopped
+ // and started between .blend file loads.
+ if(m_pyGlobalDictString) {
+ delete [] m_pyGlobalDictString;
+ m_pyGlobalDictString = 0;
+ }
+
+ m_pyGlobalDictString_Length = saveGamePythonConfig(&m_pyGlobalDictString);
+
// when exiting the mainloop
exitGamePythonScripting();
m_ketsjiengine->StopEngine();
@@ -761,6 +803,12 @@ void GPG_Application::exitEngine()
m_canvas = 0;
}
+ libtiff_exit();
+#ifdef WITH_QUICKTIME
+ quicktime_exit();
+#endif
+ GPU_extensions_exit();
+
m_exitRequested = 0;
m_engineInitialized = false;
}
@@ -838,11 +886,12 @@ bool GPG_Application::handleKey(GHOST_IEvent* event, bool isDown)
{
GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData();
GHOST_TEventKeyData* keyData = static_cast<GHOST_TEventKeyData*>(eventData);
- if (fSystem->getFullScreen()) {
- if (keyData->key == GHOST_kKeyEsc) {
+ //no need for this test
+ //if (fSystem->getFullScreen()) {
+ if (keyData->key == GHOST_kKeyEsc && !m_keyboard->m_hookesc && !m_isEmbedded) {
m_exitRequested = KX_EXIT_REQUEST_OUTSIDE;
}
- }
+ //}
m_keyboard->ConvertEvent(keyData->key, isDown);
handled = true;
}
diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h
index 024ca1dbf32..38408f919b4 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_Application.h
+++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h
@@ -50,17 +50,19 @@ class GPG_Canvas;
class GPG_KeyboardDevice;
class GPG_System;
struct Main;
+struct Scene;
class GPG_Application : public GHOST_IEventConsumer
{
public:
- GPG_Application(GHOST_ISystem* system, struct Main* maggie, STR_String startSceneName);
+ GPG_Application(GHOST_ISystem* system);
~GPG_Application(void);
- bool SetGameEngineData(struct Main* maggie,STR_String startSceneName);
+ bool SetGameEngineData(struct Main* maggie, struct Scene* scene);
bool startWindow(STR_String& title, int windowLeft, int windowTop, int windowWidth, int windowHeight,
const bool stereoVisual, const int stereoMode);
bool startFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode);
+ bool startEmbeddedWindow(STR_String& title, const GHOST_TEmbedderWindowID parent_window, const bool stereoVisual, const int stereoMode);
#ifdef WIN32
bool startScreenSaverFullScreen(int width, int height, int bpp, int frequency, const bool stereoVisual, const int stereoMode);
bool startScreenSaverPreview(HWND parentWindow, const bool stereoVisual, const int stereoMode);
@@ -100,6 +102,7 @@ protected:
/* The game data */
STR_String m_startSceneName;
+ struct Scene* m_startScene;
struct Main* m_maggie;
/* Exit state. */
@@ -118,6 +121,8 @@ protected:
bool m_engineInitialized;
/** Engine state. */
bool m_engineRunning;
+ /** Running on embedded window */
+ bool m_isEmbedded;
/** the gameengine itself */
KX_KetsjiEngine* m_ketsjiengine;
@@ -141,6 +146,13 @@ protected:
SND_IAudioDevice* m_audiodevice;
bool m_blendermat;
-
+ bool m_blenderglslmat;
+
+ /*
+ * GameLogic.globalDict as a string so that loading new blend files can use the same dict.
+ * Do this because python starts/stops when loading blend files.
+ */
+ char* m_pyGlobalDictString;
+ int m_pyGlobalDictString_Length;
};
diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
index 5226ca02662..0bf0317d8f2 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp
@@ -44,6 +44,7 @@
#endif // __APPLE__
#include "GEN_messaging.h"
#include "KX_KetsjiEngine.h"
+#include "KX_PythonInit.h"
/**********************************
* Begin Blender include block
@@ -52,25 +53,31 @@
extern "C"
{
#endif // __cplusplus
+#include "MEM_guardedalloc.h"
+#include "BKE_blender.h"
#include "BKE_global.h"
#include "BKE_icons.h"
+#include "BKE_node.h"
#include "BLI_blenlib.h"
#include "DNA_scene_types.h"
#include "BLO_readfile.h"
#include "BLO_readblenfile.h"
+#include "IMB_imbuf.h"
int GHOST_HACK_getFirstFile(char buf[]);
#ifdef __cplusplus
}
#endif // __cplusplus
+
+#include "GPU_draw.h"
+
/**********************************
* End Blender include block
**********************************/
#include "SYS_System.h"
#include "GPG_Application.h"
-#include "GPC_PolygonMaterial.h"
#include "GHOST_ISystem.h"
#include "RAS_IRasterizer.h"
@@ -146,9 +153,9 @@ static BOOL scr_saver_init(int argc, char **argv)
#endif /* WIN32 */
-void usage(char* program)
+void usage(const char* program)
{
- char * consoleoption;
+ const char * consoleoption;
#ifdef _WIN32
consoleoption = "-c ";
#else
@@ -176,9 +183,13 @@ void usage(char* program)
printf(" anaglyph (Red-Blue glasses)\n");
printf(" vinterlace (Vertical interlace for autostereo display)\n");
printf(" depending on the type of stereo you want\n");
+#ifndef _WIN32
+ printf(" -i: parent windows ID \n");
+#endif
#ifdef _WIN32
printf(" -c: keep console window open\n");
#endif
+ printf(" -d: turn debugging on\n");
printf(" -g: game engine options:\n");
printf(" Name Default Description\n");
printf(" ----------------------------------------\n");
@@ -187,14 +198,14 @@ void usage(char* program)
printf(" show_framerate 0 Show the frame rate\n");
printf(" show_properties 0 Show debug properties\n");
printf(" show_profile 0 Show profiling information\n");
- printf(" vertexarrays 1 Enable vertex arrays\n");
printf(" blender_material 0 Enable material settings\n");
printf("\n");
printf("example: %s -p 10 10 320 200 -g noaudio c:\\loadtest.blend\n", program);
- printf("example: %s -g vertexarrays = 0 c:\\loadtest.blend\n", program);
+ printf("example: %s -g show_framerate = 0 c:\\loadtest.blend\n", program);
}
-char *get_filename(int argc, char **argv) {
+static void get_filename(int argc, char **argv, char *filename)
+{
#ifdef __APPLE__
/* On Mac we park the game file (called game.blend) in the application bundle.
* The executable is located in the bundle as well.
@@ -202,22 +213,18 @@ char *get_filename(int argc, char **argv) {
*/
int srclen = ::strlen(argv[0]);
int len = 0;
- char *filename = NULL;
+ char *gamefile = NULL;
+ filename[0] = '\0';
+
if (argc > 1) {
if (BLI_exists(argv[argc-1])) {
- len = ::strlen(argv[argc-1]);
- filename = new char [len + 1];
- ::strcpy(filename, argv[argc-1]);
- return(filename);
+ BLI_strncpy(filename, argv[argc-1], FILE_MAXDIR + FILE_MAXFILE);
}
if (::strncmp(argv[argc-1], "-psn_", 5)==0) {
static char firstfilebuf[512];
if (GHOST_HACK_getFirstFile(firstfilebuf)) {
- len = ::strlen(firstfilebuf);
- filename = new char [len + 1];
- ::strcpy(filename, firstfilebuf);
- return(filename);
+ BLI_strncpy(filename, firstfilebuf, FILE_MAXDIR + FILE_MAXFILE);
}
}
}
@@ -225,23 +232,26 @@ char *get_filename(int argc, char **argv) {
srclen -= ::strlen("MacOS/blenderplayer");
if (srclen > 0) {
len = srclen + ::strlen("Resources/game.blend");
- filename = new char [len + 1];
- ::strcpy(filename, argv[0]);
- ::strcpy(filename + srclen, "Resources/game.blend");
+ gamefile = new char [len + 1];
+ ::strcpy(gamefile, argv[0]);
+ ::strcpy(gamefile + srclen, "Resources/game.blend");
//::printf("looking for file: %s\n", filename);
- if (BLI_exists(filename)) {
- return (filename);
- }
+ if (BLI_exists(gamefile))
+ BLI_strncpy(filename, gamefile, FILE_MAXDIR + FILE_MAXFILE);
+
+ delete gamefile;
}
- return(NULL);
#else
- return (argc>1)?argv[argc-1]:NULL;
+ filename[0] = '\0';
+
+ if(argc > 1)
+ BLI_strncpy(filename, argv[argc-1], FILE_MAXDIR + FILE_MAXFILE);
#endif // !_APPLE
}
-static BlendFileData *load_game_data(char *progname, char *filename = NULL) {
+static BlendFileData *load_game_data(char *progname, char *filename = NULL, char *relativename = NULL) {
BlendReadError error;
BlendFileData *bfd = NULL;
@@ -283,7 +293,7 @@ int main(int argc, char** argv)
bool fullScreenParFound = false;
bool windowParFound = false;
bool closeConsole = true;
- RAS_IRasterizer::StereoMode stereomode;
+ RAS_IRasterizer::StereoMode stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
bool stereoWindow = false;
bool stereoParFound = false;
int windowLeft = 100;
@@ -294,14 +304,16 @@ int main(int argc, char** argv)
GHOST_TUns32 fullScreenHeight= 0;
int fullScreenBpp = 32;
int fullScreenFrequency = 60;
+ GHOST_TEmbedderWindowID parentWindow = 0;
+
+
#ifdef __linux__
#ifdef __alpha__
signal (SIGFPE, SIG_IGN);
#endif /* __alpha__ */
#endif /* __linux__ */
BLI_where_am_i(bprogname, argv[0]);
-
#ifdef __APPLE__
// Can't use Carbon right now because of double defined type ID (In Carbon.h and DNA_ID.h, sigh)
/*
@@ -323,8 +335,18 @@ int main(int argc, char** argv)
::DisposeNibReference(nibRef);
*/
#endif // __APPLE__
+
+ init_nodesystem();
+ initglobals();
+
GEN_init_messaging_system();
+
+#ifdef WITH_QUICKTIME
+ quicktime_init();
+#endif
+
+ libtiff_init();
// Parse command line options
#ifndef NDEBUG
@@ -403,6 +425,12 @@ int main(int argc, char** argv)
}
}
break;
+
+ case 'd':
+ i++;
+ G.f |= G_DEBUG; /* std output printf's */
+ MEM_set_memory_debug();
+ break;
case 'p':
// Parse window position and size options
@@ -455,6 +483,16 @@ int main(int argc, char** argv)
usage(argv[0]);
return 0;
break;
+#ifndef _WIN32
+ case 'i':
+ i++;
+ if ( (i + 1) < argc )
+ parentWindow = atoi(argv[i++]);
+#ifndef NDEBUG
+ printf("XWindows ID = %d\n", parentWindow);
+#endif //NDEBUG
+
+#endif // _WIN32
case 'c':
i++;
closeConsole = false;
@@ -525,21 +563,19 @@ int main(int argc, char** argv)
return 0;
}
- if (!stereoParFound) stereomode = RAS_IRasterizer::RAS_STEREO_NOSTEREO;
-
#ifdef WIN32
if (scr_saver_mode != SCREEN_SAVER_MODE_CONFIGURATION)
#endif
{
#ifdef __APPLE__
//SYS_WriteCommandLineInt(syshandle, "show_framerate", 1);
- SYS_WriteCommandLineInt(syshandle, "nomipmap", 1);
+ //SYS_WriteCommandLineInt(syshandle, "nomipmap", 1);
//fullScreen = false; // Can't use full screen
#endif
if (SYS_GetCommandLineInt(syshandle, "nomipmap", 0))
{
- GPC_PolygonMaterial::SetMipMappingEnabled(0);
+ GPU_set_mipmap(0);
}
// Create the system
@@ -561,32 +597,46 @@ int main(int argc, char** argv)
{
int exitcode = KX_EXIT_REQUEST_NO_REQUEST;
STR_String exitstring = "";
- GPG_Application app(system, NULL, exitstring);
+ GPG_Application app(system);
bool firstTimeRunning = true;
+ char filename[FILE_MAXDIR + FILE_MAXFILE];
+ char pathname[FILE_MAXDIR + FILE_MAXFILE];
+ char *titlename;
+
+ get_filename(argc, argv, filename);
+ if(filename[0])
+ BLI_convertstringcwd(filename);
do
{
// Read the Blender file
- char *filename = get_filename(argc, argv);
- char *titlename;
- char pathname[160];
BlendFileData *bfd;
// if we got an exitcode 3 (KX_EXIT_REQUEST_START_OTHER_GAME) load a different file
if (exitcode == KX_EXIT_REQUEST_START_OTHER_GAME)
{
- char basedpath[160];
+ char basedpath[240];
- // base the actuator filename with respect
- // to the original file working directory
+ // base the actuator filename relative to the last file
strcpy(basedpath, exitstring.Ptr());
- BLI_convertstringcode(basedpath, pathname, 0);
+ BLI_convertstringcode(basedpath, pathname);
bfd = load_game_data(basedpath);
+
+ if (!bfd)
+ {
+ // just add "//" in front of it
+ char temppath[242];
+ strcpy(temppath, "//");
+ strcat(temppath, basedpath);
+
+ BLI_convertstringcode(temppath, pathname);
+ bfd = load_game_data(temppath);
+ }
}
else
{
- bfd = load_game_data(argv[0], filename);
+ bfd = load_game_data(bprogname, filename[0]? filename: NULL);
}
//::printf("game data loaded from %s\n", filename);
@@ -608,9 +658,10 @@ int main(int argc, char** argv)
#endif // WIN32
Main *maggie = bfd->main;
Scene *scene = bfd->curscene;
- strcpy (pathname, maggie->name);
- char *startscenename = scene->id.name + 2;
- G.fileflags = bfd->fileflags;
+ G.main = maggie;
+
+ if (firstTimeRunning)
+ G.fileflags = bfd->fileflags;
//Seg Fault; icon.c gIcons == 0
BKE_icons_init(1);
@@ -647,12 +698,16 @@ int main(int argc, char** argv)
}
// GPG_Application app (system, maggie, startscenename);
- app.SetGameEngineData(maggie, startscenename);
+ app.SetGameEngineData(maggie, scene);
+ BLI_strncpy(pathname, maggie->name, sizeof(pathname));
+ BLI_strncpy(G.sce, maggie->name, sizeof(G.sce));
+
if (firstTimeRunning)
{
+ setGamePythonPath(G.sce);
firstTimeRunning = false;
-
+
if (fullScreen)
{
#ifdef WIN32
@@ -710,7 +765,10 @@ int main(int argc, char** argv)
else
#endif
{
- app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight,
+ if (parentWindow != 0)
+ app.startEmbeddedWindow(title, parentWindow, stereoWindow, stereomode);
+ else
+ app.startWindow(title, windowLeft, windowTop, windowWidth, windowHeight,
stereoWindow, stereomode);
}
}
@@ -737,13 +795,8 @@ int main(int argc, char** argv)
}
}
app.StopGameEngine();
+
BLO_blendfiledata_free(bfd);
-
-#ifdef __APPLE__
- if (filename) {
- delete [] filename;
- }
-#endif // __APPLE__
}
} while (exitcode == KX_EXIT_REQUEST_RESTART_GAME || exitcode == KX_EXIT_REQUEST_START_OTHER_GAME);
}
@@ -759,6 +812,8 @@ int main(int argc, char** argv)
}
}
+ free_nodesystem();
+
return error ? -1 : 0;
}
diff --git a/source/gameengine/GamePlayer/ghost/Makefile b/source/gameengine/GamePlayer/ghost/Makefile
index fd070c006f5..52e219db8f2 100644
--- a/source/gameengine/GamePlayer/ghost/Makefile
+++ b/source/gameengine/GamePlayer/ghost/Makefile
@@ -36,10 +36,12 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
# OpenGL header files
+CPPFLAGS += -I$(NAN_GLEW)/include
CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_BMFONT)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
+CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
CPPFLAGS += -I../../GamePlayer/common
@@ -68,6 +70,9 @@ CPPFLAGS += -I../../../blender/blenloader
CPPFLAGS += -I../../../blender/imbuf
CPPFLAGS += -I../../../blender/makesdna
CPPFLAGS += -I../../../blender/readblenfile
+CPPFLAGS += -I../../../blender/gpu
+
+CPPFLAGS += -I../../../gameengine/BlenderRoutines
# kernel? GEN? stuff
CPPFLAGS += -I../../../kernel/gen_system
@@ -77,4 +82,3 @@ CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_GHOST)/include
CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
-
diff --git a/source/gameengine/GamePlayer/ghost/SConscript b/source/gameengine/GamePlayer/ghost/SConscript
index f704f02c513..a7ee2d51d14 100644
--- a/source/gameengine/GamePlayer/ghost/SConscript
+++ b/source/gameengine/GamePlayer/ghost/SConscript
@@ -3,47 +3,51 @@ import sys
Import ('env')
source_files = ['GPG_Application.cpp',
- 'GPG_Canvas.cpp',
- 'GPG_ghost.cpp',
- 'GPG_KeyboardDevice.cpp',
- 'GPG_System.cpp']
+ 'GPG_Canvas.cpp',
+ 'GPG_ghost.cpp',
+ 'GPG_KeyboardDevice.cpp',
+ 'GPG_System.cpp']
incs = ['.',
- '#intern/string',
- '#intern/ghost',
- '#intern/guardedalloc',
- '#intern/bmfont',
- '#intern/moto/include',
- '#intern/SoundSystem',
- '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer',
- '#source/kernel/gen_system',
- '#source/kernel/gen_messaging',
- '#source/gameengine/Converter',
- '#source/blender/imbuf',
- '#source/gameengine/Ketsji',
- '#source/blender/blenlib',
- '#source/blender/blenkernel',
- '#source/blender/readblenfile',
- '#source/blender',
- '#source/blender/editors/include',
- '#source/blender/makesdna',
- '#source/gameengine/Rasterizer',
- '#source/gameengine/GameLogic',
- '#source/gameengine/Expressions',
- '#source/gameengine/Network',
- '#source/gameengine/SceneGraph',
- '#source/gameengine/Physics/common',
- '#source/gameengine/Physics/Sumo',
- '#source/gameengine/Physics/Sumo/Fuzzics/include',
- '#source/gameengine/Network/LoopBackNetwork',
- '#source/gameengine/GamePlayer/common',
- '#source/blender/misc',
- '#source/blender/blenloader']
+ '#intern/string',
+ '#intern/ghost',
+ '#intern/guardedalloc',
+ '#intern/bmfont',
+ '#intern/moto/include',
+ '#intern/SoundSystem',
+ '#source/gameengine/Rasterizer/RAS_OpenGLRasterizer',
+ '#source/kernel/gen_system',
+ '#source/kernel/gen_messaging',
+ '#source/gameengine/Converter',
+ '#source/blender/imbuf',
+ '#source/gameengine/Ketsji',
+ '#source/blender/blenlib',
+ '#source/blender/blenkernel',
+ '#source/blender/readblenfile',
+ '#source/blender',
+ '#source/blender/include',
+ '#source/blender/makesdna',
+ '#source/gameengine/BlenderRoutines',
+ '#source/gameengine/Rasterizer',
+ '#source/gameengine/GameLogic',
+ '#source/gameengine/Expressions',
+ '#source/gameengine/Network',
+ '#source/gameengine/SceneGraph',
+ '#source/gameengine/Physics/common',
+ '#source/gameengine/Physics/Sumo',
+ '#source/gameengine/Physics/Sumo/Fuzzics/include',
+ '#source/gameengine/Network/LoopBackNetwork',
+ '#source/gameengine/GamePlayer/common',
+ '#source/blender/misc',
+ '#source/blender/blenloader',
+ '#source/blender/gpu',
+ '#extern/glew/include']
incs += Split(env['BF_PYTHON_INC'])
incs += Split(env['BF_SOLID_INC'])
cflags = []
if env['OURPLATFORM']=='win32-vc':
- cflags = ['/GR']
+ cflags = ['/GR']
+
env.BlenderLib (libname='gp_ghost', sources=source_files, includes = incs, defines = [], libtype='player',priority=5, compileflags=cflags)
diff --git a/source/gameengine/Ketsji/BL_BlenderShader.cpp b/source/gameengine/Ketsji/BL_BlenderShader.cpp
new file mode 100644
index 00000000000..8ec463be6ff
--- /dev/null
+++ b/source/gameengine/Ketsji/BL_BlenderShader.cpp
@@ -0,0 +1,170 @@
+
+#include "DNA_customdata_types.h"
+#include "DNA_material_types.h"
+#include "DNA_scene_types.h"
+
+#include "BKE_global.h"
+#include "BKE_main.h"
+
+#include "BL_BlenderShader.h"
+#include "BL_Material.h"
+
+#include "GPU_extensions.h"
+#include "GPU_material.h"
+
+#include "RAS_BucketManager.h"
+#include "RAS_MeshObject.h"
+#include "RAS_IRasterizer.h"
+
+BL_BlenderShader::BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lightlayer)
+:
+ mScene(scene),
+ mMat(ma),
+ mLightLayer(lightlayer)
+{
+ mBlenderScene = scene->GetBlenderScene();
+ mBlendMode = GPU_BLEND_SOLID;
+
+ if(mMat)
+ GPU_material_from_blender(mBlenderScene, mMat);
+}
+
+BL_BlenderShader::~BL_BlenderShader()
+{
+ if(mMat && GPU_material_from_blender(mBlenderScene, mMat))
+ GPU_material_unbind(GPU_material_from_blender(mBlenderScene, mMat));
+}
+
+bool BL_BlenderShader::Ok()
+{
+ return VerifyShader();
+}
+
+bool BL_BlenderShader::VerifyShader()
+{
+ if(mMat)
+ return (GPU_material_from_blender(mBlenderScene, mMat) != 0);
+ else
+ return false;
+}
+
+void BL_BlenderShader::SetProg(bool enable, double time)
+{
+ if(VerifyShader()) {
+ if(enable)
+ GPU_material_bind(GPU_material_from_blender(mBlenderScene, mMat), mLightLayer, ~0, time);
+ else
+ GPU_material_unbind(GPU_material_from_blender(mBlenderScene, mMat));
+ }
+}
+
+int BL_BlenderShader::GetAttribNum()
+{
+ GPUVertexAttribs attribs;
+ int i, enabled = 0;
+
+ if(!VerifyShader())
+ return enabled;
+
+ GPU_material_vertex_attributes(GPU_material_from_blender(mBlenderScene, mMat), &attribs);
+
+ for(i = 0; i < attribs.totlayer; i++)
+ if(attribs.layer[i].glindex+1 > enabled)
+ enabled= attribs.layer[i].glindex+1;
+
+ if(enabled > BL_MAX_ATTRIB)
+ enabled = BL_MAX_ATTRIB;
+
+ return enabled;
+}
+
+void BL_BlenderShader::SetAttribs(RAS_IRasterizer* ras, const BL_Material *mat)
+{
+ GPUVertexAttribs attribs;
+ GPUMaterial *gpumat;
+ int i, attrib_num;
+
+ ras->SetAttribNum(0);
+
+ if(!VerifyShader())
+ return;
+
+ gpumat = GPU_material_from_blender(mBlenderScene, mMat);
+
+ if(ras->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) {
+ GPU_material_vertex_attributes(gpumat, &attribs);
+ attrib_num = GetAttribNum();
+
+ ras->SetTexCoordNum(0);
+ ras->SetAttribNum(attrib_num);
+ for(i=0; i<attrib_num; i++)
+ ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_DISABLE, i);
+
+ for(i = 0; i < attribs.totlayer; i++) {
+ if(attribs.layer[i].glindex > attrib_num)
+ continue;
+
+ if(attribs.layer[i].type == CD_MTFACE) {
+ if(!mat->uvName.IsEmpty() && strcmp(mat->uvName.ReadPtr(), attribs.layer[i].name) == 0)
+ ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV1, attribs.layer[i].glindex);
+ else if(!mat->uv2Name.IsEmpty() && strcmp(mat->uv2Name.ReadPtr(), attribs.layer[i].name) == 0)
+ ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV2, attribs.layer[i].glindex);
+ else
+ ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_UV1, attribs.layer[i].glindex);
+ }
+ else if(attribs.layer[i].type == CD_TANGENT)
+ ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT, attribs.layer[i].glindex);
+ else if(attribs.layer[i].type == CD_ORCO)
+ ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_ORCO, attribs.layer[i].glindex);
+ else if(attribs.layer[i].type == CD_NORMAL)
+ ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_NORM, attribs.layer[i].glindex);
+ else if(attribs.layer[i].type == CD_MCOL)
+ ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_VCOL, attribs.layer[i].glindex);
+ else
+ ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_DISABLE, attribs.layer[i].glindex);
+ }
+ }
+}
+
+void BL_BlenderShader::Update(const RAS_MeshSlot & ms, RAS_IRasterizer* rasty )
+{
+ float obmat[4][4], viewmat[4][4], viewinvmat[4][4], obcol[4];
+ GPUMaterial *gpumat;
+
+ gpumat = GPU_material_from_blender(mBlenderScene, mMat);
+
+ if(!gpumat || !GPU_material_bound(gpumat))
+ return;
+
+ MT_Matrix4x4 model;
+ model.setValue(ms.m_OpenGLMatrix);
+ const MT_Matrix4x4& view = rasty->GetViewMatrix();
+ const MT_Matrix4x4& viewinv = rasty->GetViewInvMatrix();
+
+ // note: getValue gives back column major as needed by OpenGL
+ model.getValue((float*)obmat);
+ view.getValue((float*)viewmat);
+ viewinv.getValue((float*)viewinvmat);
+
+ if(ms.m_bObjectColor)
+ ms.m_RGBAcolor.getValue((float*)obcol);
+ else
+ obcol[0]= obcol[1]= obcol[2]= obcol[3]= 1.0f;
+
+ GPU_material_bind_uniforms(gpumat, obmat, viewmat, viewinvmat, obcol);
+
+ mBlendMode = GPU_material_blend_mode(gpumat, obcol);
+}
+
+int BL_BlenderShader::GetBlendMode()
+{
+ return mBlendMode;
+}
+
+bool BL_BlenderShader::Equals(BL_BlenderShader *blshader)
+{
+ /* to avoid unneeded state switches */
+ return (blshader && mMat == blshader->mMat && mLightLayer == blshader->mLightLayer);
+}
+
+// eof
diff --git a/source/gameengine/Ketsji/BL_BlenderShader.h b/source/gameengine/Ketsji/BL_BlenderShader.h
new file mode 100644
index 00000000000..5c1f59f94ad
--- /dev/null
+++ b/source/gameengine/Ketsji/BL_BlenderShader.h
@@ -0,0 +1,53 @@
+
+#ifndef __BL_GPUSHADER_H__
+#define __BL_GPUSHADER_H__
+
+#include "GPU_material.h"
+
+#include "MT_Matrix4x4.h"
+#include "MT_Matrix3x3.h"
+#include "MT_Tuple2.h"
+#include "MT_Tuple3.h"
+#include "MT_Tuple4.h"
+
+#include "RAS_IPolygonMaterial.h"
+
+#include "KX_Scene.h"
+
+struct Material;
+struct Scene;
+class BL_Material;
+
+#define BL_MAX_ATTRIB 16
+
+/**
+ * BL_BlenderShader
+ * Blender GPU shader material
+ */
+class BL_BlenderShader
+{
+private:
+ KX_Scene *mScene;
+ struct Scene *mBlenderScene;
+ struct Material *mMat;
+ int mLightLayer;
+ int mBlendMode;
+
+ bool VerifyShader();
+
+public:
+ BL_BlenderShader(KX_Scene *scene, struct Material *ma, int lightlayer);
+ virtual ~BL_BlenderShader();
+
+ bool Ok();
+ void SetProg(bool enable, double time=0.0);
+
+ int GetAttribNum();
+ void SetAttribs(class RAS_IRasterizer* ras, const BL_Material *mat);
+ void Update(const class RAS_MeshSlot & ms, class RAS_IRasterizer* rasty);
+ int GetBlendMode();
+
+ bool Equals(BL_BlenderShader *blshader);
+};
+
+#endif//__BL_GPUSHADER_H__
diff --git a/source/gameengine/Ketsji/BL_Material.cpp b/source/gameengine/Ketsji/BL_Material.cpp
index 7ed2da590a9..7e3d6984f19 100644
--- a/source/gameengine/Ketsji/BL_Material.cpp
+++ b/source/gameengine/Ketsji/BL_Material.cpp
@@ -34,6 +34,7 @@ BL_Material::BL_Material()
rgb[3] = 0;
IdMode = 0;
ras_mode = 0;
+ glslmat = 0;
tile = 0;
matname = "NoMaterial";
matcolor[0] = 0.5f;
@@ -104,7 +105,8 @@ void BL_Material::GetConversionRGB(unsigned int *nrgb) {
*nrgb = rgb[3];
}
-void BL_Material::SetConversionUV(MT_Point2 *nuv) {
+void BL_Material::SetConversionUV(const STR_String& name, MT_Point2 *nuv) {
+ uvName = name;
uv[0] = *nuv++;
uv[1] = *nuv++;
uv[2] = *nuv++;
@@ -117,7 +119,8 @@ void BL_Material::GetConversionUV(MT_Point2 *nuv){
*nuv++ = uv[2];
*nuv = uv[3];
}
-void BL_Material::SetConversionUV2(MT_Point2 *nuv) {
+void BL_Material::SetConversionUV2(const STR_String& name, MT_Point2 *nuv) {
+ uv2Name = name;
uv2[0] = *nuv++;
uv2[1] = *nuv++;
uv2[2] = *nuv++;
diff --git a/source/gameengine/Ketsji/BL_Material.h b/source/gameengine/Ketsji/BL_Material.h
index 8be91316237..0eaa234566c 100644
--- a/source/gameengine/Ketsji/BL_Material.h
+++ b/source/gameengine/Ketsji/BL_Material.h
@@ -18,9 +18,9 @@ struct EnvMap;
this will default to users available units
to build with more available, just increment this value
although the more you add the slower the search time will be.
- we will go for three, which should be enough
+ we will go for eight, which should be enough
*/
-#define MAXTEX 3//match in RAS_TexVert & RAS_OpenGLRasterizer
+#define MAXTEX 8 //match in RAS_TexVert & RAS_OpenGLRasterizer
// different mapping modes
class BL_Mapping
@@ -47,6 +47,7 @@ public:
int IdMode;
unsigned int ras_mode;
+ bool glslmat;
STR_String texname[MAXTEX];
unsigned int flag[MAXTEX];
@@ -82,13 +83,16 @@ public:
MT_Point2 uv[4];
MT_Point2 uv2[4];
+ STR_String uvName;
+ STR_String uv2Name;
+
void SetConversionRGB(unsigned int *rgb);
void GetConversionRGB(unsigned int *rgb);
- void SetConversionUV(MT_Point2 *uv);
+ void SetConversionUV(const STR_String& name, MT_Point2 *uv);
void GetConversionUV(MT_Point2 *uv);
- void SetConversionUV2(MT_Point2 *uv);
+ void SetConversionUV2(const STR_String& name, MT_Point2 *uv);
void GetConversionUV2(MT_Point2 *uv);
void SetSharedMaterial(bool v);
@@ -125,8 +129,7 @@ enum BL_flag
TEXALPHA=8, // use alpha combiner functions
TEXNEG=16, // negate blending
HASIPO=32,
- USENEGALPHA=64,
- ALPHA_TEST=128
+ USENEGALPHA=64
};
// BL_Material::ras_mode
@@ -135,8 +138,8 @@ enum BL_ras_mode
POLY_VIS=1,
COLLIDER=2,
ZSORT=4,
- TRANSP=8,
- TRIANGLE=16,
+ ALPHA=8,
+ // TRIANGLE=16,
USE_LIGHT=32,
WIRE=64
};
diff --git a/source/gameengine/Ketsji/BL_Shader.cpp b/source/gameengine/Ketsji/BL_Shader.cpp
index 3b74b74727a..80892764089 100644
--- a/source/gameengine/Ketsji/BL_Shader.cpp
+++ b/source/gameengine/Ketsji/BL_Shader.cpp
@@ -1,20 +1,5 @@
-
-#ifdef WIN32
-#include <windows.h>
-#endif // WIN32
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#include <OpenGL/glu.h>
-#else
-#include <GL/gl.h>
-#if defined(__sun__) && !defined(__sparc__)
-#include <mesa/glu.h>
-#else
-#include <GL/glu.h>
-#endif
-#endif
+#include "GL/glew.h"
#include <iostream>
#include "BL_Shader.h"
@@ -30,7 +15,6 @@
#include "RAS_MeshObject.h"
#include "RAS_IRasterizer.h"
-//using namespace bgl;
#define spit(x) std::cout << x << std::endl;
#define SORT_UNIFORMS 1
@@ -45,7 +29,7 @@ BL_Uniform::BL_Uniform(int data_size)
mDataLen(data_size)
{
#ifdef SORT_UNIFORMS
- MT_assert(mDataLen <= UNIFORM_MAX_LEN);
+ MT_assert((int)mDataLen <= UNIFORM_MAX_LEN);
mData = (void*)MEM_mallocN(mDataLen, "shader-uniform-alloc");
#endif
}
@@ -62,7 +46,6 @@ BL_Uniform::~BL_Uniform()
void BL_Uniform::Apply(class BL_Shader *shader)
{
-#ifdef GL_ARB_shader_objects
#ifdef SORT_UNIFORMS
MT_assert(mType > UNI_NONE && mType < UNI_MAX && mData);
@@ -73,48 +56,47 @@ void BL_Uniform::Apply(class BL_Shader *shader)
{
case UNI_FLOAT: {
float *f = (float*)mData;
- bgl::blUniform1fARB(mLoc,(GLfloat)*f);
+ glUniform1fARB(mLoc,(GLfloat)*f);
}break;
case UNI_INT: {
int *f = (int*)mData;
- bgl::blUniform1iARB(mLoc, (GLint)*f);
+ glUniform1iARB(mLoc, (GLint)*f);
}break;
case UNI_FLOAT2: {
float *f = (float*)mData;
- bgl::blUniform2fvARB(mLoc,1, (GLfloat*)f);
+ glUniform2fvARB(mLoc,1, (GLfloat*)f);
}break;
case UNI_FLOAT3: {
float *f = (float*)mData;
- bgl::blUniform3fvARB(mLoc,1,(GLfloat*)f);
+ glUniform3fvARB(mLoc,1,(GLfloat*)f);
}break;
case UNI_FLOAT4: {
float *f = (float*)mData;
- bgl::blUniform4fvARB(mLoc,1,(GLfloat*)f);
+ glUniform4fvARB(mLoc,1,(GLfloat*)f);
}break;
case UNI_INT2: {
int *f = (int*)mData;
- bgl::blUniform2ivARB(mLoc,1,(GLint*)f);
+ glUniform2ivARB(mLoc,1,(GLint*)f);
}break;
case UNI_INT3: {
int *f = (int*)mData;
- bgl::blUniform3ivARB(mLoc,1,(GLint*)f);
+ glUniform3ivARB(mLoc,1,(GLint*)f);
}break;
case UNI_INT4: {
int *f = (int*)mData;
- bgl::blUniform4ivARB(mLoc,1,(GLint*)f);
+ glUniform4ivARB(mLoc,1,(GLint*)f);
}break;
case UNI_MAT4: {
float *f = (float*)mData;
- bgl::blUniformMatrix4fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f);
+ glUniformMatrix4fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f);
}break;
case UNI_MAT3: {
float *f = (float*)mData;
- bgl::blUniformMatrix3fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f);
+ glUniformMatrix3fvARB(mLoc, 1, mTranspose?GL_TRUE:GL_FALSE,(GLfloat*)f);
}break;
}
mDirty = false;
#endif
-#endif
}
void BL_Uniform::SetData(int location, int type,bool transpose)
@@ -143,17 +125,14 @@ BL_Shader::BL_Shader(PyTypeObject *T)
mError(0),
mDirty(true)
{
- // if !RAS_EXT_support._ARB_shader_objects this class will not be used
+ // if !GLEW_ARB_shader_objects this class will not be used
//for (int i=0; i<MAXTEX; i++) {
// mSampler[i] = BL_Sampler();
//}
}
-using namespace bgl;
-
BL_Shader::~BL_Shader()
{
-#ifdef GL_ARB_shader_objects
//for (int i=0; i<MAXTEX; i++){
// if(mSampler[i].mOwn) {
// if(mSampler[i].mTexture)
@@ -163,14 +142,13 @@ BL_Shader::~BL_Shader()
ClearUniforms();
if( mShader ) {
- bgl::blDeleteObjectARB(mShader);
+ glDeleteObjectARB(mShader);
mShader = 0;
}
vertProg = 0;
fragProg = 0;
mOk = 0;
- bgl::blUseProgramObjectARB(0);
-#endif//GL_ARB_shader_objects
+ glUseProgramObjectARB(0);
}
void BL_Shader::ClearUniforms()
@@ -265,8 +243,6 @@ void BL_Shader::UnloadShader()
bool BL_Shader::LinkProgram()
{
-#ifdef GL_ARB_shader_objects
-
int vertlen = 0, fraglen=0, proglen=0;
int vertstatus=0, fragstatus=0, progstatus=0;
unsigned int tmpVert=0, tmpFrag=0, tmpProg=0;
@@ -280,25 +256,25 @@ bool BL_Shader::LinkProgram()
spit("Invalid GLSL sources");
return false;
}
- if( !RAS_EXT_support._ARB_fragment_shader) {
+ if( !GLEW_ARB_fragment_shader) {
spit("Fragment shaders not supported");
return false;
}
- if( !RAS_EXT_support._ARB_vertex_shader) {
+ if( !GLEW_ARB_vertex_shader) {
spit("Vertex shaders not supported");
return false;
}
// -- vertex shader ------------------
- tmpVert = bgl::blCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
- bgl::blShaderSourceARB(tmpVert, 1, (const char**)&vertProg, 0);
- bgl::blCompileShaderARB(tmpVert);
- bgl::blGetObjectParameterivARB(tmpVert, GL_OBJECT_INFO_LOG_LENGTH_ARB,(GLint*) &vertlen);
+ tmpVert = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
+ glShaderSourceARB(tmpVert, 1, (const char**)&vertProg, 0);
+ glCompileShaderARB(tmpVert);
+ glGetObjectParameterivARB(tmpVert, GL_OBJECT_INFO_LOG_LENGTH_ARB,(GLint*) &vertlen);
// print info if any
if( vertlen > 0 && vertlen < MAX_LOG_LEN){
logInf = (char*)MEM_mallocN(vertlen, "vert-log");
- bgl::blGetInfoLogARB(tmpVert, vertlen, (GLsizei*)&char_len, logInf);
+ glGetInfoLogARB(tmpVert, vertlen, (GLsizei*)&char_len, logInf);
if(char_len >0) {
spit("---- Vertex Shader Error ----");
spit(logInf);
@@ -307,20 +283,20 @@ bool BL_Shader::LinkProgram()
logInf=0;
}
// check for compile errors
- bgl::blGetObjectParameterivARB(tmpVert, GL_OBJECT_COMPILE_STATUS_ARB,(GLint*)&vertstatus);
+ glGetObjectParameterivARB(tmpVert, GL_OBJECT_COMPILE_STATUS_ARB,(GLint*)&vertstatus);
if(!vertstatus) {
spit("---- Vertex shader failed to compile ----");
goto programError;
}
// -- fragment shader ----------------
- tmpFrag = bgl::blCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
- bgl::blShaderSourceARB(tmpFrag, 1,(const char**)&fragProg, 0);
- bgl::blCompileShaderARB(tmpFrag);
- bgl::blGetObjectParameterivARB(tmpFrag, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &fraglen);
+ tmpFrag = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
+ glShaderSourceARB(tmpFrag, 1,(const char**)&fragProg, 0);
+ glCompileShaderARB(tmpFrag);
+ glGetObjectParameterivARB(tmpFrag, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &fraglen);
if(fraglen >0 && fraglen < MAX_LOG_LEN){
logInf = (char*)MEM_mallocN(fraglen, "frag-log");
- bgl::blGetInfoLogARB(tmpFrag, fraglen,(GLsizei*) &char_len, logInf);
+ glGetInfoLogARB(tmpFrag, fraglen,(GLsizei*) &char_len, logInf);
if(char_len >0) {
spit("---- Fragment Shader Error ----");
spit(logInf);
@@ -329,7 +305,7 @@ bool BL_Shader::LinkProgram()
logInf=0;
}
- bgl::blGetObjectParameterivARB(tmpFrag, GL_OBJECT_COMPILE_STATUS_ARB, (GLint*) &fragstatus);
+ glGetObjectParameterivARB(tmpFrag, GL_OBJECT_COMPILE_STATUS_ARB, (GLint*) &fragstatus);
if(!fragstatus){
spit("---- Fragment shader failed to compile ----");
goto programError;
@@ -338,17 +314,17 @@ bool BL_Shader::LinkProgram()
// -- program ------------------------
// set compiled vert/frag shader & link
- tmpProg = bgl::blCreateProgramObjectARB();
- bgl::blAttachObjectARB(tmpProg, tmpVert);
- bgl::blAttachObjectARB(tmpProg, tmpFrag);
- bgl::blLinkProgramARB(tmpProg);
- bgl::blGetObjectParameterivARB(tmpProg, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &proglen);
- bgl::blGetObjectParameterivARB(tmpProg, GL_OBJECT_LINK_STATUS_ARB, (GLint*) &progstatus);
+ tmpProg = glCreateProgramObjectARB();
+ glAttachObjectARB(tmpProg, tmpVert);
+ glAttachObjectARB(tmpProg, tmpFrag);
+ glLinkProgramARB(tmpProg);
+ glGetObjectParameterivARB(tmpProg, GL_OBJECT_INFO_LOG_LENGTH_ARB, (GLint*) &proglen);
+ glGetObjectParameterivARB(tmpProg, GL_OBJECT_LINK_STATUS_ARB, (GLint*) &progstatus);
if(proglen > 0 && proglen < MAX_LOG_LEN) {
logInf = (char*)MEM_mallocN(proglen, "prog-log");
- bgl::blGetInfoLogARB(tmpProg, proglen, (GLsizei*)&char_len, logInf);
+ glGetInfoLogARB(tmpProg, proglen, (GLsizei*)&char_len, logInf);
if(char_len >0) {
spit("---- GLSL Program ----");
spit(logInf);
@@ -364,24 +340,24 @@ bool BL_Shader::LinkProgram()
// set
mShader = tmpProg;
- bgl::blDeleteObjectARB(tmpVert);
- bgl::blDeleteObjectARB(tmpFrag);
+ glDeleteObjectARB(tmpVert);
+ glDeleteObjectARB(tmpFrag);
mOk = 1;
mError = 0;
return true;
programError:
if(tmpVert) {
- bgl::blDeleteObjectARB(tmpVert);
+ glDeleteObjectARB(tmpVert);
tmpVert=0;
}
if(tmpFrag) {
- bgl::blDeleteObjectARB(tmpFrag);
+ glDeleteObjectARB(tmpFrag);
tmpFrag=0;
}
if(tmpProg) {
- bgl::blDeleteObjectARB(tmpProg);
+ glDeleteObjectARB(tmpProg);
tmpProg=0;
}
@@ -389,9 +365,6 @@ programError:
mUse = 0;
mError = 1;
return false;
-#else
- return false;
-#endif//GL_ARB_shader_objects
}
const char *BL_Shader::GetVertPtr()
@@ -427,15 +400,13 @@ unsigned int BL_Shader::GetProg()
void BL_Shader::SetSampler(int loc, int unit)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
- bgl::blUniform1iARB(loc, unit);
+ glUniform1iARB(loc, unit);
}
-#endif
}
//
//void BL_Shader::InitializeSampler(int unit, BL_Texture* texture)
@@ -448,37 +419,33 @@ void BL_Shader::SetSampler(int loc, int unit)
void BL_Shader::SetProg(bool enable)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
if( mShader != 0 && mOk && enable) {
- bgl::blUseProgramObjectARB(mShader);
+ glUseProgramObjectARB(mShader);
}
else {
- bgl::blUseProgramObjectARB(0);
+ glUseProgramObjectARB(0);
}
}
-#endif
}
-void BL_Shader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty )
+void BL_Shader::Update( const RAS_MeshSlot & ms, RAS_IRasterizer* rasty )
{
-#ifdef GL_ARB_shader_objects
if(!Ok() || !mPreDef.size())
return;
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
MT_Matrix4x4 model;
model.setValue(ms.m_OpenGLMatrix);
- MT_Matrix4x4 view;
- rasty->GetViewMatrix(view);
+ const MT_Matrix4x4& view = rasty->GetViewMatrix();
if(mAttr==SHD_TANGENT)
ms.m_mesh->SetMeshModified(true);
@@ -557,13 +524,15 @@ void BL_Shader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty )
}
case VIEWMATRIX_INVERSE:
{
- view.invert();
+ MT_Matrix4x4 viewinv = view;
+ viewinv.invert();
SetUniform(uni->mLoc, view);
break;
}
case VIEWMATRIX_INVERSETRANSPOSE:
{
- view.invert();
+ MT_Matrix4x4 viewinv = view;
+ viewinv.invert();
SetUniform(uni->mLoc, view, true);
break;
}
@@ -577,210 +546,186 @@ void BL_Shader::Update( const KX_MeshSlot & ms, RAS_IRasterizer* rasty )
}
}
}
-#endif
}
int BL_Shader::GetAttribLocation(const STR_String& name)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
- return bgl::blGetAttribLocationARB(mShader, name.ReadPtr());
+ return glGetAttribLocationARB(mShader, name.ReadPtr());
}
-#endif
+
return -1;
}
void BL_Shader::BindAttribute(const STR_String& attr, int loc)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
- bgl::blBindAttribLocationARB(mShader, loc, attr.ReadPtr());
+ glBindAttribLocationARB(mShader, loc, attr.ReadPtr());
}
-#endif
}
int BL_Shader::GetUniformLocation(const STR_String& name)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
MT_assert(mShader!=0);
- int location = bgl::blGetUniformLocationARB(mShader, name.ReadPtr());
+ int location = glGetUniformLocationARB(mShader, name.ReadPtr());
if(location == -1)
spit("Invalid uniform value: " << name.ReadPtr() << ".");
return location;
}
-#endif
+
return -1;
}
void BL_Shader::SetUniform(int uniform, const MT_Tuple2& vec)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
float value[2];
vec.getValue(value);
- bgl::blUniform2fvARB(uniform, 1, value);
+ glUniform2fvARB(uniform, 1, value);
}
-#endif
}
void BL_Shader::SetUniform(int uniform, const MT_Tuple3& vec)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
float value[3];
vec.getValue(value);
- bgl::blUniform3fvARB(uniform, 1, value);
+ glUniform3fvARB(uniform, 1, value);
}
-#endif
}
void BL_Shader::SetUniform(int uniform, const MT_Tuple4& vec)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
float value[4];
vec.getValue(value);
- bgl::blUniform4fvARB(uniform, 1, value);
+ glUniform4fvARB(uniform, 1, value);
}
-#endif
}
void BL_Shader::SetUniform(int uniform, const unsigned int& val)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
- bgl::blUniform1iARB(uniform, val);
+ glUniform1iARB(uniform, val);
}
-#endif
}
void BL_Shader::SetUniform(int uniform, const int val)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
- bgl::blUniform1iARB(uniform, val);
+ glUniform1iARB(uniform, val);
}
-#endif
}
void BL_Shader::SetUniform(int uniform, const float& val)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
- bgl::blUniform1fARB(uniform, val);
+ glUniform1fARB(uniform, val);
}
-#endif
}
void BL_Shader::SetUniform(int uniform, const MT_Matrix4x4& vec, bool transpose)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
float value[16];
+ // note: getValue gives back column major as needed by OpenGL
vec.getValue(value);
- bgl::blUniformMatrix4fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value);
+ glUniformMatrix4fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value);
}
-#endif
}
void BL_Shader::SetUniform(int uniform, const MT_Matrix3x3& vec, bool transpose)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
float value[9];
value[0] = (float)vec[0][0]; value[1] = (float)vec[1][0]; value[2] = (float)vec[2][0];
value[3] = (float)vec[0][1]; value[4] = (float)vec[1][1]; value[5] = (float)vec[2][1];
value[6] = (float)vec[0][2]; value[7] = (float)vec[1][2]; value[7] = (float)vec[2][2];
- bgl::blUniformMatrix3fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value);
+ glUniformMatrix3fvARB(uniform, 1, transpose?GL_TRUE:GL_FALSE, value);
}
-#endif
}
void BL_Shader::SetUniform(int uniform, const float* val, int len)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
if(len == 2)
- bgl::blUniform2fvARB(uniform, 1,(GLfloat*)val);
+ glUniform2fvARB(uniform, 1,(GLfloat*)val);
else if (len == 3)
- bgl::blUniform3fvARB(uniform, 1,(GLfloat*)val);
+ glUniform3fvARB(uniform, 1,(GLfloat*)val);
else if (len == 4)
- bgl::blUniform4fvARB(uniform, 1,(GLfloat*)val);
+ glUniform4fvARB(uniform, 1,(GLfloat*)val);
else
MT_assert(0);
}
-#endif
}
void BL_Shader::SetUniform(int uniform, const int* val, int len)
{
-#ifdef GL_ARB_shader_objects
- if( RAS_EXT_support._ARB_fragment_shader &&
- RAS_EXT_support._ARB_vertex_shader &&
- RAS_EXT_support._ARB_shader_objects
+ if( GLEW_ARB_fragment_shader &&
+ GLEW_ARB_vertex_shader &&
+ GLEW_ARB_shader_objects
)
{
if(len == 2)
- bgl::blUniform2ivARB(uniform, 1, (GLint*)val);
+ glUniform2ivARB(uniform, 1, (GLint*)val);
else if (len == 3)
- bgl::blUniform3ivARB(uniform, 1, (GLint*)val);
+ glUniform3ivARB(uniform, 1, (GLint*)val);
else if (len == 4)
- bgl::blUniform4ivARB(uniform, 1, (GLint*)val);
+ glUniform4ivARB(uniform, 1, (GLint*)val);
else
MT_assert(0);
}
-#endif
}
@@ -848,7 +793,6 @@ PyParentObject BL_Shader::Parents[] = {
KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProgram)" )
{
-#ifdef GL_ARB_shader_objects
if(mShader !=0 && mOk )
{
// already set...
@@ -861,7 +805,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProg
vertProg = v;
fragProg = f;
if( LinkProgram() ) {
- bgl::blUseProgramObjectARB( mShader );
+ glUseProgramObjectARB( mShader );
mUse = apply!=0;
Py_Return;
}
@@ -871,23 +815,18 @@ KX_PYMETHODDEF_DOC( BL_Shader, setSource," setSource(vertexProgram, fragmentProg
Py_Return;
}
return NULL;
-#else
- Py_Return;
-#endif
}
KX_PYMETHODDEF_DOC( BL_Shader, delSource, "delSource( )" )
{
-#ifdef GL_ARB_shader_objects
ClearUniforms();
- bgl::blUseProgramObjectARB(0);
+ glUseProgramObjectARB(0);
- bgl::blDeleteObjectARB(mShader);
+ glDeleteObjectARB(mShader);
mShader = 0;
mOk = 0;
mUse = 0;
-#endif
Py_Return;
}
@@ -908,25 +847,23 @@ KX_PYMETHODDEF_DOC( BL_Shader, getFragmentProg ,"getFragmentProg( )" )
KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()")
{
-#ifdef GL_ARB_shader_objects
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
if(mShader==0) {
PyErr_Format(PyExc_TypeError, "invalid shader object");
return NULL;
}
int stat = 0;
- bgl::blValidateProgramARB(mShader);
- bgl::blGetObjectParameterivARB(mShader, GL_OBJECT_VALIDATE_STATUS_ARB,(GLint*) &stat);
+ glValidateProgramARB(mShader);
+ glGetObjectParameterivARB(mShader, GL_OBJECT_VALIDATE_STATUS_ARB,(GLint*) &stat);
if(stat > 0 && stat < MAX_LOG_LEN) {
int char_len=0;
char *logInf = (char*)MEM_mallocN(stat, "validate-log");
- bgl::blGetInfoLogARB(mShader, stat,(GLsizei*) &char_len, logInf);
+ glGetInfoLogARB(mShader, stat,(GLsizei*) &char_len, logInf);
if(char_len >0) {
spit("---- GLSL Validation ----");
spit(logInf);
@@ -934,7 +871,6 @@ KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()")
MEM_freeN(logInf);
logInf=0;
}
-#endif//GL_ARB_shader_objects
Py_Return;
}
@@ -942,11 +878,10 @@ KX_PYMETHODDEF_DOC( BL_Shader, validate, "validate()")
KX_PYMETHODDEF_DOC( BL_Shader, setSampler, "setSampler(name, index)" )
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
- char *uniform="";
+ const char *uniform="";
int index=-1;
if(PyArg_ParseTuple(args, "si", &uniform, &index))
{
@@ -965,7 +900,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setSampler, "setSampler(name, index)" )
//else
// spit("Invalid texture sample index: " << index);
}
- Py_Return;
+ Py_RETURN_NONE;
}
return NULL;
}
@@ -984,11 +919,10 @@ KX_PYMETHODDEF_DOC( BL_Shader, setNumberOfPasses, "setNumberOfPasses( max-pass )
KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" )
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
- char *uniform="";
+ const char *uniform="";
float value=0;
if(PyArg_ParseTuple(args, "sf", &uniform, &value ))
{
@@ -1010,10 +944,9 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1f, "setUniform1f(name, fx)" )
KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)")
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
- char *uniform="";
+ const char *uniform="";
float array[2]={ 0,0 };
if(PyArg_ParseTuple(args, "sff", &uniform, &array[0],&array[1] ))
{
@@ -1035,10 +968,9 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform2f , "setUniform2f(name, fx, fy)")
KX_PYMETHODDEF_DOC( BL_Shader, setUniform3f, "setUniform3f(name, fx,fy,fz) ")
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
- char *uniform="";
+ const char *uniform="";
float array[3]={0,0,0};
if(PyArg_ParseTuple(args, "sfff", &uniform, &array[0],&array[1],&array[2]))
{
@@ -1061,10 +993,9 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform3f, "setUniform3f(name, fx,fy,fz) ")
KX_PYMETHODDEF_DOC( BL_Shader, setUniform4f, "setUniform4f(name, fx,fy,fz, fw) ")
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
- char *uniform="";
+ const char *uniform="";
float array[4]={0,0,0,0};
if(PyArg_ParseTuple(args, "sffff", &uniform, &array[0],&array[1],&array[2], &array[3]))
{
@@ -1086,10 +1017,9 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4f, "setUniform4f(name, fx,fy,fz, fw) "
KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" )
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
- char *uniform="";
+ const char *uniform="";
int value=0;
if(PyArg_ParseTuple(args, "si", &uniform, &value ))
{
@@ -1111,10 +1041,9 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform1i, "setUniform1i(name, ix)" )
KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)")
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
- char *uniform="";
+ const char *uniform="";
int array[2]={ 0,0 };
if(PyArg_ParseTuple(args, "sii", &uniform, &array[0],&array[1] ))
{
@@ -1136,11 +1065,10 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform2i , "setUniform2i(name, ix, iy)")
KX_PYMETHODDEF_DOC( BL_Shader, setUniform3i, "setUniform3i(name, ix,iy,iz) ")
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
- char *uniform="";
+ const char *uniform="";
int array[3]={0,0,0};
if(PyArg_ParseTuple(args, "siii", &uniform, &array[0],&array[1],&array[2]))
{
@@ -1161,10 +1089,9 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform3i, "setUniform3i(name, ix,iy,iz) ")
KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) ")
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
- char *uniform="";
+ const char *uniform="";
int array[4]={0,0,0, 0};
if(PyArg_ParseTuple(args, "siiii", &uniform, &array[0],&array[1],&array[2], &array[3] ))
{
@@ -1185,10 +1112,9 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniform4i, "setUniform4i(name, ix,iy,iz, iw) "
KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or list3 or list4) )")
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
- char*uniform = "";
+ const char *uniform = "";
PyObject *listPtr =0;
float array_data[4] = {0.f,0.f,0.f,0.f};
@@ -1255,10 +1181,9 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformfv , "setUniformfv( float (list2 or lis
KX_PYMETHODDEF_DOC( BL_Shader, setUniformiv, "setUniformiv( int (list2 or list3 or list4) )")
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
- char*uniform = "";
+ const char *uniform = "";
PyObject *listPtr =0;
int array_data[4] = {0,0,0,0};
@@ -1328,8 +1253,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix4,
"setUniformMatrix4(uniform-name, mat-4x4, transpose(row-major=true, col-major=false)" )
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
float matr[16] = {
@@ -1339,7 +1263,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix4,
0,0,0,1
};
- char *uniform="";
+ const char *uniform="";
PyObject *matrix=0;
int transp=1; // MT_ is row major so transpose by default....
if(PyArg_ParseTuple(args, "sO|i",&uniform, &matrix,&transp))
@@ -1371,8 +1295,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3,
"setUniformMatrix3(uniform-name, list[3x3], transpose(row-major=true, col-major=false)" )
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
float matr[9] = {
@@ -1381,7 +1304,7 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3,
0,0,1,
};
- char *uniform="";
+ const char *uniform="";
PyObject *matrix=0;
int transp=1; // MT_ is row major so transpose by default....
if(PyArg_ParseTuple(args, "sO|i",&uniform, &matrix,&transp))
@@ -1411,10 +1334,8 @@ KX_PYMETHODDEF_DOC( BL_Shader, setUniformMatrix3,
KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" )
{
-#ifdef GL_ARB_shader_objects
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
int attr=0;
if(PyArg_ParseTuple(args, "i", &attr )) {
@@ -1423,23 +1344,21 @@ KX_PYMETHODDEF_DOC( BL_Shader, setAttrib, "setAttrib(enum)" )
return NULL;
}
mAttr=SHD_TANGENT;
- bgl::blUseProgramObjectARB(mShader);
- bgl::blBindAttribLocationARB(mShader, mAttr, "Tangent");
+ glUseProgramObjectARB(mShader);
+ glBindAttribLocationARB(mShader, mAttr, "Tangent");
Py_Return;
}
return NULL;
-#endif
}
KX_PYMETHODDEF_DOC( BL_Shader, setUniformDef, "setUniformDef(name, enum)" )
{
if(mError) {
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
- char *uniform="";
+ const char *uniform="";
int nloc=0;
if(PyArg_ParseTuple(args, "si",&uniform, &nloc))
{
diff --git a/source/gameengine/Ketsji/BL_Shader.h b/source/gameengine/Ketsji/BL_Shader.h
index 8f303454087..18ca8f8b4f8 100644
--- a/source/gameengine/Ketsji/BL_Shader.h
+++ b/source/gameengine/Ketsji/BL_Shader.h
@@ -102,8 +102,8 @@ private:
bool mUse; // ...
//BL_Sampler mSampler[MAXTEX]; // Number of samplers
int mAttr; // Tangent attribute
- char* vertProg; // Vertex program string
- char* fragProg; // Fragment program string
+ const char* vertProg; // Vertex program string
+ const char* fragProg; // Fragment program string
bool mError; // ...
bool mDirty; //
@@ -177,7 +177,7 @@ public:
void UnloadShader();
// Update predefined uniforms each render call
- void Update(const class KX_MeshSlot & ms, class RAS_IRasterizer* rasty);
+ void Update(const class RAS_MeshSlot & ms, class RAS_IRasterizer* rasty);
//// Set sampler units (copied)
//void InitializeSampler(int unit, BL_Texture* texture );
diff --git a/source/gameengine/Ketsji/BL_Texture.cpp b/source/gameengine/Ketsji/BL_Texture.cpp
index 53e1af46e4e..f0ef84032f7 100644
--- a/source/gameengine/Ketsji/BL_Texture.cpp
+++ b/source/gameengine/Ketsji/BL_Texture.cpp
@@ -1,22 +1,10 @@
// ------------------------------------
-#ifdef WIN32
-#include <windows.h>
-#endif // WIN32
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#include <OpenGL/glu.h>
-#else
-#include <GL/gl.h>
-#if defined(__sun__) && !defined(__sparc__)
-#include <mesa/glu.h>
-#else
-#include <GL/glu.h>
-#endif
-#endif
+
+#include "GL/glew.h"
#include <iostream>
#include <map>
+#include <stdlib.h>
#include "BL_Material.h"
#include "BL_Texture.h"
@@ -29,15 +17,11 @@
#include "BLI_blenlib.h"
#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h"
-#include "RAS_OpenGLRasterizer/ARB_multitexture.h"
#include "RAS_ICanvas.h"
#include "RAS_Rect.h"
#include "KX_GameObject.h"
-
-using namespace bgl;
-
#define spit(x) std::cout << x << std::endl;
#include "MEM_guardedalloc.h"
@@ -219,9 +203,7 @@ void BL_Texture::InitNonPow2Tex(unsigned int *pix,int x,int y,bool mipmap)
bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap)
{
-#ifdef GL_ARB_texture_cube_map
-
- if (!RAS_EXT_support._ARB_texture_cube_map)
+ if (!GLEW_ARB_texture_cube_map)
{
spit("cubemaps not supported");
mOk = false;
@@ -311,9 +293,8 @@ bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap)
glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
- #ifdef GL_VERSION_1_2
- glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE );
- #endif
+ if(GLEW_VERSION_1_2)
+ glTexParameteri( GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE );
if (needs_split)
my_free_envmapdata(cubemap);
@@ -325,13 +306,6 @@ bool BL_Texture::InitCubeMap(int unit, EnvMap *cubemap)
mOk = IsValid();
return mOk;
-
-#else
-
- mOk = false;
- return mOk;
-
-#endif//GL_ARB_texture_cube_map
}
bool BL_Texture::IsValid()
@@ -360,51 +334,41 @@ unsigned int BL_Texture::GetTextureType() const
int BL_Texture::GetMaxUnits()
{
GLint unit=0;
-#ifdef GL_ARB_multitexture
- if(RAS_EXT_support._ARB_multitexture) {
+
+ if(GLEW_ARB_multitexture) {
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &unit);
return (MAXTEX>=unit?unit:MAXTEX);
}
-#endif
+
return 0;
}
void BL_Texture::ActivateFirst()
{
-#ifdef GL_ARB_multitexture
- if(RAS_EXT_support._ARB_multitexture)
- bgl::blActiveTextureARB(GL_TEXTURE0_ARB);
-#endif
+ if(GLEW_ARB_multitexture)
+ glActiveTextureARB(GL_TEXTURE0_ARB);
}
void BL_Texture::ActivateUnit(int unit)
{
-#ifdef GL_ARB_multitexture
- if(RAS_EXT_support._ARB_multitexture)
+ if(GLEW_ARB_multitexture)
if(unit <= MAXTEX)
- bgl::blActiveTextureARB(GL_TEXTURE0_ARB+unit);
-#endif
+ glActiveTextureARB(GL_TEXTURE0_ARB+unit);
}
void BL_Texture::DisableUnit()
{
-#ifdef GL_ARB_multitexture
- if(RAS_EXT_support._ARB_multitexture)
- bgl::blActiveTextureARB(GL_TEXTURE0_ARB+mUnit);
-
-#endif
-
+ if(GLEW_ARB_multitexture)
+ glActiveTextureARB(GL_TEXTURE0_ARB+mUnit);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
- #ifdef GL_ARB_texture_cube_map
- if(RAS_EXT_support._ARB_texture_cube_map && glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB))
+ if(GLEW_ARB_texture_cube_map && glIsEnabled(GL_TEXTURE_CUBE_MAP_ARB))
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
else
- #endif
{
if (glIsEnabled(GL_TEXTURE_2D))
glDisable(GL_TEXTURE_2D);
@@ -420,11 +384,9 @@ void BL_Texture::DisableUnit()
void BL_Texture::DisableAllTextures()
{
-#ifdef GL_ARB_multitexture
- glDisable(GL_BLEND);
for(int i=0; i<MAXTEX; i++) {
- if(RAS_EXT_support._ARB_multitexture)
- bgl::blActiveTextureARB(GL_TEXTURE0_ARB+i);
+ if(GLEW_ARB_multitexture)
+ glActiveTextureARB(GL_TEXTURE0_ARB+i);
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
@@ -436,38 +398,29 @@ void BL_Texture::DisableAllTextures()
glDisable(GL_TEXTURE_GEN_Q);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
}
- if(RAS_EXT_support._ARB_multitexture)
- bgl::blActiveTextureARB(GL_TEXTURE0_ARB);
-#endif
+ if(GLEW_ARB_multitexture)
+ glActiveTextureARB(GL_TEXTURE0_ARB);
}
void BL_Texture::ActivateTexture()
{
-#ifdef GL_ARB_multitexture
- if(RAS_EXT_support._ARB_multitexture)
- bgl::blActiveTextureARB(GL_TEXTURE0_ARB+mUnit);
+ if(GLEW_ARB_multitexture)
+ glActiveTextureARB(GL_TEXTURE0_ARB+mUnit);
-#ifdef GL_ARB_texture_cube_map
- if (mType == GL_TEXTURE_CUBE_MAP_ARB && RAS_EXT_support._ARB_texture_cube_map)
+ if (mType == GL_TEXTURE_CUBE_MAP_ARB && GLEW_ARB_texture_cube_map)
{
glBindTexture( GL_TEXTURE_CUBE_MAP_ARB, mTexture );
glEnable(GL_TEXTURE_CUBE_MAP_ARB);
}
- else
-#endif
- {
-
- #ifdef GL_ARB_texture_cube_map
- if(RAS_EXT_support._ARB_texture_cube_map )
+ else {
+ if(GLEW_ARB_texture_cube_map )
glDisable(GL_TEXTURE_CUBE_MAP_ARB);
- #endif
glBindTexture( GL_TEXTURE_2D, mTexture );
glEnable(GL_TEXTURE_2D);
}
-#endif
}
void BL_Texture::SetMapping(int mode)
@@ -481,9 +434,8 @@ void BL_Texture::SetMapping(int mode)
return;
}
-#ifdef GL_ARB_texture_cube_map
if( mType == GL_TEXTURE_CUBE_MAP_ARB &&
- RAS_EXT_support._ARB_texture_cube_map &&
+ GLEW_ARB_texture_cube_map &&
mode &USEREFL)
{
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB );
@@ -497,7 +449,6 @@ void BL_Texture::SetMapping(int mode)
return;
}
else
-#endif
{
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP );
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP );
@@ -512,11 +463,7 @@ void BL_Texture::SetMapping(int mode)
void BL_Texture::setTexEnv(BL_Material *mat, bool modulate)
{
-#ifndef GL_ARB_texture_env_combine
- glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
- return;
-#else
- if(modulate || !RAS_EXT_support._ARB_texture_env_combine){
+ if(modulate || !GLEW_ARB_texture_env_combine){
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
return;
}
@@ -650,7 +597,6 @@ void BL_Texture::setTexEnv(BL_Material *mat, bool modulate)
glTexEnvf( GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 1.0);
glEndList();
-#endif //!GL_ARB_texture_env_combine
}
int BL_Texture::GetPow2(int n)
diff --git a/source/gameengine/Ketsji/BL_Texture.h b/source/gameengine/Ketsji/BL_Texture.h
index 0d0c7a277f2..830ffceb0f7 100644
--- a/source/gameengine/Ketsji/BL_Texture.h
+++ b/source/gameengine/Ketsji/BL_Texture.h
@@ -59,6 +59,14 @@ public:
void SetMapping(int mode);
void DisableUnit();
void setTexEnv(BL_Material *mat, bool modulate=false);
+ unsigned int swapTexture (unsigned int newTex) {
+ // swap texture codes
+ unsigned int tmp = mTexture;
+ mTexture = newTex;
+ // return original texture code
+ return tmp;
+ }
+
};
#endif//__BL_TEXTURE_H__
diff --git a/source/gameengine/Ketsji/CMakeLists.txt b/source/gameengine/Ketsji/CMakeLists.txt
index a10b07ff491..d054894589f 100644
--- a/source/gameengine/Ketsji/CMakeLists.txt
+++ b/source/gameengine/Ketsji/CMakeLists.txt
@@ -26,6 +26,19 @@
FILE(GLOB SRC *.cpp)
+#XXX disabled for 2.5 because of missing python
+#SET(SRC
+# ${SRC}
+# ../../../source/blender/python/api2_2x/Mathutils.c
+# ../../../source/blender/python/api2_2x/constant.c
+# ../../../source/blender/python/api2_2x/euler.c
+# ../../../source/blender/python/api2_2x/gen_utils.c
+# ../../../source/blender/python/api2_2x/matrix.c
+# ../../../source/blender/python/api2_2x/point.c
+# ../../../source/blender/python/api2_2x/quat.c
+# ../../../source/blender/python/api2_2x/vector.c
+#)
+
SET(INC
.
../../../source/kernel/gen_system
@@ -39,7 +52,8 @@ SET(INC
../../../intern/moto/include
../../../source/gameengine/Ketsji
../../../source/blender/blenlib
- ../../../source/blender/blenkernel
+ ../../../source/blender/blenkernel
+ ../../../source/blender/python/api2_2x
../../../source/blender
../../../source/blender/include
../../../source/blender/makesdna
@@ -57,8 +71,10 @@ SET(INC
../../../intern/SoundSystem
../../../source/blender/misc
../../../source/blender/blenloader
+ ../../../source/blender/gpu
../../../extern/bullet2/src
../../../extern/solid
+ ../../../extern/glew/include
${PYTHON_INC}
${SDL_INC}
)
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
index 7b5b7fdf78c..eee8e9f6827 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.cpp
@@ -55,28 +55,13 @@ KX_NetworkEventManager::~KX_NetworkEventManager()
//printf("KX_NetworkEventManager destructor\n");
}
-void KX_NetworkEventManager::RegisterSensor(class SCA_ISensor* sensor)
-{
- //printf("KX_NetworkEventManager RegisterSensor\n");
- m_sensors.push_back(sensor);
-}
-
-void KX_NetworkEventManager::RemoveSensor(class SCA_ISensor* sensor)
-{
- //printf("KX_NetworkEventManager RemoveSensor\n");
- // Network specific RemoveSensor stuff goes here
-
- // parent
- SCA_EventManager::RemoveSensor(sensor);
-}
-
void KX_NetworkEventManager::NextFrame()
{
// printf("KX_NetworkEventManager::proceed %.2f - %.2f\n", curtime, deltatime);
// each frame, the logicmanager will call the network
// eventmanager to look for network events, and process it's
// 'network' sensors
- vector<class SCA_ISensor*>::iterator it;
+ set<class SCA_ISensor*>::iterator it;
for (it = m_sensors.begin(); !(it==m_sensors.end()); it++) {
// printf("KX_NetworkEventManager::proceed sensor %.2f\n", curtime);
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h
index 0b097ba2ef6..ae88f1d4987 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkEventManager.h
@@ -42,9 +42,6 @@ public:
class NG_NetworkDeviceInterface *ndi);
virtual ~KX_NetworkEventManager ();
- virtual void RegisterSensor(class SCA_ISensor* sensor);
- virtual void RemoveSensor(class SCA_ISensor* sensor);
-
virtual void NextFrame();
virtual void EndFrame();
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
index 3ade810c394..85921ae75ca 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageActuator.cpp
@@ -158,6 +158,9 @@ PyObject* KX_NetworkMessageActuator::PySetToPropName(
if (PyArg_ParseTuple(args, "s", &ToPropName)) {
m_toPropName = ToPropName;
}
+ else {
+ return NULL;
+ }
Py_Return;
}
@@ -173,7 +176,10 @@ PyObject* KX_NetworkMessageActuator::PySetSubject(
if (PyArg_ParseTuple(args, "s", &Subject)) {
m_subject = Subject;
}
-
+ else {
+ return NULL;
+ }
+
Py_Return;
}
@@ -188,6 +194,9 @@ PyObject* KX_NetworkMessageActuator::PySetBodyType(
if (PyArg_ParseTuple(args, "i", &BodyType)) {
m_bodyType = BodyType;
}
+ else {
+ return NULL;
+ }
Py_Return;
}
@@ -203,6 +212,9 @@ PyObject* KX_NetworkMessageActuator::PySetBody(
if (PyArg_ParseTuple(args, "s", &Body)) {
m_body = Body;
}
+ else {
+ return NULL;
+ }
Py_Return;
}
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
index c9fa920a426..8956df9c96b 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.cpp
@@ -58,10 +58,15 @@ KX_NetworkMessageSensor::KX_NetworkMessageSensor(
m_NetworkScene(NetworkScene),
m_subject(subject),
m_frame_message_count (0),
- m_IsUp(false),
m_BodyList(NULL),
m_SubjectList(NULL)
{
+ Init();
+}
+
+void KX_NetworkMessageSensor::Init()
+{
+ m_IsUp = false;
}
KX_NetworkMessageSensor::~KX_NetworkMessageSensor()
@@ -139,7 +144,11 @@ bool KX_NetworkMessageSensor::Evaluate(CValue* event)
result = (WasUp != m_IsUp);
- // Return true if the message received state has changed.
+ // Return always true if a message was received otherwise we can loose messages
+ if (m_IsUp)
+ return true;
+ // Is it usefull to return also true when the first frame without a message??
+ // This will cause a fast on/off cycle that seems useless!
return result;
}
@@ -187,20 +196,20 @@ PyParentObject KX_NetworkMessageSensor::Parents[] = {
PyMethodDef KX_NetworkMessageSensor::Methods[] = {
{"setSubjectFilterText", (PyCFunction)
- KX_NetworkMessageSensor::sPySetSubjectFilterText, METH_VARARGS,
- SetSubjectFilterText_doc},
+ KX_NetworkMessageSensor::sPySetSubjectFilterText, METH_O,
+ (PY_METHODCHAR)SetSubjectFilterText_doc},
{"getFrameMessageCount", (PyCFunction)
- KX_NetworkMessageSensor::sPyGetFrameMessageCount, METH_VARARGS,
- GetFrameMessageCount_doc},
+ KX_NetworkMessageSensor::sPyGetFrameMessageCount, METH_NOARGS,
+ (PY_METHODCHAR)GetFrameMessageCount_doc},
{"getBodies", (PyCFunction)
- KX_NetworkMessageSensor::sPyGetBodies, METH_VARARGS,
- GetBodies_doc},
+ KX_NetworkMessageSensor::sPyGetBodies, METH_NOARGS,
+ (PY_METHODCHAR)GetBodies_doc},
{"getSubject", (PyCFunction)
- KX_NetworkMessageSensor::sPyGetSubject, METH_VARARGS,
- GetSubject_doc},
+ KX_NetworkMessageSensor::sPyGetSubject, METH_NOARGS,
+ (PY_METHODCHAR)GetSubject_doc},
{"getSubjects", (PyCFunction)
- KX_NetworkMessageSensor::sPyGetSubjects, METH_VARARGS,
- GetSubjects_doc},
+ KX_NetworkMessageSensor::sPyGetSubjects, METH_NOARGS,
+ (PY_METHODCHAR)GetSubjects_doc},
{NULL,NULL} //Sentinel
};
@@ -209,85 +218,66 @@ PyObject* KX_NetworkMessageSensor::_getattr(const STR_String& attr) {
}
// 1. Set the message subject that this sensor listens for
-char KX_NetworkMessageSensor::SetSubjectFilterText_doc[] =
+const char KX_NetworkMessageSensor::SetSubjectFilterText_doc[] =
"\tsetSubjectFilterText(value)\n"
"\tChange the message subject text that this sensor is listening to.\n";
-PyObject* KX_NetworkMessageSensor::PySetSubjectFilterText(
- PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_NetworkMessageSensor::PySetSubjectFilterText( PyObject* self, PyObject* value)
{
- char* Subject;
-
- if (PyArg_ParseTuple(args, "s", &Subject))
- {
- m_subject = Subject;
+ char* Subject = PyString_AsString(value);
+ if (Subject==NULL) {
+ PyErr_SetString(PyExc_TypeError, "expected a string message");
+ return NULL;
}
-
- Py_Return;
+
+ m_subject = Subject;
+ Py_RETURN_NONE;
}
// 2. Get the number of messages received since the last frame
-char KX_NetworkMessageSensor::GetFrameMessageCount_doc[] =
+const char KX_NetworkMessageSensor::GetFrameMessageCount_doc[] =
"\tgetFrameMessageCount()\n"
"\tGet the number of messages received since the last frame.\n";
-PyObject* KX_NetworkMessageSensor::PyGetFrameMessageCount(
- PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_NetworkMessageSensor::PyGetFrameMessageCount( PyObject* )
{
return PyInt_FromLong(long(m_frame_message_count));
}
// 3. Get the message bodies
-char KX_NetworkMessageSensor::GetBodies_doc[] =
+const char KX_NetworkMessageSensor::GetBodies_doc[] =
"\tgetBodies()\n"
"\tGet the list of message bodies.\n";
-PyObject* KX_NetworkMessageSensor::PyGetBodies(
- PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_NetworkMessageSensor::PyGetBodies( PyObject* )
{
if (m_BodyList) {
return ((PyObject*) m_BodyList->AddRef());
+ } else {
+ return ((PyObject*) new CListValue());
}
-
- Py_Return;
}
// 4. Get the message subject: field of the message sensor
-char KX_NetworkMessageSensor::GetSubject_doc[] =
+const char KX_NetworkMessageSensor::GetSubject_doc[] =
"\tgetSubject()\n"
"\tGet the subject: field of the message sensor.\n";
-PyObject* KX_NetworkMessageSensor::PyGetSubject(
- PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_NetworkMessageSensor::PyGetSubject( PyObject* )
{
- if (m_subject) {
- return PyString_FromString(m_subject);
- }
-
- Py_Return;
+ return PyString_FromString(m_subject ? m_subject : "");
}
// 5. Get the message subjects
-char KX_NetworkMessageSensor::GetSubjects_doc[] =
+const char KX_NetworkMessageSensor::GetSubjects_doc[] =
"\tgetSubjects()\n"
"\tGet list of message subjects.\n";
-PyObject* KX_NetworkMessageSensor::PyGetSubjects(
- PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_NetworkMessageSensor::PyGetSubjects( PyObject* )
{
if (m_SubjectList) {
- return ((PyObject*) m_SubjectList->AddRef());
- }
-
- Py_Return;
+ return ((PyObject*) m_SubjectList->AddRef());
+ } else {
+ return ((PyObject*) new CListValue());
+ }
}
diff --git a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
index d051b715aab..8cdfd6cdb5a 100644
--- a/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
+++ b/source/gameengine/Ketsji/KXNetwork/KX_NetworkMessageSensor.h
@@ -65,6 +65,7 @@ public:
virtual CValue* GetReplica();
virtual bool Evaluate(CValue* event);
virtual bool IsPositiveTrigger();
+ virtual void Init();
void EndFrame();
/* ------------------------------------------------------------- */
@@ -73,11 +74,11 @@ public:
virtual PyObject* _getattr(const STR_String& attr);
- KX_PYMETHOD_DOC(KX_NetworkMessageSensor, SetSubjectFilterText);
- KX_PYMETHOD_DOC(KX_NetworkMessageSensor, GetFrameMessageCount);
- KX_PYMETHOD_DOC(KX_NetworkMessageSensor, GetBodies);
- KX_PYMETHOD_DOC(KX_NetworkMessageSensor, GetSubject);
- KX_PYMETHOD_DOC(KX_NetworkMessageSensor, GetSubjects);
+ KX_PYMETHOD_DOC_O(KX_NetworkMessageSensor, SetSubjectFilterText);
+ KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetFrameMessageCount);
+ KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetBodies);
+ KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetSubject);
+ KX_PYMETHOD_DOC_NOARGS(KX_NetworkMessageSensor, GetSubjects);
};
diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
index bbf5640f8e0..f92200780d5 100644
--- a/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
+++ b/source/gameengine/Ketsji/KX_BlenderMaterial.cpp
@@ -6,21 +6,7 @@
#include <config.h>
#endif
-#ifdef WIN32
-#include <windows.h>
-#endif // WIN32
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#include <OpenGL/glu.h>
-#else
-#include <GL/gl.h>
-#if defined(__sun__) && !defined(__sparc__)
-#include <mesa/glu.h>
-#else
-#include <GL/glu.h>
-#endif
-#endif
+#include "GL/glew.h"
#include "KX_BlenderMaterial.h"
#include "BL_Material.h"
@@ -33,14 +19,12 @@
#include "MT_Vector4.h"
#include "MT_Matrix4x4.h"
+#include "RAS_BucketManager.h"
#include "RAS_MeshObject.h"
#include "RAS_IRasterizer.h"
#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h"
-#include "RAS_OpenGLRasterizer/ARB_multitexture.h"
-extern "C" {
-//XXX #include "BDR_drawmesh.h"
-}
+#include "GPU_draw.h"
#include "STR_HashedString.h"
@@ -51,9 +35,11 @@ extern "C" {
#include "DNA_meshdata_types.h"
#include "BKE_mesh.h"
// ------------------------------------
-using namespace bgl;
#define spit(x) std::cout << x << std::endl;
+BL_Shader *KX_BlenderMaterial::mLastShader = NULL;
+BL_BlenderShader *KX_BlenderMaterial::mLastBlenderShader = NULL;
+
//static PyObject *gTextureDict = 0;
KX_BlenderMaterial::KX_BlenderMaterial(
@@ -61,7 +47,6 @@ KX_BlenderMaterial::KX_BlenderMaterial(
BL_Material *data,
bool skin,
int lightlayer,
- void *clientobject,
PyTypeObject *T
)
: PyObjectPlus(T),
@@ -72,35 +57,33 @@ KX_BlenderMaterial::KX_BlenderMaterial(
data->tilexrep[0],
data->tileyrep[0],
data->mode,
- ((data->ras_mode &TRANSP)!=0),
+ data->transp,
+ ((data->ras_mode &ALPHA)!=0),
((data->ras_mode &ZSORT)!=0),
- lightlayer,
- ((data->ras_mode &TRIANGLE)!=0),
- clientobject
+ lightlayer
),
mMaterial(data),
mShader(0),
+ mBlenderShader(0),
mScene(scene),
mUserDefBlend(0),
mModified(0),
+ mConstructed(false),
mPass(0)
{
// --------------------------------
// RAS_IPolyMaterial variables...
- m_flag |=RAS_BLENDERMAT;
- m_flag |=(mMaterial->IdMode>=ONETEX)?RAS_MULTITEX:0;
- m_flag |=(mMaterial->ras_mode & USE_LIGHT)!=0?RAS_MULTILIGHT:0;
- m_flag |=(mMaterial->ras_mode &ALPHA_TEST)!=0?RAS_FORCEALPHA:0;
+ m_flag |= RAS_BLENDERMAT;
+ m_flag |= (mMaterial->IdMode>=ONETEX)? RAS_MULTITEX: 0;
+ m_flag |= ((mMaterial->ras_mode & USE_LIGHT)!=0)? RAS_MULTILIGHT: 0;
+ m_flag |= (mMaterial->glslmat)? RAS_BLENDERGLSL: 0;
// figure max
int enabled = mMaterial->num_enabled;
int max = BL_Texture::GetMaxUnits();
mMaterial->num_enabled = enabled>=max?max:enabled;
- // base class
- m_enabled = mMaterial->num_enabled;
-
// test the sum of the various modes for equality
// so we can ether accept or reject this material
// as being equal, this is rather important to
@@ -111,14 +94,16 @@ KX_BlenderMaterial::KX_BlenderMaterial(
mMaterial->blend_mode[i]
);
}
- m_multimode += mMaterial->IdMode+mMaterial->ras_mode;
+ m_multimode += mMaterial->IdMode+ (mMaterial->ras_mode & ~(COLLIDER|USE_LIGHT));
}
KX_BlenderMaterial::~KX_BlenderMaterial()
{
// cleanup work
- OnExit();
+ if (mConstructed)
+ // clean only if material was actually used
+ OnExit();
}
@@ -137,41 +122,77 @@ unsigned int* KX_BlenderMaterial::GetMCol(void) const
void KX_BlenderMaterial::OnConstruction()
{
+ if (mConstructed)
+ // when material are reused between objects
+ return;
+
+ if(mMaterial->glslmat)
+ SetBlenderGLSLShader();
+
// for each unique material...
int i;
for(i=0; i<mMaterial->num_enabled; i++) {
if( mMaterial->mapping[i].mapping & USEENV ) {
- if(!RAS_EXT_support._ARB_texture_cube_map) {
+ if(!GLEW_ARB_texture_cube_map) {
spit("CubeMap textures not supported");
continue;
}
if(!mTextures[i].InitCubeMap(i, mMaterial->cubemap[i] ) )
spit("unable to initialize image("<<i<<") in "<<
- mMaterial->matname<< ", image will not be available");
+ mMaterial->matname<< ", image will not be available");
}
else {
if( mMaterial->img[i] ) {
if( ! mTextures[i].InitFromImage(i, mMaterial->img[i], (mMaterial->flag[i] &MIPMAP)!=0 ))
spit("unable to initialize image("<<i<<") in "<<
- mMaterial->matname<< ", image will not be available");
+ mMaterial->matname<< ", image will not be available");
}
}
}
+
mBlendFunc[0] =0;
mBlendFunc[1] =0;
+ mConstructed = true;
+}
+
+void KX_BlenderMaterial::EndFrame()
+{
+ if(mLastBlenderShader) {
+ mLastBlenderShader->SetProg(false);
+ mLastBlenderShader = NULL;
+ }
+
+ if(mLastShader) {
+ mLastShader->SetProg(false);
+ mLastShader = NULL;
+ }
}
void KX_BlenderMaterial::OnExit()
{
if( mShader ) {
- //note, the shader here is allocated, per unique material
- //and this function is called per face
- mShader->SetProg(0);
+ //note, the shader here is allocated, per unique material
+ //and this function is called per face
+ if(mShader == mLastShader) {
+ mShader->SetProg(false);
+ mLastShader = NULL;
+ }
+
delete mShader;
mShader = 0;
}
+ if( mBlenderShader ) {
+ if(mBlenderShader == mLastBlenderShader) {
+ mBlenderShader->SetProg(false);
+ mLastBlenderShader = NULL;
+ }
+
+ delete mBlenderShader;
+ mBlenderShader = 0;
+ }
+
BL_Texture::ActivateFirst();
for(int i=0; i<mMaterial->num_enabled; i++) {
BL_Texture::ActivateUnit(i);
@@ -180,24 +201,30 @@ void KX_BlenderMaterial::OnExit()
}
if( mMaterial->tface )
- ; //XXX set_tpage(mMaterial->tface);
+ GPU_set_tpage(mMaterial->tface);
}
void KX_BlenderMaterial::setShaderData( bool enable, RAS_IRasterizer *ras)
{
- MT_assert(RAS_EXT_support._ARB_shader_objects && mShader);
+ MT_assert(GLEW_ARB_shader_objects && mShader);
int i;
if( !enable || !mShader->Ok() ) {
// frame cleanup.
- mShader->SetProg(false);
+ if(mShader == mLastShader) {
+ mShader->SetProg(false);
+ mLastShader = NULL;
+ }
+
+ ras->SetBlendingMode(TF_SOLID);
BL_Texture::DisableAllTextures();
return;
}
BL_Texture::DisableAllTextures();
mShader->SetProg(true);
+ mLastShader = mShader;
BL_Texture::ActivateFirst();
@@ -211,29 +238,60 @@ void KX_BlenderMaterial::setShaderData( bool enable, RAS_IRasterizer *ras)
}
if(!mUserDefBlend) {
- setDefaultBlending();
+ ras->SetBlendingMode(mMaterial->transp);
}
else {
+ ras->SetBlendingMode(TF_SOLID);
+ ras->SetBlendingMode(-1); // indicates custom mode
+
// tested to be valid enums
glEnable(GL_BLEND);
glBlendFunc(mBlendFunc[0], mBlendFunc[1]);
}
}
+void KX_BlenderMaterial::setBlenderShaderData( bool enable, RAS_IRasterizer *ras)
+{
+ if( !enable || !mBlenderShader->Ok() ) {
+ ras->SetBlendingMode(TF_SOLID);
+
+ // frame cleanup.
+ if(mLastBlenderShader) {
+ mLastBlenderShader->SetProg(false);
+ mLastBlenderShader= NULL;
+ }
+ else
+ BL_Texture::DisableAllTextures();
+
+ return;
+ }
+
+ if(!mBlenderShader->Equals(mLastBlenderShader)) {
+ ras->SetBlendingMode(mMaterial->transp);
+
+ if(mLastBlenderShader)
+ mLastBlenderShader->SetProg(false);
+ else
+ BL_Texture::DisableAllTextures();
+
+ mBlenderShader->SetProg(true, ras->GetTime());
+ mLastBlenderShader= mBlenderShader;
+ }
+}
void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras)
{
- if(RAS_EXT_support._ARB_shader_objects && mShader)
- mShader->SetProg(false);
-
BL_Texture::DisableAllTextures();
- if( !enable )
+
+ if( !enable ) {
+ ras->SetBlendingMode(TF_SOLID);
return;
+ }
BL_Texture::ActivateFirst();
if( mMaterial->IdMode == DEFAULT_BLENDER ) {
- setDefaultBlending();
+ ras->SetBlendingMode(mMaterial->transp);
return;
}
@@ -243,7 +301,7 @@ void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras)
mTextures[0].ActivateTexture();
mTextures[0].setTexEnv(0, true);
mTextures[0].SetMapping(mMaterial->mapping[0].mapping);
- setDefaultBlending();
+ ras->SetBlendingMode(mMaterial->transp);
}
return;
}
@@ -266,9 +324,12 @@ void KX_BlenderMaterial::setTexData( bool enable, RAS_IRasterizer *ras)
}
if(!mUserDefBlend) {
- setDefaultBlending();
+ ras->SetBlendingMode(mMaterial->transp);
}
else {
+ ras->SetBlendingMode(TF_SOLID);
+ ras->SetBlendingMode(-1); // indicates custom mode
+
glEnable(GL_BLEND);
glBlendFunc(mBlendFunc[0], mBlendFunc[1]);
}
@@ -284,29 +345,31 @@ KX_BlenderMaterial::ActivatShaders(
// reset...
if(tmp->mMaterial->IsShared())
cachingInfo =0;
-
+
+ if(mLastBlenderShader) {
+ mLastBlenderShader->SetProg(false);
+ mLastBlenderShader= NULL;
+ }
+
if (GetCachingInfo() != cachingInfo) {
if (!cachingInfo)
- tmp->setShaderData( false, rasty);
+ tmp->setShaderData(false, rasty);
cachingInfo = GetCachingInfo();
- if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED ) {
- tmp->setShaderData( true, rasty);
- rasty->EnableTextures(true);
- }
- else {
- tmp->setShaderData( false, rasty);
- rasty->EnableTextures(false);
- }
+ if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)
+ tmp->setShaderData(true, rasty);
+ else
+ tmp->setShaderData(false, rasty);
if(mMaterial->mode & RAS_IRasterizer::KX_TWOSIDE)
rasty->SetCullFace(false);
else
rasty->SetCullFace(true);
- if (((mMaterial->ras_mode &WIRE)!=0) || mMaterial->mode & RAS_IRasterizer::KX_LINES)
+ if (((mMaterial->ras_mode &WIRE)!=0) || (mMaterial->mode & RAS_IRasterizer::KX_LINES) ||
+ (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME))
{
if((mMaterial->ras_mode &WIRE)!=0)
rasty->SetCullFace(false);
@@ -321,33 +384,84 @@ KX_BlenderMaterial::ActivatShaders(
}
void
+KX_BlenderMaterial::ActivateBlenderShaders(
+ RAS_IRasterizer* rasty,
+ TCachingInfo& cachingInfo)const
+{
+ KX_BlenderMaterial *tmp = const_cast<KX_BlenderMaterial*>(this);
+
+ if(mLastShader) {
+ mLastShader->SetProg(false);
+ mLastShader= NULL;
+ }
+
+ if (GetCachingInfo() != cachingInfo) {
+ if (!cachingInfo)
+ tmp->setBlenderShaderData(false, rasty);
+
+ cachingInfo = GetCachingInfo();
+
+ if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)
+ tmp->setBlenderShaderData(true, rasty);
+ else
+ tmp->setBlenderShaderData(false, rasty);
+
+ if(mMaterial->mode & RAS_IRasterizer::KX_TWOSIDE)
+ rasty->SetCullFace(false);
+ else
+ rasty->SetCullFace(true);
+
+ if (((mMaterial->ras_mode & WIRE)!=0) || (mMaterial->mode & RAS_IRasterizer::KX_LINES) ||
+ (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME))
+ {
+ if((mMaterial->ras_mode &WIRE)!=0)
+ rasty->SetCullFace(false);
+ rasty->SetLines(true);
+ }
+ else
+ rasty->SetLines(false);
+
+ ActivatGLMaterials(rasty);
+ mBlenderShader->SetAttribs(rasty, mMaterial);
+ }
+}
+
+void
KX_BlenderMaterial::ActivateMat(
RAS_IRasterizer* rasty,
TCachingInfo& cachingInfo
)const
{
KX_BlenderMaterial *tmp = const_cast<KX_BlenderMaterial*>(this);
+
+ if(mLastShader) {
+ mLastShader->SetProg(false);
+ mLastShader= NULL;
+ }
+
+ if(mLastBlenderShader) {
+ mLastBlenderShader->SetProg(false);
+ mLastBlenderShader= NULL;
+ }
+
if (GetCachingInfo() != cachingInfo) {
if (!cachingInfo)
tmp->setTexData( false,rasty );
cachingInfo = GetCachingInfo();
- if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) {
+ if (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED)
tmp->setTexData( true,rasty );
- rasty->EnableTextures(true);
- }
- else{
+ else
tmp->setTexData( false,rasty);
- rasty->EnableTextures(false);
- }
if(mMaterial->mode & RAS_IRasterizer::KX_TWOSIDE)
rasty->SetCullFace(false);
else
rasty->SetCullFace(true);
- if (((mMaterial->ras_mode &WIRE)!=0) || mMaterial->mode & RAS_IRasterizer::KX_LINES)
+ if (((mMaterial->ras_mode &WIRE)!=0) || (mMaterial->mode & RAS_IRasterizer::KX_LINES) ||
+ (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME))
{
if((mMaterial->ras_mode &WIRE)!=0)
rasty->SetCullFace(false);
@@ -356,77 +470,113 @@ KX_BlenderMaterial::ActivateMat(
else
rasty->SetLines(false);
}
+
ActivatGLMaterials(rasty);
ActivateTexGen(rasty);
}
-
bool
KX_BlenderMaterial::Activate(
RAS_IRasterizer* rasty,
TCachingInfo& cachingInfo
)const
{
- bool dopass = false;
- if( RAS_EXT_support._ARB_shader_objects && ( mShader && mShader->Ok() ) ) {
- if( (mPass++) < mShader->getNumPass() ) {
+ if(GLEW_ARB_shader_objects && (mShader && mShader->Ok())) {
+ if((mPass++) < mShader->getNumPass() ) {
ActivatShaders(rasty, cachingInfo);
- dopass = true;
- return dopass;
+ return true;
+ }
+ else {
+ if(mShader == mLastShader) {
+ mShader->SetProg(false);
+ mLastShader = NULL;
+ }
+ mPass = 0;
+ return false;
+ }
+ }
+ else if( GLEW_ARB_shader_objects && (mBlenderShader && mBlenderShader->Ok() ) ) {
+ if(mPass++ == 0) {
+ ActivateBlenderShaders(rasty, cachingInfo);
+ return true;
}
else {
- mShader->SetProg(false);
mPass = 0;
- dopass = false;
- return dopass;
+ return false;
}
}
else {
- switch (mPass++)
- {
- case 0:
- ActivateMat(rasty, cachingInfo);
- dopass = true;
- break;
- default:
- mPass = 0;
- dopass = false;
- break;
+ if(mPass++ == 0) {
+ ActivateMat(rasty, cachingInfo);
+ return true;
+ }
+ else {
+ mPass = 0;
+ return false;
}
}
- return dopass;
}
-void KX_BlenderMaterial::ActivateMeshSlot(const KX_MeshSlot & ms, RAS_IRasterizer* rasty) const
+bool KX_BlenderMaterial::UsesLighting(RAS_IRasterizer *rasty) const
{
- if(mShader && RAS_EXT_support._ARB_shader_objects)
+ if(!RAS_IPolyMaterial::UsesLighting(rasty))
+ return false;
+
+ if(mShader && mShader->Ok())
+ return true;
+ else if(mBlenderShader && mBlenderShader->Ok())
+ return false;
+ else
+ return true;
+}
+
+void KX_BlenderMaterial::ActivateMeshSlot(const RAS_MeshSlot & ms, RAS_IRasterizer* rasty) const
+{
+ if(mShader && GLEW_ARB_shader_objects) {
mShader->Update(ms, rasty);
+ }
+ else if(mBlenderShader && GLEW_ARB_shader_objects) {
+ int blendmode;
+
+ mBlenderShader->Update(ms, rasty);
+
+ /* we do blend modes here, because they can change per object
+ * with the same material due to obcolor/obalpha */
+ blendmode = mBlenderShader->GetBlendMode();
+ if((blendmode == TF_SOLID || blendmode == TF_ALPHA) && mMaterial->transp != TF_SOLID)
+ blendmode = mMaterial->transp;
+
+ rasty->SetBlendingMode(blendmode);
+ }
}
void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const
{
- rasty->SetSpecularity(
- mMaterial->speccolor[0]*mMaterial->spec_f,
- mMaterial->speccolor[1]*mMaterial->spec_f,
- mMaterial->speccolor[2]*mMaterial->spec_f,
- mMaterial->spec_f
- );
+ if(mShader || !mBlenderShader) {
+ rasty->SetSpecularity(
+ mMaterial->speccolor[0]*mMaterial->spec_f,
+ mMaterial->speccolor[1]*mMaterial->spec_f,
+ mMaterial->speccolor[2]*mMaterial->spec_f,
+ mMaterial->spec_f
+ );
- rasty->SetShinyness( mMaterial->hard );
+ rasty->SetShinyness( mMaterial->hard );
- rasty->SetDiffuse(
- mMaterial->matcolor[0]*mMaterial->ref+mMaterial->emit,
- mMaterial->matcolor[1]*mMaterial->ref+mMaterial->emit,
- mMaterial->matcolor[2]*mMaterial->ref+mMaterial->emit,
- 1.0f);
+ rasty->SetDiffuse(
+ mMaterial->matcolor[0]*mMaterial->ref+mMaterial->emit,
+ mMaterial->matcolor[1]*mMaterial->ref+mMaterial->emit,
+ mMaterial->matcolor[2]*mMaterial->ref+mMaterial->emit,
+ 1.0f);
- rasty->SetEmissive(
- mMaterial->matcolor[0]*mMaterial->emit,
- mMaterial->matcolor[1]*mMaterial->emit,
- mMaterial->matcolor[2]*mMaterial->emit,
- 1.0 );
+ rasty->SetEmissive(
+ mMaterial->matcolor[0]*mMaterial->emit,
+ mMaterial->matcolor[1]*mMaterial->emit,
+ mMaterial->matcolor[2]*mMaterial->emit,
+ 1.0 );
+
+ rasty->SetAmbient(mMaterial->amb);
+ }
- rasty->SetAmbient(mMaterial->amb);
if (mMaterial->material)
rasty->SetPolygonOffset(-mMaterial->material->zoffs, 0.0);
}
@@ -434,52 +584,43 @@ void KX_BlenderMaterial::ActivatGLMaterials( RAS_IRasterizer* rasty )const
void KX_BlenderMaterial::ActivateTexGen(RAS_IRasterizer *ras) const
{
- if(mShader && RAS_EXT_support._ARB_shader_objects)
- if(mShader->GetAttribute() == BL_Shader::SHD_TANGENT)
- ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT);
+ if(ras->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED) {
+ ras->SetAttribNum(0);
+ if(mShader && GLEW_ARB_shader_objects) {
+ if(mShader->GetAttribute() == BL_Shader::SHD_TANGENT) {
+ ras->SetAttrib(RAS_IRasterizer::RAS_TEXCO_DISABLE, 0);
+ ras->SetAttrib(RAS_IRasterizer::RAS_TEXTANGENT, 1);
+ ras->SetAttribNum(2);
+ }
+ }
- for(int i=0; i<mMaterial->num_enabled; i++) {
- int mode = mMaterial->mapping[i].mapping;
+ ras->SetTexCoordNum(mMaterial->num_enabled);
- if (mode &USECUSTOMUV)
- {
- STR_String str = mMaterial->mapping[i].uvCoName;
- if (!str.IsEmpty())
- ras->SetTexCoords(RAS_IRasterizer::RAS_TEXCO_UV2, i);
- continue;
- }
+ for(int i=0; i<mMaterial->num_enabled; i++) {
+ int mode = mMaterial->mapping[i].mapping;
- if( mode &(USEREFL|USEOBJ))
- ras->SetTexCoords(RAS_IRasterizer::RAS_TEXCO_GEN, i);
- else if(mode &USEORCO)
- ras->SetTexCoords(RAS_IRasterizer::RAS_TEXCO_ORCO, i);
- else if(mode &USENORM)
- ras->SetTexCoords(RAS_IRasterizer::RAS_TEXCO_NORM, i);
- else if(mode &USEUV)
- ras->SetTexCoords(RAS_IRasterizer::RAS_TEXCO_UV1, i);
- else if(mode &USETANG)
- ras->SetTexCoords(RAS_IRasterizer::RAS_TEXTANGENT, i);
- else
- ras->SetTexCoords(RAS_IRasterizer::RAS_TEXCO_DISABLE, i);
- }
-}
+ if (mode &USECUSTOMUV)
+ {
+ STR_String str = mMaterial->mapping[i].uvCoName;
+ if (!str.IsEmpty())
+ ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_UV2, i);
+ continue;
+ }
-bool KX_BlenderMaterial::setDefaultBlending()
-{
- if( mMaterial->transp &TF_ADD) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_ONE, GL_ONE);
- return true;
- }
-
- if( mMaterial->transp & TF_ALPHA ) {
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- return true;
+ if( mode &(USEREFL|USEOBJ))
+ ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_GEN, i);
+ else if(mode &USEORCO)
+ ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_ORCO, i);
+ else if(mode &USENORM)
+ ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_NORM, i);
+ else if(mode &USEUV)
+ ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_UV1, i);
+ else if(mode &USETANG)
+ ras->SetTexCoord(RAS_IRasterizer::RAS_TEXTANGENT, i);
+ else
+ ras->SetTexCoord(RAS_IRasterizer::RAS_TEXCO_DISABLE, i);
+ }
}
-
- glDisable(GL_BLEND);
- return false;
}
void KX_BlenderMaterial::setTexMatrixData(int i)
@@ -487,8 +628,7 @@ void KX_BlenderMaterial::setTexMatrixData(int i)
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
-#ifdef GL_ARB_texture_cube_map
- if( RAS_EXT_support._ARB_texture_cube_map &&
+ if( GLEW_ARB_texture_cube_map &&
mTextures[i].GetTextureType() == GL_TEXTURE_CUBE_MAP_ARB &&
mMaterial->mapping[i].mapping & USEREFL) {
glScalef(
@@ -498,7 +638,6 @@ void KX_BlenderMaterial::setTexMatrixData(int i)
);
}
else
-#endif
{
glScalef(
mMaterial->mapping[i].scale[0],
@@ -556,8 +695,7 @@ void KX_BlenderMaterial::setObjectMatrixData(int i, RAS_IRasterizer *ras)
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);
- MT_Matrix4x4 mvmat;
- ras->GetViewMatrix(mvmat);
+ const MT_Matrix4x4& mvmat = ras->GetViewMatrix();
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
@@ -647,28 +785,23 @@ int KX_BlenderMaterial::_setattr(const STR_String& attr, PyObject *pyvalue)
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()")
{
-#ifdef GL_ARB_fragment_shader
- if( !RAS_EXT_support._ARB_fragment_shader) {
+ if( !GLEW_ARB_fragment_shader) {
if(!mModified)
spit("Fragment shaders not supported");
mModified = true;
Py_Return;
}
-#endif
-#ifdef GL_ARB_vertex_shader
- if( !RAS_EXT_support._ARB_vertex_shader) {
+ if( !GLEW_ARB_vertex_shader) {
if(!mModified)
spit("Vertex shaders not supported");
mModified = true;
Py_Return;
}
-#endif
-#ifdef GL_ARB_shader_objects
- if(!RAS_EXT_support._ARB_shader_objects) {
+ if(!GLEW_ARB_shader_objects) {
if(!mModified)
spit("GLSL not supported");
mModified = true;
@@ -684,7 +817,9 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()")
}
if(mShader && !mShader->GetError()) {
+ m_flag &= ~RAS_BLENDERGLSL;
mMaterial->SetSharedMaterial(true);
+ mScene->GetBucketManager()->ReleaseDisplayLists(this);
Py_INCREF(mShader);
return mShader;
}else
@@ -707,13 +842,20 @@ KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()")
}
PyErr_Format(PyExc_ValueError, "GLSL Error");
return NULL;
-
-#else
- Py_Return;
-#endif//GL_ARB_shader_objects
}
+void KX_BlenderMaterial::SetBlenderGLSLShader(void)
+{
+ if(!mBlenderShader)
+ mBlenderShader = new BL_BlenderShader(mScene, mMaterial->material, m_lightlayer);
+
+ if(!mBlenderShader->Ok()) {
+ delete mBlenderShader;
+ mBlenderShader = 0;
+ }
+}
+
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getMaterialIndex, "getMaterialIndex()")
{
return PyInt_FromLong( mMaterial->material_index );
diff --git a/source/gameengine/Ketsji/KX_BlenderMaterial.h b/source/gameengine/Ketsji/KX_BlenderMaterial.h
index 2b1264154d0..6e5db1b56c1 100644
--- a/source/gameengine/Ketsji/KX_BlenderMaterial.h
+++ b/source/gameengine/Ketsji/KX_BlenderMaterial.h
@@ -8,6 +8,7 @@
#include "BL_Material.h"
#include "BL_Texture.h"
#include "BL_Shader.h"
+#include "BL_BlenderShader.h"
#include "PyObjectPlus.h"
@@ -27,7 +28,6 @@ public:
BL_Material* mat,
bool skin,
int lightlayer,
- void* clientobject,
PyTypeObject* T=&Type
);
@@ -46,7 +46,7 @@ public:
virtual
void ActivateMeshSlot(
- const KX_MeshSlot & ms,
+ const RAS_MeshSlot & ms,
RAS_IRasterizer* rasty
) const;
@@ -60,9 +60,19 @@ public:
TCachingInfo& cachingInfo
)const;
+ void ActivateBlenderShaders(
+ RAS_IRasterizer* rasty,
+ TCachingInfo& cachingInfo
+ )const;
MTFace* GetMTFace(void) const;
unsigned int* GetMCol(void) const;
+ BL_Texture * getTex (unsigned int idx) {
+ return (idx < MAXTEX) ? mTextures + idx : NULL;
+ }
+ Image * getImage (unsigned int idx) {
+ return (idx < MAXTEX && mMaterial) ? mMaterial->img[idx] : NULL;
+ }
// for ipos
void UpdateIPO(
@@ -85,24 +95,32 @@ public:
// --------------------------------
// pre calculate to avoid pops/lag at startup
virtual void OnConstruction( );
+
+ static void EndFrame();
+
private:
- BL_Material* mMaterial;
- BL_Shader* mShader;
+ BL_Material* mMaterial;
+ BL_Shader* mShader;
+ BL_BlenderShader* mBlenderShader;
KX_Scene* mScene;
BL_Texture mTextures[MAXTEX]; // texture array
bool mUserDefBlend;
unsigned int mBlendFunc[2];
bool mModified;
+ bool mConstructed; // if false, don't clean on exit
+
+ void SetBlenderGLSLShader();
void ActivatGLMaterials( RAS_IRasterizer* rasty )const;
void ActivateTexGen( RAS_IRasterizer *ras ) const;
+ bool UsesLighting(RAS_IRasterizer *rasty) const;
// message centers
void setTexData( bool enable,RAS_IRasterizer *ras);
+ void setBlenderShaderData( bool enable, RAS_IRasterizer *ras);
void setShaderData( bool enable, RAS_IRasterizer *ras);
- bool setDefaultBlending();
void setObjectMatrixData(int i, RAS_IRasterizer *ras);
void setTexMatrixData(int i);
@@ -111,6 +129,10 @@ private:
// cleanup stuff
void OnExit();
+ // shader chacing
+ static BL_BlenderShader *mLastBlenderShader;
+ static BL_Shader *mLastShader;
+
mutable int mPass;
};
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
index aa5d1f1cec1..bf838e60210 100644
--- a/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
+++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.cpp
@@ -13,18 +13,32 @@
#include "KX_ClientObjectInfo.h"
#include "PHY_IPhysicsEnvironment.h"
+#include "CcdPhysicsEnvironment.h"
+#include "BulletSoftBody/btSoftBody.h"
KX_BulletPhysicsController::KX_BulletPhysicsController (const CcdConstructionInfo& ci, bool dyna)
: KX_IPhysicsController(dyna,(PHY_IPhysicsController*)this),
-CcdPhysicsController(ci)
+CcdPhysicsController(ci),
+m_savedCollisionFlags(0)
{
}
KX_BulletPhysicsController::~KX_BulletPhysicsController ()
{
-
+ // The game object has a direct link to
+ if (m_pObject)
+ {
+ // If we cheat in SetObject, we must also cheat here otherwise the
+ // object will still things it has a physical controller
+ // Note that it requires that m_pObject is reset in case the object is deleted
+ // before the controller (usual case, see KX_Scene::RemoveNodeDestructObjec)
+ // The non usual case is when the object is not deleted because its reference is hanging
+ // in a AddObject actuator but the node is deleted. This case is covered here.
+ KX_GameObject* gameobj = (KX_GameObject*) m_pObject->GetSGClientObject();
+ gameobj->SetPhysicsController(NULL,false);
+ }
}
void KX_BulletPhysicsController::resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ)
@@ -58,6 +72,7 @@ void KX_BulletPhysicsController::SetObject (SG_IObject* object)
}
+
void KX_BulletPhysicsController::setMargin (float collisionMargin)
{
CcdPhysicsController::SetMargin(collisionMargin);
@@ -90,10 +105,17 @@ MT_Vector3 KX_BulletPhysicsController::GetLinearVelocity()
CcdPhysicsController::GetLinearVelocity(angVel[0],angVel[1],angVel[2]);//rcruiz
return MT_Vector3(angVel[0],angVel[1],angVel[2]);
}
+MT_Vector3 KX_BulletPhysicsController::GetAngularVelocity()
+{
+ float angVel[3];
+ //CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);
+ CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);//rcruiz
+ return MT_Vector3(angVel[0],angVel[1],angVel[2]);
+}
MT_Vector3 KX_BulletPhysicsController::GetVelocity(const MT_Point3& pos)
{
float linVel[3];
- CcdPhysicsController::GetLinearVelocity(linVel[0],linVel[1],linVel[2]);
+ CcdPhysicsController::GetVelocity(pos[0], pos[1], pos[2], linVel[0],linVel[1],linVel[2]);
return MT_Vector3(linVel[0],linVel[1],linVel[2]);
}
@@ -112,9 +134,10 @@ void KX_BulletPhysicsController::getOrientation(MT_Quaternion& orn)
CcdPhysicsController::getOrientation(myorn[0],myorn[1],myorn[2],myorn[3]);
orn = MT_Quaternion(myorn[0],myorn[1],myorn[2],myorn[3]);
}
-void KX_BulletPhysicsController::setOrientation(const MT_Quaternion& orn)
+void KX_BulletPhysicsController::setOrientation(const MT_Matrix3x3& orn)
{
- CcdPhysicsController::setOrientation(orn.x(),orn.y(),orn.z(),orn.w());
+ btMatrix3x3 btmat(orn[0][0], orn[0][1], orn[0][2], orn[1][0], orn[1][1], orn[1][2], orn[2][0], orn[2][1], orn[2][2]);
+ CcdPhysicsController::setWorldOrientation(btmat);
}
void KX_BulletPhysicsController::setPosition(const MT_Point3& pos)
{
@@ -126,13 +149,23 @@ void KX_BulletPhysicsController::setScaling(const MT_Vector3& scaling)
}
MT_Scalar KX_BulletPhysicsController::GetMass()
{
-
- MT_Scalar invmass = GetRigidBody()->getInvMass();
+ if (GetSoftBody())
+ return GetSoftBody()->getTotalMass();
+
+ MT_Scalar invmass = 0.f;
+ if (GetRigidBody())
+ invmass = GetRigidBody()->getInvMass();
if (invmass)
return 1.f/invmass;
return 0.f;
}
+
+MT_Scalar KX_BulletPhysicsController::GetRadius()
+{
+ return MT_Scalar(CcdPhysicsController::GetRadius());
+}
+
MT_Vector3 KX_BulletPhysicsController::getReactionForce()
{
assert(0);
@@ -142,14 +175,37 @@ void KX_BulletPhysicsController::setRigidBody(bool rigid)
{
}
-void KX_BulletPhysicsController::SuspendDynamics()
+void KX_BulletPhysicsController::SuspendDynamics(bool ghost)
{
- GetRigidBody()->setActivationState(DISABLE_SIMULATION);
-
+ btRigidBody *body = GetRigidBody();
+ if (body && body->getActivationState() != DISABLE_SIMULATION)
+ {
+ btBroadphaseProxy* handle = body->getBroadphaseHandle();
+ m_savedCollisionFlags = body->getCollisionFlags();
+ m_savedMass = GetMass();
+ m_savedCollisionFilterGroup = handle->m_collisionFilterGroup;
+ m_savedCollisionFilterMask = handle->m_collisionFilterMask;
+ body->setActivationState(DISABLE_SIMULATION);
+ GetPhysicsEnvironment()->updateCcdPhysicsController(this,
+ 0.0,
+ btCollisionObject::CF_STATIC_OBJECT|((ghost)?btCollisionObject::CF_NO_CONTACT_RESPONSE:(m_savedCollisionFlags&btCollisionObject::CF_NO_CONTACT_RESPONSE)),
+ btBroadphaseProxy::StaticFilter,
+ btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::StaticFilter);
+ }
}
+
void KX_BulletPhysicsController::RestoreDynamics()
{
- GetRigidBody()->forceActivationState(ACTIVE_TAG);
+ btRigidBody *body = GetRigidBody();
+ if (body && body->getActivationState() == DISABLE_SIMULATION)
+ {
+ GetPhysicsEnvironment()->updateCcdPhysicsController(this,
+ m_savedMass,
+ m_savedCollisionFlags,
+ m_savedCollisionFilterGroup,
+ m_savedCollisionFilterMask);
+ GetRigidBody()->forceActivationState(ACTIVE_TAG);
+ }
}
SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode)
@@ -161,6 +217,9 @@ SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode)
//parentcontroller is here be able to avoid collisions between parent/child
PHY_IPhysicsController* parentctrl = NULL;
+ KX_BulletPhysicsController* parentKxCtrl = NULL;
+ CcdPhysicsController* ccdParent = NULL;
+
if (destnode != destnode->GetRootSGParent())
{
@@ -180,12 +239,15 @@ SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode)
KX_GameObject *clientgameobj = static_cast<KX_GameObject*>( (*childit)->GetSGClientObject());
if (clientgameobj)
{
- parentctrl = (KX_BulletPhysicsController*)clientgameobj->GetPhysicsController();
+ parentKxCtrl = (KX_BulletPhysicsController*)clientgameobj->GetPhysicsController();
+ parentctrl = parentKxCtrl;
+ ccdParent = parentKxCtrl;
}
}
}
}
+ physicsreplica->setParentCtrl(ccdParent);
physicsreplica->PostProcessReplica(motionstate,parentctrl);
physicsreplica->m_userdata = (PHY_IPhysicsController*)physicsreplica;
return physicsreplica;
@@ -196,18 +258,22 @@ SG_Controller* KX_BulletPhysicsController::GetReplica(class SG_Node* destnode)
void KX_BulletPhysicsController::SetSumoTransform(bool nondynaonly)
{
- GetRigidBody()->activate(true);
+ if (GetRigidBody())
+ GetRigidBody()->activate(true);
if (!m_bDyna)
{
- GetRigidBody()->setCollisionFlags(GetRigidBody()->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ GetCollisionObject()->setCollisionFlags(GetRigidBody()->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
} else
{
if (!nondynaonly)
{
btTransform worldTrans;
- GetRigidBody()->getMotionState()->getWorldTransform(worldTrans);
- GetRigidBody()->setCenterOfMassTransform(worldTrans);
+ if (GetRigidBody())
+ {
+ GetRigidBody()->getMotionState()->getWorldTransform(worldTrans);
+ GetRigidBody()->setCenterOfMassTransform(worldTrans);
+ }
/*
scaling?
diff --git a/source/gameengine/Ketsji/KX_BulletPhysicsController.h b/source/gameengine/Ketsji/KX_BulletPhysicsController.h
index 619ac42503f..cdcb82c87ca 100644
--- a/source/gameengine/Ketsji/KX_BulletPhysicsController.h
+++ b/source/gameengine/Ketsji/KX_BulletPhysicsController.h
@@ -7,6 +7,11 @@
class KX_BulletPhysicsController : public KX_IPhysicsController ,public CcdPhysicsController
{
+private:
+ int m_savedCollisionFlags;
+ short int m_savedCollisionFilterGroup;
+ short int m_savedCollisionFilterMask;
+ MT_Scalar m_savedMass;
public:
@@ -25,11 +30,12 @@ public:
virtual void ApplyTorque(const MT_Vector3& torque,bool local);
virtual void ApplyForce(const MT_Vector3& force,bool local);
virtual MT_Vector3 GetLinearVelocity();
+ virtual MT_Vector3 GetAngularVelocity();
virtual MT_Vector3 GetVelocity(const MT_Point3& pos);
virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local);
virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local);
virtual void getOrientation(MT_Quaternion& orn);
- virtual void setOrientation(const MT_Quaternion& orn);
+ virtual void setOrientation(const MT_Matrix3x3& orn);
virtual void setPosition(const MT_Point3& pos);
virtual void setScaling(const MT_Vector3& scaling);
virtual MT_Scalar GetMass();
@@ -38,14 +44,12 @@ public:
virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
- virtual void SuspendDynamics();
+ virtual void SuspendDynamics(bool ghost);
virtual void RestoreDynamics();
virtual SG_Controller* GetReplica(class SG_Node* destnode);
- void SetDyna(bool isDynamic) {
- m_bDyna = isDynamic;
- }
+ virtual MT_Scalar GetRadius();
virtual void SetSumoTransform(bool nondynaonly);
diff --git a/source/gameengine/Ketsji/KX_Camera.cpp b/source/gameengine/Ketsji/KX_Camera.cpp
index 86dbd06871f..53b3e348a36 100644
--- a/source/gameengine/Ketsji/KX_Camera.cpp
+++ b/source/gameengine/Ketsji/KX_Camera.cpp
@@ -29,7 +29,8 @@
*/
#include "KX_Camera.h"
-
+#include "KX_Scene.h"
+#include "KX_PythonInit.h"
#include "KX_Python.h"
#include "KX_PyMath.h"
#ifdef HAVE_CONFIG_H
@@ -54,7 +55,9 @@ KX_Camera::KX_Camera(void* sgReplicationInfo,
m_name = "cam";
m_projection_matrix.setIdentity();
m_modelview_matrix.setIdentity();
- SetProperty("camera",new CIntValue(1));
+ CValue* val = new CIntValue(1);
+ SetProperty("camera",val);
+ val->Release();
}
@@ -63,7 +66,22 @@ KX_Camera::~KX_Camera()
}
+CValue* KX_Camera::GetReplica()
+{
+ KX_Camera* replica = new KX_Camera(*this);
+
+ // this will copy properties and so on...
+ CValue::AddDataToReplica(replica);
+ ProcessReplica(replica);
+
+ return replica;
+}
+void KX_Camera::ProcessReplica(KX_Camera* replica)
+{
+ KX_GameObject::ProcessReplica(replica);
+}
+
MT_Transform KX_Camera::GetWorldToCamera() const
{
MT_Transform camtrans;
@@ -186,6 +204,11 @@ float KX_Camera::GetCameraFar() const
return m_camdata.m_clipend;
}
+float KX_Camera::GetFocalLength() const
+{
+ return m_camdata.m_focallength;
+}
+
RAS_CameraData* KX_Camera::GetCameraData()
@@ -388,6 +411,7 @@ PyMethodDef KX_Camera::Methods[] = {
KX_PYMETHODTABLE(KX_Camera, setProjectionMatrix),
KX_PYMETHODTABLE(KX_Camera, enableViewport),
KX_PYMETHODTABLE(KX_Camera, setViewport),
+ KX_PYMETHODTABLE(KX_Camera, setOnTop),
{NULL,NULL} //Sentinel
};
@@ -564,7 +588,7 @@ KX_PYMETHODDEF_DOC(KX_Camera, sphereInsideFrustum,
PyErr_SetString(PyExc_TypeError, "sphereInsideFrustum: Expected arguments: (center, radius)");
- Py_Return;
+ return NULL;
}
KX_PYMETHODDEF_DOC(KX_Camera, boxInsideFrustum,
@@ -742,6 +766,10 @@ KX_PYMETHODDEF_DOC(KX_Camera, enableViewport,
else
EnableViewport(false);
}
+ else {
+ return NULL;
+ }
+
Py_Return;
}
@@ -753,6 +781,20 @@ KX_PYMETHODDEF_DOC(KX_Camera, setViewport,
if (PyArg_ParseTuple(args,"iiii",&left, &bottom, &right, &top))
{
SetViewport(left, bottom, right, top);
+ } else {
+ return NULL;
}
Py_Return;
}
+
+KX_PYMETHODDEF_DOC(KX_Camera, setOnTop,
+"setOnTop()\n"
+"Sets this camera's viewport on top\n")
+{
+ class KX_Scene* scene;
+
+ scene = KX_GetActiveScene();
+ MT_assert(scene);
+ scene->SetCameraOnTop(this);
+ Py_Return;
+}
diff --git a/source/gameengine/Ketsji/KX_Camera.h b/source/gameengine/Ketsji/KX_Camera.h
index a276397c9c3..75d574cd697 100644
--- a/source/gameengine/Ketsji/KX_Camera.h
+++ b/source/gameengine/Ketsji/KX_Camera.h
@@ -131,6 +131,24 @@ public:
KX_Camera(void* sgReplicationInfo,SG_Callbacks callbacks,const RAS_CameraData& camdata, bool frustum_culling = true, PyTypeObject *T = &Type);
virtual ~KX_Camera();
+ /**
+ * Inherited from CValue -- return a new copy of this
+ * instance allocated on the heap. Ownership of the new
+ * object belongs with the caller.
+ */
+ virtual CValue*
+ GetReplica(
+ );
+
+ /**
+ * Inherited from CValue -- Makes sure any internal
+ * data owned by this class is deep copied. Called internally
+ */
+ virtual void
+ ProcessReplica(
+ KX_Camera* replica
+ );
+
MT_Transform GetWorldToCamera() const;
MT_Transform GetCameraToWorld() const;
@@ -166,12 +184,14 @@ public:
*/
const MT_Matrix4x4& GetModelviewMatrix() const;
- /** Gets the focal length. */
+ /** Gets the aperture. */
float GetLens() const;
/** Gets the near clip distance. */
float GetCameraNear() const;
/** Gets the far clip distance. */
float GetCameraFar() const;
+ /** Gets the focal length (only used for stereo rendering) */
+ float GetFocalLength() const;
/** Gets all camera data. */
RAS_CameraData* GetCameraData();
@@ -248,6 +268,7 @@ public:
KX_PYMETHOD_DOC(KX_Camera, enableViewport);
KX_PYMETHOD_DOC(KX_Camera, setViewport);
+ KX_PYMETHOD_DOC(KX_Camera, setOnTop);
virtual PyObject* _getattr(const STR_String& attr); /* lens, near, far, projection_matrix */
virtual int _setattr(const STR_String& attr, PyObject *pyvalue);
diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp
index cb3180cb05e..4d24e83843e 100644
--- a/source/gameengine/Ketsji/KX_CameraActuator.cpp
+++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp
@@ -35,6 +35,8 @@
#include <math.h>
#include "KX_GameObject.h"
+#include "PyObjectPlus.h"
+
STR_String KX_CameraActuator::X_AXIS_STRING = "x";
STR_String KX_CameraActuator::Y_AXIS_STRING = "y";
@@ -49,7 +51,7 @@ STR_String KX_CameraActuator::Y_AXIS_STRING = "y";
KX_CameraActuator::KX_CameraActuator(
SCA_IObject* gameobj,
- CValue *obj,
+ SCA_IObject *obj,
MT_Scalar hght,
MT_Scalar minhght,
MT_Scalar maxhght,
@@ -63,11 +65,14 @@ KX_CameraActuator::KX_CameraActuator(
m_maxHeight (maxhght),
m_x (xytog)
{
+ if (m_ob)
+ m_ob->RegisterActuator(this);
}
KX_CameraActuator::~KX_CameraActuator()
{
- //nothing to do
+ if (m_ob)
+ m_ob->UnregisterActuator(this);
}
CValue*
@@ -81,8 +86,35 @@ GetReplica(
return replica;
};
+void KX_CameraActuator::ProcessReplica()
+{
+ if (m_ob)
+ m_ob->RegisterActuator(this);
+ SCA_IActuator::ProcessReplica();
+}
+
+bool KX_CameraActuator::UnlinkObject(SCA_IObject* clientobj)
+{
+ if (clientobj == m_ob)
+ {
+ // this object is being deleted, we cannot continue to track it.
+ m_ob = NULL;
+ return true;
+ }
+ return false;
+}
+void KX_CameraActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
+{
+ void **h_obj = (*obj_map)[m_ob];
+ if (h_obj) {
+ if (m_ob)
+ m_ob->UnregisterActuator(this);
+ m_ob = (SCA_IObject*)(*h_obj);
+ m_ob->RegisterActuator(this);
+ }
+}
/* three functions copied from blender arith... don't know if there's an equivalent */
@@ -155,14 +187,25 @@ static void Kx_VecUpMat3(float *vec, float mat[][3], short axis)
mat[coz][0]= vec[0];
mat[coz][1]= vec[1];
mat[coz][2]= vec[2];
- Kx_Normalize((float *)mat[coz]);
+ if (Kx_Normalize((float *)mat[coz]) == 0.f) {
+ /* this is a very abnormal situation: the camera has reach the object center exactly
+ We will choose a completely arbitrary direction */
+ mat[coz][0] = 1.0f;
+ mat[coz][1] = 0.0f;
+ mat[coz][2] = 0.0f;
+ }
inp= mat[coz][2];
mat[coy][0]= - inp*mat[coz][0];
mat[coy][1]= - inp*mat[coz][1];
mat[coy][2]= 1.0 - inp*mat[coz][2];
- Kx_Normalize((float *)mat[coy]);
+ if (Kx_Normalize((float *)mat[coy]) == 0.f) {
+ /* the camera is vertical, chose the y axis arbitrary */
+ mat[coy][0] = 0.f;
+ mat[coy][1] = 1.f;
+ mat[coy][2] = 0.f;
+ }
Kx_Crossf(mat[cox], mat[coy], mat[coz]);
@@ -170,8 +213,14 @@ static void Kx_VecUpMat3(float *vec, float mat[][3], short axis)
bool KX_CameraActuator::Update(double curtime, bool frame)
{
- bool result = true;
+ /* wondering... is it really neccesary/desirable to suppress negative */
+ /* events here? */
+ bool bNegativeEvent = IsNegativeEvent();
+ RemoveAllEvents();
+ if (bNegativeEvent || !m_ob)
+ return false;
+
KX_GameObject *obj = (KX_GameObject*) GetParent();
MT_Point3 from = obj->NodeGetWorldPosition();
MT_Matrix3x3 frommat = obj->NodeGetWorldOrientation();
@@ -184,13 +233,6 @@ bool KX_CameraActuator::Update(double curtime, bool frame)
float mindistsq, maxdistsq, distsq;
float mat[3][3];
- /* wondering... is it really neccesary/desirable to suppress negative */
- /* events here? */
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (bNegativeEvent) return false;
-
/* The rules: */
/* CONSTRAINT 1: not implemented */
/* CONSTRAINT 2: can camera see actor? */
@@ -304,7 +346,7 @@ bool KX_CameraActuator::Update(double curtime, bool frame)
actormat[2][0]= mat[0][2]; actormat[2][1]= mat[1][2]; actormat[2][2]= mat[2][2];
obj->NodeSetLocalOrientation(actormat);
- return result;
+ return true;
}
CValue *KX_CameraActuator::findObject(char *obName)
@@ -355,16 +397,16 @@ PyParentObject KX_CameraActuator::Parents[] = {
};
PyMethodDef KX_CameraActuator::Methods[] = {
- {"setObject",(PyCFunction) KX_CameraActuator::sPySetObject, METH_VARARGS, SetObject_doc},
- {"getObject",(PyCFunction) KX_CameraActuator::sPyGetObject, METH_NOARGS, GetObject_doc},
- {"setMin" ,(PyCFunction) KX_CameraActuator::sPySetMin, METH_VARARGS, SetMin_doc},
- {"getMin" ,(PyCFunction) KX_CameraActuator::sPyGetMin, METH_NOARGS, GetMin_doc},
- {"setMax" ,(PyCFunction) KX_CameraActuator::sPySetMax, METH_VARARGS, SetMax_doc},
- {"getMax" ,(PyCFunction) KX_CameraActuator::sPyGetMax, METH_NOARGS, GetMax_doc},
- {"setHeight",(PyCFunction) KX_CameraActuator::sPySetHeight, METH_VARARGS, SetHeight_doc},
- {"getHeight",(PyCFunction) KX_CameraActuator::sPyGetHeight, METH_NOARGS, GetHeight_doc},
- {"setXY" ,(PyCFunction) KX_CameraActuator::sPySetXY, METH_VARARGS, SetXY_doc},
- {"getXY" ,(PyCFunction) KX_CameraActuator::sPyGetXY, METH_VARARGS, GetXY_doc},
+ {"setObject",(PyCFunction) KX_CameraActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc},
+ {"getObject",(PyCFunction) KX_CameraActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc},
+ {"setMin" ,(PyCFunction) KX_CameraActuator::sPySetMin, METH_VARARGS, (PY_METHODCHAR)SetMin_doc},
+ {"getMin" ,(PyCFunction) KX_CameraActuator::sPyGetMin, METH_NOARGS, (PY_METHODCHAR)GetMin_doc},
+ {"setMax" ,(PyCFunction) KX_CameraActuator::sPySetMax, METH_VARARGS, (PY_METHODCHAR)SetMax_doc},
+ {"getMax" ,(PyCFunction) KX_CameraActuator::sPyGetMax, METH_NOARGS, (PY_METHODCHAR)GetMax_doc},
+ {"setHeight",(PyCFunction) KX_CameraActuator::sPySetHeight, METH_VARARGS, (PY_METHODCHAR)SetHeight_doc},
+ {"getHeight",(PyCFunction) KX_CameraActuator::sPyGetHeight, METH_NOARGS, (PY_METHODCHAR)GetHeight_doc},
+ {"setXY" ,(PyCFunction) KX_CameraActuator::sPySetXY, METH_VARARGS, (PY_METHODCHAR)SetXY_doc},
+ {"getXY" ,(PyCFunction) KX_CameraActuator::sPyGetXY, METH_VARARGS, (PY_METHODCHAR)GetXY_doc},
{NULL,NULL,NULL,NULL} //Sentinel
};
@@ -372,48 +414,48 @@ PyObject* KX_CameraActuator::_getattr(const STR_String& attr) {
_getattr_up(SCA_IActuator);
}
/* get obj ---------------------------------------------------------- */
-char KX_CameraActuator::GetObject_doc[] =
-"getObject\n"
+const char KX_CameraActuator::GetObject_doc[] =
+"getObject(name_only = 1)\n"
+"name_only - optional arg, when true will return the KX_GameObject rather then its name\n"
"\tReturns the object this sensor reacts to.\n";
-PyObject* KX_CameraActuator::PyGetObject(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_CameraActuator::PyGetObject(PyObject* self, PyObject* args)
{
- return PyString_FromString(m_ob->GetName());
+ int ret_name_only = 1;
+ if (!PyArg_ParseTuple(args, "|i", &ret_name_only))
+ return NULL;
+
+ if (!m_ob)
+ Py_RETURN_NONE;
+
+ if (ret_name_only)
+ return PyString_FromString(m_ob->GetName());
+ else
+ return m_ob->AddRef();
}
/* set obj ---------------------------------------------------------- */
-char KX_CameraActuator::SetObject_doc[] =
-"setObject\n"
+const char KX_CameraActuator::SetObject_doc[] =
+"setObject(object)\n"
+"\t- object: KX_GameObject, string or None\n"
"\tSets the object this sensor reacts to.\n";
-PyObject* KX_CameraActuator::PySetObject(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_CameraActuator::PySetObject(PyObject* self, PyObject* value)
{
-
- PyObject* gameobj;
- if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj))
- {
- m_ob = (CValue*)gameobj;
- Py_Return;
- }
- PyErr_Clear();
+ KX_GameObject *gameobj;
- char* objectname;
- if (PyArg_ParseTuple(args, "s", &objectname))
- {
- CValue *object = (CValue*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname));
- if(object)
- {
- m_ob = object;
- Py_Return;
- }
- }
+ if (!ConvertPythonToGameObject(value, &gameobj, true))
+ return NULL; // ConvertPythonToGameObject sets the error
- return NULL;
+ if (m_ob != NULL)
+ m_ob->UnregisterActuator(this);
+
+ m_ob = (SCA_IObject*)gameobj;
+ if (m_ob)
+ m_ob->RegisterActuator(this);
+
+ Py_RETURN_NONE;
}
/* get min ---------------------------------------------------------- */
-char KX_CameraActuator::GetMin_doc[] =
+const char KX_CameraActuator::GetMin_doc[] =
"getMin\n"
"\tReturns the minimum value set in the Min: field.\n";
PyObject* KX_CameraActuator::PyGetMin(PyObject* self,
@@ -423,7 +465,7 @@ PyObject* KX_CameraActuator::PyGetMin(PyObject* self,
return PyFloat_FromDouble(m_minHeight);
}
/* set min ---------------------------------------------------------- */
-char KX_CameraActuator::SetMin_doc[] =
+const char KX_CameraActuator::SetMin_doc[] =
"setMin\n"
"\tSets the minimum value.\n";
PyObject* KX_CameraActuator::PySetMin(PyObject* self,
@@ -439,7 +481,7 @@ PyObject* KX_CameraActuator::PySetMin(PyObject* self,
return NULL;
}
/* get min ---------------------------------------------------------- */
-char KX_CameraActuator::GetMax_doc[] =
+const char KX_CameraActuator::GetMax_doc[] =
"getMax\n"
"\tReturns the maximum value set in the Max: field.\n";
PyObject* KX_CameraActuator::PyGetMax(PyObject* self,
@@ -449,7 +491,7 @@ PyObject* KX_CameraActuator::PyGetMax(PyObject* self,
return PyFloat_FromDouble(m_maxHeight);
}
/* set min ---------------------------------------------------------- */
-char KX_CameraActuator::SetMax_doc[] =
+const char KX_CameraActuator::SetMax_doc[] =
"setMax\n"
"\tSets the maximum value.\n";
PyObject* KX_CameraActuator::PySetMax(PyObject* self,
@@ -465,7 +507,7 @@ PyObject* KX_CameraActuator::PySetMax(PyObject* self,
return NULL;
}
/* get height ---------------------------------------------------------- */
-char KX_CameraActuator::GetHeight_doc[] =
+const char KX_CameraActuator::GetHeight_doc[] =
"getHeight\n"
"\tReturns the height value set in the height: field.\n";
PyObject* KX_CameraActuator::PyGetHeight(PyObject* self,
@@ -475,7 +517,7 @@ PyObject* KX_CameraActuator::PyGetHeight(PyObject* self,
return PyFloat_FromDouble(m_height);
}
/* set height ---------------------------------------------------------- */
-char KX_CameraActuator::SetHeight_doc[] =
+const char KX_CameraActuator::SetHeight_doc[] =
"setHeight\n"
"\tSets the height value.\n";
PyObject* KX_CameraActuator::PySetHeight(PyObject* self,
@@ -491,7 +533,7 @@ PyObject* KX_CameraActuator::PySetHeight(PyObject* self,
return NULL;
}
/* set XY ---------------------------------------------------------- */
-char KX_CameraActuator::SetXY_doc[] =
+const char KX_CameraActuator::SetXY_doc[] =
"setXY\n"
"\tSets axis the camera tries to get behind.\n"
"\t1=x, 0=y\n";
@@ -509,7 +551,7 @@ PyObject* KX_CameraActuator::PySetXY(PyObject* self,
}
/* get XY -------------------------------------------------------------*/
-char KX_CameraActuator::GetXY_doc[] =
+const char KX_CameraActuator::GetXY_doc[] =
"getXY\n"
"\tGets the axis the camera tries to get behind.\n"
"\tTrue = X, False = Y\n";
diff --git a/source/gameengine/Ketsji/KX_CameraActuator.h b/source/gameengine/Ketsji/KX_CameraActuator.h
index eb007e403ec..d53d12b3b82 100644
--- a/source/gameengine/Ketsji/KX_CameraActuator.h
+++ b/source/gameengine/Ketsji/KX_CameraActuator.h
@@ -49,7 +49,7 @@ class KX_CameraActuator : public SCA_IActuator
Py_Header;
private :
/** Object that will be tracked. */
- CValue *m_ob;
+ SCA_IObject *m_ob;
/** height (float), */
//const MT_Scalar m_height;
@@ -87,7 +87,7 @@ private :
SCA_IObject *gameobj,
//const CValue *ob,
- CValue *ob,
+ SCA_IObject *ob,
MT_Scalar hght,
MT_Scalar minhght,
MT_Scalar maxhght,
@@ -103,6 +103,7 @@ private :
/** Methods Inherited from CValue */
CValue* GetReplica();
+ virtual void ProcessReplica();
/** Methods inherited from SCA_IActuator */
@@ -110,7 +111,10 @@ private :
double curtime,
bool frame
);
+ virtual bool UnlinkObject(SCA_IObject* clientobj);
+ /** Methods inherited from SCA_ILogicBrick */
+ virtual void Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map);
/* --------------------------------------------------------------------- */
/* Python interface ---------------------------------------------------- */
@@ -119,9 +123,9 @@ private :
virtual PyObject* _getattr(const STR_String& attr);
/* set object to look at */
- KX_PYMETHOD_DOC(KX_CameraActuator,SetObject);
+ KX_PYMETHOD_DOC_O(KX_CameraActuator,SetObject);
/* get current object */
- KX_PYMETHOD_DOC(KX_CameraActuator,GetObject);
+ KX_PYMETHOD_DOC_VARARGS(KX_CameraActuator,GetObject);
KX_PYMETHOD_DOC(KX_CameraActuator,SetMin);
KX_PYMETHOD_DOC(KX_CameraActuator,GetMin);
KX_PYMETHOD_DOC(KX_CameraActuator,SetMax);
diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
index bd843d97199..76357e9c58f 100644
--- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp
@@ -35,6 +35,7 @@
#include "MT_Point3.h"
#include "MT_Matrix3x3.h"
#include "KX_GameObject.h"
+#include "KX_RayCast.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -45,35 +46,60 @@
/* ------------------------------------------------------------------------- */
KX_ConstraintActuator::KX_ConstraintActuator(SCA_IObject *gameobj,
- int dampTime,
+ int posDampTime,
+ int rotDampTime,
float minBound,
float maxBound,
+ float refDir[3],
int locrotxyz,
- PyTypeObject* T)
- : SCA_IActuator(gameobj, T)
+ int time,
+ int option,
+ char *property,
+ PyTypeObject* T) :
+ m_refDirection(refDir),
+ m_currentTime(0),
+ SCA_IActuator(gameobj, T)
{
- m_dampTime = dampTime;
+ m_posDampTime = posDampTime;
+ m_rotDampTime = rotDampTime;
m_locrot = locrotxyz;
+ m_option = option;
+ m_activeTime = time;
+ if (property) {
+ strncpy(m_property, property, sizeof(m_property));
+ m_property[sizeof(m_property)-1] = 0;
+ } else {
+ m_property[0] = 0;
+ }
/* The units of bounds are determined by the type of constraint. To */
/* make the constraint application easier and more transparent later on, */
/* I think converting the bounds to the applicable domain makes more */
/* sense. */
switch (m_locrot) {
- case KX_ACT_CONSTRAINT_LOCX:
- case KX_ACT_CONSTRAINT_LOCY:
- case KX_ACT_CONSTRAINT_LOCZ:
+ case KX_ACT_CONSTRAINT_ORIX:
+ case KX_ACT_CONSTRAINT_ORIY:
+ case KX_ACT_CONSTRAINT_ORIZ:
+ {
+ MT_Scalar len = m_refDirection.length();
+ if (MT_fuzzyZero(len)) {
+ // missing a valid direction
+ std::cout << "WARNING: Constraint actuator " << GetName() << ": There is no valid reference direction!" << std::endl;
+ m_locrot = KX_ACT_CONSTRAINT_NODEF;
+ } else {
+ m_refDirection /= len;
+ }
+ m_minimumBound = cos(minBound);
+ m_maximumBound = cos(maxBound);
+ m_minimumSine = sin(minBound);
+ m_maximumSine = sin(maxBound);
+ }
+ break;
+ default:
m_minimumBound = minBound;
m_maximumBound = maxBound;
+ m_minimumSine = 0.f;
+ m_maximumSine = 0.f;
break;
- case KX_ACT_CONSTRAINT_ROTX:
- case KX_ACT_CONSTRAINT_ROTY:
- case KX_ACT_CONSTRAINT_ROTZ:
- /* The user interface asks for degrees, we are radian. */
- m_minimumBound = MT_radians(minBound);
- m_maximumBound = MT_radians(maxBound);
- break;
- default:
- ; /* error */
}
} /* End of constructor */
@@ -83,77 +109,426 @@ KX_ConstraintActuator::~KX_ConstraintActuator()
// there's nothing to be done here, really....
} /* end of destructor */
-bool KX_ConstraintActuator::Update(double curtime, bool frame)
+bool KX_ConstraintActuator::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data)
{
- bool result = false;
- bool bNegativeEvent = IsNegativeEvent();
- RemoveAllEvents();
-
- if (bNegativeEvent)
- return false; // do nothing on negative events
-
- /* Constraint clamps the values to the specified range, with a sort of */
- /* low-pass filtered time response, if the damp time is unequal to 0. */
-
- /* Having to retrieve location/rotation and setting it afterwards may not */
- /* be efficient enough... Somthing to look at later. */
- KX_GameObject *parent = (KX_GameObject*) GetParent();
- MT_Point3 position = parent->NodeGetWorldPosition();
- MT_Matrix3x3 rotation = parent->NodeGetWorldOrientation();
-// MT_Vector3 eulerrot = rotation.getEuler();
-
- switch (m_locrot) {
- case KX_ACT_CONSTRAINT_LOCX:
- Clamp(position[0], m_minimumBound, m_maximumBound);
- result = true;
- break;
- case KX_ACT_CONSTRAINT_LOCY:
- Clamp(position[1], m_minimumBound, m_maximumBound);
- result = true;
- break;
- case KX_ACT_CONSTRAINT_LOCZ:
- Clamp(position[2], m_minimumBound, m_maximumBound);
- result = true;
- break;
+ m_hitObject = client->m_gameobject;
-// case KX_ACT_CONSTRAINT_ROTX:
-// /* The angles are Euler angles (I think that's what they are called) */
-// /* but we need to convert from/to the MT_Matrix3x3. */
-// Clamp(eulerrot[0], m_minimumBound, m_maximumBound);
-// break;
-// case KX_ACT_CONSTRAINT_ROTY:
-// Clamp(eulerrot[1], m_minimumBound, m_maximumBound);
-// break;
-// case KX_ACT_CONSTRAINT_ROTZ:
-// Clamp(eulerrot[2], m_minimumBound, m_maximumBound);
-// break;
-// default:
-// ; /* error */
- }
+ bool bFound = false;
- /* Will be replaced by a filtered clamp. */
-
+ if (m_property[0] == 0)
+ {
+ bFound = true;
+ }
+ else
+ {
+ if (m_option & KX_ACT_CONSTRAINT_MATERIAL)
+ {
+ if (client->m_auxilary_info)
+ {
+ bFound = !strcmp(m_property, ((char*)client->m_auxilary_info));
+ }
+ }
+ else
+ {
+ bFound = m_hitObject->GetProperty(m_property) != NULL;
+ }
+ }
+ // update the hit status
+ result->m_hitFound = bFound;
+ // stop looking
+ return true;
+}
- switch (m_locrot) {
- case KX_ACT_CONSTRAINT_LOCX:
- case KX_ACT_CONSTRAINT_LOCY:
- case KX_ACT_CONSTRAINT_LOCZ:
- parent->NodeSetLocalPosition(position);
- break;
+/* 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_ConstraintActuator::NeedRayCast(KX_ClientObjectInfo* client)
+{
+ if (client->m_type > KX_ClientObjectInfo::ACTOR)
+ {
+ // 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);
+ return false;
+ }
+ // no X-Ray function yet
+ return true;
+}
+bool KX_ConstraintActuator::Update(double curtime, bool frame)
+{
-// case KX_ACT_CONSTRAINT_ROTX:
-// case KX_ACT_CONSTRAINT_ROTY:
-// case KX_ACT_CONSTRAINT_ROTZ:
-// rotation.setEuler(eulerrot);
-// parent->NodeSetLocalOrientation(rotation);
- break;
+ bool result = false;
+ bool bNegativeEvent = IsNegativeEvent();
+ RemoveAllEvents();
- default:
- ; /* error */
+ if (!bNegativeEvent) {
+ /* Constraint clamps the values to the specified range, with a sort of */
+ /* low-pass filtered time response, if the damp time is unequal to 0. */
+
+ /* Having to retrieve location/rotation and setting it afterwards may not */
+ /* be efficient enough... Somthing to look at later. */
+ KX_GameObject *obj = (KX_GameObject*) GetParent();
+ MT_Point3 position = obj->NodeGetWorldPosition();
+ MT_Point3 newposition;
+ MT_Vector3 normal, direction, refDirection;
+ MT_Matrix3x3 rotation = obj->NodeGetWorldOrientation();
+ MT_Scalar filter, newdistance, cosangle;
+ int axis, sign;
+
+ if (m_posDampTime) {
+ filter = m_posDampTime/(1.0+m_posDampTime);
+ } else {
+ filter = 0.0;
+ }
+ switch (m_locrot) {
+ case KX_ACT_CONSTRAINT_ORIX:
+ case KX_ACT_CONSTRAINT_ORIY:
+ case KX_ACT_CONSTRAINT_ORIZ:
+ switch (m_locrot) {
+ case KX_ACT_CONSTRAINT_ORIX:
+ direction[0] = rotation[0][0];
+ direction[1] = rotation[1][0];
+ direction[2] = rotation[2][0];
+ axis = 0;
+ break;
+ case KX_ACT_CONSTRAINT_ORIY:
+ direction[0] = rotation[0][1];
+ direction[1] = rotation[1][1];
+ direction[2] = rotation[2][1];
+ axis = 1;
+ break;
+ default:
+ direction[0] = rotation[0][2];
+ direction[1] = rotation[1][2];
+ direction[2] = rotation[2][2];
+ axis = 2;
+ break;
+ }
+ if ((m_maximumBound < (1.0f-FLT_EPSILON)) || (m_minimumBound < (1.0f-FLT_EPSILON))) {
+ // reference direction needs to be evaluated
+ // 1. get the cosine between current direction and target
+ cosangle = direction.dot(m_refDirection);
+ if (cosangle >= (m_maximumBound-FLT_EPSILON) && cosangle <= (m_minimumBound+FLT_EPSILON)) {
+ // no change to do
+ result = true;
+ goto CHECK_TIME;
+ }
+ // 2. define a new reference direction
+ // compute local axis with reference direction as X and
+ // Y in direction X refDirection plane
+ MT_Vector3 zaxis = m_refDirection.cross(direction);
+ if (MT_fuzzyZero2(zaxis.length2())) {
+ // direction and refDirection are identical,
+ // choose any other direction to define plane
+ if (direction[0] < 0.9999)
+ zaxis = m_refDirection.cross(MT_Vector3(1.0,0.0,0.0));
+ else
+ zaxis = m_refDirection.cross(MT_Vector3(0.0,1.0,0.0));
+ }
+ MT_Vector3 yaxis = zaxis.cross(m_refDirection);
+ yaxis.normalize();
+ if (cosangle > m_minimumBound) {
+ // angle is too close to reference direction,
+ // choose a new reference that is exactly at minimum angle
+ refDirection = m_minimumBound * m_refDirection + m_minimumSine * yaxis;
+ } else {
+ // angle is too large, choose new reference direction at maximum angle
+ refDirection = m_maximumBound * m_refDirection + m_maximumSine * yaxis;
+ }
+ } else {
+ refDirection = m_refDirection;
+ }
+ // apply damping on the direction
+ direction = filter*direction + (1.0-filter)*refDirection;
+ obj->AlignAxisToVect(direction, axis);
+ result = true;
+ goto CHECK_TIME;
+ case KX_ACT_CONSTRAINT_DIRPX:
+ case KX_ACT_CONSTRAINT_DIRPY:
+ case KX_ACT_CONSTRAINT_DIRPZ:
+ case KX_ACT_CONSTRAINT_DIRNX:
+ case KX_ACT_CONSTRAINT_DIRNY:
+ case KX_ACT_CONSTRAINT_DIRNZ:
+ switch (m_locrot) {
+ case KX_ACT_CONSTRAINT_DIRPX:
+ normal[0] = rotation[0][0];
+ normal[1] = rotation[1][0];
+ normal[2] = rotation[2][0];
+ axis = 0; // axis according to KX_GameObject::AlignAxisToVect()
+ sign = 0; // X axis will be parrallel to direction of ray
+ break;
+ case KX_ACT_CONSTRAINT_DIRPY:
+ normal[0] = rotation[0][1];
+ normal[1] = rotation[1][1];
+ normal[2] = rotation[2][1];
+ axis = 1;
+ sign = 0;
+ break;
+ case KX_ACT_CONSTRAINT_DIRPZ:
+ normal[0] = rotation[0][2];
+ normal[1] = rotation[1][2];
+ normal[2] = rotation[2][2];
+ axis = 2;
+ sign = 0;
+ break;
+ case KX_ACT_CONSTRAINT_DIRNX:
+ normal[0] = -rotation[0][0];
+ normal[1] = -rotation[1][0];
+ normal[2] = -rotation[2][0];
+ axis = 0;
+ sign = 1;
+ break;
+ case KX_ACT_CONSTRAINT_DIRNY:
+ normal[0] = -rotation[0][1];
+ normal[1] = -rotation[1][1];
+ normal[2] = -rotation[2][1];
+ axis = 1;
+ sign = 1;
+ break;
+ case KX_ACT_CONSTRAINT_DIRNZ:
+ normal[0] = -rotation[0][2];
+ normal[1] = -rotation[1][2];
+ normal[2] = -rotation[2][2];
+ axis = 2;
+ sign = 1;
+ break;
+ }
+ normal.normalize();
+ if (m_option & KX_ACT_CONSTRAINT_LOCAL) {
+ // direction of the ray is along the local axis
+ direction = normal;
+ } else {
+ switch (m_locrot) {
+ case KX_ACT_CONSTRAINT_DIRPX:
+ direction = MT_Vector3(1.0,0.0,0.0);
+ break;
+ case KX_ACT_CONSTRAINT_DIRPY:
+ direction = MT_Vector3(0.0,1.0,0.0);
+ break;
+ case KX_ACT_CONSTRAINT_DIRPZ:
+ direction = MT_Vector3(0.0,0.0,1.0);
+ break;
+ case KX_ACT_CONSTRAINT_DIRNX:
+ direction = MT_Vector3(-1.0,0.0,0.0);
+ break;
+ case KX_ACT_CONSTRAINT_DIRNY:
+ direction = MT_Vector3(0.0,-1.0,0.0);
+ break;
+ case KX_ACT_CONSTRAINT_DIRNZ:
+ direction = MT_Vector3(0.0,0.0,-1.0);
+ break;
+ }
+ }
+ {
+ MT_Point3 topoint = position + (m_maximumBound) * direction;
+ PHY_IPhysicsEnvironment* pe = obj->GetPhysicsEnvironment();
+ KX_IPhysicsController *spc = obj->GetPhysicsController();
+
+ if (!pe) {
+ std::cout << "WARNING: Constraint actuator " << GetName() << ": There is no physics environment!" << std::endl;
+ goto CHECK_TIME;
+ }
+ if (!spc) {
+ // the object is not physical, we probably want to avoid hitting its own parent
+ KX_GameObject *parent = obj->GetParent();
+ if (parent) {
+ spc = parent->GetPhysicsController();
+ parent->Release();
+ }
+ }
+ KX_RayCast::Callback<KX_ConstraintActuator> callback(this,spc);
+ result = KX_RayCast::RayTest(pe, position, topoint, callback);
+ if (result) {
+ MT_Vector3 newnormal = callback.m_hitNormal;
+ // compute new position & orientation
+ if ((m_option & (KX_ACT_CONSTRAINT_NORMAL|KX_ACT_CONSTRAINT_DISTANCE)) == 0) {
+ // if none option is set, the actuator does nothing but detect ray
+ // (works like a sensor)
+ goto CHECK_TIME;
+ }
+ if (m_option & KX_ACT_CONSTRAINT_NORMAL) {
+ MT_Scalar rotFilter;
+ // apply damping on the direction
+ if (m_rotDampTime) {
+ rotFilter = m_rotDampTime/(1.0+m_rotDampTime);
+ } else {
+ rotFilter = filter;
+ }
+ newnormal = rotFilter*normal - (1.0-rotFilter)*newnormal;
+ obj->AlignAxisToVect((sign)?-newnormal:newnormal, axis);
+ if (m_option & KX_ACT_CONSTRAINT_LOCAL) {
+ direction = newnormal;
+ direction.normalize();
+ }
+ }
+ if (m_option & KX_ACT_CONSTRAINT_DISTANCE) {
+ if (m_posDampTime) {
+ newdistance = filter*(position-callback.m_hitPoint).length()+(1.0-filter)*m_minimumBound;
+ } else {
+ newdistance = m_minimumBound;
+ }
+ // logically we should cancel the speed along the ray direction as we set the
+ // position along that axis
+ spc = obj->GetPhysicsController();
+ if (spc && spc->IsDyna()) {
+ MT_Vector3 linV = spc->GetLinearVelocity();
+ // cancel the projection along the ray direction
+ MT_Scalar fallspeed = linV.dot(direction);
+ if (!MT_fuzzyZero(fallspeed))
+ spc->SetLinearVelocity(linV-fallspeed*direction,false);
+ }
+ } else {
+ newdistance = (position-callback.m_hitPoint).length();
+ }
+ newposition = callback.m_hitPoint-newdistance*direction;
+ } else if (m_option & KX_ACT_CONSTRAINT_PERMANENT) {
+ // no contact but still keep running
+ result = true;
+ goto CHECK_TIME;
+ }
+ }
+ break;
+ case KX_ACT_CONSTRAINT_FHPX:
+ case KX_ACT_CONSTRAINT_FHPY:
+ case KX_ACT_CONSTRAINT_FHPZ:
+ case KX_ACT_CONSTRAINT_FHNX:
+ case KX_ACT_CONSTRAINT_FHNY:
+ case KX_ACT_CONSTRAINT_FHNZ:
+ switch (m_locrot) {
+ case KX_ACT_CONSTRAINT_FHPX:
+ normal[0] = -rotation[0][0];
+ normal[1] = -rotation[1][0];
+ normal[2] = -rotation[2][0];
+ direction = MT_Vector3(1.0,0.0,0.0);
+ break;
+ case KX_ACT_CONSTRAINT_FHPY:
+ normal[0] = -rotation[0][1];
+ normal[1] = -rotation[1][1];
+ normal[2] = -rotation[2][1];
+ direction = MT_Vector3(0.0,1.0,0.0);
+ break;
+ case KX_ACT_CONSTRAINT_FHPZ:
+ normal[0] = -rotation[0][2];
+ normal[1] = -rotation[1][2];
+ normal[2] = -rotation[2][2];
+ direction = MT_Vector3(0.0,0.0,1.0);
+ break;
+ case KX_ACT_CONSTRAINT_FHNX:
+ normal[0] = rotation[0][0];
+ normal[1] = rotation[1][0];
+ normal[2] = rotation[2][0];
+ direction = MT_Vector3(-1.0,0.0,0.0);
+ break;
+ case KX_ACT_CONSTRAINT_FHNY:
+ normal[0] = rotation[0][1];
+ normal[1] = rotation[1][1];
+ normal[2] = rotation[2][1];
+ direction = MT_Vector3(0.0,-1.0,0.0);
+ break;
+ case KX_ACT_CONSTRAINT_FHNZ:
+ normal[0] = rotation[0][2];
+ normal[1] = rotation[1][2];
+ normal[2] = rotation[2][2];
+ direction = MT_Vector3(0.0,0.0,-1.0);
+ break;
+ }
+ normal.normalize();
+ {
+ PHY_IPhysicsEnvironment* pe = obj->GetPhysicsEnvironment();
+ KX_IPhysicsController *spc = obj->GetPhysicsController();
+
+ if (!pe) {
+ std::cout << "WARNING: Constraint actuator " << GetName() << ": There is no physics environment!" << std::endl;
+ goto CHECK_TIME;
+ }
+ if (!spc || !spc->IsDyna()) {
+ // the object is not dynamic, it won't support setting speed
+ goto CHECK_TIME;
+ }
+ m_hitObject = NULL;
+ // distance of Fh area is stored in m_minimum
+ MT_Point3 topoint = position + (m_minimumBound+spc->GetRadius()) * direction;
+ KX_RayCast::Callback<KX_ConstraintActuator> callback(this,spc);
+ result = KX_RayCast::RayTest(pe, position, topoint, callback);
+ // we expect a hit object
+ if (!m_hitObject)
+ result = false;
+ if (result)
+ {
+ MT_Vector3 newnormal = callback.m_hitNormal;
+ // compute new position & orientation
+ MT_Scalar distance = (callback.m_hitPoint-position).length()-spc->GetRadius();
+ // estimate the velocity of the hit point
+ MT_Point3 relativeHitPoint;
+ relativeHitPoint = (callback.m_hitPoint-m_hitObject->NodeGetWorldPosition());
+ MT_Vector3 velocityHitPoint = m_hitObject->GetVelocity(relativeHitPoint);
+ MT_Vector3 relativeVelocity = spc->GetLinearVelocity() - velocityHitPoint;
+ MT_Scalar relativeVelocityRay = direction.dot(relativeVelocity);
+ MT_Scalar springExtent = 1.0 - distance/m_minimumBound;
+ // Fh force is stored in m_maximum
+ MT_Scalar springForce = springExtent * m_maximumBound;
+ // damping is stored in m_refDirection [0] = damping, [1] = rot damping
+ MT_Scalar springDamp = relativeVelocityRay * m_refDirection[0];
+ MT_Vector3 newVelocity = spc->GetLinearVelocity()-(springForce+springDamp)*direction;
+ if (m_option & KX_ACT_CONSTRAINT_NORMAL)
+ {
+ newVelocity+=(springForce+springDamp)*(newnormal-newnormal.dot(direction)*direction);
+ }
+ spc->SetLinearVelocity(newVelocity, false);
+ if (m_option & KX_ACT_CONSTRAINT_DOROTFH)
+ {
+ MT_Vector3 angSpring = (normal.cross(newnormal))*m_maximumBound;
+ MT_Vector3 angVelocity = spc->GetAngularVelocity();
+ // remove component that is parallel to normal
+ angVelocity -= angVelocity.dot(newnormal)*newnormal;
+ MT_Vector3 angDamp = angVelocity * ((m_refDirection[1]>MT_EPSILON)?m_refDirection[1]:m_refDirection[0]);
+ spc->SetAngularVelocity(spc->GetAngularVelocity()+(angSpring-angDamp), false);
+ }
+ } else if (m_option & KX_ACT_CONSTRAINT_PERMANENT) {
+ // no contact but still keep running
+ result = true;
+ }
+ // don't set the position with this constraint
+ goto CHECK_TIME;
+ }
+ break;
+ case KX_ACT_CONSTRAINT_LOCX:
+ case KX_ACT_CONSTRAINT_LOCY:
+ case KX_ACT_CONSTRAINT_LOCZ:
+ newposition = position = obj->GetSGNode()->GetLocalPosition();
+ switch (m_locrot) {
+ case KX_ACT_CONSTRAINT_LOCX:
+ Clamp(newposition[0], m_minimumBound, m_maximumBound);
+ break;
+ case KX_ACT_CONSTRAINT_LOCY:
+ Clamp(newposition[1], m_minimumBound, m_maximumBound);
+ break;
+ case KX_ACT_CONSTRAINT_LOCZ:
+ Clamp(newposition[2], m_minimumBound, m_maximumBound);
+ break;
+ }
+ result = true;
+ if (m_posDampTime) {
+ newposition = filter*position + (1.0-filter)*newposition;
+ }
+ obj->NodeSetLocalPosition(newposition);
+ goto CHECK_TIME;
+ }
+ if (result) {
+ // set the new position but take into account parent if any
+ obj->NodeSetWorldPosition(newposition);
+ }
+ CHECK_TIME:
+ if (result && m_activeTime > 0 ) {
+ if (++m_currentTime >= m_activeTime)
+ result = false;
+ }
+ }
+ if (!result) {
+ m_currentTime = 0;
}
-
return result;
} /* end of KX_ConstraintActuator::Update(double curtime,double deltatime) */
@@ -212,14 +587,28 @@ PyParentObject KX_ConstraintActuator::Parents[] = {
};
PyMethodDef KX_ConstraintActuator::Methods[] = {
- {"setDamp", (PyCFunction) KX_ConstraintActuator::sPySetDamp, METH_VARARGS, SetDamp_doc},
- {"getDamp", (PyCFunction) KX_ConstraintActuator::sPyGetDamp, METH_VARARGS, GetDamp_doc},
- {"setMin", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, SetMin_doc},
- {"getMin", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_VARARGS, GetMin_doc},
- {"setMax", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, SetMax_doc},
- {"getMax", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_VARARGS, GetMax_doc},
- {"setLimit", (PyCFunction) KX_ConstraintActuator::sPySetLimit, METH_VARARGS, SetLimit_doc},
- {"getLimit", (PyCFunction) KX_ConstraintActuator::sPyGetLimit, METH_VARARGS, GetLimit_doc},
+ {"setDamp", (PyCFunction) KX_ConstraintActuator::sPySetDamp, METH_VARARGS, (PY_METHODCHAR)SetDamp_doc},
+ {"getDamp", (PyCFunction) KX_ConstraintActuator::sPyGetDamp, METH_NOARGS, (PY_METHODCHAR)GetDamp_doc},
+ {"setRotDamp", (PyCFunction) KX_ConstraintActuator::sPySetRotDamp, METH_VARARGS, (PY_METHODCHAR)SetRotDamp_doc},
+ {"getRotDamp", (PyCFunction) KX_ConstraintActuator::sPyGetRotDamp, METH_NOARGS, (PY_METHODCHAR)GetRotDamp_doc},
+ {"setDirection", (PyCFunction) KX_ConstraintActuator::sPySetDirection, METH_VARARGS, (PY_METHODCHAR)SetDirection_doc},
+ {"getDirection", (PyCFunction) KX_ConstraintActuator::sPyGetDirection, METH_NOARGS, (PY_METHODCHAR)GetDirection_doc},
+ {"setOption", (PyCFunction) KX_ConstraintActuator::sPySetOption, METH_VARARGS, (PY_METHODCHAR)SetOption_doc},
+ {"getOption", (PyCFunction) KX_ConstraintActuator::sPyGetOption, METH_NOARGS, (PY_METHODCHAR)GetOption_doc},
+ {"setTime", (PyCFunction) KX_ConstraintActuator::sPySetTime, METH_VARARGS, (PY_METHODCHAR)SetTime_doc},
+ {"getTime", (PyCFunction) KX_ConstraintActuator::sPyGetTime, METH_NOARGS, (PY_METHODCHAR)GetTime_doc},
+ {"setProperty", (PyCFunction) KX_ConstraintActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
+ {"getProperty", (PyCFunction) KX_ConstraintActuator::sPyGetProperty, METH_NOARGS, (PY_METHODCHAR)GetProperty_doc},
+ {"setMin", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, (PY_METHODCHAR)SetMin_doc},
+ {"getMin", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, (PY_METHODCHAR)GetMin_doc},
+ {"setDistance", (PyCFunction) KX_ConstraintActuator::sPySetMin, METH_VARARGS, (PY_METHODCHAR)SetDistance_doc},
+ {"getDistance", (PyCFunction) KX_ConstraintActuator::sPyGetMin, METH_NOARGS, (PY_METHODCHAR)GetDistance_doc},
+ {"setMax", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, (PY_METHODCHAR)SetMax_doc},
+ {"getMax", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, (PY_METHODCHAR)GetMax_doc},
+ {"setRayLength", (PyCFunction) KX_ConstraintActuator::sPySetMax, METH_VARARGS, (PY_METHODCHAR)SetRayLength_doc},
+ {"getRayLength", (PyCFunction) KX_ConstraintActuator::sPyGetMax, METH_NOARGS, (PY_METHODCHAR)GetRayLength_doc},
+ {"setLimit", (PyCFunction) KX_ConstraintActuator::sPySetLimit, METH_VARARGS, (PY_METHODCHAR)SetLimit_doc},
+ {"getLimit", (PyCFunction) KX_ConstraintActuator::sPyGetLimit, METH_NOARGS, (PY_METHODCHAR)GetLimit_doc},
{NULL,NULL} //Sentinel
};
@@ -228,10 +617,10 @@ PyObject* KX_ConstraintActuator::_getattr(const STR_String& attr) {
}
/* 2. setDamp */
-char KX_ConstraintActuator::SetDamp_doc[] =
+const char KX_ConstraintActuator::SetDamp_doc[] =
"setDamp(duration)\n"
"\t- duration: integer\n"
-"\tSets the time with which the constraint application is delayed.\n"
+"\tSets the time constant of the orientation and distance constraint.\n"
"\tIf the duration is negative, it is set to 0.\n";
PyObject* KX_ConstraintActuator::PySetDamp(PyObject* self,
PyObject* args,
@@ -241,23 +630,182 @@ PyObject* KX_ConstraintActuator::PySetDamp(PyObject* self,
return NULL;
}
- m_dampTime = dampArg;
- if (m_dampTime < 0) m_dampTime = 0;
+ m_posDampTime = dampArg;
+ if (m_posDampTime < 0) m_posDampTime = 0;
Py_Return;
}
/* 3. getDamp */
-char KX_ConstraintActuator::GetDamp_doc[] =
-"GetDamp()\n"
+const char KX_ConstraintActuator::GetDamp_doc[] =
+"getDamp()\n"
+"\tReturns the damping parameter.\n";
+PyObject* KX_ConstraintActuator::PyGetDamp(PyObject* self){
+ return PyInt_FromLong(m_posDampTime);
+}
+
+/* 2. setRotDamp */
+const char KX_ConstraintActuator::SetRotDamp_doc[] =
+"setRotDamp(duration)\n"
+"\t- duration: integer\n"
+"\tSets the time constant of the orientation constraint.\n"
+"\tIf the duration is negative, it is set to 0.\n";
+PyObject* KX_ConstraintActuator::PySetRotDamp(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ int dampArg;
+ if(!PyArg_ParseTuple(args, "i", &dampArg)) {
+ return NULL;
+ }
+
+ m_rotDampTime = dampArg;
+ if (m_rotDampTime < 0) m_rotDampTime = 0;
+
+ Py_Return;
+}
+/* 3. getRotDamp */
+const char KX_ConstraintActuator::GetRotDamp_doc[] =
+"getRotDamp()\n"
"\tReturns the damping time for application of the constraint.\n";
-PyObject* KX_ConstraintActuator::PyGetDamp(PyObject* self,
+PyObject* KX_ConstraintActuator::PyGetRotDamp(PyObject* self){
+ return PyInt_FromLong(m_rotDampTime);
+}
+
+/* 2. setDirection */
+const char KX_ConstraintActuator::SetDirection_doc[] =
+"setDirection(vector)\n"
+"\t- vector: 3-tuple\n"
+"\tSets the reference direction in world coordinate for the orientation constraint.\n";
+PyObject* KX_ConstraintActuator::PySetDirection(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ float x, y, z;
+ MT_Scalar len;
+ MT_Vector3 dir;
+
+ if(!PyArg_ParseTuple(args, "(fff)", &x, &y, &z)) {
+ return NULL;
+ }
+ dir[0] = x;
+ dir[1] = y;
+ dir[2] = z;
+ len = dir.length();
+ if (MT_fuzzyZero(len)) {
+ std::cout << "Invalid direction" << std::endl;
+ return NULL;
+ }
+ m_refDirection = dir/len;
+
+ Py_Return;
+}
+/* 3. getDirection */
+const char KX_ConstraintActuator::GetDirection_doc[] =
+"getDirection()\n"
+"\tReturns the reference direction of the orientation constraint as a 3-tuple.\n";
+PyObject* KX_ConstraintActuator::PyGetDirection(PyObject* self){
+ PyObject *retVal = PyList_New(3);
+
+ PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_refDirection[0]));
+ PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_refDirection[1]));
+ PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_refDirection[2]));
+ return retVal;
+}
+
+/* 2. setOption */
+const char KX_ConstraintActuator::SetOption_doc[] =
+"setOption(option)\n"
+"\t- option: integer\n"
+"\tSets several options of the distance constraint.\n"
+"\tBinary combination of the following values:\n"
+"\t\t 64 : Activate alignment to surface\n"
+"\t\t128 : Detect material rather than property\n"
+"\t\t256 : No deactivation if ray does not hit target\n"
+"\t\t512 : Activate distance control\n";
+PyObject* KX_ConstraintActuator::PySetOption(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ int option;
+ if(!PyArg_ParseTuple(args, "i", &option)) {
+ return NULL;
+ }
+
+ m_option = option;
+
+ Py_Return;
+}
+/* 3. getOption */
+const char KX_ConstraintActuator::GetOption_doc[] =
+"getOption()\n"
+"\tReturns the option parameter.\n";
+PyObject* KX_ConstraintActuator::PyGetOption(PyObject* self){
+ return PyInt_FromLong(m_option);
+}
+
+/* 2. setTime */
+const char KX_ConstraintActuator::SetTime_doc[] =
+"setTime(duration)\n"
+"\t- duration: integer\n"
+"\tSets the activation time of the actuator.\n"
+"\tThe actuator disables itself after this many frame.\n"
+"\tIf set to 0 or negative, the actuator is not limited in time.\n";
+PyObject* KX_ConstraintActuator::PySetTime(PyObject* self,
PyObject* args,
- PyObject* kwds){
- return PyInt_FromLong(m_dampTime);
+ PyObject* kwds) {
+ int t;
+ if(!PyArg_ParseTuple(args, "i", &t)) {
+ return NULL;
+ }
+
+ if (t < 0)
+ t = 0;
+ m_activeTime = t;
+
+ Py_Return;
+}
+/* 3. getTime */
+const char KX_ConstraintActuator::GetTime_doc[] =
+"getTime()\n"
+"\tReturns the time parameter.\n";
+PyObject* KX_ConstraintActuator::PyGetTime(PyObject* self){
+ return PyInt_FromLong(m_activeTime);
}
+/* 2. setProperty */
+const char KX_ConstraintActuator::SetProperty_doc[] =
+"setProperty(property)\n"
+"\t- property: string\n"
+"\tSets the name of the property or material for the ray detection of the distance constraint.\n"
+"\tIf empty, the ray will detect any collisioning object.\n";
+PyObject* KX_ConstraintActuator::PySetProperty(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ char *property;
+ if (!PyArg_ParseTuple(args, "s", &property)) {
+ return NULL;
+ }
+ if (property == NULL) {
+ m_property[0] = 0;
+ } else {
+ strncpy(m_property, property, sizeof(m_property));
+ m_property[sizeof(m_property)-1] = 0;
+ }
+
+ Py_Return;
+}
+/* 3. getProperty */
+const char KX_ConstraintActuator::GetProperty_doc[] =
+"getProperty()\n"
+"\tReturns the property parameter.\n";
+PyObject* KX_ConstraintActuator::PyGetProperty(PyObject* self){
+ return PyString_FromString(m_property);
+}
+
+/* 4. setDistance */
+const char KX_ConstraintActuator::SetDistance_doc[] =
+"setDistance(distance)\n"
+"\t- distance: float\n"
+"\tSets the target distance in distance constraint\n";
/* 4. setMin */
-char KX_ConstraintActuator::SetMin_doc[] =
+const char KX_ConstraintActuator::SetMin_doc[] =
"setMin(lower_bound)\n"
"\t- lower_bound: float\n"
"\tSets the lower value of the interval to which the value\n"
@@ -271,9 +819,7 @@ PyObject* KX_ConstraintActuator::PySetMin(PyObject* self,
}
switch (m_locrot) {
- case KX_ACT_CONSTRAINT_LOCX:
- case KX_ACT_CONSTRAINT_LOCY:
- case KX_ACT_CONSTRAINT_LOCZ:
+ default:
m_minimumBound = minArg;
break;
case KX_ACT_CONSTRAINT_ROTX:
@@ -281,25 +827,30 @@ PyObject* KX_ConstraintActuator::PySetMin(PyObject* self,
case KX_ACT_CONSTRAINT_ROTZ:
m_minimumBound = MT_radians(minArg);
break;
- default:
- ; /* error */
}
Py_Return;
}
+/* 5. getDistance */
+const char KX_ConstraintActuator::GetDistance_doc[] =
+"getDistance()\n"
+"\tReturns the distance parameter \n";
/* 5. getMin */
-char KX_ConstraintActuator::GetMin_doc[] =
+const char KX_ConstraintActuator::GetMin_doc[] =
"getMin()\n"
"\tReturns the lower value of the interval to which the value\n"
"\tis clipped.\n";
-PyObject* KX_ConstraintActuator::PyGetMin(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* KX_ConstraintActuator::PyGetMin(PyObject* self) {
return PyFloat_FromDouble(m_minimumBound);
}
+/* 6. setRayLength */
+const char KX_ConstraintActuator::SetRayLength_doc[] =
+"setRayLength(length)\n"
+"\t- length: float\n"
+"\tSets the maximum ray length of the distance constraint\n";
/* 6. setMax */
-char KX_ConstraintActuator::SetMax_doc[] =
+const char KX_ConstraintActuator::SetMax_doc[] =
"setMax(upper_bound)\n"
"\t- upper_bound: float\n"
"\tSets the upper value of the interval to which the value\n"
@@ -313,9 +864,7 @@ PyObject* KX_ConstraintActuator::PySetMax(PyObject* self,
}
switch (m_locrot) {
- case KX_ACT_CONSTRAINT_LOCX:
- case KX_ACT_CONSTRAINT_LOCY:
- case KX_ACT_CONSTRAINT_LOCZ:
+ default:
m_maximumBound = maxArg;
break;
case KX_ACT_CONSTRAINT_ROTX:
@@ -323,31 +872,41 @@ PyObject* KX_ConstraintActuator::PySetMax(PyObject* self,
case KX_ACT_CONSTRAINT_ROTZ:
m_maximumBound = MT_radians(maxArg);
break;
- default:
- ; /* error */
}
Py_Return;
}
+/* 7. getRayLength */
+const char KX_ConstraintActuator::GetRayLength_doc[] =
+"getRayLength()\n"
+"\tReturns the length of the ray\n";
/* 7. getMax */
-char KX_ConstraintActuator::GetMax_doc[] =
+const char KX_ConstraintActuator::GetMax_doc[] =
"getMax()\n"
"\tReturns the upper value of the interval to which the value\n"
"\tis clipped.\n";
-PyObject* KX_ConstraintActuator::PyGetMax(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* KX_ConstraintActuator::PyGetMax(PyObject* self) {
return PyFloat_FromDouble(m_maximumBound);
}
/* This setter/getter probably for the constraint type */
/* 8. setLimit */
-char KX_ConstraintActuator::SetLimit_doc[] =
+const char KX_ConstraintActuator::SetLimit_doc[] =
"setLimit(type)\n"
-"\t- type: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY,\n"
-"\t KX_CONSTRAINTACT_LOCZ, KX_CONSTRAINTACT_ROTX,\n"
-"\t KX_CONSTRAINTACT_ROTY, or KX_CONSTRAINTACT_ROTZ.\n"
+"\t- type: integer\n"
+"\t 1 : LocX\n"
+"\t 2 : LocY\n"
+"\t 3 : LocZ\n"
+"\t 7 : Distance along +X axis\n"
+"\t 8 : Distance along +Y axis\n"
+"\t 9 : Distance along +Z axis\n"
+"\t 10 : Distance along -X axis\n"
+"\t 11 : Distance along -Y axis\n"
+"\t 12 : Distance along -Z axis\n"
+"\t 13 : Align X axis\n"
+"\t 14 : Align Y axis\n"
+"\t 15 : Align Z axis\n"
"\tSets the type of constraint.\n";
PyObject* KX_ConstraintActuator::PySetLimit(PyObject* self,
PyObject* args,
@@ -362,12 +921,10 @@ PyObject* KX_ConstraintActuator::PySetLimit(PyObject* self,
Py_Return;
}
/* 9. getLimit */
-char KX_ConstraintActuator::GetLimit_doc[] =
-"getLimit(type)\n"
+const char KX_ConstraintActuator::GetLimit_doc[] =
+"getLimit()\n"
"\tReturns the type of constraint.\n";
-PyObject* KX_ConstraintActuator::PyGetLimit(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* KX_ConstraintActuator::PyGetLimit(PyObject* self) {
return PyInt_FromLong(m_locrot);
}
diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.h b/source/gameengine/Ketsji/KX_ConstraintActuator.h
index a21a5f30de6..28b9b1e6a0b 100644
--- a/source/gameengine/Ketsji/KX_ConstraintActuator.h
+++ b/source/gameengine/Ketsji/KX_ConstraintActuator.h
@@ -34,19 +34,40 @@
#include "SCA_IActuator.h"
#include "MT_Scalar.h"
+#include "MT_Vector3.h"
+#include "KX_ClientObjectInfo.h"
+
+class KX_RayCast;
+class KX_GameObject;
class KX_ConstraintActuator : public SCA_IActuator
{
Py_Header;
protected:
// Damp time (int),
- int m_dampTime;
- // min (float),
+ int m_posDampTime;
+ int m_rotDampTime;
+ // min (float)
float m_minimumBound;
- // max (float),
+ // max (float)
float m_maximumBound;
+ // sinus of minimum angle
+ float m_minimumSine;
+ // sinus of maximum angle
+ float m_maximumSine;
+ // reference direction
+ MT_Vector3 m_refDirection;
// locrotxyz choice (pick one): only one choice allowed at a time!
int m_locrot;
+ // active time of actuator
+ int m_activeTime;
+ int m_currentTime;
+ // option
+ int m_option;
+ // property to check
+ char m_property[32];
+ // hit object
+ KX_GameObject* m_hitObject;
/**
* Clamp <var> to <min>, <max>. Borders are included (in as far as
@@ -56,6 +77,7 @@ protected:
public:
+ // m_locrot
enum KX_CONSTRAINTTYPE {
KX_ACT_CONSTRAINT_NODEF = 0,
KX_ACT_CONSTRAINT_LOCX,
@@ -64,16 +86,46 @@ protected:
KX_ACT_CONSTRAINT_ROTX,
KX_ACT_CONSTRAINT_ROTY,
KX_ACT_CONSTRAINT_ROTZ,
+ KX_ACT_CONSTRAINT_DIRPX,
+ KX_ACT_CONSTRAINT_DIRPY,
+ KX_ACT_CONSTRAINT_DIRPZ,
+ KX_ACT_CONSTRAINT_DIRNX,
+ KX_ACT_CONSTRAINT_DIRNY,
+ KX_ACT_CONSTRAINT_DIRNZ,
+ KX_ACT_CONSTRAINT_ORIX,
+ KX_ACT_CONSTRAINT_ORIY,
+ KX_ACT_CONSTRAINT_ORIZ,
+ KX_ACT_CONSTRAINT_FHPX,
+ KX_ACT_CONSTRAINT_FHPY,
+ KX_ACT_CONSTRAINT_FHPZ,
+ KX_ACT_CONSTRAINT_FHNX,
+ KX_ACT_CONSTRAINT_FHNY,
+ KX_ACT_CONSTRAINT_FHNZ,
KX_ACT_CONSTRAINT_MAX
};
-
+ // match ACT_CONST_... values from BIF_interface.h
+ enum KX_CONSTRAINTOPT {
+ KX_ACT_CONSTRAINT_NORMAL = 64,
+ KX_ACT_CONSTRAINT_MATERIAL = 128,
+ KX_ACT_CONSTRAINT_PERMANENT = 256,
+ KX_ACT_CONSTRAINT_DISTANCE = 512,
+ KX_ACT_CONSTRAINT_LOCAL = 1024,
+ KX_ACT_CONSTRAINT_DOROTFH = 2048
+ };
bool IsValidMode(KX_CONSTRAINTTYPE m);
+ bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
+ bool NeedRayCast(KX_ClientObjectInfo*);
KX_ConstraintActuator(SCA_IObject* gameobj,
- int damptime,
+ int posDamptime,
+ int rotDampTime,
float min,
float max,
+ float refDir[3],
int locrot,
+ int time,
+ int option,
+ char *property,
PyTypeObject* T=&Type);
virtual ~KX_ConstraintActuator();
virtual CValue* GetReplica() {
@@ -93,14 +145,27 @@ protected:
virtual PyObject* _getattr(const STR_String& attr);
KX_PYMETHOD_DOC(KX_ConstraintActuator,SetDamp);
- KX_PYMETHOD_DOC(KX_ConstraintActuator,GetDamp);
+ KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetDamp);
+ KX_PYMETHOD_DOC(KX_ConstraintActuator,SetRotDamp);
+ KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetRotDamp);
+ KX_PYMETHOD_DOC(KX_ConstraintActuator,SetDirection);
+ KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetDirection);
+ KX_PYMETHOD_DOC(KX_ConstraintActuator,SetOption);
+ KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetOption);
+ KX_PYMETHOD_DOC(KX_ConstraintActuator,SetTime);
+ KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetTime);
+ KX_PYMETHOD_DOC(KX_ConstraintActuator,SetProperty);
+ KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetProperty);
KX_PYMETHOD_DOC(KX_ConstraintActuator,SetMin);
- KX_PYMETHOD_DOC(KX_ConstraintActuator,GetMin);
+ KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetMin);
+ static const char SetDistance_doc[];
+ static const char GetDistance_doc[];
KX_PYMETHOD_DOC(KX_ConstraintActuator,SetMax);
- KX_PYMETHOD_DOC(KX_ConstraintActuator,GetMax);
+ KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetMax);
+ static const char SetRayLength_doc[];
+ static const char GetRayLength_doc[];
KX_PYMETHOD_DOC(KX_ConstraintActuator,SetLimit);
- KX_PYMETHOD_DOC(KX_ConstraintActuator,GetLimit);
-
+ KX_PYMETHOD_DOC_NOARGS(KX_ConstraintActuator,GetLimit);
};
#endif //__KX_CONSTRAINTACTUATOR
diff --git a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
index 987125ca9ba..c9095ff34f6 100644
--- a/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_ConstraintWrapper.cpp
@@ -27,6 +27,7 @@
* ***** END GPL LICENSE BLOCK *****
*/
#include <Python.h>
+#include "PyObjectPlus.h"
#include "KX_ConstraintWrapper.h"
#include "PHY_IPhysicsEnvironment.h"
@@ -53,8 +54,7 @@ PyObject* KX_ConstraintWrapper::PyTestMethod(PyObject* self,
PyObject* kwds)
{
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyObject* KX_ConstraintWrapper::PyGetConstraintId(PyObject* self,
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
index 6653026f28a..53486cecf73 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObject.h
@@ -75,6 +75,7 @@ struct KX_CBounds
struct KX_ObjectProperties
{
bool m_dyna;
+ bool m_softbody;
double m_radius;
bool m_angular_rigidbody;
bool m_in_active_layer;
@@ -86,6 +87,47 @@ struct KX_ObjectProperties
bool m_disableSleeping;
bool m_hasCompoundChildren;
bool m_isCompoundChild;
+
+ /////////////////////////
+
+ int m_gamesoftFlag;
+ float m_soft_linStiff; /* linear stiffness 0..1 */
+ float m_soft_angStiff; /* angular stiffness 0..1 */
+ float m_soft_volume; /* volume preservation 0..1 */
+
+ int m_soft_viterations; /* Velocities solver iterations */
+ int m_soft_piterations; /* Positions solver iterations */
+ int m_soft_diterations; /* Drift solver iterations */
+ int m_soft_citerations; /* Cluster solver iterations */
+
+ float m_soft_kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */
+ float m_soft_kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */
+ float m_soft_kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */
+ float m_soft_kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+
+ float m_soft_kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+ float m_soft_kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+ float m_soft_kVCF; /* Velocities correction factor (Baumgarte) */
+ float m_soft_kDP; /* Damping coefficient [0,1] */
+
+ float m_soft_kDG; /* Drag coefficient [0,+inf] */
+ float m_soft_kLF; /* Lift coefficient [0,+inf] */
+ float m_soft_kPR; /* Pressure coefficient [-inf,+inf] */
+ float m_soft_kVC; /* Volume conversation coefficient [0,+inf] */
+
+ float m_soft_kDF; /* Dynamic friction coefficient [0,1] */
+ float m_soft_kMT; /* Pose matching coefficient [0,1] */
+ float m_soft_kCHR; /* Rigid contacts hardness [0,1] */
+ float m_soft_kKHR; /* Kinetic contacts hardness [0,1] */
+
+ float m_soft_kSHR; /* Soft contacts hardness [0,1] */
+ float m_soft_kAHR; /* Anchors hardness [0,1] */
+ int m_soft_collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
+ int m_soft_numclusteriterations; /* number of iterations to refine collision clusters*/
+
+ /////////////////////////
+
+ double m_margin;
KX_BoundBoxClass m_boundclass;
union {
KX_BoxBounds box;
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
index 26e0b47b84b..0e7a6d92ec1 100644
--- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
+++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp
@@ -38,6 +38,8 @@
#include "RAS_MeshObject.h"
#include "KX_Scene.h"
#include "SYS_System.h"
+#include "BL_SkinMeshObject.h"
+#include "BulletSoftBody/btSoftBody.h"
#include "PHY_Pro.h" //todo cleanup
#include "KX_ClientObjectInfo.h"
@@ -76,16 +78,16 @@
struct KX_PhysicsInstance
{
DT_VertexBaseHandle m_vertexbase;
- int m_vtxarray;
+ RAS_DisplayArray* m_darray;
RAS_IPolyMaterial* m_material;
-
- KX_PhysicsInstance(DT_VertexBaseHandle vertex_base, int vtxarray, RAS_IPolyMaterial* mat)
+
+ KX_PhysicsInstance(DT_VertexBaseHandle vertex_base, RAS_DisplayArray *darray, RAS_IPolyMaterial* mat)
: m_vertexbase(vertex_base),
- m_vtxarray(vtxarray),
- m_material(mat)
+ m_darray(darray),
+ m_material(mat)
{
}
-
+
~KX_PhysicsInstance()
{
DT_DeleteVertexBase(m_vertexbase);
@@ -100,11 +102,11 @@ static void BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoSce
static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope);
void KX_ConvertSumoObject( KX_GameObject* gameobj,
- RAS_MeshObject* meshobj,
- KX_Scene* kxscene,
- PHY_ShapeProps* kxshapeprops,
- PHY_MaterialProps* kxmaterial,
- struct KX_ObjectProperties* objprop)
+ RAS_MeshObject* meshobj,
+ KX_Scene* kxscene,
+ PHY_ShapeProps* kxshapeprops,
+ PHY_MaterialProps* kxmaterial,
+ struct KX_ObjectProperties* objprop)
{
@@ -150,23 +152,23 @@ void KX_ConvertSumoObject( KX_GameObject* gameobj,
objprop->m_boundobject.box.m_extends[1],
objprop->m_boundobject.box.m_extends[2]);
smprop->m_inertia.scale(objprop->m_boundobject.box.m_extends[0]*objprop->m_boundobject.box.m_extends[0],
- objprop->m_boundobject.box.m_extends[1]*objprop->m_boundobject.box.m_extends[1],
- objprop->m_boundobject.box.m_extends[2]*objprop->m_boundobject.box.m_extends[2]);
+ objprop->m_boundobject.box.m_extends[1]*objprop->m_boundobject.box.m_extends[1],
+ objprop->m_boundobject.box.m_extends[2]*objprop->m_boundobject.box.m_extends[2]);
smprop->m_inertia *= smprop->m_mass/MT_Vector3(objprop->m_boundobject.box.m_extends).length();
break;
case KX_BOUNDCYLINDER:
shape = DT_NewCylinder(smprop->m_radius, objprop->m_boundobject.c.m_height);
smprop->m_inertia.scale(smprop->m_mass*smprop->m_radius*smprop->m_radius,
- smprop->m_mass*smprop->m_radius*smprop->m_radius,
- smprop->m_mass*objprop->m_boundobject.c.m_height*objprop->m_boundobject.c.m_height);
+ smprop->m_mass*smprop->m_radius*smprop->m_radius,
+ smprop->m_mass*objprop->m_boundobject.c.m_height*objprop->m_boundobject.c.m_height);
break;
case KX_BOUNDCONE:
shape = DT_NewCone(objprop->m_radius, objprop->m_boundobject.c.m_height);
smprop->m_inertia.scale(smprop->m_mass*smprop->m_radius*smprop->m_radius,
- smprop->m_mass*smprop->m_radius*smprop->m_radius,
- smprop->m_mass*objprop->m_boundobject.c.m_height*objprop->m_boundobject.c.m_height);
+ smprop->m_mass*smprop->m_radius*smprop->m_radius,
+ smprop->m_mass*objprop->m_boundobject.c.m_height*objprop->m_boundobject.c.m_height);
break;
- /* Dynamic mesh objects. WARNING! slow. */
+ /* Dynamic mesh objects. WARNING! slow. */
case KX_BOUNDPOLYTOPE:
polytope = true;
// fall through
@@ -186,15 +188,15 @@ void KX_ConvertSumoObject( KX_GameObject* gameobj,
shape = DT_NewSphere(objprop->m_radius);
smprop->m_inertia *= smprop->m_mass*smprop->m_radius*smprop->m_radius;
break;
-
+
}
-
+
sumoObj = new SM_Object(shape, !objprop->m_ghost?smmaterial:NULL,smprop,NULL);
-
+
sumoObj->setRigidBody(objprop->m_angular_rigidbody?true:false);
-
+
BL_RegisterSumoObject(gameobj,sceneptr,sumoObj,"",true, true);
-
+
}
else {
// non physics object
@@ -320,12 +322,11 @@ static void BL_RegisterSumoObject(
physicscontroller->SetObject(gameobj->GetSGNode());
}
-static DT_ShapeHandle InstancePhysicsComplex(RAS_MeshObject* meshobj, int vtxarray, RAS_IPolyMaterial *mat)
+static DT_ShapeHandle InstancePhysicsComplex(RAS_MeshObject* meshobj, RAS_DisplayArray *darray, RAS_IPolyMaterial *mat)
{
// instance a mesh from a single vertex array & material
- const RAS_TexVert *vertex_array = &((*meshobj->GetVertexCache(mat)[vtxarray])[0]);
- //const KX_IndexArray &index_array = *meshobj->GetIndexCache(mat)[vtxarray];
- DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getLocalXYZ(), sizeof(RAS_TexVert));
+ const RAS_TexVert *vertex_array = &darray->m_vertex[0];
+ DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getXYZ(), sizeof(RAS_TexVert));
DT_ShapeHandle shape = DT_NewComplexShape(vertex_base);
@@ -337,15 +338,19 @@ static DT_ShapeHandle InstancePhysicsComplex(RAS_MeshObject* meshobj, int vtxarr
// only add polygons that have the collisionflag set
if (poly->IsCollider())
{
- DT_VertexIndices(3, poly->GetVertexIndexBase().m_indexarray);
+ DT_Begin();
+ DT_VertexIndex(poly->GetVertexOffset(0));
+ DT_VertexIndex(poly->GetVertexOffset(1));
+ DT_VertexIndex(poly->GetVertexOffset(2));
+ DT_End();
// tesselate
if (poly->VertexCount() == 4)
{
DT_Begin();
- DT_VertexIndex(poly->GetVertexIndexBase().m_indexarray[0]);
- DT_VertexIndex(poly->GetVertexIndexBase().m_indexarray[2]);
- DT_VertexIndex(poly->GetVertexIndexBase().m_indexarray[3]);
+ DT_VertexIndex(poly->GetVertexOffset(0));
+ DT_VertexIndex(poly->GetVertexOffset(2));
+ DT_VertexIndex(poly->GetVertexOffset(3));
DT_End();
}
}
@@ -354,16 +359,15 @@ static DT_ShapeHandle InstancePhysicsComplex(RAS_MeshObject* meshobj, int vtxarr
//DT_VertexIndices(indices.size(), &indices[0]);
DT_EndComplexShape();
- map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, vtxarray, mat));
+ map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, darray, mat));
return shape;
}
-static DT_ShapeHandle InstancePhysicsPolytope(RAS_MeshObject* meshobj, int vtxarray, RAS_IPolyMaterial *mat)
+static DT_ShapeHandle InstancePhysicsPolytope(RAS_MeshObject* meshobj, RAS_DisplayArray *darray, RAS_IPolyMaterial *mat)
{
// instance a mesh from a single vertex array & material
- const RAS_TexVert *vertex_array = &((*meshobj->GetVertexCache(mat)[vtxarray])[0]);
- //const KX_IndexArray &index_array = *meshobj->GetIndexCache(mat)[vtxarray];
- DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getLocalXYZ(), sizeof(RAS_TexVert));
+ const RAS_TexVert *vertex_array = &darray->m_vertex[0];
+ DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getXYZ(), sizeof(RAS_TexVert));
std::vector<DT_Index> indices;
for (int p = 0; p < meshobj->NumPolygons(); p++)
@@ -373,12 +377,12 @@ static DT_ShapeHandle InstancePhysicsPolytope(RAS_MeshObject* meshobj, int vtxar
// only add polygons that have the collisionflag set
if (poly->IsCollider())
{
- indices.push_back(poly->GetVertexIndexBase().m_indexarray[0]);
- indices.push_back(poly->GetVertexIndexBase().m_indexarray[1]);
- indices.push_back(poly->GetVertexIndexBase().m_indexarray[2]);
+ indices.push_back(poly->GetVertexOffset(0));
+ indices.push_back(poly->GetVertexOffset(1));
+ indices.push_back(poly->GetVertexOffset(2));
if (poly->VertexCount() == 4)
- indices.push_back(poly->GetVertexIndexBase().m_indexarray[3]);
+ indices.push_back(poly->GetVertexOffset(3));
}
}
@@ -386,7 +390,7 @@ static DT_ShapeHandle InstancePhysicsPolytope(RAS_MeshObject* meshobj, int vtxar
DT_VertexIndices(indices.size(), &indices[0]);
DT_EndPolytope();
- map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, vtxarray, mat));
+ map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, darray, mat));
return shape;
}
@@ -398,8 +402,8 @@ bool KX_ReInstanceShapeFromMesh(RAS_MeshObject* meshobj)
KX_PhysicsInstance *instance = *map_gamemesh_to_instance[GEN_HashedPtr(meshobj)];
if (instance)
{
- const RAS_TexVert *vertex_array = &((*meshobj->GetVertexCache(instance->m_material)[instance->m_vtxarray])[0]);
- DT_ChangeVertexBase(instance->m_vertexbase, vertex_array[0].getLocalXYZ());
+ const RAS_TexVert *vertex_array = &instance->m_darray->m_vertex[0];
+ DT_ChangeVertexBase(instance->m_vertexbase, vertex_array[0].getXYZ());
return true;
}
return false;
@@ -425,7 +429,7 @@ static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope
// Count the number of collision polygons and check they all come from the same
// vertex array
int numvalidpolys = 0;
- int vtxarray = -1;
+ RAS_DisplayArray *darray = NULL;
RAS_IPolyMaterial *poly_material = NULL;
bool reinstance = true;
@@ -437,14 +441,14 @@ static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope
if (poly->IsCollider())
{
// check polygon is from the same vertex array
- if (poly->GetVertexIndexBase().m_vtxarray != vtxarray)
+ if (poly->GetDisplayArray() != darray)
{
- if (vtxarray < 0)
- vtxarray = poly->GetVertexIndexBase().m_vtxarray;
+ if (darray == NULL)
+ darray = poly->GetDisplayArray();
else
{
reinstance = false;
- vtxarray = -1;
+ darray = NULL;
}
}
@@ -478,9 +482,9 @@ static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope
if (reinstance)
{
if (polytope)
- shape = InstancePhysicsPolytope(meshobj, vtxarray, poly_material);
+ shape = InstancePhysicsPolytope(meshobj, darray, poly_material);
else
- shape = InstancePhysicsComplex(meshobj, vtxarray, poly_material);
+ shape = InstancePhysicsComplex(meshobj, darray, poly_material);
}
else
{
@@ -489,7 +493,7 @@ static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope
std::cout << "CreateShapeFromMesh: " << meshobj->GetName() << " is not suitable for polytope." << std::endl;
if (!poly_material)
std::cout << " Check mesh materials." << std::endl;
- if (vtxarray < 0)
+ if (darray == NULL)
std::cout << " Check number of vertices." << std::endl;
}
@@ -505,18 +509,10 @@ static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope
if (poly->IsCollider())
{ /* We have to tesselate here because SOLID can only raycast triangles */
DT_Begin();
- /* V1 */
- DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[2],
- poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ());
- /* V2 */
- DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[1],
- poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ());
- /* V3 */
- DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[0],
- poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ());
+ /* V1, V2, V3 */
+ DT_Vertex(poly->GetVertex(2)->getXYZ());
+ DT_Vertex(poly->GetVertex(1)->getXYZ());
+ DT_Vertex(poly->GetVertex(0)->getXYZ());
numvalidpolys++;
DT_End();
@@ -524,18 +520,10 @@ static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope
if (poly->VertexCount() == 4)
{
DT_Begin();
- /* V1 */
- DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[3],
- poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ());
- /* V3 */
- DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[2],
- poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ());
- /* V4 */
- DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[0],
- poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ());
+ /* V1, V3, V4 */
+ DT_Vertex(poly->GetVertex(3)->getXYZ());
+ DT_Vertex(poly->GetVertex(2)->getXYZ());
+ DT_Vertex(poly->GetVertex(0)->getXYZ());
numvalidpolys++;
DT_End();
@@ -679,196 +667,107 @@ void KX_ConvertODEEngineObject(KX_GameObject* gameobj,
#endif //WIN32
-static GEN_Map<GEN_HashedPtr,btCollisionShape*> map_gamemesh_to_bulletshape;
-
-// forward declarations
-static btCollisionShape* CreateBulletShapeFromMesh(RAS_MeshObject* meshobj, bool polytope)
-{
- if (!meshobj)
- return 0;
-
- btCollisionShape* collisionMeshShape = 0;
- btConvexHullShape* convexHullShape = 0;
- btTriangleMeshShape* concaveShape = 0;
-
- btTriangleMesh* collisionMeshData = 0;
-
- //see if there is any polygons, if not, bail out.
-
- int numPoints = 0;
- btVector3* points = 0;
-
- btCollisionShape** shapeptr = map_gamemesh_to_bulletshape[GEN_HashedPtr(meshobj)];
-
- // Mesh has already been converted: reuse
- if (shapeptr)
- {
- //return *shapeptr;
- }
-
- // Mesh has no polygons!
- int numpolys = meshobj->NumPolygons();
- if (!numpolys)
- {
- return NULL;
- }
-
- // Count the number of collision polygons and check they all come from the same
- // vertex array
- int numvalidpolys = 0;
- int vtxarray = -1;
- RAS_IPolyMaterial *poly_material = NULL;
- bool reinstance = true;
-
- for (int p=0; p<numpolys; p++)
+
+ class KX_SoftBodyDeformer : public RAS_Deformer
{
- RAS_Polygon* poly = meshobj->GetPolygon(p);
+ class RAS_MeshObject* m_pMeshObject;
+ class KX_GameObject* m_gameobj;
- // only add polygons that have the collisionflag set
- if (poly->IsCollider())
+ public:
+ KX_SoftBodyDeformer(RAS_MeshObject* pMeshObject,KX_GameObject* gameobj)
+ :m_pMeshObject(pMeshObject),
+ m_gameobj(gameobj)
{
- // check polygon is from the same vertex array
- if (poly->GetVertexIndexBase().m_vtxarray != vtxarray)
- {
- if (vtxarray < 0)
- vtxarray = poly->GetVertexIndexBase().m_vtxarray;
- else
- {
- reinstance = false;
- vtxarray = -1;
- }
- }
-
- // check poly is from the same material
- if (poly->GetMaterial()->GetPolyMaterial() != poly_material)
- {
- if (poly_material)
- {
- reinstance = false;
- poly_material = NULL;
- }
- else
- poly_material = poly->GetMaterial()->GetPolyMaterial();
- }
-
- // count the number of collision polys
- numvalidpolys++;
+ //printf("KX_SoftBodyDeformer\n");
+ };
- // We have one collision poly, and we can't reinstance, so we
- // might as well break here.
- if (!reinstance)
- break;
+ virtual ~KX_SoftBodyDeformer()
+ {
+ //printf("~KX_SoftBodyDeformer\n");
+ };
+ virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map)
+ {
+ //printf("relink\n");
}
- }
-
- // No collision polygons
- if (numvalidpolys < 1)
- return NULL;
+ virtual bool Apply(class RAS_IPolyMaterial *polymat)
+ {
+ KX_BulletPhysicsController* ctrl = (KX_BulletPhysicsController*) m_gameobj->GetPhysicsController();
+ if (!ctrl)
+ return false;
+ btSoftBody* softBody= ctrl->GetSoftBody();
+ if (!softBody)
+ return false;
- if (polytope)
- {
- convexHullShape = new btConvexHullShape(&points[0].getX(),numPoints);
- collisionMeshShape = convexHullShape;
- } else
- {
- collisionMeshData = new btTriangleMesh();
-// concaveShape = new btTriangleMeshShape(collisionMeshData);
- //collisionMeshShape = concaveShape;
+ //printf("apply\n");
+ RAS_MeshSlot::iterator it;
+ RAS_MeshMaterial *mmat;
+ RAS_MeshSlot *slot;
+ size_t i;
- }
+ // update the vertex in m_transverts
+ Update();
- numvalidpolys = 0;
- for (int p2=0; p2<numpolys; p2++)
- {
- RAS_Polygon* poly = meshobj->GetPolygon(p2);
+ // The vertex cache can only be updated for this deformer:
+ // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object)
+ // share the same mesh (=the same cache). As the rendering is done per polymaterial
+ // cycling through the objects, the entire mesh cache cannot be updated in one shot.
+ mmat = m_pMeshObject->GetMeshMaterial(polymat);
+ if(!mmat->m_slots[(void*)m_gameobj])
+ return true;
- // only add polygons that have the collisionflag set
- if (poly->IsCollider())
- {
- //Bullet can raycast any shape, so
- if (polytope)
- {
- for (int i=0;i<poly->VertexCount();i++)
- {
- const float* vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[i],
- poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ();
- btPoint3 point(vtx[0],vtx[1],vtx[2]);
- convexHullShape->addPoint(point);
- }
- if (poly->VertexCount())
- numvalidpolys++;
+ slot = *mmat->m_slots[(void*)m_gameobj];
- } else
+ // for each array
+ for(slot->begin(it); !slot->end(it); slot->next(it))
{
- {
- const float* vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[2],
- poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ();
- btPoint3 vertex0(vtx[0],vtx[1],vtx[2]);
- vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[1],
- poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ();
- btPoint3 vertex1(vtx[0],vtx[1],vtx[2]);
- vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[0],
- poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ();
- btPoint3 vertex2(vtx[0],vtx[1],vtx[2]);
- collisionMeshData->addTriangle(vertex0,vertex1,vertex2);
- numvalidpolys++;
- }
- if (poly->VertexCount() == 4)
- {
- const float* vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[3],
- poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ();
- btPoint3 vertex0(vtx[0],vtx[1],vtx[2]);
- vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[2],
- poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ();
- btPoint3 vertex1(vtx[0],vtx[1],vtx[2]);
- vtx = meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray,
- poly->GetVertexIndexBase().m_indexarray[0],
- poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ();
- btPoint3 vertex2(vtx[0],vtx[1],vtx[2]);
- collisionMeshData->addTriangle(vertex0,vertex1,vertex2);
- numvalidpolys++;
- }
+ btSoftBody::tNodeArray& nodes(softBody->m_nodes);
- }
- }
- }
+ int index = 0;
+ for(i=it.startvertex; i<it.endvertex; i++,index++) {
+ RAS_TexVert& v = it.vertex[i];
+ btAssert(v.getSoftBodyIndex() >= 0);
+ MT_Point3 pt (
+ nodes[v.getSoftBodyIndex()].m_x.getX(),
+ nodes[v.getSoftBodyIndex()].m_x.getY(),
+ nodes[v.getSoftBodyIndex()].m_x.getZ());
+ v.SetXYZ(pt);
+ MT_Vector3 normal (
+ nodes[v.getSoftBodyIndex()].m_n.getX(),
+ nodes[v.getSoftBodyIndex()].m_n.getY(),
+ nodes[v.getSoftBodyIndex()].m_n.getZ());
+ v.SetNormal(normal);
- if (numvalidpolys > 0)
- {
-
- //map_gamemesh_to_bulletshape.insert(GEN_HashedPtr(meshobj),collisionMeshShape);
- if (!polytope)
+ }
+ }
+ return true;
+ }
+ virtual bool Update(void)
{
- bool useQuantization = true;
- concaveShape = new btBvhTriangleMeshShape( collisionMeshData, useQuantization );
- //concaveShape = new btTriangleMeshShape( collisionMeshData );
-
- concaveShape->recalcLocalAabb();
- collisionMeshShape = concaveShape;
-
- }
-
-
+ //printf("update\n");
+ return true;//??
+ }
+ virtual RAS_Deformer *GetReplica(class KX_GameObject* replica)
+ {
+ KX_SoftBodyDeformer* deformer = new KX_SoftBodyDeformer(replica->GetMesh(0),replica);
+ return deformer;
+ }
- return collisionMeshShape;
- }
+ virtual bool SkipVertexTransform()
+ {
+ return true;
+ }
- delete collisionMeshShape;
- return NULL;
+ protected:
+ //class RAS_MeshObject *m_pMesh;
+ };
-}
+// forward declarations
void KX_ConvertBulletObject( class KX_GameObject* gameobj,
class RAS_MeshObject* meshobj,
@@ -885,6 +784,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
bool isbulletdyna = false;
CcdConstructionInfo ci;
class PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode());
+ class CcdShapeConstructionInfo *shapeInfo = new CcdShapeConstructionInfo();
@@ -892,125 +792,108 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
{
ci.m_collisionFlags |= btCollisionObject::CF_STATIC_OBJECT;
}
+ if (objprop->m_ghost)
+ {
+ ci.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE;
+ }
ci.m_MotionState = motionstate;
ci.m_gravity = btVector3(0,0,0);
ci.m_localInertiaTensor =btVector3(0,0,0);
ci.m_mass = objprop->m_dyna ? shapeprops->m_mass : 0.f;
+ ci.m_margin = objprop->m_margin;
+ shapeInfo->m_radius = objprop->m_radius;
isbulletdyna = objprop->m_dyna;
ci.m_localInertiaTensor = btVector3(ci.m_mass/3.f,ci.m_mass/3.f,ci.m_mass/3.f);
- btTransform trans;
- trans.setIdentity();
-
btCollisionShape* bm = 0;
switch (objprop->m_boundclass)
{
case KX_BOUNDSPHERE:
{
- float radius = objprop->m_radius;
- btVector3 inertiaHalfExtents (
- radius,
- radius,
- radius);
+ //float radius = objprop->m_radius;
+ //btVector3 inertiaHalfExtents (
+ // radius,
+ // radius,
+ // radius);
//blender doesn't support multisphere, but for testing:
//bm = new MultiSphereShape(inertiaHalfExtents,,&trans.getOrigin(),&radius,1);
- bm = new btSphereShape(objprop->m_radius);
- bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
+ shapeInfo->m_shapeType = PHY_SHAPE_SPHERE;
+ bm = shapeInfo->CreateBulletShape();
break;
};
case KX_BOUNDBOX:
{
- MT_Vector3 halfExtents (
+ shapeInfo->m_halfExtend.setValue(
objprop->m_boundobject.box.m_extends[0],
- objprop->m_boundobject.box.m_extends[1],
- objprop->m_boundobject.box.m_extends[2]);
-
- halfExtents /= 2.f;
-
- //btVector3 he (halfExtents[0]-CONVEX_DISTANCE_MARGIN ,halfExtents[1]-CONVEX_DISTANCE_MARGIN ,halfExtents[2]-CONVEX_DISTANCE_MARGIN );
- //he = he.absolute();
-
- btVector3 he (halfExtents[0],halfExtents[1],halfExtents[2]);
- he = he.absolute();
-
+ objprop->m_boundobject.box.m_extends[1],
+ objprop->m_boundobject.box.m_extends[2]);
- bm = new btBoxShape(he);
- bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
+ shapeInfo->m_halfExtend /= 2.0;
+ shapeInfo->m_halfExtend = shapeInfo->m_halfExtend.absolute();
+ shapeInfo->m_shapeType = PHY_SHAPE_BOX;
+ bm = shapeInfo->CreateBulletShape();
break;
};
case KX_BOUNDCYLINDER:
{
- btVector3 halfExtents (
+ shapeInfo->m_halfExtend.setValue(
objprop->m_boundobject.c.m_radius,
objprop->m_boundobject.c.m_radius,
objprop->m_boundobject.c.m_height * 0.5f
);
- bm = new btCylinderShapeZ(halfExtents);
- bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
-
+ shapeInfo->m_shapeType = PHY_SHAPE_CYLINDER;
+ bm = shapeInfo->CreateBulletShape();
break;
}
- case KX_BOUNDCONE:
+ case KX_BOUNDCONE:
{
- btVector3 halfExtents (objprop->m_boundobject.box.m_extends[0],
- objprop->m_boundobject.box.m_extends[1],
- objprop->m_boundobject.box.m_extends[2]);
-
-
- halfExtents /= 2.f;
-
- bm = new btConeShapeZ(objprop->m_boundobject.c.m_radius,objprop->m_boundobject.c.m_height);
- bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
-
+ shapeInfo->m_radius = objprop->m_boundobject.c.m_radius;
+ shapeInfo->m_height = objprop->m_boundobject.c.m_height;
+ shapeInfo->m_shapeType = PHY_SHAPE_CONE;
+ bm = shapeInfo->CreateBulletShape();
break;
}
- case KX_BOUNDPOLYTOPE:
- {
- bm = CreateBulletShapeFromMesh(meshobj,true);
- if (bm)
+ case KX_BOUNDPOLYTOPE:
+ {
+ shapeInfo->SetMesh(meshobj, true,false);
+ bm = shapeInfo->CreateBulletShape();
+ break;
+ }
+ case KX_BOUNDMESH:
+ {
+
+ if (!ci.m_mass ||objprop->m_softbody)
+ {
+ // mesh shapes can be shared, check first if we already have a shape on that mesh
+ class CcdShapeConstructionInfo *sharedShapeInfo = CcdShapeConstructionInfo::FindMesh(meshobj, false);
+ if (sharedShapeInfo != NULL)
{
- bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
- }
- break;
- }
- case KX_BOUNDMESH:
- {
- if (!ci.m_mass)
- {
- bm = CreateBulletShapeFromMesh(meshobj,false);
- ci.m_localInertiaTensor.setValue(0.f,0.f,0.f);
- //no moving concave meshes, so don't bother calculating inertia
- //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
+ delete shapeInfo;
+ shapeInfo = sharedShapeInfo;
+ shapeInfo->AddRef();
+ } else
+ {
+ shapeInfo->SetMesh(meshobj, false,false);
}
+ if (objprop->m_softbody)
+ shapeInfo->setVertexWeldingThreshold(0.01f); //todo: expose this to the UI
- break;
- }
-
- default:
- //interpret the shape as a concave triangle-mesh
- {
- if (meshobj)
+ bm = shapeInfo->CreateBulletShape();
+ //no moving concave meshes, so don't bother calculating inertia
+ //bm->calculateLocalInertia(ci.m_mass,ci.m_localInertiaTensor);
+ } else
{
- bm = CreateBulletShapeFromMesh(meshobj,false);
- ci.m_localInertiaTensor.setValue(0.f,0.f,0.f);
-
- // assert(0);
-
- /*
- meshobj->ScheduleCollisionPolygons();
-
- KX_DeformableMesh* gfxmesh = new KX_DeformableMesh(meshobj);
- gfxmesh->sendFixedMapping();
- //trianglemesh
- bm = new TriangleMeshInterface(gfxmesh,trans);
- */
+ shapeInfo->SetMesh(meshobj, false,true);
+ bm = shapeInfo->CreateBulletShape();
}
+
+ break;
}
}
@@ -1018,10 +901,13 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
// ci.m_localInertiaTensor.setValue(0.1f,0.1f,0.1f);
if (!bm)
+ {
+ delete motionstate;
+ delete shapeInfo;
return;
+ }
- bm->setMargin(0.06);
-
+ bm->setMargin(ci.m_margin);
if (objprop->m_isCompoundChild)
@@ -1030,30 +916,46 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
//take relative transform into account!
KX_BulletPhysicsController* parentCtrl = (KX_BulletPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController();
assert(parentCtrl);
+ CcdShapeConstructionInfo* parentShapeInfo = parentCtrl->GetShapeInfo();
btRigidBody* rigidbody = parentCtrl->GetRigidBody();
btCollisionShape* colShape = rigidbody->getCollisionShape();
assert(colShape->isCompound());
btCompoundShape* compoundShape = (btCompoundShape*)colShape;
- btTransform childTrans;
- childTrans.setIdentity();
- NodeList& children = objprop->m_dynamic_parent->GetSGNode()->GetSGChildren();
- MT_Point3 childPos = gameobj->GetSGNode()->GetLocalPosition();
- MT_Matrix3x3 childRot = gameobj->GetSGNode()->GetLocalOrientation();
- MT_Vector3 childScale = gameobj->GetSGNode()->GetLocalScale();
+ // compute the local transform from parent, this may include a parent inverse node
+ SG_Node* gameNode = gameobj->GetSGNode();
+ SG_Node* parentInverseNode = gameNode->GetSGParent();
+ if (parentInverseNode && parentInverseNode->GetSGClientObject() != NULL)
+ // this is not a parent inverse node, cancel it
+ parentInverseNode = NULL;
+ // now combine the parent inverse node and the game node
+ MT_Point3 childPos = gameNode->GetLocalPosition();
+ MT_Matrix3x3 childRot = gameNode->GetLocalOrientation();
+ MT_Vector3 childScale = gameNode->GetLocalScale();
+ if (parentInverseNode)
+ {
+ const MT_Point3& parentInversePos = parentInverseNode->GetLocalPosition();
+ const MT_Matrix3x3& parentInverseRot = parentInverseNode->GetLocalOrientation();
+ const MT_Vector3& parentInverseScale = parentInverseNode->GetLocalScale();
+ childRot = parentInverseRot * childRot;
+ childScale = parentInverseScale * childScale;
+ childPos = parentInversePos+parentInverseScale*(parentInverseRot*childPos);
+ }
- bm->setLocalScaling(btVector3(childScale.x(),childScale.y(),childScale.z()));
- childTrans.setOrigin(btVector3(childPos.x(),childPos.y(),childPos.z()));
+ shapeInfo->m_childScale.setValue(childScale.x(),childScale.y(),childScale.z());
+ bm->setLocalScaling(shapeInfo->m_childScale);
+
+ shapeInfo->m_childTrans.setOrigin(btVector3(childPos.x(),childPos.y(),childPos.z()));
float rotval[12];
childRot.getValue(rotval);
btMatrix3x3 newRot;
newRot.setValue(rotval[0],rotval[1],rotval[2],rotval[4],rotval[5],rotval[6],rotval[8],rotval[9],rotval[10]);
newRot = newRot.transpose();
- childTrans.setBasis(newRot);
-
-
- compoundShape->addChildShape(childTrans,bm);
+ shapeInfo->m_childTrans.setBasis(newRot);
+ parentShapeInfo->AddShape(shapeInfo);
+
+ compoundShape->addChildShape(shapeInfo->m_childTrans,bm);
//do some recalc?
//recalc inertia for rigidbody
if (!rigidbody->isStaticOrKinematicObject())
@@ -1068,12 +970,16 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
if (objprop->m_hasCompoundChildren)
{
- //replace shape by compoundShape
+ // create a compound shape info
+ CcdShapeConstructionInfo *compoundShapeInfo = new CcdShapeConstructionInfo();
+ compoundShapeInfo->m_shapeType = PHY_SHAPE_COMPOUND;
+ compoundShapeInfo->AddShape(shapeInfo);
+ // create the compound shape manually as we already have the child shape
btCompoundShape* compoundShape = new btCompoundShape();
- btTransform identTrans;
- identTrans.setIdentity();
- compoundShape->addChildShape(identTrans,bm);
+ compoundShape->addChildShape(shapeInfo->m_childTrans,bm);
+ // now replace the shape
bm = compoundShape;
+ shapeInfo = compoundShapeInfo;
}
@@ -1109,9 +1015,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
ci.m_collisionShape = bm;
-
-
-
+ ci.m_shapeInfo = shapeInfo;
ci.m_friction = smmaterial->m_friction;//tweak the friction a bit, so the default 0.5 works nice
ci.m_restitution = smmaterial->m_restitution;
ci.m_physicsEnv = env;
@@ -1121,7 +1025,69 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
//need a bit of damping, else system doesn't behave well
ci.m_inertiaFactor = shapeprops->m_inertia/0.4f;//defaults to 0.4, don't want to change behaviour
+ ci.m_do_anisotropic = shapeprops->m_do_anisotropic;
+ ci.m_anisotropicFriction.setValue(shapeprops->m_friction_scaling[0],shapeprops->m_friction_scaling[1],shapeprops->m_friction_scaling[2]);
+
+
+//////////
+ //do Fh, do Rot Fh
+ ci.m_do_fh = shapeprops->m_do_fh;
+ ci.m_do_rot_fh = shapeprops->m_do_rot_fh ;
+ ci.m_fh_damping = smmaterial->m_fh_damping;
+ ci.m_fh_distance = smmaterial->m_fh_distance;
+ ci.m_fh_normal = smmaterial->m_fh_normal;
+ ci.m_fh_spring = smmaterial->m_fh_spring;
+ ci.m_radius = objprop->m_radius;
+
+
+ ///////////////////
+ ci.m_gamesoftFlag = objprop->m_gamesoftFlag;
+ ci.m_soft_linStiff = objprop->m_soft_linStiff;
+ ci.m_soft_angStiff = objprop->m_soft_angStiff; /* angular stiffness 0..1 */
+ ci.m_soft_volume= objprop->m_soft_volume; /* volume preservation 0..1 */
+
+ ci.m_soft_viterations= objprop->m_soft_viterations; /* Velocities solver iterations */
+ ci.m_soft_piterations= objprop->m_soft_piterations; /* Positions solver iterations */
+ ci.m_soft_diterations= objprop->m_soft_diterations; /* Drift solver iterations */
+ ci.m_soft_citerations= objprop->m_soft_citerations; /* Cluster solver iterations */
+
+ ci.m_soft_kSRHR_CL= objprop->m_soft_kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */
+ ci.m_soft_kSKHR_CL= objprop->m_soft_kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */
+ ci.m_soft_kSSHR_CL= objprop->m_soft_kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */
+ ci.m_soft_kSR_SPLT_CL= objprop->m_soft_kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+
+ ci.m_soft_kSK_SPLT_CL= objprop->m_soft_kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+ ci.m_soft_kSS_SPLT_CL= objprop->m_soft_kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+ ci.m_soft_kVCF= objprop->m_soft_kVCF; /* Velocities correction factor (Baumgarte) */
+ ci.m_soft_kDP= objprop->m_soft_kDP; /* Damping coefficient [0,1] */
+
+ ci.m_soft_kDG= objprop->m_soft_kDG; /* Drag coefficient [0,+inf] */
+ ci.m_soft_kLF= objprop->m_soft_kLF; /* Lift coefficient [0,+inf] */
+ ci.m_soft_kPR= objprop->m_soft_kPR; /* Pressure coefficient [-inf,+inf] */
+ ci.m_soft_kVC= objprop->m_soft_kVC; /* Volume conversation coefficient [0,+inf] */
+
+ ci.m_soft_kDF= objprop->m_soft_kDF; /* Dynamic friction coefficient [0,1] */
+ ci.m_soft_kMT= objprop->m_soft_kMT; /* Pose matching coefficient [0,1] */
+ ci.m_soft_kCHR= objprop->m_soft_kCHR; /* Rigid contacts hardness [0,1] */
+ ci.m_soft_kKHR= objprop->m_soft_kKHR; /* Kinetic contacts hardness [0,1] */
+
+ ci.m_soft_kSHR= objprop->m_soft_kSHR; /* Soft contacts hardness [0,1] */
+ ci.m_soft_kAHR= objprop->m_soft_kAHR; /* Anchors hardness [0,1] */
+ ci.m_soft_collisionflags= objprop->m_soft_collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
+ ci.m_soft_numclusteriterations= objprop->m_soft_numclusteriterations; /* number of iterations to refine collision clusters*/
+
+ ////////////////////
+
+ ci.m_collisionFilterGroup = (isbulletdyna) ? short(CcdConstructionInfo::DefaultFilter) : short(CcdConstructionInfo::StaticFilter);
+ ci.m_collisionFilterMask = (isbulletdyna) ? short(CcdConstructionInfo::AllFilter) : short(CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::StaticFilter);
+ ci.m_bRigid = objprop->m_dyna && objprop->m_angular_rigidbody;
+ ci.m_bSoft = objprop->m_softbody;
+ MT_Vector3 scaling = gameobj->NodeGetWorldScaling();
+ ci.m_scaling.setValue(scaling[0], scaling[1], scaling[2]);
KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna);
+ // shapeInfo is reference counted, decrement now as we don't use it anymore
+ if (shapeInfo)
+ shapeInfo->Release();
if (objprop->m_in_active_layer)
{
@@ -1132,15 +1098,23 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
gameobj->SetPhysicsController(physicscontroller,isbulletdyna);
physicscontroller->setNewClientInfo(gameobj->getClientInfo());
- btRigidBody* rbody = physicscontroller->GetRigidBody();
-
- if (objprop->m_disableSleeping)
- rbody->setActivationState(DISABLE_DEACTIVATION);
-
- if (objprop->m_ghost)
{
- rbody->setCollisionFlags(rbody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
+ btRigidBody* rbody = physicscontroller->GetRigidBody();
+
+ if (rbody && objprop->m_disableSleeping)
+ rbody->setActivationState(DISABLE_DEACTIVATION);
}
+
+ CcdPhysicsController* parentCtrl = objprop->m_dynamic_parent ? (KX_BulletPhysicsController*)objprop->m_dynamic_parent->GetPhysicsController() : 0;
+ physicscontroller->setParentCtrl(parentCtrl);
+
+
+ //Now done directly in ci.m_collisionFlags so that it propagates to replica
+ //if (objprop->m_ghost)
+ //{
+ // rbody->setCollisionFlags(rbody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
+ //}
+
if (objprop->m_dyna && !objprop->m_angular_rigidbody)
{
/*
@@ -1155,8 +1129,10 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
*/
//env->createConstraint(physicscontroller,0,PHY_ANGULAR_CONSTRAINT,0,0,0,0,0,1);
- physicscontroller->GetRigidBody()->setAngularFactor(0.f);
-
+
+ //Now done directly in ci.m_bRigid so that it propagates to replica
+ //physicscontroller->GetRigidBody()->setAngularFactor(0.f);
+ ;
}
bool isActor = objprop->m_isactor;
@@ -1180,22 +1156,25 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
physicscontroller->SetObject(gameobj->GetSGNode());
+
+ ///test for soft bodies
+ if (objprop->m_softbody && physicscontroller)
+ {
+ btSoftBody* softBody = physicscontroller->GetSoftBody();
+ if (softBody && gameobj->GetMesh(0))//only the first mesh, if any
+ {
+ //should be a mesh then, so add a soft body deformer
+ KX_SoftBodyDeformer* softbodyDeformer = new KX_SoftBodyDeformer( gameobj->GetMesh(0),gameobj);
+ gameobj->SetDeformer(softbodyDeformer);
+
+ }
+ }
+
}
void KX_ClearBulletSharedShapes()
{
- int numshapes = map_gamemesh_to_bulletshape.size();
- int i;
- btCollisionShape*shape=0;
- for (i=0;i<numshapes ;i++)
- {
- shape = *map_gamemesh_to_bulletshape.at(i);
- //delete shape;
- }
-
- map_gamemesh_to_bulletshape.clear();
-
}
#endif
diff --git a/source/gameengine/Ketsji/KX_GameActuator.cpp b/source/gameengine/Ketsji/KX_GameActuator.cpp
index fcd32d5f4fe..76459e46731 100644
--- a/source/gameengine/Ketsji/KX_GameActuator.cpp
+++ b/source/gameengine/Ketsji/KX_GameActuator.cpp
@@ -34,6 +34,7 @@
//#include <iostream>
#include "KX_Scene.h"
#include "KX_KetsjiEngine.h"
+#include "KX_PythonInit.h" /* for config load/saving */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -125,6 +126,71 @@ bool KX_GameActuator::Update()
}
break;
}
+ case KX_GAME_SAVECFG:
+ {
+ if (m_ketsjiengine)
+ {
+ char mashal_path[512];
+ char *marshal_buffer = NULL;
+ int marshal_length;
+ FILE *fp = NULL;
+
+ pathGamePythonConfig(mashal_path);
+ marshal_length = saveGamePythonConfig(&marshal_buffer);
+
+ if (marshal_length && marshal_buffer) {
+ fp = fopen(mashal_path, "wb");
+ if (fp) {
+ if (fwrite(marshal_buffer, 1, marshal_length, fp) != marshal_length) {
+ printf("Warning: could not write marshal data\n");
+ }
+ fclose(fp);
+ } else {
+ printf("Warning: could not open marshal file\n");
+ }
+ } else {
+ printf("Warning: could not create marshal buffer\n");
+ }
+ }
+ break;
+ }
+ case KX_GAME_LOADCFG:
+ {
+ if (m_ketsjiengine)
+ {
+ char mashal_path[512];
+ char *marshal_buffer;
+ int marshal_length;
+ FILE *fp = NULL;
+ int result;
+
+ pathGamePythonConfig(mashal_path);
+
+ fp = fopen(mashal_path, "rb");
+ if (fp) {
+ // obtain file size:
+ fseek (fp , 0 , SEEK_END);
+ marshal_length = ftell(fp);
+ rewind(fp);
+
+ marshal_buffer = (char*) malloc (sizeof(char)*marshal_length);
+
+ result = fread (marshal_buffer, 1, marshal_length, fp);
+
+ if (result == marshal_length) {
+ loadGamePythonConfig(marshal_buffer, marshal_length);
+ } else {
+ printf("warning: could not read all of '%s'\n", mashal_path);
+ }
+
+ free(marshal_buffer);
+ fclose(fp);
+ } else {
+ printf("warning: could not open '%s'\n", mashal_path);
+ }
+ }
+ break;
+ }
default:
; /* do nothing? this is an internal error !!! */
}
@@ -175,13 +241,13 @@ PyParentObject KX_GameActuator::Parents[] =
PyMethodDef KX_GameActuator::Methods[] =
{
- {"getFile", (PyCFunction) KX_GameActuator::sPyGetFile, METH_VARARGS, GetFile_doc},
- {"setFile", (PyCFunction) KX_GameActuator::sPySetFile, METH_VARARGS, SetFile_doc},
+ {"getFile", (PyCFunction) KX_GameActuator::sPyGetFile, METH_VARARGS, (PY_METHODCHAR)GetFile_doc},
+ {"setFile", (PyCFunction) KX_GameActuator::sPySetFile, METH_VARARGS, (PY_METHODCHAR)SetFile_doc},
{NULL,NULL} //Sentinel
};
/* getFile */
-char KX_GameActuator::GetFile_doc[] =
+const char KX_GameActuator::GetFile_doc[] =
"getFile()\n"
"get the name of the file to start.\n";
PyObject* KX_GameActuator::PyGetFile(PyObject* self, PyObject* args, PyObject* kwds)
@@ -190,7 +256,7 @@ PyObject* KX_GameActuator::PyGetFile(PyObject* self, PyObject* args, PyObject* k
}
/* setFile */
-char KX_GameActuator::SetFile_doc[] =
+const char KX_GameActuator::SetFile_doc[] =
"setFile(name)\n"
"set the name of the file to start.\n";
PyObject* KX_GameActuator::PySetFile(PyObject* self, PyObject* args, PyObject* kwds)
diff --git a/source/gameengine/Ketsji/KX_GameActuator.h b/source/gameengine/Ketsji/KX_GameActuator.h
index 8565dc46caa..bb3448995dc 100644
--- a/source/gameengine/Ketsji/KX_GameActuator.h
+++ b/source/gameengine/Ketsji/KX_GameActuator.h
@@ -54,6 +54,8 @@ protected:
KX_GAME_START,
KX_GAME_RESTART,
KX_GAME_QUIT,
+ KX_GAME_SAVECFG,
+ KX_GAME_LOADCFG,
KX_GAME_MAX
};
diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp
index 1cb64585ff8..a168beb9a70 100644
--- a/source/gameengine/Ketsji/KX_GameObject.cpp
+++ b/source/gameengine/Ketsji/KX_GameObject.cpp
@@ -51,6 +51,7 @@ typedef unsigned long uint_ptr;
#include "KX_GameObject.h"
#include "RAS_MeshObject.h"
#include "KX_MeshProxy.h"
+#include "KX_PolyProxy.h"
#include <stdio.h> // printf
#include "SG_Controller.h"
#include "KX_IPhysicsController.h"
@@ -58,8 +59,13 @@ typedef unsigned long uint_ptr;
#include "SG_Controller.h"
#include "KX_ClientObjectInfo.h"
#include "RAS_BucketManager.h"
-
+#include "KX_RayCast.h"
+#include "KX_PythonInit.h"
#include "KX_PyMath.h"
+#include "SCA_IActuator.h"
+#include "SCA_ISensor.h"
+
+#include "PyObjectPlus.h" /* python stuff */
// This file defines relationships between parents and children
// in the game engine.
@@ -73,36 +79,56 @@ KX_GameObject::KX_GameObject(
) :
SCA_IObject(T),
m_bDyna(false),
+ m_layer(0),
+ m_pBlenderObject(NULL),
+ m_pBlenderGroupObject(NULL),
m_bSuspendDynamics(false),
m_bUseObjectColor(false),
+ m_bIsNegativeScaling(false),
m_bVisible(true),
+ m_bCulled(true),
m_pPhysicsController1(NULL),
+ m_pPhysicsEnvironment(NULL),
+ m_xray(false),
+ m_pHitObject(NULL),
m_isDeformable(false)
{
m_ignore_activity_culling = false;
m_pClient_info = new KX_ClientObjectInfo(this, KX_ClientObjectInfo::ACTOR);
m_pSGNode = new SG_Node(this,sgReplicationInfo,callbacks);
-
+
// define the relationship between this node and it's parent.
KX_NormalParentRelation * parent_relation =
KX_NormalParentRelation::New();
m_pSGNode->SetParentRelation(parent_relation);
-
-
};
KX_GameObject::~KX_GameObject()
{
+ RemoveMeshes();
+
// is this delete somewhere ?
//if (m_sumoObj)
// delete m_sumoObj;
delete m_pClient_info;
//if (m_pSGNode)
// delete m_pSGNode;
-
+ 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);
+ }
}
@@ -186,7 +212,73 @@ KX_GameObject* KX_GameObject::GetParent()
}
+void KX_GameObject::SetParent(KX_Scene *scene, KX_GameObject* obj)
+{
+ // check on valid node in case a python controller holds a reference to a deleted object
+ if (obj && GetSGNode() && obj->GetSGNode() && GetSGNode()->GetSGParent() != obj->GetSGNode())
+ {
+ // 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());
+
+ if (m_pPhysicsController1)
+ {
+ m_pPhysicsController1->SuspendDynamics(true);
+ }
+ // Set us to our new scale, position, and orientation
+ scale2[0] = 1.0/scale2[0];
+ scale2[1] = 1.0/scale2[1];
+ scale2[2] = 1.0/scale2[2];
+ scale1 = scale1 * scale2;
+ MT_Matrix3x3 invori = obj->NodeGetWorldOrientation().inverse();
+ MT_Vector3 newpos = invori*(NodeGetWorldPosition()-obj->NodeGetWorldPosition())*scale2;
+
+ NodeSetLocalScale(scale1);
+ NodeSetLocalPosition(MT_Point3(newpos[0],newpos[1],newpos[2]));
+ NodeSetLocalOrientation(invori*NodeGetWorldOrientation());
+ NodeUpdateGS(0.f,true);
+ // 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();
+ }
+}
+
+void KX_GameObject::RemoveParent(KX_Scene *scene)
+{
+ // check on valid node in case a python controller holds a reference to a deleted object
+ if (GetSGNode() && GetSGNode()->GetSGParent())
+ {
+ // Set us to the right spot
+ GetSGNode()->SetLocalScale(GetSGNode()->GetWorldScaling());
+ GetSGNode()->SetLocalOrientation(GetSGNode()->GetWorldOrientation());
+ GetSGNode()->SetLocalPosition(GetSGNode()->GetWorldPosition());
+ // Remove us from our parent
+ GetSGNode()->DisconnectFromParent();
+ NodeUpdateGS(0.f,true);
+ // 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());
+ if (m_pPhysicsController1)
+ {
+ m_pPhysicsController1->RestoreDynamics();
+ }
+ }
+}
void KX_GameObject::ProcessReplica(KX_GameObject* replica)
{
@@ -194,6 +286,7 @@ void KX_GameObject::ProcessReplica(KX_GameObject* replica)
replica->m_pSGNode = NULL;
replica->m_pClient_info = new KX_ClientObjectInfo(*m_pClient_info);
replica->m_pClient_info->m_gameobject = replica;
+ replica->m_state = 0;
}
@@ -201,11 +294,11 @@ void KX_GameObject::ProcessReplica(KX_GameObject* replica)
CValue* KX_GameObject::GetReplica()
{
KX_GameObject* replica = new KX_GameObject(*this);
-
+
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
ProcessReplica(replica);
-
+
return replica;
}
@@ -241,12 +334,12 @@ void KX_GameObject::ApplyMovement(const MT_Vector3& dloc,bool local)
void KX_GameObject::ApplyRotation(const MT_Vector3& drot,bool local)
{
MT_Matrix3x3 rotmat(drot);
- rotmat.transpose();
-
- if (m_pPhysicsController1) // (IsDynamic())
- m_pPhysicsController1->RelativeRotate(rotmat,local);
- // in worldspace
+
GetSGNode()->RelativeRotate(rotmat,local);
+
+ if (m_pPhysicsController1) { // (IsDynamic())
+ m_pPhysicsController1->RelativeRotate(rotmat,local);
+ }
}
@@ -264,31 +357,54 @@ double* KX_GameObject::GetOpenGLMatrix()
trans.setBasis(GetSGNode()->GetWorldOrientation());
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);
return fl;
}
+void KX_GameObject::AddMeshUser()
+{
+ for (size_t i=0;i<m_meshes.size();i++)
+ m_meshes[i]->AddMeshUser(this);
+
+ UpdateBuckets(false);
+}
+
+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::Bucketize()
+void KX_GameObject::UpdateBuckets( bool recursive )
{
double* fl = GetOpenGLMatrix();
for (size_t i=0;i<m_meshes.size();i++)
- m_meshes[i]->Bucketize(fl, this, m_bUseObjectColor, m_objectColor);
+ m_meshes[i]->UpdateBuckets(this, fl, m_bUseObjectColor, m_objectColor, m_bVisible, m_bCulled);
+
+ if (recursive) {
+ UpdateBuckets_recursive(m_pSGNode);
+ }
}
-
-
void KX_GameObject::RemoveMeshes()
{
- double* fl = GetOpenGLMatrix();
-
for (size_t i=0;i<m_meshes.size();i++)
- m_meshes[i]->RemoveFromBuckets(fl, this);
+ m_meshes[i]->RemoveFromBuckets(this);
//note: meshes can be shared, and are deleted by KX_BlenderSceneConverter
@@ -332,34 +448,25 @@ void KX_GameObject::ResetDebugColor()
SetDebugColor(0xff000000);
}
+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++;
+ }
+}
void KX_GameObject::UpdateIPO(float curframetime,
- bool recurse,
- bool ipo_as_force,
- bool force_local)
+ bool recurse)
{
-
- // The ipo-actuator needs a sumo reference... this is retrieved (unfortunately)
- // by the iposgcontr itself...
-// ipocontr->SetSumoReference(gameobj->GetSumoScene(),
-// gameobj->GetSumoObject());
-
-
- // The ipo has to be treated as a force, and not a displacement!
- // For this case, we send some settings to the controller. This
- // may need some caching...
- if (ipo_as_force) {
- SGControllerList::iterator it = GetSGNode()->GetSGControllerList().begin();
-
- while (it != GetSGNode()->GetSGControllerList().end()) {
- (*it)->SetOption(SG_Controller::SG_CONTR_IPO_IPO_AS_FORCE, ipo_as_force);
- (*it)->SetOption(SG_Controller::SG_CONTR_IPO_FORCES_ACT_LOCAL, force_local);
- it++;
- }
- }
-
- // The rest is the 'normal' update procedure.
+ // just the 'normal' update procedure.
GetSGNode()->SetSimulatedTime(curframetime,recurse);
GetSGNode()->UpdateWorldData(curframetime);
UpdateTransform();
@@ -368,6 +475,7 @@ void KX_GameObject::UpdateIPO(float curframetime,
// IPO update
void
KX_GameObject::UpdateMaterialData(
+ dword matname_hash,
MT_Vector4 rgba,
MT_Vector3 specrgb,
MT_Scalar hard,
@@ -380,15 +488,34 @@ KX_GameObject::UpdateMaterialData(
{
int mesh = 0;
if (((unsigned int)mesh < m_meshes.size()) && mesh >= 0) {
- RAS_MaterialBucket::Set::iterator mit = m_meshes[mesh]->GetFirstMaterial();
+ list<RAS_MeshMaterial>::iterator mit = m_meshes[mesh]->GetFirstMaterial();
+
for(; mit != m_meshes[mesh]->GetLastMaterial(); ++mit)
{
- RAS_IPolyMaterial* poly = (*mit)->GetPolyMaterial();
+ RAS_IPolyMaterial* poly = mit->m_bucket->GetPolyMaterial();
+
if(poly->GetFlag() & RAS_BLENDERMAT )
{
- SetObjectColor(rgba);
KX_BlenderMaterial *m = static_cast<KX_BlenderMaterial*>(poly);
- m->UpdateIPO(rgba, specrgb,hard,spec,ref,emit, alpha);
+
+ if (matname_hash == NULL)
+ {
+ 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)
+ SetObjectColor(rgba);
+ }
+ 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
+ }
+ }
}
}
}
@@ -401,56 +528,75 @@ KX_GameObject::GetVisible(
return m_bVisible;
}
+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);
+ }
+}
+
+
void
KX_GameObject::SetVisible(
- bool v
+ bool v,
+ bool recursive
)
{
m_bVisible = v;
+ if (recursive)
+ setVisible_recursive(m_pSGNode, v);
}
-// used by Python, and the actuatorshould _not_ be misused by the
-// scene!
-void
-KX_GameObject::MarkVisible(
- bool visible
+bool
+KX_GameObject::GetCulled(
+ void
)
{
- /* If explicit visibility settings are used, this is
- * determined on this level. Maybe change this to mesh level
- * later on? */
-
- double* fl = GetOpenGLMatrixPtr()->getPointer();
- for (size_t i=0;i<m_meshes.size();i++)
- {
- m_meshes[i]->MarkVisible(fl,this,visible,m_bUseObjectColor,m_objectColor);
- }
+ return m_bCulled;
}
+void
+KX_GameObject::SetCulled(
+ bool c
+ )
+{
+ m_bCulled = c;
+}
-// Always use the flag?
-void
-KX_GameObject::MarkVisible(
- void
+
+void
+KX_GameObject::SetLayer(
+ int l
)
{
- double* fl = GetOpenGLMatrixPtr()->getPointer();
- for (size_t i=0;i<m_meshes.size();i++)
- {
- m_meshes[i]->MarkVisible(fl,
- this,
- m_bVisible,
- m_bUseObjectColor,
- m_objectColor
- );
- }
+ m_layer = l;
}
+int
+KX_GameObject::GetLayer(
+ void
+ )
+{
+ return m_layer;
+}
void KX_GameObject::addLinearVelocity(const MT_Vector3& lin_vel,bool local)
{
- if (m_pPhysicsController1)
- m_pPhysicsController1->SetLinearVelocity(lin_vel + m_pPhysicsController1->GetLinearVelocity(),local);
+ if (m_pPhysicsController1)
+ {
+ MT_Vector3 lv = local ? NodeGetWorldOrientation() * lin_vel : lin_vel;
+ m_pPhysicsController1->SetLinearVelocity(lv + m_pPhysicsController1->GetLinearVelocity(), 0);
+ }
}
@@ -492,62 +638,205 @@ void KX_GameObject::SetObjectColor(const MT_Vector4& rgbavec)
m_objectColor = rgbavec;
}
+void KX_GameObject::AlignAxisToVect(const MT_Vector3& dir, int axis, float fac)
+{
+ MT_Matrix3x3 orimat;
+ MT_Vector3 vect,ori,z,x,y;
+ MT_Scalar len;
+ // check on valid node in case a python controller holds a reference to a deleted object
+ if (!GetSGNode())
+ return;
-MT_Vector3 KX_GameObject::GetLinearVelocity()
-{
- MT_Vector3 velocity(0.0,0.0,0.0);
+ vect = dir;
+ len = vect.length();
+ if (MT_fuzzyZero(len))
+ {
+ cout << "alignAxisToVect() Error: Null vector!\n";
+ return;
+ }
+
+ if (fac<=0.0) {
+ return;
+ }
+ // normalize
+ vect /= len;
+ orimat = GetSGNode()->GetWorldOrientation();
+ switch (axis)
+ {
+ case 0: //x axis
+ ori = MT_Vector3(orimat[0][2], orimat[1][2], orimat[2][2]); //pivot axis
+ if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON) //is the vector paralell to the pivot?
+ ori = MT_Vector3(orimat[0][1], orimat[1][1], orimat[2][1]); //change the pivot!
+ 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;
+ }
+ y = ori.cross(x);
+ z = x.cross(y);
+ break;
+ case 1: //y axis
+ ori = MT_Vector3(orimat[0][0], orimat[1][0], orimat[2][0]);
+ if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON)
+ ori = MT_Vector3(orimat[0][2], orimat[1][2], orimat[2][2]);
+ 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;
+ }
+ z = ori.cross(y);
+ x = y.cross(z);
+ break;
+ case 2: //z axis
+ ori = MT_Vector3(orimat[0][1], orimat[1][1], orimat[2][1]);
+ if (MT_abs(vect.dot(ori)) > 1.0-3.0*MT_EPSILON)
+ ori = MT_Vector3(orimat[0][0], orimat[1][0], orimat[2][0]);
+ 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;
+ }
+ 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();
+ orimat = MT_Matrix3x3( x[0],y[0],z[0],
+ x[1],y[1],z[1],
+ x[2],y[2],z[2]);
+ 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);
+}
+
+MT_Scalar KX_GameObject::GetMass()
+{
+ if (m_pPhysicsController1)
+ {
+ return m_pPhysicsController1->GetMass();
+ }
+ return 0.0;
+}
+
+MT_Vector3 KX_GameObject::GetLinearVelocity(bool local)
+{
+ MT_Vector3 velocity(0.0,0.0,0.0), locvel;
+ MT_Matrix3x3 ori;
if (m_pPhysicsController1)
{
velocity = m_pPhysicsController1->GetLinearVelocity();
+
+ if (local)
+ {
+ ori = GetSGNode()->GetWorldOrientation();
+
+ locvel = velocity * ori;
+ return locvel;
+ }
}
- return velocity;
-
+ return velocity;
+}
+
+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;
}
+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);
+}
// scenegraph node stuff
void KX_GameObject::NodeSetLocalPosition(const MT_Point3& trans)
{
- if (m_pPhysicsController1)
+ // check on valid node in case a python controller holds a reference to a deleted object
+ if (!GetSGNode())
+ return;
+
+ if (m_pPhysicsController1 && !GetSGNode()->GetSGParent())
{
+ // 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
m_pPhysicsController1->setPosition(trans);
}
- if (GetSGNode())
- GetSGNode()->SetLocalPosition(trans);
+ GetSGNode()->SetLocalPosition(trans);
}
void KX_GameObject::NodeSetLocalOrientation(const MT_Matrix3x3& rot)
{
- if (m_pPhysicsController1)
- {
- m_pPhysicsController1->setOrientation(rot.getRotation());
- }
- if (GetSGNode())
- GetSGNode()->SetLocalOrientation(rot);
- else
+ // check on valid node in case a python controller holds a reference to a deleted object
+ if (!GetSGNode())
+ return;
+
+ if (m_pPhysicsController1 && !GetSGNode()->GetSGParent())
{
- int i;
- i=0;
+ // see note above
+ m_pPhysicsController1->setOrientation(rot);
}
+ GetSGNode()->SetLocalOrientation(rot);
}
void KX_GameObject::NodeSetLocalScale(const MT_Vector3& scale)
{
- if (m_pPhysicsController1)
+ // check on valid node in case a python controller holds a reference to a deleted object
+ if (!GetSGNode())
+ return;
+
+ if (m_pPhysicsController1 && !GetSGNode()->GetSGParent())
{
+ // see note above
m_pPhysicsController1->setScaling(scale);
}
-
- if (GetSGNode())
- GetSGNode()->SetLocalScale(scale);
+ GetSGNode()->SetLocalScale(scale);
}
@@ -555,9 +844,44 @@ void KX_GameObject::NodeSetLocalScale(const MT_Vector3& scale)
void KX_GameObject::NodeSetRelativeScale(const MT_Vector3& scale)
{
if (GetSGNode())
+ {
GetSGNode()->RelativeScale(scale);
+ 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);
+ }
+ }
}
+void KX_GameObject::NodeSetWorldPosition(const MT_Point3& trans)
+{
+ SG_Node* parent = m_pSGNode->GetSGParent();
+ 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);
+ }
+}
void KX_GameObject::NodeUpdateGS(double time,bool bInitiator)
@@ -570,6 +894,13 @@ void KX_GameObject::NodeUpdateGS(double time,bool bInitiator)
const MT_Matrix3x3& KX_GameObject::NodeGetWorldOrientation() const
{
+ static MT_Matrix3x3 defaultOrientation = MT_Matrix3x3( 1.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0,
+ 0.0, 0.0, 1.0);
+
+ // check on valid node in case a python controller holds a reference to a deleted object
+ if (!GetSGNode())
+ return defaultOrientation;
return GetSGNode()->GetWorldOrientation();
}
@@ -577,6 +908,12 @@ const MT_Matrix3x3& KX_GameObject::NodeGetWorldOrientation() const
const MT_Vector3& KX_GameObject::NodeGetWorldScaling() const
{
+ static MT_Vector3 defaultScaling = MT_Vector3(1.0, 1.0, 1.0);
+
+ // check on valid node in case a python controller holds a reference to a deleted object
+ if (!GetSGNode())
+ return defaultScaling;
+
return GetSGNode()->GetWorldScaling();
}
@@ -584,6 +921,12 @@ const MT_Vector3& KX_GameObject::NodeGetWorldScaling() const
const MT_Point3& KX_GameObject::NodeGetWorldPosition() const
{
+ static MT_Point3 defaultPosition = MT_Point3(0.0, 0.0, 0.0);
+
+ // check on valid node in case a python controller holds a reference to a deleted object
+ if (!GetSGNode())
+ return defaultPosition;
+
return GetSGNode()->GetWorldPosition();
}
@@ -604,7 +947,7 @@ void KX_GameObject::Resume(void)
}
}
-void KX_GameObject::Suspend(void)
+void KX_GameObject::Suspend()
{
if ((!m_ignore_activity_culling)
&& (!m_suspended)) {
@@ -623,25 +966,44 @@ void KX_GameObject::Suspend(void)
PyMethodDef KX_GameObject::Methods[] = {
- {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_VARARGS},
- {"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_VARARGS},
- {"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_VARARGS},
- {"getOrientation", (PyCFunction) KX_GameObject::sPyGetOrientation, METH_VARARGS},
- {"setOrientation", (PyCFunction) KX_GameObject::sPySetOrientation, METH_VARARGS},
+ {"getPosition", (PyCFunction) KX_GameObject::sPyGetPosition, METH_NOARGS},
+ {"setPosition", (PyCFunction) KX_GameObject::sPySetPosition, METH_O},
+ {"setWorldPosition", (PyCFunction) KX_GameObject::sPySetWorldPosition, METH_O},
{"getLinearVelocity", (PyCFunction) KX_GameObject::sPyGetLinearVelocity, METH_VARARGS},
+ {"setLinearVelocity", (PyCFunction) KX_GameObject::sPySetLinearVelocity, METH_VARARGS},
+ {"getAngularVelocity", (PyCFunction) KX_GameObject::sPyGetAngularVelocity, METH_VARARGS},
+ {"setAngularVelocity", (PyCFunction) KX_GameObject::sPySetAngularVelocity, METH_VARARGS},
{"getVelocity", (PyCFunction) KX_GameObject::sPyGetVelocity, METH_VARARGS},
- {"getMass", (PyCFunction) KX_GameObject::sPyGetMass, METH_VARARGS},
- {"getReactionForce", (PyCFunction) KX_GameObject::sPyGetReactionForce, METH_VARARGS},
+ {"getMass", (PyCFunction) KX_GameObject::sPyGetMass, METH_NOARGS},
+ {"getReactionForce", (PyCFunction) KX_GameObject::sPyGetReactionForce, METH_NOARGS},
+ {"getOrientation", (PyCFunction) KX_GameObject::sPyGetOrientation, METH_NOARGS},
+ {"setOrientation", (PyCFunction) KX_GameObject::sPySetOrientation, METH_O},
+ {"getVisible",(PyCFunction) KX_GameObject::sPyGetVisible, METH_NOARGS},
+ {"setVisible",(PyCFunction) KX_GameObject::sPySetVisible, METH_VARARGS},
+ {"getState",(PyCFunction) KX_GameObject::sPyGetState, METH_NOARGS},
+ {"setState",(PyCFunction) KX_GameObject::sPySetState, METH_O},
+ {"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},
{"applyImpulse", (PyCFunction) KX_GameObject::sPyApplyImpulse, METH_VARARGS},
- {"setCollisionMargin", (PyCFunction) KX_GameObject::sPySetCollisionMargin, METH_VARARGS},
- {"suspendDynamics", (PyCFunction)KX_GameObject::sPySuspendDynamics,METH_VARARGS},
- {"restoreDynamics", (PyCFunction)KX_GameObject::sPyRestoreDynamics,METH_VARARGS},
- {"enableRigidBody", (PyCFunction)KX_GameObject::sPyEnableRigidBody,METH_VARARGS},
- {"disableRigidBody", (PyCFunction)KX_GameObject::sPyDisableRigidBody,METH_VARARGS},
- {"getParent", (PyCFunction)KX_GameObject::sPyGetParent,METH_VARARGS},
+ {"setCollisionMargin", (PyCFunction) KX_GameObject::sPySetCollisionMargin, METH_O},
+ {"getParent", (PyCFunction)KX_GameObject::sPyGetParent,METH_NOARGS},
+ {"setParent", (PyCFunction)KX_GameObject::sPySetParent,METH_O},
+ {"removeParent", (PyCFunction)KX_GameObject::sPyRemoveParent,METH_NOARGS},
+ {"getChildren", (PyCFunction)KX_GameObject::sPyGetChildren,METH_NOARGS},
+ {"getChildrenRecursive", (PyCFunction)KX_GameObject::sPyGetChildrenRecursive,METH_NOARGS},
{"getMesh", (PyCFunction)KX_GameObject::sPyGetMesh,METH_VARARGS},
- {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_VARARGS},
+ {"getPhysicsId", (PyCFunction)KX_GameObject::sPyGetPhysicsId,METH_NOARGS},
+ {"getPropertyNames", (PyCFunction)KX_GameObject::sPyGetPropertyNames,METH_NOARGS},
+ {"replaceMesh",(PyCFunction) KX_GameObject::sPyReplaceMesh, METH_O},
+ {"endObject",(PyCFunction) KX_GameObject::sPyEndObject, METH_NOARGS},
+ KX_PYMETHODTABLE(KX_GameObject, rayCastTo),
+ KX_PYMETHODTABLE(KX_GameObject, rayCast),
KX_PYMETHODTABLE(KX_GameObject, getDistanceTo),
+ KX_PYMETHODTABLE(KX_GameObject, getVectTo),
{NULL,NULL} //Sentinel
};
@@ -663,19 +1025,40 @@ bool KX_GameObject::ConvertPythonVectorArgs(PyObject* args,
}
*/
-
-PyObject* KX_GameObject::sPySetPosition(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PyReplaceMesh(PyObject* self, PyObject* value)
{
- return ((KX_GameObject*) self)->PySetPosition(self, args, kwds);
+ KX_Scene *scene = KX_GetActiveScene();
+ char* meshname;
+ void* mesh_pt;
+
+ meshname = PyString_AsString(value);
+ if (meshname==NULL) {
+ PyErr_SetString(PyExc_ValueError, "Expected a mesh name");
+ return NULL;
+ }
+ mesh_pt = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname));
+
+ if (mesh_pt==NULL) {
+ PyErr_SetString(PyExc_ValueError, "The mesh name given does not exist");
+ return NULL;
+ }
+ scene->ReplaceMesh(this, (class RAS_MeshObject*)mesh_pt);
+
+ Py_RETURN_NONE;
}
+
+PyObject* KX_GameObject::PyEndObject(PyObject* self)
+{
+
+ KX_Scene *scene = KX_GetActiveScene();
+ scene->DelayedRemoveObject(this);
+ Py_RETURN_NONE;
+
+}
-PyObject* KX_GameObject::PyGetPosition(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PyGetPosition(PyObject* self)
{
return PyObjectFrom(NodeGetWorldPosition());
}
@@ -729,7 +1112,7 @@ PyObject* KX_GameObject::_getattr(const STR_String& attr)
parent->AddRef();
return parent;
}
- Py_Return;
+ Py_RETURN_NONE;
}
if (attr == "visible")
@@ -746,27 +1129,53 @@ PyObject* KX_GameObject::_getattr(const STR_String& attr)
if (attr == "name")
return PyString_FromString(m_name.ReadPtr());
+ if (attr == "timeOffset") {
+ if (m_pSGNode->GetSGParent()->IsSlowParent()) {
+ return PyFloat_FromDouble(static_cast<KX_SlowParentRelation *>(m_pSGNode->GetSGParent()->GetParentRelation())->GetTimeOffset());
+ } else {
+ return PyFloat_FromDouble(0.0);
+ }
+ }
+
_getattr_up(SCA_IObject);
}
int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr method
{
- if (attr == "mass")
+ if (attr == "mass") {
+ PyErr_SetString(PyExc_AttributeError, "attribute \"mass\" is read only");
return 1;
+ }
- if (attr == "parent")
+ if (attr == "parent") {
+ PyErr_SetString(PyExc_AttributeError, "attribute \"mass\" is read only\nUse setParent()");
return 1;
+ }
if (PyInt_Check(value))
{
int val = PyInt_AsLong(value);
if (attr == "visible")
{
- SetVisible(val != 0);
+ SetVisible(val != 0, false);
+ UpdateBuckets(false);
return 0;
}
}
+
+ if (PyFloat_Check(value))
+ {
+ MT_Scalar val = PyFloat_AsDouble(value);
+ if (attr == "timeOffset") {
+ if (m_pSGNode->GetSGParent() && m_pSGNode->GetSGParent()->IsSlowParent()) {
+ static_cast<KX_SlowParentRelation *>(m_pSGNode->GetSGParent()->GetParentRelation())->SetTimeOffset(val);
+ return 0;
+ } else {
+ return 0;
+ }
+ }
+ }
if (PySequence_Check(value))
{
@@ -778,6 +1187,7 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr
if (PyMatTo(value, rot))
{
NodeSetLocalOrientation(rot);
+ NodeUpdateGS(0.f,true);
return 0;
}
return 1;
@@ -790,6 +1200,7 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr
{
rot.setRotation(qrot);
NodeSetLocalOrientation(rot);
+ NodeUpdateGS(0.f,true);
return 0;
}
return 1;
@@ -802,11 +1213,12 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr
{
rot.setEuler(erot);
NodeSetLocalOrientation(rot);
+ NodeUpdateGS(0.f,true);
return 0;
}
return 1;
}
-
+ PyErr_SetString(PyExc_AttributeError, "could not set the orientation from a 3x3 matrix, quaternion or euler sequence");
return 1;
}
@@ -816,6 +1228,7 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr
if (PyVecTo(value, pos))
{
NodeSetLocalPosition(pos);
+ NodeUpdateGS(0.f,true);
return 0;
}
return 1;
@@ -827,6 +1240,7 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr
if (PyVecTo(value, scale))
{
NodeSetLocalScale(scale);
+ NodeUpdateGS(0.f,true);
return 0;
}
return 1;
@@ -842,44 +1256,117 @@ int KX_GameObject::_setattr(const STR_String& attr, PyObject *value) // _setattr
}
}
+ /* Need to have parent settable here too */
+
return SCA_IObject::_setattr(attr, value);
}
-PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PyGetLinearVelocity(PyObject* self, PyObject* args)
{
// only can get the velocity if we have a physics object connected to us...
- return PyObjectFrom(GetLinearVelocity());
+ int local = 0;
+ if (PyArg_ParseTuple(args,"|i",&local))
+ {
+ return PyObjectFrom(GetLinearVelocity((local!=0)));
+ }
+ else
+ {
+ return NULL;
+ }
}
-
-
-PyObject* KX_GameObject::PySetVisible(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PySetLinearVelocity(PyObject* self, PyObject* args)
{
- int visible = 1;
+ int local = 0;
+ PyObject* pyvect;
- if (PyArg_ParseTuple(args,"i",&visible))
+ if (PyArg_ParseTuple(args,"O|i",&pyvect,&local)) {
+ MT_Vector3 velocity;
+ if (PyVecTo(pyvect, velocity)) {
+ setLinearVelocity(velocity, (local!=0));
+ Py_RETURN_NONE;
+ }
+ }
+ return NULL;
+}
+
+PyObject* KX_GameObject::PyGetAngularVelocity(PyObject* self, PyObject* args)
+{
+ // only can get the velocity if we have a physics object connected to us...
+ int local = 0;
+ if (PyArg_ParseTuple(args,"|i",&local))
{
- MarkVisible(visible!=0);
- m_bVisible = (visible!=0);
+ return PyObjectFrom(GetAngularVelocity((local!=0)));
}
else
{
- return NULL;
+ return NULL;
}
- Py_Return;
+}
+
+PyObject* KX_GameObject::PySetAngularVelocity(PyObject* self, PyObject* args)
+{
+ int local = 0;
+ PyObject* pyvect;
+ if (PyArg_ParseTuple(args,"O|i",&pyvect,&local)) {
+ MT_Vector3 velocity;
+ if (PyVecTo(pyvect, velocity)) {
+ setAngularVelocity(velocity, (local!=0));
+ Py_RETURN_NONE;
+ }
+ }
+ return NULL;
+}
+
+PyObject* KX_GameObject::PySetVisible(PyObject* self, PyObject* args)
+{
+ int visible, recursive = 0;
+ if (!PyArg_ParseTuple(args,"i|i",&visible, &recursive))
+ return NULL;
+
+ SetVisible(visible ? true:false, recursive ? true:false);
+ UpdateBuckets(recursive ? true:false);
+ Py_RETURN_NONE;
+
+}
+
+PyObject* KX_GameObject::PyGetVisible(PyObject* self)
+{
+ return PyInt_FromLong(m_bVisible);
+}
+
+PyObject* KX_GameObject::PyGetState(PyObject* self)
+{
+ int state = 0;
+ state |= GetState();
+ return PyInt_FromLong(state);
+}
+
+PyObject* KX_GameObject::PySetState(PyObject* self, PyObject* value)
+{
+ int state_i = PyInt_AsLong(value);
+ unsigned int state = 0;
+
+ if (state_i == -1 && PyErr_Occurred()) {
+ PyErr_SetString(PyExc_TypeError, "expected an int bit field");
+ return NULL;
+ }
+
+ state |= state_i;
+ if ((state & ((1<<30)-1)) == 0) {
+ PyErr_SetString(PyExc_AttributeError, "The state bitfield was not between 0 and 30 (1<<0 and 1<<29)");
+ return NULL;
+ }
+ SetState(state);
+
+ Py_RETURN_NONE;
}
-PyObject* KX_GameObject::PyGetVelocity(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PyGetVelocity(PyObject* self, PyObject* args)
{
// only can get the velocity if we have a physics object connected to us...
MT_Vector3 velocity(0.0,0.0,0.0);
@@ -892,6 +1379,9 @@ PyObject* KX_GameObject::PyGetVelocity(PyObject* self,
if (pypos)
PyVecTo(pypos, point);
}
+ else {
+ return NULL;
+ }
if (m_pPhysicsController1)
{
@@ -903,26 +1393,14 @@ PyObject* KX_GameObject::PyGetVelocity(PyObject* self,
-PyObject* KX_GameObject::PyGetMass(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PyGetMass(PyObject* self)
{
- PyObject* pymass = NULL;
-
- float mass = GetPhysicsController()->GetMass();
- pymass = PyFloat_FromDouble(mass);
-
- if (pymass)
- return pymass;
-
- Py_Return;
+ return PyFloat_FromDouble(GetPhysicsController()->GetMass());
}
-PyObject* KX_GameObject::PyGetReactionForce(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PyGetReactionForce(PyObject* self)
{
// only can get the velocity if we have a physics object connected to us...
return PyObjectFrom(GetPhysicsController()->getReactionForce());
@@ -930,32 +1408,25 @@ PyObject* KX_GameObject::PyGetReactionForce(PyObject* self,
-PyObject* KX_GameObject::PyEnableRigidBody(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PyEnableRigidBody(PyObject* self)
{
-
GetPhysicsController()->setRigidBody(true);
- Py_Return;
+ Py_RETURN_NONE;
}
-PyObject* KX_GameObject::PyDisableRigidBody(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PyDisableRigidBody(PyObject* self)
{
GetPhysicsController()->setRigidBody(false);
- Py_Return;
+ Py_RETURN_NONE;
}
-PyObject* KX_GameObject::PyGetParent(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PyGetParent(PyObject* self)
{
KX_GameObject* parent = this->GetParent();
if (parent)
@@ -963,69 +1434,128 @@ PyObject* KX_GameObject::PyGetParent(PyObject* self,
parent->AddRef();
return parent;
}
- Py_Return;
+ Py_RETURN_NONE;
+}
+
+PyObject* KX_GameObject::PySetParent(PyObject* self, PyObject* value)
+{
+ if (!PyObject_TypeCheck(value, &KX_GameObject::Type)) {
+ PyErr_SetString(PyExc_TypeError, "expected a KX_GameObject type");
+ return NULL;
+ }
+
+ // The object we want to set as parent
+ CValue *m_ob = (CValue*)value;
+ KX_GameObject *obj = ((KX_GameObject*)m_ob);
+ KX_Scene *scene = KX_GetActiveScene();
+
+ this->SetParent(scene, obj);
+
+ Py_RETURN_NONE;
}
+PyObject* KX_GameObject::PyRemoveParent(PyObject* self)
+{
+ KX_Scene *scene = KX_GetActiveScene();
+ this->RemoveParent(scene);
+ Py_RETURN_NONE;
+}
-PyObject* KX_GameObject::PyGetMesh(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+static void walk_children(SG_Node* node, CListValue* list, bool recursive)
{
- int mesh = 0;
+ NodeList& children = node->GetSGChildren();
- if (PyArg_ParseTuple(args, "|i", &mesh))
+ for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit)
{
- if (((unsigned int)mesh < m_meshes.size()) && mesh >= 0)
+ SG_Node* childnode = (*childit);
+ CValue* childobj = (CValue*)childnode->GetSGClientObject();
+ if (childobj != NULL) // This is a GameObject
{
- KX_MeshProxy* meshproxy = new KX_MeshProxy(m_meshes[mesh]);
- return meshproxy;
+ // 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);
}
}
- Py_Return;
}
+PyObject* KX_GameObject::PyGetChildren(PyObject* self)
+{
+ CListValue* list = new CListValue();
+ walk_children(m_pSGNode, list, 0);
+ return list;
+}
+PyObject* KX_GameObject::PyGetChildrenRecursive(PyObject* self)
+{
+ CListValue* list = new CListValue();
+ walk_children(m_pSGNode, list, 1);
+ return list;
+}
-
-
-PyObject* KX_GameObject::PySetCollisionMargin(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PyGetMesh(PyObject* self, PyObject* args)
{
- float collisionMargin;
- if (PyArg_ParseTuple(args, "f", &collisionMargin))
+ int mesh = 0;
+
+ if (!PyArg_ParseTuple(args, "|i", &mesh))
+ return NULL; // python sets a simple error
+
+ if (((unsigned int)mesh < m_meshes.size()) && mesh >= 0)
{
- if (m_pPhysicsController1)
- {
- m_pPhysicsController1->setMargin(collisionMargin);
- Py_Return;
- }
+ KX_MeshProxy* meshproxy = new KX_MeshProxy(m_meshes[mesh]);
+ return meshproxy;
+ }
+
+ Py_RETURN_NONE;
+}
+
+
+
+
+PyObject* KX_GameObject::PySetCollisionMargin(PyObject* self, PyObject* value)
+{
+ float collisionMargin = PyFloat_AsDouble(value);
+
+ if (collisionMargin==-1 && PyErr_Occurred()) {
+ PyErr_SetString(PyExc_TypeError, "expected a float");
+ return NULL;
}
+ if (m_pPhysicsController1)
+ {
+ m_pPhysicsController1->setMargin(collisionMargin);
+ Py_RETURN_NONE;
+ }
+ PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller");
return NULL;
}
-PyObject* KX_GameObject::PyApplyImpulse(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PyApplyImpulse(PyObject* self, PyObject* args)
{
PyObject* pyattach;
PyObject* pyimpulse;
+
+ if (!m_pPhysicsController1) {
+ PyErr_SetString(PyExc_RuntimeError, "This object has no physics controller");
+ return NULL;
+ }
+
if (PyArg_ParseTuple(args, "OO", &pyattach, &pyimpulse))
{
MT_Point3 attach;
MT_Vector3 impulse;
- if (m_pPhysicsController1)
+ if (PyVecTo(pyattach, attach) && PyVecTo(pyimpulse, impulse))
{
- if (PyVecTo(pyattach, attach) && PyVecTo(pyimpulse, impulse))
- {
- m_pPhysicsController1->applyImpulse(attach, impulse);
- Py_Return;
- }
+ m_pPhysicsController1->applyImpulse(attach, impulse);
+ Py_RETURN_NONE;
}
}
@@ -1035,102 +1565,109 @@ PyObject* KX_GameObject::PyApplyImpulse(PyObject* self,
-PyObject* KX_GameObject::PySuspendDynamics(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PySuspendDynamics(PyObject* self)
{
- if (m_bSuspendDynamics)
- {
- Py_Return;
- }
-
- if (m_pPhysicsController1)
- {
- m_pPhysicsController1->SuspendDynamics();
- }
- m_bSuspendDynamics = true;
-
- Py_Return;
+ SuspendDynamics();
+ Py_RETURN_NONE;
}
-PyObject* KX_GameObject::PyRestoreDynamics(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PyRestoreDynamics(PyObject* self)
{
-
- if (!m_bSuspendDynamics)
- {
- Py_Return;
- }
-
- if (m_pPhysicsController1)
- {
- m_pPhysicsController1->RestoreDynamics();
- }
- m_bSuspendDynamics = false;
-
- Py_Return;
+ RestoreDynamics();
+ Py_RETURN_NONE;
}
-PyObject* KX_GameObject::PyGetOrientation(PyObject* self,
- PyObject* args,
- PyObject* kwds) //keywords
+PyObject* KX_GameObject::PyGetOrientation(PyObject* self) //keywords
{
return PyObjectFrom(NodeGetWorldOrientation());
}
-PyObject* KX_GameObject::PySetOrientation(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PySetOrientation(PyObject* self, PyObject* value)
{
- PyObject* pylist;
-
- if (PyArg_ParseTuple(args,"O",&pylist))
+ MT_Matrix3x3 matrix;
+ if (PyObject_IsMT_Matrix(value, 3) && PyMatTo(value, matrix))
{
- MT_Matrix3x3 matrix;
- if (PyObject_IsMT_Matrix(pylist, 3) && PyMatTo(pylist, matrix))
- {
- NodeSetLocalOrientation(matrix);
- Py_Return;
- }
+ NodeSetLocalOrientation(matrix);
+ NodeUpdateGS(0.f,true);
+ Py_RETURN_NONE;
+ }
+
+ MT_Quaternion quat;
+ if (PyVecTo(value, quat))
+ {
+ matrix.setRotation(quat);
+ NodeSetLocalOrientation(matrix);
+ NodeUpdateGS(0.f,true);
+ Py_RETURN_NONE;
+ }
+ return NULL;
+}
+
+PyObject* KX_GameObject::PyAlignAxisToVect(PyObject* self, PyObject* args)
+{
+ PyObject* pyvect;
+ int axis = 2; //z axis is the default
+ float fac = 1.0;
- MT_Quaternion quat;
- if (PyVecTo(pylist, quat))
+ if (PyArg_ParseTuple(args,"O|if",&pyvect,&axis, &fac))
+ {
+ MT_Vector3 vect;
+ if (PyVecTo(pyvect, vect))
{
- matrix.setRotation(quat);
- NodeSetLocalOrientation(matrix);
- Py_Return;
+ if (fac<=0.0) Py_RETURN_NONE; // Nothing to do.
+ if (fac> 1.0) fac= 1.0;
+
+ AlignAxisToVect(vect,axis,fac);
+ NodeUpdateGS(0.f,true);
+ Py_RETURN_NONE;
}
}
return NULL;
}
+PyObject* KX_GameObject::PyGetAxisVect(PyObject* self, PyObject* value)
+{
+ MT_Vector3 vect;
+ if (PyVecTo(value, vect))
+ {
+ return PyObjectFrom(NodeGetWorldOrientation() * vect);
+ }
+ return NULL;
+}
-
-PyObject* KX_GameObject::PySetPosition(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PySetPosition(PyObject* self, PyObject* value)
{
MT_Point3 pos;
- if (PyVecArgTo(args, pos))
+ if (PyVecTo(value, pos))
{
NodeSetLocalPosition(pos);
NodeUpdateGS(0.f,true);
- Py_Return;
+ Py_RETURN_NONE;
}
-
+
return NULL;
}
-PyObject* KX_GameObject::PyGetPhysicsId(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_GameObject::PySetWorldPosition(PyObject* self, PyObject* value)
+{
+ MT_Point3 pos;
+ if (PyVecTo(value, pos))
+ {
+ NodeSetWorldPosition(pos);
+ NodeUpdateGS(0.f,true);
+ Py_RETURN_NONE;
+ }
+
+ return NULL;
+}
+
+PyObject* KX_GameObject::PyGetPhysicsId(PyObject* self)
{
KX_IPhysicsController* ctrl = GetPhysicsController();
uint_ptr physid=0;
@@ -1141,6 +1678,11 @@ PyObject* KX_GameObject::PyGetPhysicsId(PyObject* self,
return PyInt_FromLong((long)physid);
}
+PyObject* KX_GameObject::PyGetPropertyNames(PyObject* self)
+{
+ return ConvertKeysToPython();
+}
+
KX_PYMETHODDEF_DOC(KX_GameObject, getDistanceTo,
"getDistanceTo(other): get distance to another point/KX_GameObject")
{
@@ -1152,20 +1694,356 @@ KX_PYMETHODDEF_DOC(KX_GameObject, getDistanceTo,
PyErr_Clear();
PyObject *pyother;
- if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &pyother))
+ KX_GameObject *other;
+ if (PyArg_ParseTuple(args, "O", &pyother) && ConvertPythonToGameObject(pyother, &other, false))
{
- KX_GameObject *other = static_cast<KX_GameObject*>(pyother);
return PyFloat_FromDouble(NodeGetWorldPosition().distance(other->NodeGetWorldPosition()));
}
return NULL;
}
+KX_PYMETHODDEF_DOC(KX_GameObject, getVectTo,
+"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;
+
+ PyObject *returnValue;
+ PyObject *pyother;
+
+ if (!PyVecArgTo(args, toPoint))
+ {
+ PyErr_Clear();
+
+ KX_GameObject *other;
+ if (PyArg_ParseTuple(args, "O", &pyother) && ConvertPythonToGameObject(pyother, &other, false))
+ {
+ toPoint = other->NodeGetWorldPosition();
+ } else
+ {
+ PyErr_SetString(PyExc_TypeError, "Expected a 3D Vector or GameObject type");
+ 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();
+ }
+
+ 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));
+ }
+ return returnValue;
+}
+
+bool KX_GameObject::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data)
+{
+ 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;
+}
+
+/* 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)
+{
+ KX_GameObject* hitKXObj = client->m_gameobject;
+
+ if (client->m_type > KX_ClientObjectInfo::ACTOR)
+ {
+ // 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);
+ return false;
+ }
+
+ // 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)
+ {
+ return true;
+ }
+ // skip the object
+ return false;
+}
+
+KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo,
+"rayCastTo(other,dist,prop): look towards another point/KX_GameObject and return first object hit within dist that matches prop\n"
+" 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;
+
+ if (!PyArg_ParseTuple(args,"O|fs", &pyarg, &dist, &propName)) {
+ return NULL; // python sets simple error
+ }
+
+ if (!PyVecTo(pyarg, toPoint))
+ {
+ KX_GameObject *other;
+ PyErr_Clear();
+
+ if (ConvertPythonToGameObject(pyarg, &other, false))
+ {
+ toPoint = other->NodeGetWorldPosition();
+ } else
+ {
+ PyErr_SetString(PyExc_TypeError, "the first argument to rayCastTo must be a vector or a KX_GameObject");
+ return NULL;
+ }
+ }
+ MT_Point3 fromPoint = NodeGetWorldPosition();
+ if (dist != 0.0f)
+ {
+ MT_Vector3 toDir = toPoint-fromPoint;
+ toDir.normalize();
+ toPoint = fromPoint + (dist) * toDir;
+ }
+
+ PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment();
+ 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);
+ KX_RayCast::Callback<KX_GameObject> callback(this,spc);
+ KX_RayCast::RayTest(pe, fromPoint, toPoint, callback);
+
+ if (m_pHitObject)
+ {
+ m_pHitObject->AddRef();
+ return m_pHitObject;
+ }
+ Py_RETURN_NONE;
+}
+
+KX_PYMETHODDEF_DOC(KX_GameObject, rayCast,
+ "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) of contact point with object within dist that matches prop.\n"
+ " If no hit, return (None,None,None) or (None,None,None,None).\n"
+" to = 3-tuple or object reference for destination of ray (if object, use center of object)\n"
+" from = 3-tuple or object reference for origin of ray (if object, use center of object)\n"
+" Can be None or omitted => start from self object center\n"
+" 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"
+" 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")
+{
+ MT_Point3 toPoint;
+ MT_Point3 fromPoint;
+ PyObject* pyto;
+ PyObject* pyfrom = NULL;
+ float dist = 0.0f;
+ char *propName = NULL;
+ KX_GameObject *other;
+ int face=0, xray=0, poly=0;
+
+ if (!PyArg_ParseTuple(args,"O|Ofsiii", &pyto, &pyfrom, &dist, &propName, &face, &xray, &poly)) {
+ return NULL; // Python sets a simple error
+ }
+
+ if (!PyVecTo(pyto, toPoint))
+ {
+ PyErr_Clear();
+
+ if (ConvertPythonToGameObject(pyto, &other, false))
+ {
+ toPoint = other->NodeGetWorldPosition();
+ } else
+ {
+ PyErr_SetString(PyExc_TypeError, "the first argument to rayCast must be a vector or a KX_GameObject");
+ return NULL;
+ }
+ }
+ if (!pyfrom || pyfrom == Py_None)
+ {
+ fromPoint = NodeGetWorldPosition();
+ }
+ else if (!PyVecTo(pyfrom, fromPoint))
+ {
+ PyErr_Clear();
+
+ if (ConvertPythonToGameObject(pyfrom, &other, false))
+ {
+ fromPoint = other->NodeGetWorldPosition();
+ } else
+ {
+ PyErr_SetString(PyExc_TypeError, "the second optional argument to rayCast must be a vector or a KX_GameObject");
+ return NULL;
+ }
+ }
+
+ if (dist != 0.0f) {
+ MT_Vector3 toDir = toPoint-fromPoint;
+ if (MT_fuzzyZero(toDir.length2())) {
+ return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
+ }
+ toDir.normalize();
+ toPoint = fromPoint + (dist) * toDir;
+ } else if (MT_fuzzyZero((toPoint-fromPoint).length2())) {
+ return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
+ }
+
+ PHY_IPhysicsEnvironment* pe = GetPhysicsEnvironment();
+ 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);
+ m_xray = xray;
+ // to get the hit results
+ KX_RayCast::Callback<KX_GameObject> callback(this,spc,NULL,face);
+ KX_RayCast::RayTest(pe, fromPoint, toPoint, callback);
+
+ if (m_pHitObject)
+ {
+ PyObject* returnValue = (poly) ? PyTuple_New(4) : PyTuple_New(3);
+ if (returnValue) { // unlikely this would ever fail, if it does python sets an error
+ PyTuple_SET_ITEM(returnValue, 0, m_pHitObject->AddRef());
+ 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
+ RAS_Polygon* poly = callback.m_hitMesh->GetPolygon(callback.m_hitPolygon);
+ KX_PolyProxy* polyproxy = new KX_PolyProxy(callback.m_hitMesh, poly);
+ PyTuple_SET_ITEM(returnValue, 3, polyproxy);
+ }
+ else
+ {
+ Py_INCREF(Py_None);
+ PyTuple_SET_ITEM(returnValue, 3, Py_None);
+ }
+ }
+ }
+ return returnValue;
+ }
+ // no hit
+ if (poly)
+ return Py_BuildValue("OOOO", Py_None, Py_None, Py_None, Py_None);
+ else
+ return Py_BuildValue("OOO", Py_None, Py_None, Py_None);
+}
+
/* ---------------------------------------------------------------------
* Some stuff taken from the header
* --------------------------------------------------------------------- */
void KX_GameObject::Relink(GEN_Map<GEN_HashedPtr, void*> *map_parameter)
{
- /* intentionally empty ? */
+ // 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);
+ }
}
+bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok)
+{
+ if (value==NULL) {
+ PyErr_SetString(PyExc_TypeError, "Error in ConvertPythonToGameObject, python pointer NULL, should never happen");
+ *object = NULL;
+ return false;
+ }
+
+ if (value==Py_None) {
+ *object = NULL;
+
+ if (py_none_ok) {
+ return true;
+ } else {
+ PyErr_SetString(PyExc_TypeError, "Expected KX_GameObject or a string for a name of a KX_GameObject, None is invalid");
+ return false;
+ }
+ return (py_none_ok ? true : false);
+ }
+
+ if (PyString_Check(value)) {
+ *object = (KX_GameObject *)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String( PyString_AsString(value) ));
+
+ if (*object) {
+ return true;
+ } else {
+ PyErr_SetString(PyExc_ValueError, "Requested name did not match any KX_GameObject");
+ return false;
+ }
+ }
+
+ if (PyObject_TypeCheck(value, &KX_GameObject::Type)) {
+ *object = static_cast<KX_GameObject*>(value);
+ return true;
+ }
+
+ *object = NULL;
+
+ if (py_none_ok) {
+ PyErr_SetString(PyExc_TypeError, "Expect a KX_GameObject, a string or None");
+ } else {
+ PyErr_SetString(PyExc_TypeError, "Expect a KX_GameObject or a string");
+ }
+
+ return false;
+}
diff --git a/source/gameengine/Ketsji/KX_GameObject.h b/source/gameengine/Ketsji/KX_GameObject.h
index c82ee9cfdab..20b15787d27 100644
--- a/source/gameengine/Ketsji/KX_GameObject.h
+++ b/source/gameengine/Ketsji/KX_GameObject.h
@@ -44,17 +44,21 @@
#include "MT_CmMatrix4x4.h"
#include "GEN_Map.h"
#include "GEN_HashedPtr.h"
-
-#define KX_FIXED_FRAME_PER_SEC 25.0f
-#define KX_FIXED_SEC_PER_FRAME (1.0f / KX_FIXED_FRAME_PER_SEC)
+#include "KX_Scene.h"
+#include "KX_KetsjiEngine.h" /* for m_anim_framerate */
+#include "KX_IPhysicsController.h" /* for suspend/resume */
+#include "DNA_object_types.h"
+#include "SCA_LogicManager.h" /* for ConvertPythonToGameObject to search object names */
#define KX_OB_DYNAMIC 1
//Forward declarations.
struct KX_ClientObjectInfo;
+class KX_RayCast;
class RAS_MeshObject;
class KX_IPhysicsController;
-
+class PHY_IPhysicsEnvironment;
+struct Object;
/**
* KX_GameObject is the main class for dynamic objects.
@@ -68,17 +72,28 @@ protected:
KX_ClientObjectInfo* m_pClient_info;
STR_String m_name;
STR_String m_text;
+ int m_layer;
std::vector<RAS_MeshObject*> m_meshes;
+ struct Object* m_pBlenderObject;
+ struct Object* m_pBlenderGroupObject;
bool m_bSuspendDynamics;
bool m_bUseObjectColor;
+ bool m_bIsNegativeScaling;
MT_Vector4 m_objectColor;
- // Is this object set to be visible? Only useful for the
- // visibility subsystem right now.
- bool m_bVisible;
+ // visible = user setting
+ // culled = while rendering, depending on camera
+ bool m_bVisible;
+ bool m_bCulled;
KX_IPhysicsController* m_pPhysicsController1;
+ // used for ray casting
+ PHY_IPhysicsEnvironment* m_pPhysicsEnvironment;
+ STR_String m_testPropName;
+ bool m_xray;
+ KX_GameObject* m_pHitObject;
+
SG_Node* m_pSGNode;
MT_CmMatrix4x4 m_OpenGL_4x4Matrix;
@@ -125,6 +140,15 @@ public:
GetParent(
);
+ /**
+ * Sets the parent of this object to a game object
+ */
+ void SetParent(KX_Scene *scene, KX_GameObject *obj);
+
+ /**
+ * Removes the parent of this object to a game object
+ */
+ void RemoveParent(KX_Scene *scene);
/**
* Construct a game object. This class also inherits the
@@ -235,8 +259,42 @@ public:
/**
* Return the linear velocity of the game object.
*/
- MT_Vector3
+ MT_Vector3
GetLinearVelocity(
+ bool local=false
+ );
+
+ /**
+ * Return the linear velocity of a given point in world coordinate
+ * but relative to center of object ([0,0,0]=center of object)
+ */
+ MT_Vector3
+ GetVelocity(
+ const MT_Point3& position
+ );
+
+ /**
+ * Return the mass of the object
+ */
+ MT_Scalar
+ GetMass();
+
+ /**
+ * Return the angular velocity of the game object.
+ */
+ MT_Vector3
+ GetAngularVelocity(
+ bool local=false
+ );
+
+ /**
+ * Align the object to a given normal.
+ */
+ void
+ AlignAxisToVect(
+ const MT_Vector3& vect,
+ int axis = 2,
+ float fac = 1.0
);
/**
@@ -259,6 +317,19 @@ public:
/**
+ * @return a pointer to the physics environment in use during the game, for rayCasting
+ */
+ PHY_IPhysicsEnvironment* GetPhysicsEnvironment()
+ {
+ return m_pPhysicsEnvironment;
+ }
+
+ void SetPhysicsEnvironment(PHY_IPhysicsEnvironment* physicsEnvironment)
+ {
+ m_pPhysicsEnvironment = physicsEnvironment;
+ }
+
+ /**
* @return a pointer to the physics controller owned by this class.
*/
@@ -270,6 +341,14 @@ public:
m_pPhysicsController1 = physicscontroller;
}
+ virtual class RAS_Deformer* GetDeformer()
+ {
+ return 0;
+ }
+ virtual void SetDeformer(class RAS_Deformer* deformer)
+ {
+
+ }
/**
* @section Coordinate system manipulation functions
@@ -283,6 +362,9 @@ public:
void NodeSetRelativeScale( const MT_Vector3& scale );
+ // adapt local position so that world position is set to desired position
+ void NodeSetWorldPosition(const MT_Point3& trans);
+
void
NodeUpdateGS(
double time,
@@ -320,6 +402,37 @@ public:
}
/**
+ * @section blender object accessor functions.
+ */
+
+ struct Object* GetBlenderObject( )
+ {
+ return m_pBlenderObject;
+ }
+
+ void SetBlenderObject( struct Object* obj)
+ {
+ m_pBlenderObject = obj;
+ }
+
+ struct Object* GetBlenderGroupObject( )
+ {
+ return m_pBlenderGroupObject;
+ }
+
+ void SetBlenderGroupObject( struct Object* obj)
+ {
+ m_pBlenderGroupObject = obj;
+ }
+
+ bool IsDupliGroup()
+ {
+ return (m_pBlenderObject &&
+ (m_pBlenderObject->transflag & OB_DUPLIGROUP) &&
+ m_pBlenderObject->dup_group != NULL) ? true : false;
+ }
+
+ /**
* Set the Scene graph node for this game object.
* warning - it is your responsibility to make sure
* all controllers look at this new node. You must
@@ -337,7 +450,18 @@ public:
{
return m_bDyna;
}
-
+
+ /**
+ * Check if this object has a vertex parent relationship
+ */
+ bool IsVertexParent( )
+ {
+ return (m_pSGNode && m_pSGNode->GetSGParent() && m_pSGNode->GetSGParent()->IsVertexParent());
+ }
+
+ bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
+ bool NeedRayCast(KX_ClientObjectInfo* client);
+
/**
* @section Physics accessors for this node.
@@ -408,20 +532,29 @@ public:
);
/**
+ * Function to set IPO option at start of IPO
+ */
+ void
+ InitIPO(
+ bool ipo_as_force,
+ bool ipo_add,
+ bool ipo_local
+ );
+
+ /**
* Odd function to update an ipo. ???
*/
void
UpdateIPO(
float curframetime,
- bool recurse,
- bool ipo_as_force,
- bool force_ipo_local
+ bool recurse
);
/**
* Updates Material Ipo data
*/
void
UpdateMaterialData(
+ dword matname_hash,
MT_Vector4 rgba,
MT_Vector3 specrgb,
MT_Scalar hard,
@@ -434,18 +567,23 @@ public:
/**
* @section Mesh accessor functions.
*/
+
+ /**
+ * Update buckets to indicate that there is a new
+ * user of this object's meshes.
+ */
+ void
+ AddMeshUser(
+ );
/**
- * Run through the meshes associated with this
- * object and bucketize them. See RAS_Mesh for
- * more details on this function. Interesting to
- * note that polygon bucketizing seems to happen on a per
- * object basis. Which may explain why there is such
- * a big performance gain when all static objects
- * are joined into 1.
+ * Update buckets with data about the mesh after
+ * creating or duplicating the object, changing
+ * visibility, object color, .. .
*/
void
- Bucketize(
+ UpdateBuckets(
+ bool recursive
);
/**
@@ -506,42 +644,74 @@ public:
ResetDebugColor(
);
- /**
- * Set the visibility of the meshes associated with this
- * object.
+ /**
+ * Was this object marked visible? (only for the explicit
+ * visibility system).
*/
- void
- MarkVisible(
- bool visible
+ bool
+ GetVisible(
+ void
);
- /**
- * Set the visibility according to the visibility flag.
+ /**
+ * Set visibility flag of this object
*/
- void
- MarkVisible(
void
+ SetVisible(
+ bool b,
+ bool recursive
);
/**
- * Was this object marked visible? (only for the ewxplicit
- * visibility system).
+ * Was this object culled?
*/
bool
- GetVisible(
+ GetCulled(
void
);
/**
- * Set visibility flag of this object
+ * Set culled flag of this object
*/
void
- SetVisible(
- bool b
+ SetCulled(
+ bool c
);
+ /**
+ * Change the layer of the object (when it is added in another layer
+ * than the original layer)
+ */
+ void
+ SetLayer(
+ int l
+ );
+
+ /**
+ * Get the object layer
+ */
+ int
+ GetLayer(
+ void
+ );
/**
+ * Get the negative scaling state
+ */
+ bool
+ IsNegativeScaling(
+ void
+ ) { return m_bIsNegativeScaling; }
+
+ /**
+ * Is this a light?
+ */
+ virtual bool
+ IsLight(
+ void
+ ) { return false; }
+
+ /**
* @section Logic bubbling methods.
*/
@@ -555,6 +725,32 @@ public:
*/
void Resume(void);
+ void SuspendDynamics(void) {
+ if (m_bSuspendDynamics)
+ {
+ return;
+ }
+
+ if (m_pPhysicsController1)
+ {
+ m_pPhysicsController1->SuspendDynamics();
+ }
+ m_bSuspendDynamics = true;
+ }
+
+ void RestoreDynamics(void) {
+ if (!m_bSuspendDynamics)
+ {
+ return;
+ }
+
+ if (m_pPhysicsController1)
+ {
+ m_pPhysicsController1->RestoreDynamics();
+ }
+ m_bSuspendDynamics = false;
+ }
+
KX_ClientObjectInfo* getClientInfo() { return m_pClient_info; }
/**
* @section Python interface functions.
@@ -573,39 +769,45 @@ public:
PyObject *value
); // _setattr method
- PyObject*
- PySetPosition(
- PyObject* self,
- PyObject* args,
- PyObject* kwds
- );
-
- static
- PyObject*
- sPySetPosition(
- PyObject* self,
- PyObject* args,
- PyObject* kwds
- );
-
- KX_PYMETHOD(KX_GameObject,GetPosition);
- KX_PYMETHOD(KX_GameObject,GetLinearVelocity);
- KX_PYMETHOD(KX_GameObject,GetVelocity);
- KX_PYMETHOD(KX_GameObject,GetMass);
- KX_PYMETHOD(KX_GameObject,GetReactionForce);
- KX_PYMETHOD(KX_GameObject,GetOrientation);
- KX_PYMETHOD(KX_GameObject,SetOrientation);
- KX_PYMETHOD(KX_GameObject,SetVisible);
- KX_PYMETHOD(KX_GameObject,SuspendDynamics);
- KX_PYMETHOD(KX_GameObject,RestoreDynamics);
- KX_PYMETHOD(KX_GameObject,EnableRigidBody);
- KX_PYMETHOD(KX_GameObject,DisableRigidBody);
- KX_PYMETHOD(KX_GameObject,ApplyImpulse);
- KX_PYMETHOD(KX_GameObject,SetCollisionMargin);
- KX_PYMETHOD(KX_GameObject,GetMesh);
- KX_PYMETHOD(KX_GameObject,GetParent);
- KX_PYMETHOD(KX_GameObject,GetPhysicsId);
+ KX_PYMETHOD_NOARGS(KX_GameObject,GetPosition);
+ KX_PYMETHOD_O(KX_GameObject,SetPosition);
+ KX_PYMETHOD_O(KX_GameObject,SetWorldPosition);
+ KX_PYMETHOD_VARARGS(KX_GameObject,GetLinearVelocity);
+ KX_PYMETHOD_VARARGS(KX_GameObject,SetLinearVelocity);
+ KX_PYMETHOD_VARARGS(KX_GameObject,GetAngularVelocity);
+ KX_PYMETHOD_VARARGS(KX_GameObject,SetAngularVelocity);
+ KX_PYMETHOD_VARARGS(KX_GameObject,GetVelocity);
+ KX_PYMETHOD_NOARGS(KX_GameObject,GetMass);
+ KX_PYMETHOD_NOARGS(KX_GameObject,GetReactionForce);
+ KX_PYMETHOD_NOARGS(KX_GameObject,GetOrientation);
+ KX_PYMETHOD_O(KX_GameObject,SetOrientation);
+ KX_PYMETHOD_NOARGS(KX_GameObject,GetVisible);
+ KX_PYMETHOD_VARARGS(KX_GameObject,SetVisible);
+ KX_PYMETHOD_NOARGS(KX_GameObject,GetState);
+ KX_PYMETHOD_O(KX_GameObject,SetState);
+ KX_PYMETHOD_VARARGS(KX_GameObject,AlignAxisToVect);
+ KX_PYMETHOD_O(KX_GameObject,GetAxisVect);
+ KX_PYMETHOD_NOARGS(KX_GameObject,SuspendDynamics);
+ KX_PYMETHOD_NOARGS(KX_GameObject,RestoreDynamics);
+ KX_PYMETHOD_NOARGS(KX_GameObject,EnableRigidBody);
+ KX_PYMETHOD_NOARGS(KX_GameObject,DisableRigidBody);
+ KX_PYMETHOD_VARARGS(KX_GameObject,ApplyImpulse);
+ KX_PYMETHOD_O(KX_GameObject,SetCollisionMargin);
+ KX_PYMETHOD_NOARGS(KX_GameObject,GetParent);
+ KX_PYMETHOD_O(KX_GameObject,SetParent);
+ KX_PYMETHOD_NOARGS(KX_GameObject,RemoveParent);
+ KX_PYMETHOD_NOARGS(KX_GameObject,GetChildren);
+ KX_PYMETHOD_NOARGS(KX_GameObject,GetChildrenRecursive);
+ KX_PYMETHOD_VARARGS(KX_GameObject,GetMesh);
+ KX_PYMETHOD_NOARGS(KX_GameObject,GetPhysicsId);
+ KX_PYMETHOD_NOARGS(KX_GameObject,GetPropertyNames);
+ KX_PYMETHOD_O(KX_GameObject,ReplaceMesh);
+ KX_PYMETHOD_NOARGS(KX_GameObject,EndObject);
+ KX_PYMETHOD_DOC(KX_GameObject,rayCastTo);
+ KX_PYMETHOD_DOC(KX_GameObject,rayCast);
KX_PYMETHOD_DOC(KX_GameObject,getDistanceTo);
+ KX_PYMETHOD_DOC(KX_GameObject,getVectTo);
+
private :
/**
@@ -623,5 +825,8 @@ private :
};
+/* utility conversion function */
+bool ConvertPythonToGameObject(PyObject * value, KX_GameObject **object, bool py_none_ok);
+
#endif //__KX_GAMEOBJECT
diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.cpp b/source/gameengine/Ketsji/KX_IPO_SGController.cpp
index bb4b75c6c4a..67d54cf0b0b 100644
--- a/source/gameengine/Ketsji/KX_IPO_SGController.cpp
+++ b/source/gameengine/Ketsji/KX_IPO_SGController.cpp
@@ -48,20 +48,24 @@ typedef unsigned long uint_ptr;
#include "KX_ScalarInterpolator.h"
#include "KX_GameObject.h"
#include "KX_IPhysicsController.h"
+#include "DNA_ipo_types.h"
+#include "BLI_arithb.h"
// All objects should start on frame 1! Will we ever need an object to
// start on another frame, the 1.0 should change.
KX_IpoSGController::KX_IpoSGController()
-: m_modify_position(false),
- m_modify_orientation(false),
- m_modify_scaling(false),
- m_ipo_as_force(false),
- m_force_ipo_acts_local(false),
+: m_ipo_as_force(false),
+ m_ipo_add(false),
+ m_ipo_local(false),
m_modified(true),
- m_ipotime(1.0)
+ m_ipo_start_initialized(false),
+ m_ipotime(1.0),
+ m_ipo_start_euler(0.0,0.0,0.0),
+ m_ipo_euler_initialized(false)
{
m_game_object = NULL;
-
+ for (int i=0; i < KX_MAX_IPO_CHANNELS; i++)
+ m_ipo_channels_active[i] = false;
}
@@ -74,8 +78,23 @@ void KX_IpoSGController::SetOption(
m_ipo_as_force = (value != 0);
m_modified = true;
break;
- case SG_CONTR_IPO_FORCES_ACT_LOCAL:
- m_force_ipo_acts_local = (value != 0);
+ case SG_CONTR_IPO_IPO_ADD:
+ m_ipo_add = (value != 0);
+ m_modified = true;
+ break;
+ case SG_CONTR_IPO_RESET:
+ if (m_ipo_start_initialized && value) {
+ m_ipo_start_initialized = false;
+ m_modified = true;
+ }
+ break;
+ case SG_CONTR_IPO_LOCAL:
+ if (value/* && ((SG_Node*)m_pObject)->GetSGParent() == NULL*/) {
+ // only accept local Ipo if the object has no parent
+ m_ipo_local = true;
+ } else {
+ m_ipo_local = false;
+ }
m_modified = true;
break;
default:
@@ -112,35 +131,200 @@ bool KX_IpoSGController::Update(double currentTime)
}
SG_Spatial* ob = (SG_Spatial*)m_pObject;
-
- if (m_modify_position) {
- if (m_ipo_as_force) {
-
- if (m_game_object && ob) {
- m_game_object->GetPhysicsController()->ApplyForce(m_force_ipo_acts_local ?
+
+ //initialization on the first frame of the IPO
+ if (! m_ipo_start_initialized && currentTime > 0.0) {
+ m_ipo_start_point = ob->GetLocalPosition();
+ m_ipo_start_orient = ob->GetLocalOrientation();
+ m_ipo_start_scale = ob->GetLocalScale();
+ m_ipo_start_initialized = true;
+ if (!m_ipo_euler_initialized) {
+ // do it only once to avoid angle discontinuities
+ m_ipo_start_orient.getEuler(m_ipo_start_euler[0], m_ipo_start_euler[1], m_ipo_start_euler[2]);
+ m_ipo_euler_initialized = true;
+ }
+ }
+
+ //modifies position?
+ if (m_ipo_channels_active[OB_LOC_X] || m_ipo_channels_active[OB_LOC_Y] || m_ipo_channels_active[OB_LOC_Z] || m_ipo_channels_active[OB_DLOC_X] || m_ipo_channels_active[OB_DLOC_Y] || m_ipo_channels_active[OB_DLOC_Z])
+ {
+ if (m_ipo_as_force == true)
+ {
+ if (m_game_object && ob && m_game_object->GetPhysicsController())
+ {
+ m_game_object->GetPhysicsController()->ApplyForce(m_ipo_local ?
ob->GetWorldOrientation() * m_ipo_xform.GetPosition() :
m_ipo_xform.GetPosition(), false);
}
-
- } else {
- ob->SetLocalPosition(m_ipo_xform.GetPosition());
+ }
+ else
+ {
+ // Local ipo should be defined with the object position at (0,0,0)
+ // Local transform is applied to the object based on initial position
+ MT_Point3 newPosition(0.0,0.0,0.0);
+
+ if (!m_ipo_add)
+ newPosition = ob->GetLocalPosition();
+ //apply separate IPO channels if there is any data in them
+ //Loc and dLoc act by themselves or are additive
+ //LocX and dLocX
+ if (m_ipo_channels_active[OB_LOC_X]) {
+ newPosition[0] = (m_ipo_channels_active[OB_DLOC_X] ? m_ipo_xform.GetPosition()[0] + m_ipo_xform.GetDeltaPosition()[0] : m_ipo_xform.GetPosition()[0]);
+ }
+ else if (m_ipo_channels_active[OB_DLOC_X] && m_ipo_start_initialized) {
+ newPosition[0] = (((!m_ipo_add)?m_ipo_start_point[0]:0.0) + m_ipo_xform.GetDeltaPosition()[0]);
+ }
+ //LocY and dLocY
+ if (m_ipo_channels_active[OB_LOC_Y]) {
+ newPosition[1] = (m_ipo_channels_active[OB_DLOC_Y] ? m_ipo_xform.GetPosition()[1] + m_ipo_xform.GetDeltaPosition()[1] : m_ipo_xform.GetPosition()[1]);
+ }
+ else if (m_ipo_channels_active[OB_DLOC_Y] && m_ipo_start_initialized) {
+ newPosition[1] = (((!m_ipo_add)?m_ipo_start_point[1]:0.0) + m_ipo_xform.GetDeltaPosition()[1]);
+ }
+ //LocZ and dLocZ
+ if (m_ipo_channels_active[OB_LOC_Z]) {
+ newPosition[2] = (m_ipo_channels_active[OB_DLOC_Z] ? m_ipo_xform.GetPosition()[2] + m_ipo_xform.GetDeltaPosition()[2] : m_ipo_xform.GetPosition()[2]);
+ }
+ else if (m_ipo_channels_active[OB_DLOC_Z] && m_ipo_start_initialized) {
+ newPosition[2] = (((!m_ipo_add)?m_ipo_start_point[2]:0.0) + m_ipo_xform.GetDeltaPosition()[2]);
+ }
+ if (m_ipo_add) {
+ if (m_ipo_local)
+ newPosition = m_ipo_start_point + m_ipo_start_scale*(m_ipo_start_orient*newPosition);
+ else
+ newPosition = m_ipo_start_point + newPosition;
+ }
+ ob->SetLocalPosition(newPosition);
}
}
- if (m_modify_orientation) {
+ //modifies orientation?
+ if (m_ipo_channels_active[OB_ROT_X] || m_ipo_channels_active[OB_ROT_Y] || m_ipo_channels_active[OB_ROT_Z] || m_ipo_channels_active[OB_DROT_X] || m_ipo_channels_active[OB_DROT_Y] || m_ipo_channels_active[OB_DROT_Z]) {
if (m_ipo_as_force) {
if (m_game_object && ob) {
- m_game_object->ApplyTorque(m_force_ipo_acts_local ?
+ m_game_object->ApplyTorque(m_ipo_local ?
ob->GetWorldOrientation() * m_ipo_xform.GetEulerAngles() :
m_ipo_xform.GetEulerAngles(), false);
}
+ } else if (m_ipo_add) {
+ if (m_ipo_start_initialized) {
+ double yaw=0, pitch=0, roll=0; //delta Euler angles
- } else {
- ob->SetLocalOrientation(MT_Matrix3x3(m_ipo_xform.GetEulerAngles()));
+ //RotX and dRotX
+ if (m_ipo_channels_active[OB_ROT_X])
+ yaw += m_ipo_xform.GetEulerAngles()[0];
+ if (m_ipo_channels_active[OB_DROT_X])
+ yaw += m_ipo_xform.GetDeltaEulerAngles()[0];
+
+ //RotY dRotY
+ if (m_ipo_channels_active[OB_ROT_Y])
+ pitch += m_ipo_xform.GetEulerAngles()[1];
+ if (m_ipo_channels_active[OB_DROT_Y])
+ pitch += m_ipo_xform.GetDeltaEulerAngles()[1];
+
+ //RotZ and dRotZ
+ if (m_ipo_channels_active[OB_ROT_Z])
+ roll += m_ipo_xform.GetEulerAngles()[2];
+ if (m_ipo_channels_active[OB_DROT_Z])
+ roll += m_ipo_xform.GetDeltaEulerAngles()[2];
+
+ MT_Matrix3x3 rotation(MT_Vector3(yaw, pitch, roll));
+ if (m_ipo_local)
+ rotation = m_ipo_start_orient * rotation;
+ else
+ rotation = rotation * m_ipo_start_orient;
+ ob->SetLocalOrientation(rotation);
+ }
+ } else if (m_ipo_channels_active[OB_ROT_X] || m_ipo_channels_active[OB_ROT_Y] || m_ipo_channels_active[OB_ROT_Z]) {
+ if (m_ipo_euler_initialized) {
+ // assume all channel absolute
+ // All 3 channels should be specified but if they are not, we will take
+ // the value at the start of the game to avoid angle sign reversal
+ double yaw=m_ipo_start_euler[0], pitch=m_ipo_start_euler[1], roll=m_ipo_start_euler[2];
+
+ //RotX and dRotX
+ if (m_ipo_channels_active[OB_ROT_X]) {
+ yaw = (m_ipo_channels_active[OB_DROT_X] ? (m_ipo_xform.GetEulerAngles()[0] + m_ipo_xform.GetDeltaEulerAngles()[0]) : m_ipo_xform.GetEulerAngles()[0] );
+ }
+ else if (m_ipo_channels_active[OB_DROT_X]) {
+ yaw += m_ipo_xform.GetDeltaEulerAngles()[0];
+ }
+
+ //RotY dRotY
+ if (m_ipo_channels_active[OB_ROT_Y]) {
+ pitch = (m_ipo_channels_active[OB_DROT_Y] ? (m_ipo_xform.GetEulerAngles()[1] + m_ipo_xform.GetDeltaEulerAngles()[1]) : m_ipo_xform.GetEulerAngles()[1] );
+ }
+ else if (m_ipo_channels_active[OB_DROT_Y]) {
+ pitch += m_ipo_xform.GetDeltaEulerAngles()[1];
+ }
+
+ //RotZ and dRotZ
+ if (m_ipo_channels_active[OB_ROT_Z]) {
+ roll = (m_ipo_channels_active[OB_DROT_Z] ? (m_ipo_xform.GetEulerAngles()[2] + m_ipo_xform.GetDeltaEulerAngles()[2]) : m_ipo_xform.GetEulerAngles()[2] );
+ }
+ else if (m_ipo_channels_active[OB_DROT_Z]) {
+ roll += m_ipo_xform.GetDeltaEulerAngles()[2];
+ }
+ ob->SetLocalOrientation(MT_Vector3(yaw, pitch, roll));
+ }
+ } else if (m_ipo_start_initialized) {
+ // only DROT, treat as Add
+ double yaw=0, pitch=0, roll=0; //delta Euler angles
+
+ //dRotX
+ if (m_ipo_channels_active[OB_DROT_X])
+ yaw = m_ipo_xform.GetDeltaEulerAngles()[0];
+
+ //dRotY
+ if (m_ipo_channels_active[OB_DROT_Y])
+ pitch = m_ipo_xform.GetDeltaEulerAngles()[1];
+
+ //dRotZ
+ if (m_ipo_channels_active[OB_DROT_Z])
+ roll = m_ipo_xform.GetDeltaEulerAngles()[2];
+
+ // dRot are always local
+ MT_Matrix3x3 rotation(MT_Vector3(yaw, pitch, roll));
+ rotation = m_ipo_start_orient * rotation;
+ ob->SetLocalOrientation(rotation);
+ }
+ }
+ //modifies scale?
+ if (m_ipo_channels_active[OB_SIZE_X] || m_ipo_channels_active[OB_SIZE_Y] || m_ipo_channels_active[OB_SIZE_Z] || m_ipo_channels_active[OB_DSIZE_X] || m_ipo_channels_active[OB_DSIZE_Y] || m_ipo_channels_active[OB_DSIZE_Z]) {
+ //default is no scale change
+ MT_Vector3 newScale(1.0,1.0,1.0);
+ if (!m_ipo_add)
+ newScale = ob->GetLocalScale();
+
+ if (m_ipo_channels_active[OB_SIZE_X]) {
+ newScale[0] = (m_ipo_channels_active[OB_DSIZE_X] ? (m_ipo_xform.GetScaling()[0] + m_ipo_xform.GetDeltaScaling()[0]) : m_ipo_xform.GetScaling()[0]);
+ }
+ else if (m_ipo_channels_active[OB_DSIZE_X] && m_ipo_start_initialized) {
+ newScale[0] = (m_ipo_xform.GetDeltaScaling()[0] + ((!m_ipo_add)?m_ipo_start_scale[0]:0.0));
+ }
+
+ //RotY dRotY
+ if (m_ipo_channels_active[OB_SIZE_Y]) {
+ newScale[1] = (m_ipo_channels_active[OB_DSIZE_Y] ? (m_ipo_xform.GetScaling()[1] + m_ipo_xform.GetDeltaScaling()[1]): m_ipo_xform.GetScaling()[1]);
+ }
+ else if (m_ipo_channels_active[OB_DSIZE_Y] && m_ipo_start_initialized) {
+ newScale[1] = (m_ipo_xform.GetDeltaScaling()[1] + ((!m_ipo_add)?m_ipo_start_scale[1]:0.0));
}
+
+ //RotZ and dRotZ
+ if (m_ipo_channels_active[OB_SIZE_Z]) {
+ newScale[2] = (m_ipo_channels_active[OB_DSIZE_Z] ? (m_ipo_xform.GetScaling()[2] + m_ipo_xform.GetDeltaScaling()[2]) : m_ipo_xform.GetScaling()[2]);
+ }
+ else if (m_ipo_channels_active[OB_DSIZE_Z] && m_ipo_start_initialized) {
+ newScale[2] = (m_ipo_xform.GetDeltaScaling()[2] + ((!m_ipo_add)?m_ipo_start_scale[2]:1.0));
+ }
+
+ if (m_ipo_add) {
+ newScale = m_ipo_start_scale * newScale;
+ }
+
+ ob->SetLocalScale(newScale);
}
- if (m_modify_scaling)
- ob->SetLocalScale(m_ipo_xform.GetScaling());
m_modified=false;
}
diff --git a/source/gameengine/Ketsji/KX_IPO_SGController.h b/source/gameengine/Ketsji/KX_IPO_SGController.h
index a010e8e3e6c..031b74294ce 100644
--- a/source/gameengine/Ketsji/KX_IPO_SGController.h
+++ b/source/gameengine/Ketsji/KX_IPO_SGController.h
@@ -35,27 +35,49 @@
#include "KX_IPOTransform.h"
#include "KX_IInterpolator.h"
+#define KX_MAX_IPO_CHANNELS 19 //note- [0] is not used
+
class KX_IpoSGController : public SG_Controller
{
KX_IPOTransform m_ipo_xform;
T_InterpolatorList m_interpolators;
- /* Why not bools? */
- short m_modify_position : 1;
- short m_modify_orientation : 1;
- short m_modify_scaling : 1;
+
+ /** Flag for each IPO channel that can be applied to a game object */
+ bool m_ipo_channels_active[KX_MAX_IPO_CHANNELS];
/** Interpret the ipo as a force rather than a displacement? */
bool m_ipo_as_force;
- /** Ipo-as-force acts in local rather than in global coordinates? */
- bool m_force_ipo_acts_local;
+ /** Add Ipo curve to current loc/rot/scale */
+ bool m_ipo_add;
+ /** Ipo must be applied in local coordinate rather than in global coordinates (used for force and Add mode)*/
+ bool m_ipo_local;
+
/** Were settings altered since the last update? */
bool m_modified;
/** Local time of this ipo.*/
double m_ipotime;
+ /** Location of the object when the IPO is first fired (for local transformations) */
+ class MT_Point3 m_ipo_start_point;
+
+ /** Orientation of the object when the IPO is first fired (for local transformations) */
+ class MT_Matrix3x3 m_ipo_start_orient;
+
+ /** Scale of the object when the IPO is first fired (for local transformations) */
+ class MT_Vector3 m_ipo_start_scale;
+
+ /** if IPO initial position has been set for local normal IPO */
+ bool m_ipo_start_initialized;
+
+ /** Euler angles at the start of the game, needed for incomplete ROT Ipo curves */
+ class MT_Vector3 m_ipo_start_euler;
+
+ /** true is m_ipo_start_euler has been initialized */
+ bool m_ipo_euler_initialized;
+
/** A reference to the original game object. */
class KX_GameObject* m_game_object;
@@ -77,16 +99,12 @@ public:
/** Set reference to the corresponding game object. */
void SetGameObject(class KX_GameObject*);
- void SetModifyPosition(bool modifypos) {
- m_modify_position=modifypos;
- }
- void SetModifyOrientation(bool modifyorient) {
- m_modify_orientation=modifyorient;
- }
- void SetModifyScaling(bool modifyscale) {
- m_modify_scaling=modifyscale;
+ void SetIPOChannelActive(int index, bool value) {
+ //indexes found in makesdna\DNA_ipo_types.h
+ m_ipo_channels_active[index] = value;
}
+
KX_IPOTransform& GetIPOTransform()
{
return m_ipo_xform;
@@ -102,3 +120,4 @@ public:
#endif //__IPO_SGCONTROLLER_H
+
diff --git a/source/gameengine/Ketsji/KX_IPhysicsController.h b/source/gameengine/Ketsji/KX_IPhysicsController.h
index 009db40d3e8..4ea283e9f98 100644
--- a/source/gameengine/Ketsji/KX_IPhysicsController.h
+++ b/source/gameengine/Ketsji/KX_IPhysicsController.h
@@ -64,20 +64,22 @@ public:
virtual void ApplyTorque(const MT_Vector3& torque,bool local)=0;
virtual void ApplyForce(const MT_Vector3& force,bool local)=0;
virtual MT_Vector3 GetLinearVelocity()=0;
+ virtual MT_Vector3 GetAngularVelocity()=0;
virtual MT_Vector3 GetVelocity(const MT_Point3& pos)=0;
virtual void SetAngularVelocity(const MT_Vector3& ang_vel,bool local)=0;
virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local)=0;
virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ) = 0;
virtual void getOrientation(MT_Quaternion& orn)=0;
- virtual void setOrientation(const MT_Quaternion& orn)=0;
+ virtual void setOrientation(const MT_Matrix3x3& orn)=0;
+ //virtual void setOrientation(const MT_Quaternion& orn)=0;
virtual void setPosition(const MT_Point3& pos)=0;
virtual void setScaling(const MT_Vector3& scaling)=0;
virtual MT_Scalar GetMass()=0;
virtual MT_Vector3 getReactionForce()=0;
virtual void setRigidBody(bool rigid)=0;
- virtual void SuspendDynamics()=0;
+ virtual void SuspendDynamics(bool ghost=false)=0;
virtual void RestoreDynamics()=0;
virtual SG_Controller* GetReplica(class SG_Node* destnode)=0;
@@ -86,7 +88,11 @@ public:
m_bDyna = isDynamic;
}
+ bool IsDyna(void) {
+ return m_bDyna;
+ }
+ virtual MT_Scalar GetRadius()=0;
virtual void SetSumoTransform(bool nondynaonly)=0;
// todo: remove next line !
virtual void SetSimulatedTime(double time)=0;
diff --git a/source/gameengine/Ketsji/KX_ISceneConverter.h b/source/gameengine/Ketsji/KX_ISceneConverter.h
index cb749801827..3709fa8c784 100644
--- a/source/gameengine/Ketsji/KX_ISceneConverter.h
+++ b/source/gameengine/Ketsji/KX_ISceneConverter.h
@@ -32,6 +32,8 @@
#include "STR_String.h"
#include "KX_Python.h"
+struct Scene;
+
class KX_ISceneConverter
{
@@ -52,6 +54,8 @@ public:
class RAS_IRenderTools* rendertools,
class RAS_ICanvas* canvas)=0;
+ virtual void RemoveScene(class KX_Scene *scene)=0;
+
virtual void SetAlwaysUseExpandFraming(bool to_what) = 0;
virtual void SetNewFileName(const STR_String& filename) = 0;
@@ -72,6 +76,11 @@ public:
virtual void SetMaterials(bool val) =0;
virtual bool GetMaterials()=0;
+ // use blender glsl materials
+ virtual void SetGLSLMaterials(bool val) =0;
+ virtual bool GetGLSLMaterials()=0;
+
+ virtual struct Scene* GetBlenderSceneForName(const STR_String& name)=0;
};
#endif //__KX_ISCENECONVERTER_H
diff --git a/source/gameengine/Ketsji/KX_IpoActuator.cpp b/source/gameengine/Ketsji/KX_IpoActuator.cpp
index 3af1316ba5d..f5e17118ffb 100644
--- a/source/gameengine/Ketsji/KX_IpoActuator.cpp
+++ b/source/gameengine/Ketsji/KX_IpoActuator.cpp
@@ -37,6 +37,7 @@
#include "KX_IpoActuator.h"
#include "KX_GameObject.h"
+#include "FloatValue.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -59,49 +60,17 @@ STR_String KX_IpoActuator::S_KX_ACT_IPO_FROM_PROP_STRING = "FromProp";
/* ------------------------------------------------------------------------- */
/* Native functions */
/* ------------------------------------------------------------------------- */
-/** Another poltergeist? This seems to be a very transient class... */
-class CIpoAction : public CAction
-{
- float m_curtime;
- bool m_recurse;
- KX_GameObject* m_gameobj;
- bool m_ipo_as_force;
- bool m_force_ipo_local;
-
-public:
- CIpoAction(KX_GameObject* gameobj,
- float curtime,
- bool recurse,
- bool ipo_as_force,
- bool force_ipo_local) :
- m_curtime(curtime) ,
- m_recurse(recurse),
- m_gameobj(gameobj),
- m_ipo_as_force(ipo_as_force),
- m_force_ipo_local(force_ipo_local)
- {
- /* intentionally empty */
- };
-
- virtual void Execute() const
- {
- m_gameobj->UpdateIPO(
- m_curtime,
- m_recurse,
- m_ipo_as_force,
- m_force_ipo_local);
- };
-
-};
KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
const STR_String& propname,
+ const STR_String& framePropname,
float starttime,
float endtime,
bool recurse,
int acttype,
bool ipo_as_force,
- bool force_ipo_local,
+ bool ipo_add,
+ bool ipo_local,
PyTypeObject* T)
: SCA_IActuator(gameobj,T),
m_bNegativeEvent(false),
@@ -111,8 +80,10 @@ KX_IpoActuator::KX_IpoActuator(SCA_IObject* gameobj,
m_localtime(starttime),
m_direction(1),
m_propname(propname),
+ m_framepropname(framePropname),
m_ipo_as_force(ipo_as_force),
- m_force_ipo_local(force_ipo_local),
+ m_ipo_add(ipo_add),
+ m_ipo_local(ipo_local),
m_type((IpoActType)acttype)
{
m_starttime = -2.0*fabs(m_endframe - m_startframe) - 1.0;
@@ -160,18 +131,17 @@ bool KX_IpoActuator::ClampLocalTime()
void KX_IpoActuator::SetStartTime(float curtime)
{
- float direction = m_startframe < m_endframe ? 1.0 : -1.0;
+ float direction = m_startframe < m_endframe ? 1.0f : -1.0f;
- curtime = curtime - KX_KetsjiEngine::GetSuspendedDelta();
if (m_direction > 0)
- m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_FIXED_FRAME_PER_SEC;
+ m_starttime = curtime - direction*(m_localtime - m_startframe)/KX_KetsjiEngine::GetAnimFrameRate();
else
- m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_FIXED_FRAME_PER_SEC;
+ m_starttime = curtime - direction*(m_endframe - m_localtime)/KX_KetsjiEngine::GetAnimFrameRate();
}
void KX_IpoActuator::SetLocalTime(float curtime)
{
- float delta_time = ((curtime - m_starttime) - KX_KetsjiEngine::GetSuspendedDelta())*KX_FIXED_FRAME_PER_SEC;
+ float delta_time = (curtime - m_starttime)*KX_KetsjiEngine::GetAnimFrameRate();
// negative delta_time is caused by floating point inaccuracy
// perhaps the inaccuracy could be reduced a bit
@@ -195,36 +165,28 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
// maybe there are events for us in the queue !
bool bNegativeEvent = false;
int numevents = 0;
+ bool bIpoStart = false;
+
+ curtime -= KX_KetsjiEngine::GetSuspendedDelta();
if (frame)
{
numevents = m_events.size();
- for (vector<CValue*>::iterator i=m_events.end(); !(i==m_events.begin());)
- {
- --i;
- if ((*i)->GetNumber() == 0.0f)
- bNegativeEvent = true;
-
- (*i)->Release();
- }
- m_events.clear();
-
- if (m_type != KX_ACT_IPO_PLAY)
- {
- if (bNegativeEvent)
- RemoveAllEvents();
- }
+ bNegativeEvent = IsNegativeEvent();
+ RemoveAllEvents();
}
- double start_smaller_then_end = ( m_startframe < m_endframe ? 1.0 : -1.0);
+ float start_smaller_then_end = ( m_startframe < m_endframe ? 1.0f : -1.0f);
bool result=true;
if (!bNegativeEvent)
{
- if (m_starttime < -2.0*start_smaller_then_end*(m_endframe - m_startframe))
+ if (m_starttime < -2.0f*start_smaller_then_end*(m_endframe - m_startframe))
{
- m_starttime = curtime - KX_KetsjiEngine::GetSuspendedDelta();
+ // start for all Ipo, initial start for LOOP_STOP
+ m_starttime = curtime;
m_bIpoPlaying = true;
+ bIpoStart = true;
}
}
@@ -235,17 +197,10 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
{
// Check if playing forwards. result = ! finished
- if (!bNegativeEvent)
- {
- if (start_smaller_then_end > 0.0)
- result = (m_localtime < m_endframe && !(m_localtime == m_startframe && bNegativeEvent));
- else
- result = (m_localtime > m_endframe && !(m_localtime == m_startframe && bNegativeEvent));
- }
+ if (start_smaller_then_end > 0.f)
+ result = (m_localtime < m_endframe && m_bIpoPlaying);
else
- {
- result = (m_bIpoPlaying && (m_localtime < m_endframe));
- }
+ result = (m_localtime > m_endframe && m_bIpoPlaying);
if (result)
{
@@ -253,18 +208,13 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
/* Perform clamping */
ClampLocalTime();
-
- CIpoAction ipoaction(
- (KX_GameObject*)GetParent(),
- m_localtime,
- m_recurse,
- m_ipo_as_force,
- m_force_ipo_local);
- GetParent()->Execute(ipoaction);
+
+ if (bIpoStart)
+ ((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
+ ((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
} else
{
m_localtime=m_startframe;
- SetStartTime(curtime);
m_direction=1;
}
break;
@@ -272,7 +222,7 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
case KX_ACT_IPO_PINGPONG:
{
result = true;
- if (bNegativeEvent && ((m_localtime == m_startframe )|| (m_localtime == m_endframe)))
+ if (bNegativeEvent && !m_bIpoPlaying)
result = false;
else
SetLocalTime(curtime);
@@ -283,39 +233,35 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
m_direction = -m_direction;
}
- CIpoAction ipoaction(
- (KX_GameObject*) GetParent(),
- m_localtime,
- m_recurse,
- m_ipo_as_force,
- m_force_ipo_local);
- GetParent()->Execute(ipoaction);
+ if (bIpoStart && m_direction > 0)
+ ((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
+ ((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
break;
}
case KX_ACT_IPO_FLIPPER:
{
- result = !(bNegativeEvent && (m_localtime == m_startframe));
+ if (bNegativeEvent && !m_bIpoPlaying)
+ result = false;
if (numevents)
{
+ float oldDirection = m_direction;
if (bNegativeEvent)
m_direction = -1;
else
m_direction = 1;
- SetStartTime(curtime);
+ if (m_direction != oldDirection)
+ // changing direction, reset start time
+ SetStartTime(curtime);
}
SetLocalTime(curtime);
if (ClampLocalTime() && m_localtime == m_startframe)
result = false;
-
- CIpoAction ipoaction(
- (KX_GameObject*) GetParent(),
- m_localtime,
- m_recurse,
- m_ipo_as_force,
- m_force_ipo_local);
- GetParent()->Execute(ipoaction);
+
+ if (bIpoStart)
+ ((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
+ ((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
break;
}
@@ -329,18 +275,26 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
m_bNegativeEvent = false;
numevents = 0;
}
- SetStartTime(curtime);
+ if (!m_bIpoPlaying)
+ {
+ // Ipo was stopped, make sure we will restart from where it stopped
+ SetStartTime(curtime);
+ if (!bNegativeEvent)
+ // positive signal will restart the Ipo
+ m_bIpoPlaying = true;
+ }
+
} // fall through to loopend, and quit the ipo animation immediatly
}
case KX_ACT_IPO_LOOPEND:
{
if (numevents){
- if (bNegativeEvent){
+ if (bNegativeEvent && m_bIpoPlaying){
m_bNegativeEvent = true;
}
}
- if (bNegativeEvent && m_localtime == m_startframe){
+ if (bNegativeEvent && !m_bIpoPlaying){
result = false;
}
else
@@ -353,8 +307,12 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
if (!m_bNegativeEvent){
/* Perform wraparound */
SetLocalTime(curtime);
- m_localtime = m_startframe + fmod(m_localtime, m_startframe - m_endframe);
+ if (start_smaller_then_end > 0.f)
+ m_localtime = m_startframe + fmod(m_localtime - m_startframe, m_endframe - m_startframe);
+ else
+ m_localtime = m_startframe - fmod(m_startframe - m_localtime, m_startframe - m_endframe);
SetStartTime(curtime);
+ bIpoStart = true;
}
else
{
@@ -366,13 +324,9 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
}
}
- CIpoAction ipoaction(
- (KX_GameObject*) GetParent(),
- m_localtime,
- m_recurse,
- m_ipo_as_force,
- m_force_ipo_local);
- GetParent()->Execute(ipoaction);
+ if (m_bIpoPlaying && bIpoStart)
+ ((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
+ ((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
break;
}
@@ -392,14 +346,9 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
{
m_localtime = propval->GetNumber();
- CIpoAction ipoaction(
- (KX_GameObject*) GetParent(),
- m_localtime,
- m_recurse,
- m_ipo_as_force,
- m_force_ipo_local);
- GetParent()->Execute(ipoaction);
-
+ if (bIpoStart)
+ ((KX_GameObject*)GetParent())->InitIPO(m_ipo_as_force, m_ipo_add, m_ipo_local);
+ ((KX_GameObject*)GetParent())->UpdateIPO(m_localtime,m_recurse);
} else
{
result = false;
@@ -410,9 +359,26 @@ bool KX_IpoActuator::Update(double curtime, bool frame)
default:
result = false;
}
-
- if (!result && m_type != KX_ACT_IPO_LOOPSTOP)
- m_starttime = -2.0*start_smaller_then_end*(m_endframe - m_startframe) - 1.0;
+
+ /* Set the property if its defined */
+ if (m_framepropname[0] != '\0') {
+ CValue* propowner = GetParent();
+ CValue* oldprop = propowner->GetProperty(m_framepropname);
+ CValue* newval = new CFloatValue(m_localtime);
+ if (oldprop) {
+ oldprop->SetValue(newval);
+ } else {
+ propowner->SetProperty(m_framepropname, newval);
+ }
+ newval->Release();
+ }
+
+ if (!result)
+ {
+ if (m_type != KX_ACT_IPO_LOOPSTOP)
+ m_starttime = -2.0*start_smaller_then_end*(m_endframe - m_startframe) - 1.0;
+ m_bIpoPlaying = false;
+ }
return result;
}
@@ -474,30 +440,20 @@ PyParentObject KX_IpoActuator::Parents[] = {
};
PyMethodDef KX_IpoActuator::Methods[] = {
- {"set", (PyCFunction) KX_IpoActuator::sPySet,
- METH_VARARGS, Set_doc},
- {"setProperty", (PyCFunction) KX_IpoActuator::sPySetProperty,
- METH_VARARGS, SetProperty_doc},
- {"setStart", (PyCFunction) KX_IpoActuator::sPySetStart,
- METH_VARARGS, SetStart_doc},
- {"getStart", (PyCFunction) KX_IpoActuator::sPyGetStart,
- METH_VARARGS, GetStart_doc},
- {"setEnd", (PyCFunction) KX_IpoActuator::sPySetEnd,
- METH_VARARGS, SetEnd_doc},
- {"getEnd", (PyCFunction) KX_IpoActuator::sPyGetEnd,
- METH_VARARGS, GetEnd_doc},
- {"setIpoAsForce", (PyCFunction) KX_IpoActuator::sPySetIpoAsForce,
- METH_VARARGS, SetIpoAsForce_doc},
- {"getIpoAsForce", (PyCFunction) KX_IpoActuator::sPyGetIpoAsForce,
- METH_VARARGS, GetIpoAsForce_doc},
- {"setType", (PyCFunction) KX_IpoActuator::sPySetType,
- METH_VARARGS, SetType_doc},
- {"getType", (PyCFunction) KX_IpoActuator::sPyGetType,
- METH_VARARGS, GetType_doc},
- {"setForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPySetForceIpoActsLocal,
- METH_VARARGS, SetForceIpoActsLocal_doc},
- {"getForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPyGetForceIpoActsLocal,
- METH_VARARGS, GetForceIpoActsLocal_doc},
+ {"set", (PyCFunction) KX_IpoActuator::sPySet, METH_VARARGS, (PY_METHODCHAR)Set_doc},
+ {"setProperty", (PyCFunction) KX_IpoActuator::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
+ {"setStart", (PyCFunction) KX_IpoActuator::sPySetStart, METH_VARARGS, (PY_METHODCHAR)SetStart_doc},
+ {"getStart", (PyCFunction) KX_IpoActuator::sPyGetStart, METH_NOARGS, (PY_METHODCHAR)GetStart_doc},
+ {"setEnd", (PyCFunction) KX_IpoActuator::sPySetEnd, METH_VARARGS, (PY_METHODCHAR)SetEnd_doc},
+ {"getEnd", (PyCFunction) KX_IpoActuator::sPyGetEnd, METH_NOARGS, (PY_METHODCHAR)GetEnd_doc},
+ {"setIpoAsForce", (PyCFunction) KX_IpoActuator::sPySetIpoAsForce, METH_VARARGS, (PY_METHODCHAR)SetIpoAsForce_doc},
+ {"getIpoAsForce", (PyCFunction) KX_IpoActuator::sPyGetIpoAsForce, METH_NOARGS, (PY_METHODCHAR)GetIpoAsForce_doc},
+ {"setIpoAdd", (PyCFunction) KX_IpoActuator::sPySetIpoAdd, METH_VARARGS, (PY_METHODCHAR)SetIpoAdd_doc},
+ {"getIpoAdd", (PyCFunction) KX_IpoActuator::sPyGetIpoAdd, METH_NOARGS, (PY_METHODCHAR)GetIpoAdd_doc},
+ {"setType", (PyCFunction) KX_IpoActuator::sPySetType, METH_VARARGS, (PY_METHODCHAR)SetType_doc},
+ {"getType", (PyCFunction) KX_IpoActuator::sPyGetType, METH_NOARGS, (PY_METHODCHAR)GetType_doc},
+ {"setForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPySetForceIpoActsLocal, METH_VARARGS, (PY_METHODCHAR)SetForceIpoActsLocal_doc},
+ {"getForceIpoActsLocal", (PyCFunction) KX_IpoActuator::sPyGetForceIpoActsLocal, METH_NOARGS, (PY_METHODCHAR)GetForceIpoActsLocal_doc},
{NULL,NULL} //Sentinel
};
@@ -508,12 +464,12 @@ PyObject* KX_IpoActuator::_getattr(const STR_String& attr) {
/* set --------------------------------------------------------------------- */
-char KX_IpoActuator::Set_doc[] =
-"set(mode, startframe, endframe, force?)\n"
-"\t - mode: Play, PingPong, Flipper, LoopStop, LoopEnd or FromProp (string)\n"
+const char KX_IpoActuator::Set_doc[] =
+"set(type, startframe, endframe, mode?)\n"
+"\t - type: Play, PingPong, Flipper, LoopStop, LoopEnd or FromProp (string)\n"
"\t - startframe: first frame to use (int)\n"
"\t - endframe : last frame to use (int)\n"
-"\t - force? : interpret this ipo as a force? (KX_TRUE, KX_FALSE)"
+"\t - mode? : special mode (0=normal, 1=interpret location as force, 2=additive)"
"\tSet the properties of the actuator.\n";
PyObject* KX_IpoActuator::PySet(PyObject* self,
PyObject* args,
@@ -540,7 +496,8 @@ PyObject* KX_IpoActuator::PySet(PyObject* self,
m_type = modenum;
m_startframe = startFrame;
m_endframe = stopFrame;
- m_ipo_as_force = PyArgToBool(forceToggle);
+ m_ipo_as_force = forceToggle == 1;
+ m_ipo_add = forceToggle == 2;
break;
default:
; /* error */
@@ -550,7 +507,7 @@ PyObject* KX_IpoActuator::PySet(PyObject* self,
}
/* set property ----------------------------------------------------------- */
-char KX_IpoActuator::SetProperty_doc[] =
+const char KX_IpoActuator::SetProperty_doc[] =
"setProperty(propname)\n"
"\t - propname: name of the property (string)\n"
"\tSet the property to be used in FromProp mode.\n";
@@ -570,7 +527,7 @@ PyObject* KX_IpoActuator::PySetProperty(PyObject* self,
}
/* 4. setStart: */
-char KX_IpoActuator::SetStart_doc[] =
+const char KX_IpoActuator::SetStart_doc[] =
"setStart(frame)\n"
"\t - frame: first frame to use (int)\n"
"\tSet the frame from which the ipo starts playing.\n";
@@ -587,17 +544,15 @@ PyObject* KX_IpoActuator::PySetStart(PyObject* self,
Py_Return;
}
/* 5. getStart: */
-char KX_IpoActuator::GetStart_doc[] =
+const char KX_IpoActuator::GetStart_doc[] =
"getStart()\n"
"\tReturns the frame from which the ipo starts playing.\n";
-PyObject* KX_IpoActuator::PyGetStart(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* KX_IpoActuator::PyGetStart(PyObject* self) {
return PyFloat_FromDouble(m_startframe);
}
/* 6. setEnd: */
-char KX_IpoActuator::SetEnd_doc[] =
+const char KX_IpoActuator::SetEnd_doc[] =
"setEnd(frame)\n"
"\t - frame: last frame to use (int)\n"
"\tSet the frame at which the ipo stops playing.\n";
@@ -614,17 +569,15 @@ PyObject* KX_IpoActuator::PySetEnd(PyObject* self,
Py_Return;
}
/* 7. getEnd: */
-char KX_IpoActuator::GetEnd_doc[] =
+const char KX_IpoActuator::GetEnd_doc[] =
"getEnd()\n"
"\tReturns the frame at which the ipo stops playing.\n";
-PyObject* KX_IpoActuator::PyGetEnd(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* KX_IpoActuator::PyGetEnd(PyObject* self) {
return PyFloat_FromDouble(m_endframe);
}
/* 6. setIpoAsForce: */
-char KX_IpoActuator::SetIpoAsForce_doc[] =
+const char KX_IpoActuator::SetIpoAsForce_doc[] =
"setIpoAsForce(force?)\n"
"\t - force? : interpret this ipo as a force? (KX_TRUE, KX_FALSE)\n"
"\tSet whether to interpret the ipo as a force rather than a displacement.\n";
@@ -638,21 +591,49 @@ PyObject* KX_IpoActuator::PySetIpoAsForce(PyObject* self,
}
m_ipo_as_force = PyArgToBool(boolArg);
+ if (m_ipo_as_force)
+ m_ipo_add = false;
Py_Return;
}
/* 7. getIpoAsForce: */
-char KX_IpoActuator::GetIpoAsForce_doc[] =
+const char KX_IpoActuator::GetIpoAsForce_doc[] =
"getIpoAsForce()\n"
"\tReturns whether to interpret the ipo as a force rather than a displacement.\n";
-PyObject* KX_IpoActuator::PyGetIpoAsForce(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* KX_IpoActuator::PyGetIpoAsForce(PyObject* self) {
return BoolToPyArg(m_ipo_as_force);
}
+/* 6. setIpoAsForce: */
+const char KX_IpoActuator::SetIpoAdd_doc[] =
+"setIpoAdd(add?)\n"
+"\t - add? : add flag (KX_TRUE, KX_FALSE)\n"
+"\tSet whether to interpret the ipo as additive rather than absolute.\n";
+PyObject* KX_IpoActuator::PySetIpoAdd(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ int boolArg;
+
+ if (!PyArg_ParseTuple(args, "i", &boolArg)) {
+ return NULL;
+ }
+
+ m_ipo_add = PyArgToBool(boolArg);
+ if (m_ipo_add)
+ m_ipo_as_force = false;
+
+ Py_Return;
+}
+/* 7. getIpoAsForce: */
+const char KX_IpoActuator::GetIpoAdd_doc[] =
+"getIpoAsAdd()\n"
+"\tReturns whether to interpret the ipo as additive rather than absolute.\n";
+PyObject* KX_IpoActuator::PyGetIpoAdd(PyObject* self) {
+ return BoolToPyArg(m_ipo_add);
+}
+
/* 8. setType: */
-char KX_IpoActuator::SetType_doc[] =
+const char KX_IpoActuator::SetType_doc[] =
"setType(mode)\n"
"\t - mode: Play, PingPong, Flipper, LoopStop, LoopEnd or FromProp (string)\n"
"\tSet the operation mode of the actuator.\n";
@@ -673,17 +654,15 @@ PyObject* KX_IpoActuator::PySetType(PyObject* self,
Py_Return;
}
/* 9. getType: */
-char KX_IpoActuator::GetType_doc[] =
+const char KX_IpoActuator::GetType_doc[] =
"getType()\n"
"\tReturns the operation mode of the actuator.\n";
-PyObject* KX_IpoActuator::PyGetType(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* KX_IpoActuator::PyGetType(PyObject* self) {
return PyInt_FromLong(m_type);
}
/* 10. setForceIpoActsLocal: */
-char KX_IpoActuator::SetForceIpoActsLocal_doc[] =
+const char KX_IpoActuator::SetForceIpoActsLocal_doc[] =
"setForceIpoActsLocal(local?)\n"
"\t - local? : Apply the ipo-as-force in the object's local\n"
"\t coordinates? (KX_TRUE, KX_FALSE)\n"
@@ -698,19 +677,17 @@ PyObject* KX_IpoActuator::PySetForceIpoActsLocal(PyObject* self,
return NULL;
}
- m_force_ipo_local = PyArgToBool(boolArg);
+ m_ipo_local = PyArgToBool(boolArg);
Py_Return;
}
/* 11. getForceIpoActsLocal: */
-char KX_IpoActuator::GetForceIpoActsLocal_doc[] =
+const char KX_IpoActuator::GetForceIpoActsLocal_doc[] =
"getForceIpoActsLocal()\n"
"\tReturn whether to apply the force in the object's local\n"
"\tcoordinates rather than the world global coordinates.\n";
-PyObject* KX_IpoActuator::PyGetForceIpoActsLocal(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
- return BoolToPyArg(m_force_ipo_local);
+PyObject* KX_IpoActuator::PyGetForceIpoActsLocal(PyObject* self) {
+ return BoolToPyArg(m_ipo_local);
}
diff --git a/source/gameengine/Ketsji/KX_IpoActuator.h b/source/gameengine/Ketsji/KX_IpoActuator.h
index 79e8daa3f87..8e5baed0530 100644
--- a/source/gameengine/Ketsji/KX_IpoActuator.h
+++ b/source/gameengine/Ketsji/KX_IpoActuator.h
@@ -72,11 +72,17 @@ protected:
/** Name of the property (only used in from_prop mode). */
STR_String m_propname;
+ /** Name of the property where we write the current frame number */
+ STR_String m_framepropname;
+
/** Interpret the ipo as a force? */
bool m_ipo_as_force;
- /** Apply a force-ipo locally? */
- bool m_force_ipo_local;
+ /** Add Ipo curve to current loc/rot/scale */
+ bool m_ipo_add;
+
+ /** The Ipo curve is applied in local coordinates */
+ bool m_ipo_local;
bool m_bIpoPlaying;
@@ -108,12 +114,14 @@ public:
KX_IpoActuator(SCA_IObject* gameobj,
const STR_String& propname,
+ const STR_String& framePropname,
float starttime,
float endtime,
bool recurse,
int acttype,
bool ipo_as_force,
- bool force_ipo_local,
+ bool ipo_add,
+ bool ipo_local,
PyTypeObject* T=&Type);
virtual ~KX_IpoActuator() {};
@@ -139,15 +147,17 @@ public:
KX_PYMETHOD_DOC(KX_IpoActuator,SetProperty);
/* KX_PYMETHOD_DOC(KX_IpoActuator,SetKey2Key); */
KX_PYMETHOD_DOC(KX_IpoActuator,SetStart);
- KX_PYMETHOD_DOC(KX_IpoActuator,GetStart);
+ KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetStart);
KX_PYMETHOD_DOC(KX_IpoActuator,SetEnd);
- KX_PYMETHOD_DOC(KX_IpoActuator,GetEnd);
+ KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetEnd);
KX_PYMETHOD_DOC(KX_IpoActuator,SetIpoAsForce);
- KX_PYMETHOD_DOC(KX_IpoActuator,GetIpoAsForce);
+ KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetIpoAsForce);
+ KX_PYMETHOD_DOC(KX_IpoActuator,SetIpoAdd);
+ KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetIpoAdd);
KX_PYMETHOD_DOC(KX_IpoActuator,SetType);
- KX_PYMETHOD_DOC(KX_IpoActuator,GetType);
+ KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetType);
KX_PYMETHOD_DOC(KX_IpoActuator,SetForceIpoActsLocal);
- KX_PYMETHOD_DOC(KX_IpoActuator,GetForceIpoActsLocal);
+ KX_PYMETHOD_DOC_NOARGS(KX_IpoActuator,GetForceIpoActsLocal);
};
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
index 64bfa90d4d6..8bcda4479e1 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp
@@ -55,6 +55,7 @@
#include "KX_Scene.h"
#include "MT_CmMatrix4x4.h"
#include "KX_Camera.h"
+#include "KX_Light.h"
#include "KX_PythonInit.h"
#include "KX_PyConstraintBinding.h"
#include "PHY_IPhysicsEnvironment.h"
@@ -71,6 +72,7 @@
#include "KX_TimeCategoryLogger.h"
#include "RAS_FramingManager.h"
+#include "stdio.h"
// If define: little test for Nzc: guarded drawing. If the canvas is
// not valid, skip rendering this frame.
@@ -91,9 +93,10 @@ const char KX_KetsjiEngine::m_profileLabels[tc_numCategories][15] = {
};
double KX_KetsjiEngine::m_ticrate = DEFAULT_LOGIC_TIC_RATE;
-
+double KX_KetsjiEngine::m_anim_framerate = 25.0;
double KX_KetsjiEngine::m_suspendedtime = 0.0;
double KX_KetsjiEngine::m_suspendeddelta = 0.0;
+double KX_KetsjiEngine::m_average_framerate = 0.0;
/**
@@ -116,7 +119,6 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
m_bInitialized(false),
m_activecam(0),
m_bFixedTime(false),
- m_game2ipo(false),
m_firstframe(true),
@@ -133,6 +135,8 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
m_overrideCam(false),
m_overrideCamUseOrtho(false),
+ m_overrideCamNear(0.0),
+ m_overrideCamFar(0.0),
m_stereo(false),
m_curreye(0),
@@ -146,6 +150,8 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system)
m_showBackground(false),
m_show_debug_properties(false),
+ m_game2ipo(false),
+
// Default behavior is to hide the cursor every frame.
m_hideCursor(false),
@@ -229,7 +235,10 @@ void KX_KetsjiEngine::SetRasterizer(RAS_IRasterizer* rasterizer)
}
-
+/*
+ * At the moment the GameLogic module is imported into 'pythondictionary' after this function is called.
+ * if this function ever changes to assign a copy, make sure the game logic module is imported into this dictionary before hand.
+ */
void KX_KetsjiEngine::SetPythonDictionary(PyObject* pythondictionary)
{
MT_assert(pythondictionary);
@@ -269,30 +278,73 @@ void KX_KetsjiEngine::StartEngine(bool clearIpo)
}
-bool KX_KetsjiEngine::BeginFrame()
+void KX_KetsjiEngine::ClearFrame()
{
- bool result = false;
+ // clear unless we're drawing overlapping stereo
+ if(m_rasterizer->InterlacedStereo() &&
+ m_rasterizer->GetEye() == RAS_IRasterizer::RAS_STEREO_RIGHTEYE)
+ return;
- RAS_Rect vp;
- KX_Scene* firstscene = *m_scenes.begin();
- const RAS_FrameSettings &framesettings = firstscene->GetFramingType();
+ // clear the viewports with the background color of the first scene
+ bool doclear = false;
+ KX_SceneList::iterator sceneit;
+ RAS_Rect clearvp, area, viewport;
- // set the area used for rendering
- m_rasterizer->SetRenderArea();
+ for (sceneit = m_scenes.begin(); sceneit != m_scenes.end(); sceneit++)
+ {
+ KX_Scene* scene = *sceneit;
+ //const RAS_FrameSettings &framesettings = scene->GetFramingType();
+ list<class KX_Camera*>* cameras = scene->GetCameras();
+
+ list<KX_Camera*>::iterator it;
+ for(it = cameras->begin(); it != cameras->end(); it++)
+ {
+ GetSceneViewport(scene, (*it), area, viewport);
+
+ if(!doclear) {
+ clearvp = viewport;
+ doclear = true;
+ }
+ else {
+ if(viewport.GetLeft() < clearvp.GetLeft())
+ clearvp.SetLeft(viewport.GetLeft());
+ if(viewport.GetBottom() < clearvp.GetBottom())
+ clearvp.SetBottom(viewport.GetBottom());
+ if(viewport.GetRight() > clearvp.GetRight())
+ clearvp.SetRight(viewport.GetRight());
+ if(viewport.GetTop() > clearvp.GetTop())
+ clearvp.SetTop(viewport.GetTop());
+
+ }
+ }
+ }
+
+ if(doclear) {
+ KX_Scene* firstscene = *m_scenes.begin();
+ SetBackGround(firstscene->GetWorldInfo());
+
+ m_canvas->SetViewPort(clearvp.GetLeft(), clearvp.GetBottom(),
+ clearvp.GetRight(), clearvp.GetTop());
+ m_rasterizer->ClearColorBuffer();
+ }
+}
- RAS_FramingManager::ComputeViewport(framesettings, m_canvas->GetDisplayArea(), vp);
+bool KX_KetsjiEngine::BeginFrame()
+{
+ // set the area used for rendering (stereo can assign only a subset)
+ m_rasterizer->SetRenderArea();
if (m_canvas->BeginDraw())
{
- result = true;
+ ClearFrame();
+
+ m_rasterizer->BeginFrame(m_drawingmode , m_kxsystem->GetTimeInSeconds());
+ m_rendertools->BeginFrame(m_rasterizer);
- m_canvas->SetViewPort(vp.GetLeft(), vp.GetBottom(), vp.GetRight(), vp.GetTop());
- SetBackGround( firstscene->GetWorldInfo() );
- m_rasterizer->BeginFrame( m_drawingmode , m_kxsystem->GetTimeInSeconds());
- m_rendertools->BeginFrame( m_rasterizer);
+ return true;
}
- return result;
+ return false;
}
@@ -304,6 +356,12 @@ void KX_KetsjiEngine::EndFrame()
{
RenderDebugProperties();
}
+
+ m_average_framerate = m_logger->GetAverage();
+ if (m_average_framerate < 1e-6)
+ m_average_framerate = 1e-6;
+ m_average_framerate = 1.0/m_average_framerate;
+
// Go to next profiling measurement, time spend after this call is shown in the next frame.
m_logger->NextMeasurement(m_kxsystem->GetTimeInSeconds());
@@ -315,8 +373,6 @@ void KX_KetsjiEngine::EndFrame()
m_canvas->EndDraw();
-
-
}
//#include "PIL_time.h"
@@ -414,7 +470,7 @@ else
m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
// set Python hooks for each scene
PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
- PHY_SetActiveScene(scene);
+ KX_SetActiveScene(scene);
scene->GetPhysicsEnvironment()->endFrame();
@@ -512,7 +568,7 @@ else
// set Python hooks for each scene
PHY_SetActiveEnvironment(scene->GetPhysicsEnvironment());
- PHY_SetActiveScene(scene);
+ KX_SetActiveScene(scene);
m_logger->StartLog(tc_scenegraph, m_kxsystem->GetTimeInSeconds(), true);
scene->UpdateParents(m_clockTime);
@@ -595,7 +651,7 @@ void KX_KetsjiEngine::Render()
);
}
// clear the -whole- viewport
- m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER);
+ m_canvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER|RAS_ICanvas::DEPTH_BUFFER);
}
m_rasterizer->SetEye(RAS_IRasterizer::RAS_STEREO_LEFTEYE);
@@ -613,25 +669,25 @@ void KX_KetsjiEngine::Render()
// pass the scene's worldsettings to the rasterizer
SetWorldSettings(scene->GetWorldInfo());
+ // shadow buffers
+ RenderShadowBuffers(scene);
+
// Avoid drawing the scene with the active camera twice when it's viewport is enabled
- if(!cam->GetViewport())
+ if(cam && !cam->GetViewport())
{
if (scene->IsClearingZBuffer())
m_rasterizer->ClearDepthBuffer();
m_rendertools->SetAuxilaryClientInfo(scene);
- //Initialize scene viewport.
- SetupRenderFrame(scene, cam);
-
// do the rendering
RenderFrame(scene, cam);
}
- set<class KX_Camera*>* cameras = scene->GetCameras();
+ list<class KX_Camera*>* cameras = scene->GetCameras();
// Draw the scene once for each camera with an enabled viewport
- set<KX_Camera*>::iterator it = cameras->begin();
+ list<KX_Camera*>::iterator it = cameras->begin();
while(it != cameras->end())
{
if((*it)->GetViewport())
@@ -641,9 +697,6 @@ void KX_KetsjiEngine::Render()
m_rendertools->SetAuxilaryClientInfo(scene);
- //Initialize scene viewport.
- SetupRenderFrame(scene, (*it));
-
// do the rendering
RenderFrame(scene, (*it));
}
@@ -676,10 +729,6 @@ void KX_KetsjiEngine::Render()
//pass the scene, for picking and raycasting (shadows)
m_rendertools->SetAuxilaryClientInfo(scene);
- //Initialize scene viewport.
- //SetupRenderFrame(scene);
- SetupRenderFrame(scene, cam);
-
// do the rendering
//RenderFrame(scene);
RenderFrame(scene, cam);
@@ -839,8 +888,13 @@ void KX_KetsjiEngine::SetCameraOverrideViewMatrix(const MT_CmMatrix4x4& mat)
m_overrideCamViewMat = mat;
}
-
-void KX_KetsjiEngine::SetupRenderFrame(KX_Scene *scene, KX_Camera* cam)
+void KX_KetsjiEngine::SetCameraOverrideClipping(float near, float far)
+{
+ m_overrideCamNear = near;
+ m_overrideCamFar = far;
+}
+
+void KX_KetsjiEngine::GetSceneViewport(KX_Scene *scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport)
{
// In this function we make sure the rasterizer settings are upto
// date. We compute the viewport so that logic
@@ -848,14 +902,26 @@ void KX_KetsjiEngine::SetupRenderFrame(KX_Scene *scene, KX_Camera* cam)
// Note we postpone computation of the projection matrix
// so that we are using the latest camera position.
+ if (cam->GetViewport()) {
+ RAS_Rect userviewport;
- RAS_Rect viewport;
+ userviewport.SetLeft(cam->GetViewportLeft());
+ userviewport.SetBottom(cam->GetViewportBottom());
+ userviewport.SetRight(cam->GetViewportRight());
+ userviewport.SetTop(cam->GetViewportTop());
- if (cam->GetViewport()) {
- viewport.SetLeft(cam->GetViewportLeft());
- viewport.SetBottom(cam->GetViewportBottom());
- viewport.SetRight(cam->GetViewportRight());
- viewport.SetTop(cam->GetViewportTop());
+ // Don't do bars on user specified viewport
+ RAS_FrameSettings settings = scene->GetFramingType();
+ if(settings.FrameType() == RAS_FrameSettings::e_frame_bars)
+ settings.SetFrameType(RAS_FrameSettings::e_frame_extend);
+
+ RAS_FramingManager::ComputeViewport(
+ scene->GetFramingType(),
+ userviewport,
+ viewport
+ );
+
+ area = userviewport;
}
else if ( m_overrideCam || (scene->GetName() != m_overrideSceneName) || m_overrideCamUseOrtho ) {
RAS_FramingManager::ComputeViewport(
@@ -863,42 +929,95 @@ void KX_KetsjiEngine::SetupRenderFrame(KX_Scene *scene, KX_Camera* cam)
m_canvas->GetDisplayArea(),
viewport
);
+
+ area = m_canvas->GetDisplayArea();
} else {
viewport.SetLeft(0);
viewport.SetBottom(0);
viewport.SetRight(int(m_canvas->GetWidth()));
viewport.SetTop(int(m_canvas->GetHeight()));
+
+ area = m_canvas->GetDisplayArea();
}
- // store the computed viewport in the scene
+}
- scene->SetSceneViewport(viewport);
+void KX_KetsjiEngine::RenderShadowBuffers(KX_Scene *scene)
+{
+ CListValue *objectlist = scene->GetObjectList();
+ int i, drawmode;
- // set the viewport for this frame and scene
- m_canvas->SetViewPort(
- viewport.GetLeft(),
- viewport.GetBottom(),
- viewport.GetRight(),
- viewport.GetTop()
- );
+ m_rendertools->SetAuxilaryClientInfo(scene);
-}
+ for(i=0; i<objectlist->GetCount(); i++) {
+ KX_GameObject *gameobj = (KX_GameObject*)objectlist->GetValue(i);
+
+ if(!gameobj->IsLight())
+ continue;
+
+ KX_LightObject *light = (KX_LightObject*)gameobj;
+
+ light->Update();
+
+ if(m_drawingmode == RAS_IRasterizer::KX_TEXTURED && light->HasShadowBuffer()) {
+ /* make temporary camera */
+ RAS_CameraData camdata = RAS_CameraData();
+ KX_Camera *cam = new KX_Camera(scene, scene->m_callbacks, camdata, false);
+ cam->SetName("__shadow__cam__");
+
+ MT_Transform camtrans;
+
+ /* switch drawmode for speed */
+ drawmode = m_rasterizer->GetDrawingMode();
+ m_rasterizer->SetDrawingMode(RAS_IRasterizer::KX_SHADOW);
+
+ /* binds framebuffer object, sets up camera .. */
+ light->BindShadowBuffer(m_rasterizer, cam, camtrans);
+ /* update scene */
+ scene->UpdateMeshTransformations();
+ scene->CalculateVisibleMeshes(m_rasterizer, cam, light->GetShadowLayer());
+
+ /* render */
+ m_rasterizer->ClearDepthBuffer();
+ scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools);
+
+ /* unbind framebuffer object, restore drawmode, free camera */
+ light->UnbindShadowBuffer(m_rasterizer);
+ m_rasterizer->SetDrawingMode(drawmode);
+ cam->Release();
+ }
+ }
+}
// update graphics
void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
{
- float left, right, bottom, top, nearfrust, farfrust;
+ bool override_camera;
+ RAS_Rect viewport, area;
+ float left, right, bottom, top, nearfrust, farfrust, focallength;
const float ortho = 100.0;
// KX_Camera* cam = scene->GetActiveCamera();
if (!cam)
return;
+
+ GetSceneViewport(scene, cam, area, viewport);
+
+ // store the computed viewport in the scene
+ scene->SetSceneViewport(viewport);
+
+ // set the viewport for this frame and scene
+ m_canvas->SetViewPort(viewport.GetLeft(), viewport.GetBottom(),
+ viewport.GetRight(), viewport.GetTop());
// see KX_BlenderMaterial::Activate
//m_rasterizer->SetAmbient();
m_rasterizer->DisplayFog();
- if (m_overrideCam && (scene->GetName() == m_overrideSceneName) && m_overrideCamUseOrtho) {
+ override_camera = m_overrideCam && (scene->GetName() == m_overrideSceneName);
+ override_camera = override_camera && (cam->GetName() == "__default__cam__");
+
+ if (override_camera && m_overrideCamUseOrtho) {
MT_CmMatrix4x4 projmat = m_overrideCamProjMat;
m_rasterizer->SetProjectionMatrix(projmat);
} else if (cam->hasValidProjectionMatrix() && !cam->GetViewport() )
@@ -908,11 +1027,17 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
{
RAS_FrameFrustum frustum;
float lens = cam->GetLens();
+ bool orthographic = !cam->GetCameraData()->m_perspective;
nearfrust = cam->GetCameraNear();
farfrust = cam->GetCameraFar();
+ focallength = cam->GetFocalLength();
- if (!cam->GetCameraData()->m_perspective)
- {
+ if(override_camera) {
+ nearfrust = m_overrideCamNear;
+ farfrust = m_overrideCamFar;
+ }
+
+ if (orthographic) {
lens *= ortho;
nearfrust = (nearfrust + 1.0)*ortho;
farfrust *= ortho;
@@ -920,8 +1045,8 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
RAS_FramingManager::ComputeFrustum(
scene->GetFramingType(),
- m_canvas->GetDisplayArea(),
- scene->GetSceneViewport(),
+ area,
+ viewport,
lens,
nearfrust,
farfrust,
@@ -936,8 +1061,8 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
farfrust = frustum.camfar;
MT_Matrix4x4 projmat = m_rasterizer->GetFrustumMatrix(
- left, right, bottom, top, nearfrust, farfrust);
-
+ left, right, bottom, top, nearfrust, farfrust, focallength);
+
cam->SetProjectionMatrix(projmat);
// Otherwise the projection matrix for each eye will be the same...
@@ -963,13 +1088,18 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
scene->CalculateVisibleMeshes(m_rasterizer,cam);
scene->RenderBuckets(camtrans, m_rasterizer, m_rendertools);
+
+ PostRenderFrame();
+}
+void KX_KetsjiEngine::PostRenderFrame()
+{
+ m_rendertools->PushMatrix();
+ m_rendertools->Render2DFilters(m_canvas);
m_rendertools->MotionBlur(m_rasterizer);
-
+ m_rendertools->PopMatrix();
}
-
-
void KX_KetsjiEngine::StopEngine()
{
if (m_bInitialized)
@@ -985,7 +1115,7 @@ void KX_KetsjiEngine::StopEngine()
for (sceneit = m_scenes.begin();sceneit != m_scenes.end() ; sceneit++)
{
KX_Scene* scene = *sceneit;
- delete scene;
+ m_sceneconverter->RemoveScene(scene);
}
m_scenes.clear();
@@ -1039,6 +1169,8 @@ void KX_KetsjiEngine::PostProcessScene(KX_Scene* scene)
scene->SetActiveCamera(activecam);
scene->GetObjectList()->Add(activecam->AddRef());
scene->GetRootParentList()->Add(activecam->AddRef());
+ //done with activecam
+ activecam->Release();
}
scene->UpdateParents(0.0);
@@ -1111,19 +1243,49 @@ void KX_KetsjiEngine::RenderDebugProperties()
CValue* propobj = (*it)->m_obj;
STR_String objname = propobj->GetName();
STR_String propname = (*it)->m_name;
- CValue* propval = propobj->GetProperty(propname);
- if (propval)
+ if (propname == "__state__")
{
- STR_String text = propval->GetText();
- debugtxt = objname + "." + propname + " = " + text;
+ // reserve name for object state
+ KX_GameObject* gameobj = static_cast<KX_GameObject*>(propobj);
+ unsigned int state = gameobj->GetState();
+ debugtxt = objname + "." + propname + " = ";
+ bool first = true;
+ for (int statenum=1;state;state >>= 1, statenum++)
+ {
+ if (state & 1)
+ {
+ if (!first)
+ {
+ debugtxt += ",";
+ }
+ debugtxt += STR_String(statenum);
+ first = false;
+ }
+ }
m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
- debugtxt.Ptr(),
- xcoord,
- ycoord,
- m_canvas->GetWidth(),
- m_canvas->GetHeight());
+ debugtxt.Ptr(),
+ xcoord,
+ ycoord,
+ m_canvas->GetWidth(),
+ m_canvas->GetHeight());
ycoord += 14;
}
+ else
+ {
+ CValue* propval = propobj->GetProperty(propname);
+ if (propval)
+ {
+ STR_String text = propval->GetText();
+ debugtxt = objname + "." + propname + " = " + text;
+ m_rendertools->RenderText2D(RAS_IRenderTools::RAS_TEXT_PADDED,
+ debugtxt.Ptr(),
+ xcoord,
+ ycoord,
+ m_canvas->GetWidth(),
+ m_canvas->GetHeight());
+ ycoord += 14;
+ }
+ }
}
}
}
@@ -1207,7 +1369,7 @@ void KX_KetsjiEngine::RemoveScheduledScenes()
KX_Scene* scene = *sceneit;
if (scene->GetName()==scenename)
{
- delete scene;
+ m_sceneconverter->RemoveScene(scene);
m_scenes.erase(sceneit);
break;
}
@@ -1221,12 +1383,13 @@ void KX_KetsjiEngine::RemoveScheduledScenes()
KX_Scene* KX_KetsjiEngine::CreateScene(const STR_String& scenename)
{
-
+ Scene *scene = m_sceneconverter->GetBlenderSceneForName(scenename);
KX_Scene* tmpscene = new KX_Scene(m_keyboarddevice,
m_mousedevice,
m_networkdevice,
m_audiodevice,
- scenename);
+ scenename,
+ scene);
m_sceneconverter->ConvertScene(scenename,
tmpscene,
@@ -1305,7 +1468,7 @@ void KX_KetsjiEngine::ReplaceScheduledScenes()
KX_Scene* scene = *sceneit;
if (scene->GetName() == oldscenename)
{
- delete scene;
+ m_sceneconverter->RemoveScene(scene);
KX_Scene* tmpscene = CreateScene(newscenename);
m_scenes[i]=tmpscene;
PostProcessScene(tmpscene);
@@ -1372,6 +1535,26 @@ void KX_KetsjiEngine::SetTicRate(double ticrate)
m_ticrate = ticrate;
}
+double KX_KetsjiEngine::GetAnimFrameRate()
+{
+ return m_anim_framerate;
+}
+
+double KX_KetsjiEngine::GetClockTime(void) const
+{
+ return m_clockTime;
+}
+
+void KX_KetsjiEngine::SetAnimFrameRate(double framerate)
+{
+ m_anim_framerate = framerate;
+}
+
+double KX_KetsjiEngine::GetAverageFrameRate()
+{
+ return m_average_framerate;
+}
+
void KX_KetsjiEngine::SetTimingDisplay(bool frameRate, bool profile, bool properties)
{
m_show_framerate = frameRate;
@@ -1464,3 +1647,4 @@ void KX_KetsjiEngine::GetOverrideFrameColor(float& r, float& g, float& b) const
}
+
diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h
index e727452423b..4184202c518 100644
--- a/source/gameengine/Ketsji/KX_KetsjiEngine.h
+++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h
@@ -103,6 +103,7 @@ private:
double m_remainingTime;
static double m_ticrate;
+ static double m_anim_framerate; /* for animation playback only - ipo and action */
static double m_suspendedtime;
static double m_suspendeddelta;
@@ -123,6 +124,8 @@ private:
bool m_overrideCamUseOrtho;
MT_CmMatrix4x4 m_overrideCamProjMat;
MT_CmMatrix4x4 m_overrideCamViewMat;
+ float m_overrideCamNear;
+ float m_overrideCamFar;
bool m_stereo;
int m_curreye;
@@ -148,6 +151,8 @@ private:
/** Labels for profiling display. */
static const char m_profileLabels[tc_numCategories][15];
+ /** Last estimated framerate */
+ static double m_average_framerate;
/** Show the framerate on the game display? */
bool m_show_framerate;
/** Show profiling info on the game display? */
@@ -174,9 +179,10 @@ private:
/** Blue component of framing bar color. */
float m_overrideFrameColorB;
- void SetupRenderFrame(KX_Scene *scene, KX_Camera* cam);
void RenderFrame(KX_Scene* scene, KX_Camera* cam);
+ void PostRenderFrame();
void RenderDebugProperties();
+ void RenderShadowBuffers(KX_Scene *scene);
void SetBackGround(KX_WorldInfo* worldinfo);
void SetWorldSettings(KX_WorldInfo* worldinfo);
void DoSound(KX_Scene* scene);
@@ -198,6 +204,8 @@ public:
void SetSceneConverter(KX_ISceneConverter* sceneconverter);
void SetGame2IpoMode(bool game2ipo,int startFrame);
+ RAS_IRasterizer* GetRasterizer(){return m_rasterizer;};
+
///returns true if an update happened to indicate -> Render
bool NextFrame();
void Render();
@@ -221,6 +229,8 @@ public:
void SuspendScene(const STR_String& scenename);
void ResumeScene(const STR_String& scenename);
+ void GetSceneViewport(KX_Scene* scene, KX_Camera* cam, RAS_Rect& area, RAS_Rect& viewport);
+
void SetDrawType(int drawingtype);
void SetCameraZoom(float camzoom);
@@ -229,6 +239,7 @@ public:
void SetCameraOverrideUseOrtho(bool useOrtho);
void SetCameraOverrideProjectionMatrix(const MT_CmMatrix4x4& mat);
void SetCameraOverrideViewMatrix(const MT_CmMatrix4x4& mat);
+ void SetCameraOverrideClipping(float near, float far);
/**
* Sets display of all frames.
@@ -243,6 +254,11 @@ public:
bool GetUseFixedTime(void) const;
/**
+ * Returns current render frame clock time
+ */
+ double GetClockTime(void) const;
+
+ /**
* Returns the difference between the local time of the scene (when it
* was running and not suspended) and the "curtime"
*/
@@ -258,6 +274,20 @@ public:
static void SetTicRate(double ticrate);
/**
+ * Gets the framerate for playing animations. (actions and ipos)
+ */
+ static double GetAnimFrameRate();
+ /**
+ * Sets the framerate for playing animations. (actions and ipos)
+ */
+ static void SetAnimFrameRate(double framerate);
+
+ /**
+ * Gets the last estimated average framerate
+ */
+ static double GetAverageFrameRate();
+
+ /**
* Activates or deactivates timing information display.
* @param frameRate Display for frame rate on or off.
* @param profile Display for individual components on or off.
@@ -334,8 +364,10 @@ protected:
KX_Scene* CreateScene(const STR_String& scenename);
bool BeginFrame();
+ void ClearFrame();
void EndFrame();
};
#endif //__KX_KETSJI_ENGINE
+
diff --git a/source/gameengine/Ketsji/KX_Light.cpp b/source/gameengine/Ketsji/KX_Light.cpp
index 3ae09c01270..e0f171e78e0 100644
--- a/source/gameengine/Ketsji/KX_Light.cpp
+++ b/source/gameengine/Ketsji/KX_Light.cpp
@@ -36,14 +36,19 @@
#endif
#include "KX_Light.h"
+#include "KX_Camera.h"
+#include "RAS_IRasterizer.h"
#include "RAS_IRenderTools.h"
#include "KX_PyMath.h"
+#include "DNA_object_types.h"
+#include "GPU_material.h"
KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,
class RAS_IRenderTools* rendertools,
const RAS_LightObject& lightobj,
+ bool glsl,
PyTypeObject* T
)
:
@@ -53,11 +58,19 @@ KX_LightObject::KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,
m_lightobj = lightobj;
m_lightobj.m_worldmatrix = GetOpenGLMatrixPtr();
m_rendertools->AddLight(&m_lightobj);
+ m_glsl = glsl;
+ m_blenderscene = ((KX_Scene*)sgReplicationInfo)->GetBlenderScene();
};
KX_LightObject::~KX_LightObject()
{
+ GPULamp *lamp;
+
+ if((lamp = GetGPULamp())) {
+ float obmat[4][4] = {{0}};
+ GPU_lamp_update(lamp, 0, obmat);
+ }
m_rendertools->RemoveLight(&m_lightobj);
}
@@ -67,7 +80,7 @@ CValue* KX_LightObject::GetReplica()
{
KX_LightObject* replica = new KX_LightObject(*this);
-
+
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
@@ -75,9 +88,90 @@ CValue* KX_LightObject::GetReplica()
replica->m_lightobj.m_worldmatrix = replica->GetOpenGLMatrixPtr();
m_rendertools->AddLight(&replica->m_lightobj);
+
return replica;
}
+GPULamp *KX_LightObject::GetGPULamp()
+{
+ if(m_glsl)
+ return GPU_lamp_from_blender(m_blenderscene, GetBlenderObject(), GetBlenderGroupObject());
+ else
+ return false;
+}
+
+void KX_LightObject::Update()
+{
+ GPULamp *lamp;
+
+ if((lamp = GetGPULamp())) {
+ float obmat[4][4];
+ double *dobmat = GetOpenGLMatrixPtr()->getPointer();
+
+ for(int i=0; i<4; i++)
+ for(int j=0; j<4; j++, dobmat++)
+ obmat[i][j] = (float)*dobmat;
+
+ GPU_lamp_update(lamp, m_lightobj.m_layer, obmat);
+ }
+}
+
+bool KX_LightObject::HasShadowBuffer()
+{
+ GPULamp *lamp;
+
+ if((lamp = GetGPULamp()))
+ return GPU_lamp_has_shadow_buffer(lamp);
+ else
+ return false;
+}
+
+int KX_LightObject::GetShadowLayer()
+{
+ GPULamp *lamp;
+
+ if((lamp = GetGPULamp()))
+ return GPU_lamp_shadow_layer(lamp);
+ else
+ return 0;
+}
+
+void KX_LightObject::BindShadowBuffer(RAS_IRasterizer *ras, KX_Camera *cam, MT_Transform& camtrans)
+{
+ GPULamp *lamp;
+ float viewmat[4][4], winmat[4][4];
+ int winsize;
+
+ /* bind framebuffer */
+ lamp = GetGPULamp();
+ GPU_lamp_shadow_buffer_bind(lamp, viewmat, &winsize, winmat);
+
+ /* setup camera transformation */
+ MT_Matrix4x4 modelviewmat((float*)viewmat);
+ MT_Matrix4x4 projectionmat((float*)winmat);
+
+ MT_Transform trans = MT_Transform((float*)viewmat);
+ camtrans.invert(trans);
+
+ cam->SetModelviewMatrix(modelviewmat);
+ cam->SetProjectionMatrix(projectionmat);
+
+ cam->NodeSetLocalPosition(camtrans.getOrigin());
+ cam->NodeSetLocalOrientation(camtrans.getBasis());
+ cam->NodeUpdateGS(0,true);
+
+ /* setup rasterizer transformations */
+ ras->SetProjectionMatrix(projectionmat);
+ ras->SetViewMatrix(modelviewmat, cam->NodeGetWorldPosition(),
+ cam->GetCameraLocation(), cam->GetCameraOrientation());
+}
+
+void KX_LightObject::UnbindShadowBuffer(RAS_IRasterizer *ras)
+{
+ GPULamp *lamp = GetGPULamp();
+ GPU_lamp_shadow_buffer_unbind(lamp);
+}
+
PyObject* KX_LightObject::_getattr(const STR_String& attr)
{
if (attr == "layer")
@@ -223,7 +317,7 @@ char KX_LightObject::doc[] = "Module KX_LightObject\n\n"
"\t\tThe effect radius of the light.\n"
"\tcolour -> list [r, g, b].\n"
"\tcolor -> list [r, g, b].\n"
-"\t\tThe colour of the light.\n"
+"\t\tThe color of the light.\n"
"\tlin_attenuation -> float.\n"
"\t\tThe attenuation factor for the light.\n"
"\tspotsize -> float.\n"
diff --git a/source/gameengine/Ketsji/KX_Light.h b/source/gameengine/Ketsji/KX_Light.h
index 236d3e4e12e..e5dbf0b7f4a 100644
--- a/source/gameengine/Ketsji/KX_Light.h
+++ b/source/gameengine/Ketsji/KX_Light.h
@@ -32,22 +32,41 @@
#include "RAS_LightObject.h"
#include "KX_GameObject.h"
+struct GPULamp;
+struct Scene;
+class KX_Camera;
+class RAS_IRasterizer;
+class RAS_IRenderTools;
+class MT_Transform;
+
class KX_LightObject : public KX_GameObject
{
Py_Header;
protected:
RAS_LightObject m_lightobj;
class RAS_IRenderTools* m_rendertools; //needed for registering and replication of lightobj
- static char doc[];
+ bool m_glsl;
+ Scene* m_blenderscene;
+ static char doc[];
public:
- KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,class RAS_IRenderTools* rendertools,const struct RAS_LightObject& lightobj, PyTypeObject *T = &Type);
+ KX_LightObject(void* sgReplicationInfo,SG_Callbacks callbacks,class RAS_IRenderTools* rendertools,const struct RAS_LightObject& lightobj, bool glsl, PyTypeObject *T = &Type);
virtual ~KX_LightObject();
virtual CValue* GetReplica();
RAS_LightObject* GetLightData() { return &m_lightobj;}
+
+ /* GLSL shadow */
+ struct GPULamp *GetGPULamp();
+ bool HasShadowBuffer();
+ int GetShadowLayer();
+ void BindShadowBuffer(class RAS_IRasterizer *ras, class KX_Camera *cam, class MT_Transform& camtrans);
+ void UnbindShadowBuffer(class RAS_IRasterizer *ras);
+ void Update();
virtual PyObject* _getattr(const STR_String& attr); /* lens, near, far, projection_matrix */
virtual int _setattr(const STR_String& attr, PyObject *pyvalue);
+
+ virtual bool IsLight(void) { return true; }
};
#endif //__KX_LIGHT
diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.cpp b/source/gameengine/Ketsji/KX_MaterialIpoController.cpp
index c0757a32b9c..85d514bd22f 100644
--- a/source/gameengine/Ketsji/KX_MaterialIpoController.cpp
+++ b/source/gameengine/Ketsji/KX_MaterialIpoController.cpp
@@ -3,6 +3,8 @@
#include "KX_ScalarInterpolator.h"
#include "KX_GameObject.h"
+#include "BLO_sys_types.h" // for intptr_t support
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -37,6 +39,7 @@ bool KX_MaterialIpoController::Update(double currentTime)
//kxgameobj->SetObjectColor(m_rgba);
kxgameobj->UpdateMaterialData(
+ m_matname_hash,
m_rgba,
m_specrgb,
m_hard,
@@ -75,10 +78,10 @@ SG_Controller* KX_MaterialIpoController::GetReplica(class SG_Node* destnode)
iporeplica->AddInterpolator(copyipo);
MT_Scalar* scaal = ((KX_ScalarInterpolator*)*i)->GetTarget();
- long orgbase = (long)this;
- long orgloc = (long)scaal;
- long offset = orgloc-orgbase;
- long newaddrbase = (long)iporeplica + offset;
+ intptr_t orgbase = (intptr_t)this;
+ intptr_t orgloc = (intptr_t)scaal;
+ intptr_t offset = orgloc-orgbase;
+ intptr_t newaddrbase = (intptr_t)iporeplica + offset;
MT_Scalar* blaptr = (MT_Scalar*) newaddrbase;
copyipo->SetNewTarget((MT_Scalar*)blaptr);
}
diff --git a/source/gameengine/Ketsji/KX_MaterialIpoController.h b/source/gameengine/Ketsji/KX_MaterialIpoController.h
index e76ddeefb04..4d2e258bf94 100644
--- a/source/gameengine/Ketsji/KX_MaterialIpoController.h
+++ b/source/gameengine/Ketsji/KX_MaterialIpoController.h
@@ -7,6 +7,8 @@
#include "SG_Spatial.h"
#include "KX_IInterpolator.h"
+#include "STR_String.h" //typedef dword
+
class KX_MaterialIpoController : public SG_Controller
{
public:
@@ -23,10 +25,12 @@ private:
bool m_modified;
double m_ipotime;
+ dword m_matname_hash;
public:
- KX_MaterialIpoController() :
+ KX_MaterialIpoController(dword matname_hash) :
m_modified(true),
- m_ipotime(0.0)
+ m_ipotime(0.0),
+ m_matname_hash(matname_hash)
{}
virtual ~KX_MaterialIpoController();
virtual SG_Controller* GetReplica(class SG_Node* destnode);
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.cpp b/source/gameengine/Ketsji/KX_MeshProxy.cpp
index 5c8fef1fca0..5cc102248f2 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.cpp
+++ b/source/gameengine/Ketsji/KX_MeshProxy.cpp
@@ -35,6 +35,7 @@
#include "RAS_MeshObject.h"
#include "KX_VertexProxy.h"
+#include "KX_PolyProxy.h"
#include "KX_PolygonMaterial.h"
#include "KX_BlenderMaterial.h"
@@ -42,6 +43,8 @@
#include "KX_PyMath.h"
#include "KX_ConvertPhysicsObject.h"
+#include "PyObjectPlus.h"
+
PyTypeObject KX_MeshProxy::Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
@@ -71,10 +74,12 @@ PyParentObject KX_MeshProxy::Parents[] = {
PyMethodDef KX_MeshProxy::Methods[] = {
{"getNumMaterials", (PyCFunction)KX_MeshProxy::sPyGetNumMaterials,METH_VARARGS},
+{"getNumPolygons", (PyCFunction)KX_MeshProxy::sPyGetNumPolygons,METH_NOARGS},
{"getMaterialName", (PyCFunction)KX_MeshProxy::sPyGetMaterialName,METH_VARARGS},
{"getTextureName", (PyCFunction)KX_MeshProxy::sPyGetTextureName,METH_VARARGS},
{"getVertexArrayLength", (PyCFunction)KX_MeshProxy::sPyGetVertexArrayLength,METH_VARARGS},
{"getVertex", (PyCFunction)KX_MeshProxy::sPyGetVertex,METH_VARARGS},
+{"getPolygon", (PyCFunction)KX_MeshProxy::sPyGetPolygon,METH_VARARGS},
KX_PYMETHODTABLE(KX_MeshProxy, reinstancePhysicsMesh),
//{"getIndexArrayLength", (PyCFunction)KX_MeshProxy::sPyGetIndexArrayLength,METH_VARARGS},
@@ -93,10 +98,11 @@ KX_MeshProxy::_getattr(const STR_String& attr)
if (attr == "materials")
{
PyObject *materials = PyList_New(0);
- RAS_MaterialBucket::Set::iterator mit = m_meshobj->GetFirstMaterial();
+ list<RAS_MeshMaterial>::iterator mit = m_meshobj->GetFirstMaterial();
for(; mit != m_meshobj->GetLastMaterial(); ++mit)
{
- RAS_IPolyMaterial *polymat = (*mit)->GetPolyMaterial();
+ RAS_IPolyMaterial *polymat = mit->m_bucket->GetPolyMaterial();
+
if(polymat->GetFlag() & RAS_BLENDERMAT)
{
KX_BlenderMaterial *mat = static_cast<KX_BlenderMaterial*>(polymat);
@@ -146,6 +152,12 @@ PyObject* KX_MeshProxy::PyGetNumMaterials(PyObject* self,
return PyInt_FromLong(num);
}
+PyObject* KX_MeshProxy::PyGetNumPolygons(PyObject* self)
+{
+ int num = m_meshobj->NumPolygons();
+ return PyInt_FromLong(num);
+}
+
PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* self,
PyObject* args,
PyObject* kwds)
@@ -157,6 +169,9 @@ PyObject* KX_MeshProxy::PyGetMaterialName(PyObject* self,
{
matname = m_meshobj->GetMaterialName(matid);
}
+ else {
+ return NULL;
+ }
return PyString_FromString(matname.Ptr());
@@ -174,6 +189,9 @@ PyObject* KX_MeshProxy::PyGetTextureName(PyObject* self,
{
matname = m_meshobj->GetTextureName(matid);
}
+ else {
+ return NULL;
+ }
return PyString_FromString(matname.Ptr());
@@ -189,11 +207,14 @@ PyObject* KX_MeshProxy::PyGetVertexArrayLength(PyObject* self,
if (PyArg_ParseTuple(args,"i",&matid))
{
- RAS_IPolyMaterial* mat = m_meshobj->GetMaterialBucket(matid)->GetPolyMaterial();
+ RAS_MeshMaterial *mmat = m_meshobj->GetMeshMaterial(matid);
+ RAS_IPolyMaterial* mat = mmat->m_bucket->GetPolyMaterial();
+
if (mat)
- {
- length = m_meshobj->GetVertexArrayLength(mat);
- }
+ length = m_meshobj->NumVertices(mat);
+ }
+ else {
+ return NULL;
}
return PyInt_FromLong(length);
@@ -217,14 +238,39 @@ PyObject* KX_MeshProxy::PyGetVertex(PyObject* self,
vertexob = new KX_VertexProxy(this, vertex);
}
}
+ else {
+ return NULL;
+ }
return vertexob;
}
+PyObject* KX_MeshProxy::PyGetPolygon(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ int polyindex= 1;
+ PyObject* polyob = NULL;
+
+ if (!PyArg_ParseTuple(args,"i",&polyindex))
+ return NULL;
+
+ RAS_Polygon* polygon = m_meshobj->GetPolygon(polyindex);
+ if (polygon)
+ {
+ polyob = new KX_PolyProxy(m_meshobj, polygon);
+ }
+ else
+ {
+ PyErr_SetString(PyExc_AttributeError, "Invalid polygon index");
+ }
+ return polyob;
+}
+
KX_PYMETHODDEF_DOC(KX_MeshProxy, reinstancePhysicsMesh,
"Reinstance the physics mesh.")
{
//this needs to be reviewed, it is dependend on Sumo/Solid. Who is using this ?
- return Py_None;//Py_Success(KX_ReInstanceShapeFromMesh(m_meshobj));
+ Py_RETURN_NONE;//(KX_ReInstanceShapeFromMesh(m_meshobj)) ? Py_RETURN_TRUE : Py_RETURN_FALSE;
}
diff --git a/source/gameengine/Ketsji/KX_MeshProxy.h b/source/gameengine/Ketsji/KX_MeshProxy.h
index 7c6202c15a4..3335c349673 100644
--- a/source/gameengine/Ketsji/KX_MeshProxy.h
+++ b/source/gameengine/Ketsji/KX_MeshProxy.h
@@ -57,10 +57,12 @@ public:
KX_PYMETHOD(KX_MeshProxy,GetNumMaterials);
KX_PYMETHOD(KX_MeshProxy,GetMaterialName);
KX_PYMETHOD(KX_MeshProxy,GetTextureName);
+ KX_PYMETHOD_NOARGS(KX_MeshProxy,GetNumPolygons);
// both take materialid (int)
KX_PYMETHOD(KX_MeshProxy,GetVertexArrayLength);
KX_PYMETHOD(KX_MeshProxy,GetVertex);
+ KX_PYMETHOD(KX_MeshProxy,GetPolygon);
KX_PYMETHOD_DOC(KX_MeshProxy, reinstancePhysicsMesh);
};
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
index 60b90138abe..28279b9a6b8 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.cpp
@@ -62,43 +62,54 @@ KX_MouseFocusSensor::KX_MouseFocusSensor(SCA_MouseManager* eventmgr,
int focusmode,
RAS_ICanvas* canvas,
KX_Scene* kxscene,
+ KX_KetsjiEngine *kxengine,
SCA_IObject* gameobj,
PyTypeObject* T)
: SCA_MouseSensor(eventmgr, startx, starty, mousemode, gameobj, T),
m_focusmode(focusmode),
m_gp_canvas(canvas),
- m_kxscene(kxscene)
+ m_kxscene(kxscene),
+ m_kxengine(kxengine)
{
+ Init();
+}
- m_mouse_over_in_previous_frame = false;
+void KX_MouseFocusSensor::Init()
+{
+ m_mouse_over_in_previous_frame = (m_invert)?true:false;
m_positive_event = false;
m_hitObject = 0;
-
+ m_reset = true;
}
bool KX_MouseFocusSensor::Evaluate(CValue* event)
{
bool result = false;
bool obHasFocus = false;
+ bool reset = m_reset && m_level;
// cout << "evaluate focus mouse sensor "<<endl;
-
+ m_reset = false;
if (m_focusmode) {
/* Focus behaviour required. Test mouse-on. The rest is
* equivalent to handling a key. */
obHasFocus = ParentObjectHasFocus();
if (!obHasFocus) {
+ m_positive_event = false;
if (m_mouse_over_in_previous_frame) {
- m_positive_event = false;
- result = true;
+ result = true;
}
} else {
+ m_positive_event = true;
if (!m_mouse_over_in_previous_frame) {
- m_positive_event = true;
result = true;
}
}
+ if (reset) {
+ // force an event
+ result = true;
+ }
} else {
/* No focus behaviour required: revert to the basic mode. This
* mode is never used, because the converter never makes this
@@ -113,16 +124,10 @@ bool KX_MouseFocusSensor::Evaluate(CValue* event)
return result;
}
-bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo* client_info, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data)
+bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo* client_info, KX_RayCast* result, void * const data)
{
KX_GameObject* hitKXObj = client_info->m_gameobject;
- if (client_info->m_type > KX_ClientObjectInfo::ACTOR)
- {
- // false hit
- return false;
- }
-
/* Is this me? In the ray test, there are a lot of extra checks
* for aliasing artefacts from self-hits. That doesn't happen
* here, so a simple test suffices. Or does the camera also get
@@ -133,8 +138,8 @@ bool KX_MouseFocusSensor::RayHit(KX_ClientObjectInfo* client_info, MT_Point3& hi
if ((m_focusmode == 2) || hitKXObj == thisObj)
{
m_hitObject = hitKXObj;
- m_hitPosition = hit_point;
- m_hitNormal = hit_normal;
+ m_hitPosition = result->m_hitPoint;
+ m_hitNormal = result->m_hitNormal;
return true;
}
@@ -149,8 +154,6 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void)
m_hitObject = 0;
m_hitPosition = MT_Vector3(0,0,0);
m_hitNormal = MT_Vector3(1,0,0);
- MT_Point3 resultpoint;
- MT_Vector3 resultnormal;
/* All screen handling in the gameengine is done by GL,
* specifically the model/view and projection parts. The viewport
@@ -192,11 +195,14 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void)
* calculations don't bomb. Maybe we should explicitly guard for
* division by 0.0...*/
- /**
- * Get the scenes current viewport.
- */
+ KX_Camera* cam = m_kxscene->GetActiveCamera();
+
+ /* get the scenes current viewport. we recompute it because there
+ * may be multiple cameras and m_kxscene->GetSceneViewport() only
+ * has the one that was last drawn */
- const RAS_Rect & viewport = m_kxscene->GetSceneViewport();
+ RAS_Rect area, viewport;
+ m_kxengine->GetSceneViewport(m_kxscene, cam, area, viewport);
float height = float(viewport.m_y2 - viewport.m_y1 + 1);
float width = float(viewport.m_x2 - viewport.m_x1 + 1);
@@ -204,9 +210,9 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void)
float x_lb = float(viewport.m_x1);
float y_lb = float(viewport.m_y1);
- KX_Camera* cam = m_kxscene->GetActiveCamera();
/* There's some strangeness I don't fully get here... These values
* _should_ be wrong! */
+
/* old: */
float nearclip = 0.0;
@@ -271,7 +277,8 @@ bool KX_MouseFocusSensor::ParentObjectHasFocus(void)
bool result = false;
- result = KX_RayCast::RayTest(physics_controller, physics_environment, frompoint3, topoint3, resultpoint, resultnormal, KX_RayCast::Callback<KX_MouseFocusSensor>(this));
+ KX_RayCast::Callback<KX_MouseFocusSensor> callback(this,physics_controller);
+ KX_RayCast::RayTest(physics_environment, frompoint3, topoint3, callback);
result = (m_hitObject!=0);
@@ -313,14 +320,12 @@ PyParentObject KX_MouseFocusSensor::Parents[] = {
};
PyMethodDef KX_MouseFocusSensor::Methods[] = {
- {"getRayTarget", (PyCFunction) KX_MouseFocusSensor::sPyGetRayTarget,
- METH_VARARGS, GetRayTarget_doc},
- {"getRaySource", (PyCFunction) KX_MouseFocusSensor::sPyGetRaySource,
- METH_VARARGS, GetRaySource_doc},
- {"getHitObject",(PyCFunction) KX_MouseFocusSensor::sPyGetHitObject,METH_VARARGS, GetHitObject_doc},
- {"getHitPosition",(PyCFunction) KX_MouseFocusSensor::sPyGetHitPosition,METH_VARARGS, GetHitPosition_doc},
- {"getHitNormal",(PyCFunction) KX_MouseFocusSensor::sPyGetHitNormal,METH_VARARGS, GetHitNormal_doc},
- {"getRayDirection",(PyCFunction) KX_MouseFocusSensor::sPyGetRayDirection,METH_VARARGS, GetRayDirection_doc},
+ {"getRayTarget", (PyCFunction) KX_MouseFocusSensor::sPyGetRayTarget, METH_VARARGS, (PY_METHODCHAR)GetRayTarget_doc},
+ {"getRaySource", (PyCFunction) KX_MouseFocusSensor::sPyGetRaySource, METH_VARARGS, (PY_METHODCHAR)GetRaySource_doc},
+ {"getHitObject",(PyCFunction) KX_MouseFocusSensor::sPyGetHitObject,METH_VARARGS, (PY_METHODCHAR)GetHitObject_doc},
+ {"getHitPosition",(PyCFunction) KX_MouseFocusSensor::sPyGetHitPosition,METH_VARARGS, (PY_METHODCHAR)GetHitPosition_doc},
+ {"getHitNormal",(PyCFunction) KX_MouseFocusSensor::sPyGetHitNormal,METH_VARARGS, (PY_METHODCHAR)GetHitNormal_doc},
+ {"getRayDirection",(PyCFunction) KX_MouseFocusSensor::sPyGetRayDirection,METH_VARARGS, (PY_METHODCHAR)GetRayDirection_doc},
{NULL,NULL} //Sentinel
@@ -331,7 +336,7 @@ PyObject* KX_MouseFocusSensor::_getattr(const STR_String& attr) {
}
-char KX_MouseFocusSensor::GetHitObject_doc[] =
+const char KX_MouseFocusSensor::GetHitObject_doc[] =
"getHitObject()\n"
"\tReturns the name of the object that was hit by this ray.\n";
PyObject* KX_MouseFocusSensor::PyGetHitObject(PyObject* self,
@@ -346,7 +351,7 @@ PyObject* KX_MouseFocusSensor::PyGetHitObject(PyObject* self,
}
-char KX_MouseFocusSensor::GetHitPosition_doc[] =
+const char KX_MouseFocusSensor::GetHitPosition_doc[] =
"getHitPosition()\n"
"\tReturns the position (in worldcoordinates) where the object was hit by this ray.\n";
PyObject* KX_MouseFocusSensor::PyGetHitPosition(PyObject* self,
@@ -366,7 +371,7 @@ PyObject* KX_MouseFocusSensor::PyGetHitPosition(PyObject* self,
}
-char KX_MouseFocusSensor::GetRayDirection_doc[] =
+const char KX_MouseFocusSensor::GetRayDirection_doc[] =
"getRayDirection()\n"
"\tReturns the direction from the ray (in worldcoordinates) .\n";
PyObject* KX_MouseFocusSensor::PyGetRayDirection(PyObject* self,
@@ -387,7 +392,7 @@ PyObject* KX_MouseFocusSensor::PyGetRayDirection(PyObject* self,
}
-char KX_MouseFocusSensor::GetHitNormal_doc[] =
+const char KX_MouseFocusSensor::GetHitNormal_doc[] =
"getHitNormal()\n"
"\tReturns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.\n";
PyObject* KX_MouseFocusSensor::PyGetHitNormal(PyObject* self,
@@ -408,7 +413,7 @@ PyObject* KX_MouseFocusSensor::PyGetHitNormal(PyObject* self,
/* getRayTarget */
-char KX_MouseFocusSensor::GetRayTarget_doc[] =
+const char KX_MouseFocusSensor::GetRayTarget_doc[] =
"getRayTarget()\n"
"\tReturns the target of the ray that seeks the focus object,\n"
"\tin worldcoordinates.";
@@ -425,7 +430,7 @@ PyObject* KX_MouseFocusSensor::PyGetRayTarget(PyObject* self,
}
/* getRayTarget */
-char KX_MouseFocusSensor::GetRaySource_doc[] =
+const char KX_MouseFocusSensor::GetRaySource_doc[] =
"getRaySource()\n"
"\tReturns the source of the ray that seeks the focus object,\n"
"\tin worldcoordinates.";
diff --git a/source/gameengine/Ketsji/KX_MouseFocusSensor.h b/source/gameengine/Ketsji/KX_MouseFocusSensor.h
index 86f32fbf4be..6731444699b 100644
--- a/source/gameengine/Ketsji/KX_MouseFocusSensor.h
+++ b/source/gameengine/Ketsji/KX_MouseFocusSensor.h
@@ -33,6 +33,8 @@
#include "SCA_MouseSensor.h"
+class KX_RayCast;
+
/**
* The mouse focus sensor extends the basic SCA_MouseSensor. It has
* been placed in KX because it needs access to the rasterizer and
@@ -54,6 +56,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
int focusmode,
RAS_ICanvas* canvas,
KX_Scene* kxscene,
+ KX_KetsjiEngine* kxengine,
SCA_IObject* gameobj,
PyTypeObject* T=&Type );
@@ -68,6 +71,7 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
* @attention Overrides default evaluate.
*/
virtual bool Evaluate(CValue* event);
+ virtual void Init();
virtual bool IsPositiveTrigger() {
bool result = m_positive_event;
@@ -75,7 +79,9 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
return result;
};
- bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data);
+ bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
+ bool NeedRayCast(KX_ClientObjectInfo* client) { return true; }
+
/* --------------------------------------------------------------------- */
@@ -138,12 +144,6 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
/**
- * Ref to the engine, for retrieving a reference to the current
- * scene. */
- class KX_KetsjiEngine* m_engine;
-
-
- /**
* The active canvas. The size of this canvas determines a part of
* the start position of the picking ray. */
RAS_ICanvas* m_gp_canvas;
@@ -153,6 +153,9 @@ class KX_MouseFocusSensor : public SCA_MouseSensor
* determines a part of the start location of the picking ray. */
KX_Scene* m_kxscene;
+ /**
+ * The KX engine is needed for computing the viewport */
+ KX_KetsjiEngine* m_kxengine;
};
#endif //__KX_MOUSESENSOR
diff --git a/source/gameengine/Ketsji/KX_NearSensor.cpp b/source/gameengine/Ketsji/KX_NearSensor.cpp
index d893990735f..bae87c28123 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.cpp
+++ b/source/gameengine/Ketsji/KX_NearSensor.cpp
@@ -75,6 +75,21 @@ KX_NearSensor::KX_NearSensor(SCA_EventManager* eventmgr,
SynchronizeTransform();
}
+void KX_NearSensor::SynchronizeTransform()
+{
+ // The near and radar sensors are using a different physical object which is
+ // not linked to the parent object, must synchronize it.
+ if (m_physCtrl)
+ {
+ KX_GameObject* parent = ((KX_GameObject*)GetParent());
+ MT_Vector3 pos = parent->NodeGetWorldPosition();
+ MT_Quaternion orn = parent->NodeGetWorldOrientation().getRotation();
+ m_physCtrl->setPosition(pos.x(),pos.y(),pos.z());
+ m_physCtrl->setOrientation(orn.x(),orn.y(),orn.z(),orn.w());
+ m_physCtrl->calcXform();
+ }
+}
+
void KX_NearSensor::RegisterSumo(KX_TouchEventManager *touchman)
{
if (m_physCtrl)
@@ -83,14 +98,19 @@ void KX_NearSensor::RegisterSumo(KX_TouchEventManager *touchman)
}
}
+void KX_NearSensor::UnregisterSumo(KX_TouchEventManager* touchman)
+{
+ if (m_physCtrl)
+ {
+ touchman->GetPhysicsEnvironment()->removeSensor(m_physCtrl);
+ }
+}
+
CValue* KX_NearSensor::GetReplica()
{
KX_NearSensor* replica = new KX_NearSensor(*this);
replica->m_colliders = new CListValue();
- replica->m_bCollision = false;
- replica->m_bTriggered= false;
- replica->m_hitObject = NULL;
- replica->m_bLastTriggered = false;
+ replica->Init();
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
@@ -123,9 +143,6 @@ CValue* KX_NearSensor::GetReplica()
void KX_NearSensor::ReParent(SCA_IObject* parent)
{
-
- SCA_ISensor::ReParent(parent);
-
m_client_info->m_gameobject = static_cast<KX_GameObject*>(parent);
m_client_info->m_sensors.push_back(this);
@@ -139,6 +156,7 @@ void KX_NearSensor::ReParent(SCA_IObject* parent)
*/
((KX_GameObject*)GetParent())->GetSGNode()->ComputeWorldTransforms(NULL);
SynchronizeTransform();
+ SCA_ISensor::ReParent(parent);
}
@@ -172,13 +190,13 @@ bool KX_NearSensor::Evaluate(CValue* event)
{
if (m_physCtrl)
{
- m_physCtrl->SetMargin(m_ResetMargin);
+ m_physCtrl->SetRadius(m_ResetMargin);
}
} else
{
if (m_physCtrl)
{
- m_physCtrl->SetMargin(m_Margin);
+ m_physCtrl->SetRadius(m_Margin);
}
}
@@ -188,7 +206,36 @@ bool KX_NearSensor::Evaluate(CValue* event)
return result;
}
+// this function is called at broad phase stage to check if the two controller
+// need to interact at all. It is used for Near/Radar sensor that don't need to
+// check collision with object not included in filter
+bool KX_NearSensor::BroadPhaseFilterCollision(void*obj1,void*obj2)
+{
+ KX_GameObject* parent = static_cast<KX_GameObject*>(GetParent());
+
+ // need the mapping from PHY_IPhysicsController to gameobjects now
+ assert(obj1==m_physCtrl && obj2);
+ KX_ClientObjectInfo* client_info = static_cast<KX_ClientObjectInfo*>((static_cast<PHY_IPhysicsController*>(obj2))->getNewClientInfo());
+ KX_GameObject* gameobj = ( client_info ?
+ client_info->m_gameobject :
+ NULL);
+
+ if (gameobj && (gameobj != parent))
+ {
+ // only take valid colliders
+ if (client_info->m_type == KX_ClientObjectInfo::ACTOR)
+ {
+ if ((m_touchedpropname.Length() == 0) ||
+ (gameobj->GetProperty(m_touchedpropname)))
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
bool KX_NearSensor::NewHandleCollision(void* obj1,void* obj2,const PHY_CollData * coll_data)
{
@@ -205,20 +252,24 @@ bool KX_NearSensor::NewHandleCollision(void* obj1,void* obj2,const PHY_CollData
client_info->m_gameobject :
NULL);
- if (gameobj && (gameobj != parent))
+ // Add the same check as in SCA_ISensor::Activate(),
+ // we don't want to record collision when the sensor is not active.
+ if (m_links && !m_suspended &&
+ gameobj /* done in BroadPhaseFilterCollision() && (gameobj != parent)*/)
{
if (!m_colliders->SearchValue(gameobj))
m_colliders->Add(gameobj->AddRef());
// only take valid colliders
- if (client_info->m_type == KX_ClientObjectInfo::ACTOR)
- {
- if ((m_touchedpropname.Length() == 0) ||
- (gameobj->GetProperty(m_touchedpropname)))
- {
+ // These checks are done already in BroadPhaseFilterCollision()
+ //if (client_info->m_type == KX_ClientObjectInfo::ACTOR)
+ //{
+ // if ((m_touchedpropname.Length() == 0) ||
+ // (gameobj->GetProperty(m_touchedpropname)))
+ // {
m_bTriggered = true;
m_hitObject = gameobj;
- }
- }
+ // }
+ //}
}
return DT_CONTINUE;
@@ -260,14 +311,10 @@ PyParentObject KX_NearSensor::Parents[] = {
PyMethodDef KX_NearSensor::Methods[] = {
- {"setProperty",
- (PyCFunction) KX_NearSensor::sPySetProperty, METH_VARARGS, SetProperty_doc},
- {"getProperty",
- (PyCFunction) KX_NearSensor::sPyGetProperty, METH_VARARGS, GetProperty_doc},
- {"getHitObject",
- (PyCFunction) KX_NearSensor::sPyGetHitObject, METH_VARARGS, GetHitObject_doc},
- {"getHitObjectList",
- (PyCFunction) KX_NearSensor::sPyGetHitObjectList, METH_VARARGS, GetHitObjectList_doc},
+ {"setProperty", (PyCFunction) KX_NearSensor::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
+ {"getProperty", (PyCFunction) KX_NearSensor::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
+ {"getHitObject",(PyCFunction) KX_NearSensor::sPyGetHitObject, METH_VARARGS, (PY_METHODCHAR)GetHitObject_doc},
+ {"getHitObjectList", (PyCFunction) KX_NearSensor::sPyGetHitObjectList, METH_VARARGS, (PY_METHODCHAR)GetHitObjectList_doc},
{NULL,NULL} //Sentinel
};
diff --git a/source/gameengine/Ketsji/KX_NearSensor.h b/source/gameengine/Ketsji/KX_NearSensor.h
index 096822f99ed..3f7078ef9fd 100644
--- a/source/gameengine/Ketsji/KX_NearSensor.h
+++ b/source/gameengine/Ketsji/KX_NearSensor.h
@@ -68,13 +68,16 @@ public:
PyTypeObject* T=&Type);
*/
virtual ~KX_NearSensor();
+ virtual void SynchronizeTransform();
virtual CValue* GetReplica();
virtual bool Evaluate(CValue* event);
virtual void ReParent(SCA_IObject* parent);
virtual bool NewHandleCollision(void* obj1,void* obj2,
const PHY_CollData * coll_data);
+ virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2);
virtual void RegisterSumo(KX_TouchEventManager *touchman);
+ virtual void UnregisterSumo(KX_TouchEventManager* touchman);
virtual PyObject* _getattr(const STR_String& attr);
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.cpp b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
index 22a406792f9..98e73d4f0d7 100644
--- a/source/gameengine/Ketsji/KX_ObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_ObjectActuator.cpp
@@ -50,6 +50,7 @@ KX_ObjectActuator(
const MT_Vector3& drot,
const MT_Vector3& linV,
const MT_Vector3& angV,
+ const short damping,
const KX_LocalFlags& flag,
PyTypeObject* T
) :
@@ -60,9 +61,23 @@ KX_ObjectActuator(
m_drot(drot),
m_linear_velocity(linV),
m_angular_velocity(angV),
+ m_linear_length2(0.0),
+ m_current_linear_factor(0.0),
+ m_current_angular_factor(0.0),
+ m_damping(damping),
m_bitLocalFlag (flag),
- m_active_combined_velocity (false)
+ m_active_combined_velocity (false),
+ m_linear_damping_active(false),
+ m_angular_damping_active(false),
+ m_error_accumulator(0.0,0.0,0.0),
+ m_previous_error(0.0,0.0,0.0)
{
+ if (m_bitLocalFlag.ServoControl)
+ {
+ // in servo motion, the force is local if the target velocity is local
+ m_bitLocalFlag.Force = m_bitLocalFlag.LinearVelocity;
+ }
+ UpdateFuzzyFlags();
}
bool KX_ObjectActuator::Update()
@@ -79,51 +94,153 @@ bool KX_ObjectActuator::Update()
// it should reconcile the externally set velocity with it's
// own velocity.
if (m_active_combined_velocity) {
- parent->ResolveCombinedVelocities(
- m_linear_velocity,
- m_angular_velocity,
- (m_bitLocalFlag.LinearVelocity) != 0,
- (m_bitLocalFlag.AngularVelocity) != 0
- );
+ if (parent)
+ parent->ResolveCombinedVelocities(
+ m_linear_velocity,
+ m_angular_velocity,
+ (m_bitLocalFlag.LinearVelocity) != 0,
+ (m_bitLocalFlag.AngularVelocity) != 0
+ );
m_active_combined_velocity = false;
}
+ m_linear_damping_active = false;
+ m_angular_damping_active = false;
+ m_error_accumulator.setValue(0.0,0.0,0.0);
+ m_previous_error.setValue(0.0,0.0,0.0);
return false;
- } else
- if (parent)
+ } else if (parent)
{
- /* Probably better to use some flags, so these MT_zero tests can be */
- /* skipped. */
- if (!MT_fuzzyZero(m_force))
- {
- parent->ApplyForce(m_force,(m_bitLocalFlag.Force) != 0);
- }
- if (!MT_fuzzyZero(m_torque))
- {
- parent->ApplyTorque(m_torque,(m_bitLocalFlag.Torque) != 0);
- }
- if (!MT_fuzzyZero(m_dloc))
+ if (m_bitLocalFlag.ServoControl)
{
- parent->ApplyMovement(m_dloc,(m_bitLocalFlag.DLoc) != 0);
- }
- if (!MT_fuzzyZero(m_drot))
- {
- parent->ApplyRotation(m_drot,(m_bitLocalFlag.DRot) != 0);
- }
- if (!MT_fuzzyZero(m_linear_velocity))
+ // In this mode, we try to reach a target speed using force
+ // As we don't know the friction, we must implement a generic
+ // servo control to achieve the speed in a configurable
+ // v = current velocity
+ // V = target velocity
+ // e = V-v = speed error
+ // dt = time interval since previous update
+ // I = sum(e(t)*dt)
+ // dv = e(t) - e(t-1)
+ // KP, KD, KI : coefficient
+ // F = KP*e+KI*I+KD*dv
+ MT_Scalar mass = parent->GetMass();
+ if (mass < MT_EPSILON)
+ return false;
+ MT_Vector3 v = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity);
+ MT_Vector3 e = m_linear_velocity - v;
+ MT_Vector3 dv = e - m_previous_error;
+ MT_Vector3 I = m_error_accumulator + e;
+
+ m_force = m_torque.x()*e+m_torque.y()*I+m_torque.z()*dv;
+ // to automatically adapt the PID coefficient to mass;
+ m_force *= mass;
+ if (m_bitLocalFlag.Torque)
+ {
+ if (m_force[0] > m_dloc[0])
+ {
+ m_force[0] = m_dloc[0];
+ I[0] = m_error_accumulator[0];
+ } else if (m_force[0] < m_drot[0])
+ {
+ m_force[0] = m_drot[0];
+ I[0] = m_error_accumulator[0];
+ }
+ }
+ if (m_bitLocalFlag.DLoc)
+ {
+ if (m_force[1] > m_dloc[1])
+ {
+ m_force[1] = m_dloc[1];
+ I[1] = m_error_accumulator[1];
+ } else if (m_force[1] < m_drot[1])
+ {
+ m_force[1] = m_drot[1];
+ I[1] = m_error_accumulator[1];
+ }
+ }
+ if (m_bitLocalFlag.DRot)
+ {
+ if (m_force[2] > m_dloc[2])
+ {
+ m_force[2] = m_dloc[2];
+ I[2] = m_error_accumulator[2];
+ } else if (m_force[2] < m_drot[2])
+ {
+ m_force[2] = m_drot[2];
+ I[2] = m_error_accumulator[2];
+ }
+ }
+ m_previous_error = e;
+ m_error_accumulator = I;
+ parent->ApplyForce(m_force,(m_bitLocalFlag.LinearVelocity) != 0);
+ } else
{
- if (m_bitLocalFlag.AddOrSetLinV) {
- parent->addLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0);
- } else {
+ if (!m_bitLocalFlag.ZeroForce)
+ {
+ parent->ApplyForce(m_force,(m_bitLocalFlag.Force) != 0);
+ }
+ if (!m_bitLocalFlag.ZeroTorque)
+ {
+ parent->ApplyTorque(m_torque,(m_bitLocalFlag.Torque) != 0);
+ }
+ if (!m_bitLocalFlag.ZeroDLoc)
+ {
+ parent->ApplyMovement(m_dloc,(m_bitLocalFlag.DLoc) != 0);
+ }
+ if (!m_bitLocalFlag.ZeroDRot)
+ {
+ parent->ApplyRotation(m_drot,(m_bitLocalFlag.DRot) != 0);
+ }
+ if (!m_bitLocalFlag.ZeroLinearVelocity)
+ {
+ if (m_bitLocalFlag.AddOrSetLinV) {
+ parent->addLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0);
+ } else {
+ m_active_combined_velocity = true;
+ if (m_damping > 0) {
+ MT_Vector3 linV;
+ if (!m_linear_damping_active) {
+ // delta and the start speed (depends on the existing speed in that direction)
+ linV = parent->GetLinearVelocity(m_bitLocalFlag.LinearVelocity);
+ // keep only the projection along the desired direction
+ m_current_linear_factor = linV.dot(m_linear_velocity)/m_linear_length2;
+ m_linear_damping_active = true;
+ }
+ if (m_current_linear_factor < 1.0)
+ m_current_linear_factor += 1.0/m_damping;
+ if (m_current_linear_factor > 1.0)
+ m_current_linear_factor = 1.0;
+ linV = m_current_linear_factor * m_linear_velocity;
+ parent->setLinearVelocity(linV,(m_bitLocalFlag.LinearVelocity) != 0);
+ } else {
+ parent->setLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0);
+ }
+ }
+ }
+ if (!m_bitLocalFlag.ZeroAngularVelocity)
+ {
m_active_combined_velocity = true;
- parent->setLinearVelocity(m_linear_velocity,(m_bitLocalFlag.LinearVelocity) != 0);
+ if (m_damping > 0) {
+ MT_Vector3 angV;
+ if (!m_angular_damping_active) {
+ // delta and the start speed (depends on the existing speed in that direction)
+ angV = parent->GetAngularVelocity(m_bitLocalFlag.AngularVelocity);
+ // keep only the projection along the desired direction
+ m_current_angular_factor = angV.dot(m_angular_velocity)/m_angular_length2;
+ m_angular_damping_active = true;
+ }
+ if (m_current_angular_factor < 1.0)
+ m_current_angular_factor += 1.0/m_damping;
+ if (m_current_angular_factor > 1.0)
+ m_current_angular_factor = 1.0;
+ angV = m_current_angular_factor * m_angular_velocity;
+ parent->setAngularVelocity(angV,(m_bitLocalFlag.AngularVelocity) != 0);
+ } else {
+ parent->setAngularVelocity(m_angular_velocity,(m_bitLocalFlag.AngularVelocity) != 0);
+ }
}
}
- if (!MT_fuzzyZero(m_angular_velocity))
- {
- parent->setAngularVelocity(m_angular_velocity,(m_bitLocalFlag.AngularVelocity) != 0);
- m_active_combined_velocity = true;
- }
}
return true;
@@ -187,18 +304,29 @@ PyParentObject KX_ObjectActuator::Parents[] = {
};
PyMethodDef KX_ObjectActuator::Methods[] = {
- {"getForce", (PyCFunction) KX_ObjectActuator::sPyGetForce, METH_VARARGS},
+ {"getForce", (PyCFunction) KX_ObjectActuator::sPyGetForce, METH_NOARGS},
{"setForce", (PyCFunction) KX_ObjectActuator::sPySetForce, METH_VARARGS},
- {"getTorque", (PyCFunction) KX_ObjectActuator::sPyGetTorque, METH_VARARGS},
+ {"getTorque", (PyCFunction) KX_ObjectActuator::sPyGetTorque, METH_NOARGS},
{"setTorque", (PyCFunction) KX_ObjectActuator::sPySetTorque, METH_VARARGS},
- {"getDLoc", (PyCFunction) KX_ObjectActuator::sPyGetDLoc, METH_VARARGS},
+ {"getDLoc", (PyCFunction) KX_ObjectActuator::sPyGetDLoc, METH_NOARGS},
{"setDLoc", (PyCFunction) KX_ObjectActuator::sPySetDLoc, METH_VARARGS},
- {"getDRot", (PyCFunction) KX_ObjectActuator::sPyGetDRot, METH_VARARGS},
+ {"getDRot", (PyCFunction) KX_ObjectActuator::sPyGetDRot, METH_NOARGS},
{"setDRot", (PyCFunction) KX_ObjectActuator::sPySetDRot, METH_VARARGS},
- {"getLinearVelocity", (PyCFunction) KX_ObjectActuator::sPyGetLinearVelocity, METH_VARARGS},
+ {"getLinearVelocity", (PyCFunction) KX_ObjectActuator::sPyGetLinearVelocity, METH_NOARGS},
{"setLinearVelocity", (PyCFunction) KX_ObjectActuator::sPySetLinearVelocity, METH_VARARGS},
- {"getAngularVelocity", (PyCFunction) KX_ObjectActuator::sPyGetAngularVelocity, METH_VARARGS},
+ {"getAngularVelocity", (PyCFunction) KX_ObjectActuator::sPyGetAngularVelocity, METH_NOARGS},
{"setAngularVelocity", (PyCFunction) KX_ObjectActuator::sPySetAngularVelocity, METH_VARARGS},
+ {"setDamping", (PyCFunction) KX_ObjectActuator::sPySetDamping, METH_VARARGS},
+ {"getDamping", (PyCFunction) KX_ObjectActuator::sPyGetDamping, METH_NOARGS},
+ {"setForceLimitX", (PyCFunction) KX_ObjectActuator::sPySetForceLimitX, METH_VARARGS},
+ {"getForceLimitX", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitX, METH_NOARGS},
+ {"setForceLimitY", (PyCFunction) KX_ObjectActuator::sPySetForceLimitY, METH_VARARGS},
+ {"getForceLimitY", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitY, METH_NOARGS},
+ {"setForceLimitZ", (PyCFunction) KX_ObjectActuator::sPySetForceLimitZ, METH_VARARGS},
+ {"getForceLimitZ", (PyCFunction) KX_ObjectActuator::sPyGetForceLimitZ, METH_NOARGS},
+ {"setPID", (PyCFunction) KX_ObjectActuator::sPyGetPID, METH_NOARGS},
+ {"getPID", (PyCFunction) KX_ObjectActuator::sPySetPID, METH_VARARGS},
+
{NULL,NULL} //Sentinel
@@ -212,9 +340,7 @@ PyObject* KX_ObjectActuator::_getattr(const STR_String& attr) {
/* Removed! */
/* 2. getForce */
-PyObject* KX_ObjectActuator::PyGetForce(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_ObjectActuator::PyGetForce(PyObject* self)
{
PyObject *retVal = PyList_New(4);
@@ -238,13 +364,12 @@ PyObject* KX_ObjectActuator::PySetForce(PyObject* self,
}
m_force.setValue(vecArg);
m_bitLocalFlag.Force = PyArgToBool(bToggle);
+ UpdateFuzzyFlags();
Py_Return;
}
/* 4. getTorque */
-PyObject* KX_ObjectActuator::PyGetTorque(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_ObjectActuator::PyGetTorque(PyObject* self)
{
PyObject *retVal = PyList_New(4);
@@ -268,13 +393,12 @@ PyObject* KX_ObjectActuator::PySetTorque(PyObject* self,
}
m_torque.setValue(vecArg);
m_bitLocalFlag.Torque = PyArgToBool(bToggle);
+ UpdateFuzzyFlags();
Py_Return;
}
/* 6. getDLoc */
-PyObject* KX_ObjectActuator::PyGetDLoc(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_ObjectActuator::PyGetDLoc(PyObject* self)
{
PyObject *retVal = PyList_New(4);
@@ -298,13 +422,12 @@ PyObject* KX_ObjectActuator::PySetDLoc(PyObject* self,
}
m_dloc.setValue(vecArg);
m_bitLocalFlag.DLoc = PyArgToBool(bToggle);
+ UpdateFuzzyFlags();
Py_Return;
}
/* 8. getDRot */
-PyObject* KX_ObjectActuator::PyGetDRot(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_ObjectActuator::PyGetDRot(PyObject* self)
{
PyObject *retVal = PyList_New(4);
@@ -328,13 +451,12 @@ PyObject* KX_ObjectActuator::PySetDRot(PyObject* self,
}
m_drot.setValue(vecArg);
m_bitLocalFlag.DRot = PyArgToBool(bToggle);
+ UpdateFuzzyFlags();
Py_Return;
}
/* 10. getLinearVelocity */
-PyObject* KX_ObjectActuator::PyGetLinearVelocity(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* KX_ObjectActuator::PyGetLinearVelocity(PyObject* self) {
PyObject *retVal = PyList_New(4);
PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0]));
@@ -357,14 +479,13 @@ PyObject* KX_ObjectActuator::PySetLinearVelocity(PyObject* self,
}
m_linear_velocity.setValue(vecArg);
m_bitLocalFlag.LinearVelocity = PyArgToBool(bToggle);
+ UpdateFuzzyFlags();
Py_Return;
}
/* 12. getAngularVelocity */
-PyObject* KX_ObjectActuator::PyGetAngularVelocity(PyObject* self,
- PyObject* args,
- PyObject* kwds) {
+PyObject* KX_ObjectActuator::PyGetAngularVelocity(PyObject* self) {
PyObject *retVal = PyList_New(4);
PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_angular_velocity[0]));
@@ -386,10 +507,133 @@ PyObject* KX_ObjectActuator::PySetAngularVelocity(PyObject* self,
}
m_angular_velocity.setValue(vecArg);
m_bitLocalFlag.AngularVelocity = PyArgToBool(bToggle);
+ UpdateFuzzyFlags();
+ Py_Return;
+}
+
+/* 13. setDamping */
+PyObject* KX_ObjectActuator::PySetDamping(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ int damping = 0;
+ if (!PyArg_ParseTuple(args, "i", &damping) || damping < 0 || damping > 1000) {
+ return NULL;
+ }
+ m_damping = damping;
+ Py_Return;
+}
+
+/* 13. getVelocityDamping */
+PyObject* KX_ObjectActuator::PyGetDamping(PyObject* self) {
+ return Py_BuildValue("i",m_damping);
+}
+/* 6. getForceLimitX */
+PyObject* KX_ObjectActuator::PyGetForceLimitX(PyObject* self)
+{
+ PyObject *retVal = PyList_New(3);
+
+ PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[0]));
+ PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[0]));
+ PyList_SetItem(retVal, 2, BoolToPyArg(m_bitLocalFlag.Torque));
+
+ return retVal;
+}
+/* 7. setForceLimitX */
+PyObject* KX_ObjectActuator::PySetForceLimitX(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ float vecArg[2];
+ int bToggle = 0;
+ if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) {
+ return NULL;
+ }
+ m_drot[0] = vecArg[0];
+ m_dloc[0] = vecArg[1];
+ m_bitLocalFlag.Torque = PyArgToBool(bToggle);
+ Py_Return;
+}
+
+/* 6. getForceLimitY */
+PyObject* KX_ObjectActuator::PyGetForceLimitY(PyObject* self)
+{
+ PyObject *retVal = PyList_New(3);
+
+ PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[1]));
+ PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[1]));
+ PyList_SetItem(retVal, 2, BoolToPyArg(m_bitLocalFlag.DLoc));
+
+ return retVal;
+}
+/* 7. setForceLimitY */
+PyObject* KX_ObjectActuator::PySetForceLimitY(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ float vecArg[2];
+ int bToggle = 0;
+ if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) {
+ return NULL;
+ }
+ m_drot[1] = vecArg[0];
+ m_dloc[1] = vecArg[1];
+ m_bitLocalFlag.DLoc = PyArgToBool(bToggle);
+ Py_Return;
+}
+
+/* 6. getForceLimitZ */
+PyObject* KX_ObjectActuator::PyGetForceLimitZ(PyObject* self)
+{
+ PyObject *retVal = PyList_New(3);
+
+ PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_drot[2]));
+ PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_dloc[2]));
+ PyList_SetItem(retVal, 2, BoolToPyArg(m_bitLocalFlag.DRot));
+
+ return retVal;
+}
+/* 7. setForceLimitZ */
+PyObject* KX_ObjectActuator::PySetForceLimitZ(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ float vecArg[2];
+ int bToggle = 0;
+ if(!PyArg_ParseTuple(args, "ffi", &vecArg[0], &vecArg[1], &bToggle)) {
+ return NULL;
+ }
+ m_drot[2] = vecArg[0];
+ m_dloc[2] = vecArg[1];
+ m_bitLocalFlag.DRot = PyArgToBool(bToggle);
+ Py_Return;
+}
+
+/* 4. getPID */
+PyObject* KX_ObjectActuator::PyGetPID(PyObject* self)
+{
+ PyObject *retVal = PyList_New(3);
+
+ PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_torque[0]));
+ PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_torque[1]));
+ PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_torque[2]));
+
+ return retVal;
+}
+/* 5. setPID */
+PyObject* KX_ObjectActuator::PySetPID(PyObject* self,
+ PyObject* args,
+ PyObject* kwds)
+{
+ float vecArg[3];
+ if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2])) {
+ return NULL;
+ }
+ m_torque.setValue(vecArg);
Py_Return;
}
+
/* eof */
diff --git a/source/gameengine/Ketsji/KX_ObjectActuator.h b/source/gameengine/Ketsji/KX_ObjectActuator.h
index edbae154b8b..aa686f41233 100644
--- a/source/gameengine/Ketsji/KX_ObjectActuator.h
+++ b/source/gameengine/Ketsji/KX_ObjectActuator.h
@@ -46,7 +46,12 @@ struct KX_LocalFlags {
DLoc(false),
LinearVelocity(false),
AngularVelocity(false),
- AddOrSetLinV(false)
+ AddOrSetLinV(false),
+ ZeroForce(false),
+ ZeroDRot(false),
+ ZeroDLoc(false),
+ ZeroLinearVelocity(false),
+ ZeroAngularVelocity(false)
{
}
@@ -57,6 +62,13 @@ struct KX_LocalFlags {
unsigned short LinearVelocity : 1;
unsigned short AngularVelocity : 1;
unsigned short AddOrSetLinV : 1;
+ unsigned short ServoControl : 1;
+ unsigned short ZeroForce : 1;
+ unsigned short ZeroTorque : 1;
+ unsigned short ZeroDRot : 1;
+ unsigned short ZeroDLoc : 1;
+ unsigned short ZeroLinearVelocity : 1;
+ unsigned short ZeroAngularVelocity : 1;
};
class KX_ObjectActuator : public SCA_IActuator
@@ -69,6 +81,15 @@ class KX_ObjectActuator : public SCA_IActuator
MT_Vector3 m_drot;
MT_Vector3 m_linear_velocity;
MT_Vector3 m_angular_velocity;
+ MT_Scalar m_linear_length2;
+ MT_Scalar m_angular_length2;
+ // used in damping
+ MT_Scalar m_current_linear_factor;
+ MT_Scalar m_current_angular_factor;
+ short m_damping;
+ // used in servo control
+ MT_Vector3 m_previous_error;
+ MT_Vector3 m_error_accumulator;
KX_LocalFlags m_bitLocalFlag;
// A hack bool -- oh no sorry everyone
@@ -77,6 +98,8 @@ class KX_ObjectActuator : public SCA_IActuator
// setting linear velocity.
bool m_active_combined_velocity;
+ bool m_linear_damping_active;
+ bool m_angular_damping_active;
public:
enum KX_OBJECT_ACT_VEC_TYPE {
@@ -103,6 +126,7 @@ public:
const MT_Vector3& drot,
const MT_Vector3& linV,
const MT_Vector3& angV,
+ const short damping,
const KX_LocalFlags& flag,
PyTypeObject* T=&Type
);
@@ -110,6 +134,17 @@ public:
CValue* GetReplica();
void SetForceLoc(const double force[3]) { /*m_force=force;*/ }
+ void UpdateFuzzyFlags()
+ {
+ m_bitLocalFlag.ZeroForce = MT_fuzzyZero(m_force);
+ m_bitLocalFlag.ZeroTorque = MT_fuzzyZero(m_torque);
+ m_bitLocalFlag.ZeroDLoc = MT_fuzzyZero(m_dloc);
+ m_bitLocalFlag.ZeroDRot = MT_fuzzyZero(m_drot);
+ m_bitLocalFlag.ZeroLinearVelocity = MT_fuzzyZero(m_linear_velocity);
+ m_linear_length2 = (m_bitLocalFlag.ZeroLinearVelocity) ? 0.0 : m_linear_velocity.length2();
+ m_bitLocalFlag.ZeroAngularVelocity = MT_fuzzyZero(m_angular_velocity);
+ m_angular_length2 = (m_bitLocalFlag.ZeroAngularVelocity) ? 0.0 : m_angular_velocity.length2();
+ }
virtual bool Update();
@@ -120,18 +155,28 @@ public:
virtual PyObject* _getattr(const STR_String& attr);
- KX_PYMETHOD(KX_ObjectActuator,GetForce);
+ KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForce);
KX_PYMETHOD(KX_ObjectActuator,SetForce);
- KX_PYMETHOD(KX_ObjectActuator,GetTorque);
+ KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetTorque);
KX_PYMETHOD(KX_ObjectActuator,SetTorque);
- KX_PYMETHOD(KX_ObjectActuator,GetDLoc);
+ KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetDLoc);
KX_PYMETHOD(KX_ObjectActuator,SetDLoc);
- KX_PYMETHOD(KX_ObjectActuator,GetDRot);
+ KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetDRot);
KX_PYMETHOD(KX_ObjectActuator,SetDRot);
- KX_PYMETHOD(KX_ObjectActuator,GetLinearVelocity);
+ KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetLinearVelocity);
KX_PYMETHOD(KX_ObjectActuator,SetLinearVelocity);
- KX_PYMETHOD(KX_ObjectActuator,GetAngularVelocity);
+ KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetAngularVelocity);
KX_PYMETHOD(KX_ObjectActuator,SetAngularVelocity);
+ KX_PYMETHOD(KX_ObjectActuator,SetDamping);
+ KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetDamping);
+ KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForceLimitX);
+ KX_PYMETHOD(KX_ObjectActuator,SetForceLimitX);
+ KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForceLimitY);
+ KX_PYMETHOD(KX_ObjectActuator,SetForceLimitY);
+ KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetForceLimitZ);
+ KX_PYMETHOD(KX_ObjectActuator,SetForceLimitZ);
+ KX_PYMETHOD_NOARGS(KX_ObjectActuator,GetPID);
+ KX_PYMETHOD(KX_ObjectActuator,SetPID);
};
#endif //__KX_OBJECTACTUATOR
diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp
index 4e45ce484e3..6a701a5f25b 100644
--- a/source/gameengine/Ketsji/KX_OdePhysicsController.cpp
+++ b/source/gameengine/Ketsji/KX_OdePhysicsController.cpp
@@ -133,8 +133,9 @@ void KX_OdePhysicsController::SetLinearVelocity(const MT_Vector3& lin_vel,bool l
ODEPhysicsController::SetLinearVelocity(lin_vel[0],lin_vel[1],lin_vel[2],local);
}
-void KX_OdePhysicsController::setOrientation(const MT_Quaternion& orn)
+void KX_OdePhysicsController::setOrientation(const MT_Matrix3x3& rot)
{
+ MT_Quaternion orn = rot.getRotation();
ODEPhysicsController::setOrientation(orn[0],orn[1],orn[2],orn[3]);
}
@@ -168,6 +169,11 @@ MT_Scalar KX_OdePhysicsController::GetMass()
return ODEPhysicsController::getMass();
}
+MT_Scalar KX_OdePhysicsController::GetRadius()
+{
+ return MT_Scalar(0.f);
+}
+
MT_Vector3 KX_OdePhysicsController::getReactionForce()
{
return MT_Vector3(0,0,0);
@@ -177,7 +183,7 @@ void KX_OdePhysicsController::setRigidBody(bool rigid)
}
-void KX_OdePhysicsController::SuspendDynamics()
+void KX_OdePhysicsController::SuspendDynamics(bool)
{
ODEPhysicsController::SuspendDynamics();
}
diff --git a/source/gameengine/Ketsji/KX_OdePhysicsController.h b/source/gameengine/Ketsji/KX_OdePhysicsController.h
index 07a0bee9775..53050f6ce3e 100644
--- a/source/gameengine/Ketsji/KX_OdePhysicsController.h
+++ b/source/gameengine/Ketsji/KX_OdePhysicsController.h
@@ -67,16 +67,16 @@ public:
virtual void SetLinearVelocity(const MT_Vector3& lin_vel,bool local);
virtual void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
virtual void getOrientation(MT_Quaternion& orn);
- virtual void setOrientation(const MT_Quaternion& orn);
+ virtual void setOrientation(const MT_Matrix3x3& orn);
virtual void setPosition(const MT_Point3& pos);
virtual void setScaling(const MT_Vector3& scaling);
virtual MT_Scalar GetMass();
virtual MT_Vector3 getReactionForce();
virtual void setRigidBody(bool rigid);
- virtual void SuspendDynamics();
+ virtual void SuspendDynamics(bool);
virtual void RestoreDynamics();
-
+ virtual MT_Scalar GetRadius();
virtual SG_Controller* GetReplica(class SG_Node* destnode);
diff --git a/source/gameengine/Ketsji/KX_ParentActuator.cpp b/source/gameengine/Ketsji/KX_ParentActuator.cpp
new file mode 100644
index 00000000000..89549ca6b57
--- /dev/null
+++ b/source/gameengine/Ketsji/KX_ParentActuator.cpp
@@ -0,0 +1,221 @@
+/**
+ * Set or remove an objects parent
+ *
+ * $Id: SCA_ParentActuator.cpp 13932 2008-03-01 19:05:41Z ben2610 $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include "KX_ParentActuator.h"
+#include "KX_GameObject.h"
+#include "KX_PythonInit.h"
+
+#include "PyObjectPlus.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* ------------------------------------------------------------------------- */
+/* Native functions */
+/* ------------------------------------------------------------------------- */
+
+KX_ParentActuator::KX_ParentActuator(SCA_IObject *gameobj,
+ int mode,
+ SCA_IObject *ob,
+ PyTypeObject* T)
+ : SCA_IActuator(gameobj, T),
+ m_mode(mode),
+ m_ob(ob)
+{
+ if (m_ob)
+ m_ob->RegisterActuator(this);
+}
+
+
+
+KX_ParentActuator::~KX_ParentActuator()
+{
+ if (m_ob)
+ m_ob->UnregisterActuator(this);
+}
+
+
+
+CValue* KX_ParentActuator::GetReplica()
+{
+ KX_ParentActuator* replica = new KX_ParentActuator(*this);
+ // replication just copy the m_base pointer => common random generator
+ replica->ProcessReplica();
+ CValue::AddDataToReplica(replica);
+
+ return replica;
+}
+
+void KX_ParentActuator::ProcessReplica()
+{
+ if (m_ob)
+ m_ob->RegisterActuator(this);
+ SCA_IActuator::ProcessReplica();
+}
+
+
+bool KX_ParentActuator::UnlinkObject(SCA_IObject* clientobj)
+{
+ if (clientobj == m_ob)
+ {
+ // this object is being deleted, we cannot continue to track it.
+ m_ob = NULL;
+ return true;
+ }
+ return false;
+}
+
+void KX_ParentActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
+{
+ void **h_obj = (*obj_map)[m_ob];
+ if (h_obj) {
+ if (m_ob)
+ m_ob->UnregisterActuator(this);
+ m_ob = (SCA_IObject*)(*h_obj);
+ m_ob->RegisterActuator(this);
+ }
+}
+
+
+
+bool KX_ParentActuator::Update()
+{
+ bool bNegativeEvent = IsNegativeEvent();
+ RemoveAllEvents();
+
+ if (bNegativeEvent)
+ return false; // do nothing on negative events
+
+ KX_GameObject *obj = (KX_GameObject*) GetParent();
+ KX_Scene *scene = KX_GetActiveScene();
+ switch (m_mode) {
+ case KX_PARENT_SET:
+ if (m_ob)
+ obj->SetParent(scene, (KX_GameObject*)m_ob);
+ break;
+ case KX_PARENT_REMOVE:
+ obj->RemoveParent(scene);
+ break;
+ };
+
+ return false;
+}
+
+/* ------------------------------------------------------------------------- */
+/* Python functions */
+/* ------------------------------------------------------------------------- */
+
+/* Integration hooks ------------------------------------------------------- */
+PyTypeObject KX_ParentActuator::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "KX_ParentActuator",
+ sizeof(KX_ParentActuator),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject KX_ParentActuator::Parents[] = {
+ &KX_ParentActuator::Type,
+ &SCA_IActuator::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+PyMethodDef KX_ParentActuator::Methods[] = {
+ {"setObject", (PyCFunction) KX_ParentActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc},
+ {"getObject", (PyCFunction) KX_ParentActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc},
+ {NULL,NULL} //Sentinel
+};
+
+PyObject* KX_ParentActuator::_getattr(const STR_String& attr) {
+ _getattr_up(SCA_IActuator);
+}
+
+/* 1. setObject */
+const char KX_ParentActuator::SetObject_doc[] =
+"setObject(object)\n"
+"\t- object: KX_GameObject, string or None\n"
+"\tSet the object to set as parent.\n";
+PyObject* KX_ParentActuator::PySetObject(PyObject* self, PyObject* value) {
+ KX_GameObject *gameobj;
+
+ if (!ConvertPythonToGameObject(value, &gameobj, true))
+ return NULL; // ConvertPythonToGameObject sets the error
+
+ if (m_ob != NULL)
+ m_ob->UnregisterActuator(this);
+
+ m_ob = (SCA_IObject*)gameobj;
+ if (m_ob)
+ m_ob->RegisterActuator(this);
+
+ Py_RETURN_NONE;
+}
+
+/* 2. getObject */
+
+/* get obj ---------------------------------------------------------- */
+const char KX_ParentActuator::GetObject_doc[] =
+"getObject(name_only = 1)\n"
+"name_only - optional arg, when true will return the KX_GameObject rather then its name\n"
+"\tReturns the object that is set to.\n";
+PyObject* KX_ParentActuator::PyGetObject(PyObject* self, PyObject* args)
+{
+ int ret_name_only = 1;
+ if (!PyArg_ParseTuple(args, "|i", &ret_name_only))
+ return NULL;
+
+ if (!m_ob)
+ Py_RETURN_NONE;
+
+ if (ret_name_only)
+ return PyString_FromString(m_ob->GetName());
+ else
+ return m_ob->AddRef();
+}
+
+/* eof */
diff --git a/source/gameengine/Ketsji/KX_ParentActuator.h b/source/gameengine/Ketsji/KX_ParentActuator.h
new file mode 100644
index 00000000000..e2b30ba2d0f
--- /dev/null
+++ b/source/gameengine/Ketsji/KX_ParentActuator.h
@@ -0,0 +1,89 @@
+/**
+ * Set or remove an objects parent
+ *
+ *
+ * $Id: KX_ParentActuator.h 3271 2004-10-16 11:41:50Z kester $
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __KX_PARENTACTUATOR
+#define __KX_PARENTACTUATOR
+
+#include "SCA_IActuator.h"
+#include "SCA_LogicManager.h"
+
+class KX_ParentActuator : public SCA_IActuator
+{
+ Py_Header;
+
+ /** Mode */
+ int m_mode;
+
+ /** Object to set as parent */
+ SCA_IObject *m_ob;
+
+
+
+ public:
+ enum KX_PARENTACT_MODE
+ {
+ KX_PARENT_NODEF = 0,
+ KX_PARENT_SET,
+ KX_PARENT_REMOVE,
+
+ };
+
+ KX_ParentActuator(class SCA_IObject* gameobj,
+ int mode,
+ SCA_IObject *ob,
+ PyTypeObject* T=&Type);
+ virtual ~KX_ParentActuator();
+ virtual bool Update();
+
+ virtual CValue* GetReplica();
+ virtual void ProcessReplica();
+ virtual void Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map);
+ virtual bool UnlinkObject(SCA_IObject* clientobj);
+
+ /* --------------------------------------------------------------------- */
+ /* Python interface ---------------------------------------------------- */
+ /* --------------------------------------------------------------------- */
+
+ virtual PyObject* _getattr(const STR_String& attr);
+
+ /* 1. setObject */
+ KX_PYMETHOD_DOC_O(KX_ParentActuator,SetObject);
+ /* 2. getObject */
+ KX_PYMETHOD_DOC_VARARGS(KX_ParentActuator,GetObject);
+
+}; /* end of class KX_ParentActuator : public SCA_PropertyActuator */
+
+#endif
+
diff --git a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp
index 27cfaefc076..da4f05ced7c 100644
--- a/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_PhysicsObjectWrapper.cpp
@@ -27,6 +27,8 @@
* ***** END GPL LICENSE BLOCK *****
*/
#include <Python.h>
+#include "PyObjectPlus.h"
+
#include "KX_PhysicsObjectWrapper.h"
#include "PHY_IPhysicsEnvironment.h"
#include "PHY_IPhysicsController.h"
@@ -58,7 +60,10 @@ PyObject* KX_PhysicsObjectWrapper::PySetPosition(PyObject* self,
{
m_ctrl->setPosition(x,y,z);
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
@@ -72,7 +77,10 @@ PyObject* KX_PhysicsObjectWrapper::PySetLinearVelocity(PyObject* self,
{
m_ctrl->SetLinearVelocity(x,y,z,local != 0);
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
PyObject* KX_PhysicsObjectWrapper::PySetAngularVelocity(PyObject* self,
@@ -85,7 +93,10 @@ PyObject* KX_PhysicsObjectWrapper::PySetAngularVelocity(PyObject* self,
{
m_ctrl->SetAngularVelocity(x,y,z,local != 0);
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
PyObject* KX_PhysicsObjectWrapper::PySetActive(PyObject* self,
@@ -97,7 +108,10 @@ PyObject* KX_PhysicsObjectWrapper::PySetActive(PyObject* self,
{
m_ctrl->SetActive(active!=0);
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.cpp b/source/gameengine/Ketsji/KX_PolyProxy.cpp
new file mode 100644
index 00000000000..c6f6bc2db01
--- /dev/null
+++ b/source/gameengine/Ketsji/KX_PolyProxy.cpp
@@ -0,0 +1,265 @@
+/**
+ * $Id$
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "KX_PolyProxy.h"
+#include "KX_MeshProxy.h"
+#include "RAS_MeshObject.h"
+#include "KX_BlenderMaterial.h"
+#include "KX_PolygonMaterial.h"
+
+#include "KX_PyMath.h"
+
+PyTypeObject KX_PolyProxy::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "KX_PolyProxy",
+ sizeof(KX_PolyProxy),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject KX_PolyProxy::Parents[] = {
+ &KX_PolyProxy::Type,
+ &SCA_IObject::Type,
+ &CValue::Type,
+ NULL
+};
+
+PyMethodDef KX_PolyProxy::Methods[] = {
+ KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMaterialIndex),
+ KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getNumVertex),
+ KX_PYMETHODTABLE_NOARG(KX_PolyProxy,isVisible),
+ KX_PYMETHODTABLE_NOARG(KX_PolyProxy,isCollider),
+ KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMaterialName),
+ KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getTextureName),
+ KX_PYMETHODTABLE(KX_PolyProxy,getVertexIndex),
+ KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMesh),
+ KX_PYMETHODTABLE_NOARG(KX_PolyProxy,getMaterial),
+ {NULL,NULL} //Sentinel
+};
+
+PyObject*
+KX_PolyProxy::_getattr(const STR_String& attr)
+{
+ if (attr == "matname")
+ {
+ return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
+ }
+ if (attr == "texture")
+ {
+ return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
+ }
+ if (attr == "material")
+ {
+ RAS_IPolyMaterial *polymat = m_polygon->GetMaterial()->GetPolyMaterial();
+ if(polymat->GetFlag() & RAS_BLENDERMAT)
+ {
+ KX_BlenderMaterial* mat = static_cast<KX_BlenderMaterial*>(polymat);
+ Py_INCREF(mat);
+ return mat;
+ }
+ else
+ {
+ KX_PolygonMaterial* mat = static_cast<KX_PolygonMaterial*>(polymat);
+ Py_INCREF(mat);
+ return mat;
+ }
+ }
+ if (attr == "matid")
+ {
+ // we'll have to scan through the material bucket of the mes and compare with
+ // the one of the polygon
+ RAS_MaterialBucket* polyBucket = m_polygon->GetMaterial();
+ unsigned int matid;
+ for (matid=0; matid<m_mesh->NumMaterials(); matid++)
+ {
+ RAS_MeshMaterial* meshMat = m_mesh->GetMeshMaterial(matid);
+ if (meshMat->m_bucket == polyBucket)
+ // found it
+ break;
+ }
+ return PyInt_FromLong(matid);
+ }
+ if (attr == "v1")
+ {
+ return PyInt_FromLong(m_polygon->GetVertexOffset(0));
+ }
+ if (attr == "v2")
+ {
+ return PyInt_FromLong(m_polygon->GetVertexOffset(1));
+ }
+ if (attr == "v3")
+ {
+ return PyInt_FromLong(m_polygon->GetVertexOffset(2));
+ }
+ if (attr == "v4")
+ {
+ return PyInt_FromLong(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffset(3):0));
+ }
+ if (attr == "visible")
+ {
+ return PyInt_FromLong(m_polygon->IsVisible());
+ }
+ if (attr == "collide")
+ {
+ return PyInt_FromLong(m_polygon->IsCollider());
+ }
+ _getattr_up(SCA_IObject);
+}
+
+KX_PolyProxy::KX_PolyProxy(const RAS_MeshObject*mesh, RAS_Polygon* polygon)
+: m_mesh((RAS_MeshObject*)mesh),
+ m_polygon(polygon)
+{
+}
+
+KX_PolyProxy::~KX_PolyProxy()
+{
+}
+
+
+// stuff for cvalue related things
+CValue* KX_PolyProxy::Calc(VALUE_OPERATOR, CValue *) { return NULL;}
+CValue* KX_PolyProxy::CalcFinal(VALUE_DATA_TYPE, VALUE_OPERATOR, CValue *) { return NULL;}
+STR_String sPolyName="polygone";
+const STR_String & KX_PolyProxy::GetText() {return sPolyName;};
+float KX_PolyProxy::GetNumber() { return -1;}
+STR_String KX_PolyProxy::GetName() { return sPolyName;}
+void KX_PolyProxy::SetName(STR_String) { };
+CValue* KX_PolyProxy::GetReplica() { return NULL;}
+void KX_PolyProxy::ReplicaSetName(STR_String) {};
+
+
+// stuff for python integration
+
+KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterialIndex,
+"getMaterialIndex() : return the material index of the polygon in the mesh\n")
+{
+ RAS_MaterialBucket* polyBucket = m_polygon->GetMaterial();
+ unsigned int matid;
+ for (matid=0; matid<m_mesh->NumMaterials(); matid++)
+ {
+ RAS_MeshMaterial* meshMat = m_mesh->GetMeshMaterial(matid);
+ if (meshMat->m_bucket == polyBucket)
+ // found it
+ break;
+ }
+ return PyInt_FromLong(matid);
+}
+
+KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getNumVertex,
+"getNumVertex() : returns the number of vertex of the polygon, 3 or 4\n")
+{
+ return PyInt_FromLong(m_polygon->VertexCount());
+}
+
+KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, isVisible,
+"isVisible() : returns whether the polygon is visible or not\n")
+{
+ return PyInt_FromLong(m_polygon->IsVisible());
+}
+
+KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, isCollider,
+"isCollider() : returns whether the polygon is receives collision or not\n")
+{
+ return PyInt_FromLong(m_polygon->IsCollider());
+}
+
+KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterialName,
+"getMaterialName() : returns the polygon material name, \"NoMaterial\" if no material\n")
+{
+ return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
+}
+
+KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getTextureName,
+"getTexturelName() : returns the polygon texture name, \"NULL\" if no texture\n")
+{
+ return PyString_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
+}
+
+KX_PYMETHODDEF_DOC(KX_PolyProxy, getVertexIndex,
+"getVertexIndex(vertex) : returns the mesh vertex index of a polygon vertex\n"
+"vertex: index of the vertex in the polygon: 0->3\n"
+"return value can be used to retrieve the vertex details through mesh proxy\n"
+"Note: getVertexIndex(3) on a triangle polygon returns 0\n")
+{
+ int index;
+ if (!PyArg_ParseTuple(args,"i",&index))
+ {
+ return NULL;
+ }
+ if (index < 0 || index > 3)
+ {
+ PyErr_SetString(PyExc_AttributeError, "Valid range for index is 0-3");
+ return NULL;
+ }
+ if (index < m_polygon->VertexCount())
+ {
+ return PyInt_FromLong(m_polygon->GetVertexOffset(index));
+ }
+ return PyInt_FromLong(0);
+}
+
+KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMesh,
+"getMesh() : returns a mesh proxy\n")
+{
+ KX_MeshProxy* meshproxy = new KX_MeshProxy((RAS_MeshObject*)m_mesh);
+ return meshproxy;
+}
+
+KX_PYMETHODDEF_DOC_NOARG(KX_PolyProxy, getMaterial,
+"getMaterial() : returns a material\n")
+{
+ RAS_IPolyMaterial *polymat = m_polygon->GetMaterial()->GetPolyMaterial();
+ if(polymat->GetFlag() & RAS_BLENDERMAT)
+ {
+ KX_BlenderMaterial* mat = static_cast<KX_BlenderMaterial*>(polymat);
+ Py_INCREF(mat);
+ return mat;
+ }
+ else
+ {
+ KX_PolygonMaterial* mat = static_cast<KX_PolygonMaterial*>(polymat);
+ Py_INCREF(mat);
+ return mat;
+ }
+}
diff --git a/source/gameengine/Ketsji/KX_PolyProxy.h b/source/gameengine/Ketsji/KX_PolyProxy.h
new file mode 100644
index 00000000000..506e2c2a656
--- /dev/null
+++ b/source/gameengine/Ketsji/KX_PolyProxy.h
@@ -0,0 +1,71 @@
+/**
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+#ifndef __KX_POLYROXY
+#define __KX_POLYPROXY
+
+#include "SCA_IObject.h"
+
+class KX_PolyProxy : public SCA_IObject
+{
+ Py_Header;
+protected:
+ class RAS_Polygon* m_polygon;
+ class RAS_MeshObject* m_mesh;
+public:
+ KX_PolyProxy(const class RAS_MeshObject*mesh, class RAS_Polygon* polygon);
+ virtual ~KX_PolyProxy();
+
+ // stuff for cvalue related things
+ CValue* Calc(VALUE_OPERATOR op, CValue *val) ;
+ CValue* CalcFinal(VALUE_DATA_TYPE dtype, VALUE_OPERATOR op, CValue *val);
+ const STR_String & GetText();
+ float GetNumber();
+ STR_String GetName();
+ void SetName(STR_String name); // Set the name of the value
+ void ReplicaSetName(STR_String name);
+ CValue* GetReplica();
+
+
+// stuff for python integration
+ virtual PyObject* _getattr(const STR_String& attr);
+
+ KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterialIndex)
+ KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getNumVertex)
+ KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,isVisible)
+ KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,isCollider)
+ KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterialName)
+ KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getTextureName)
+ KX_PYMETHOD_DOC(KX_PolyProxy,getVertexIndex)
+ KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMesh)
+ KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterial)
+
+};
+
+#endif //__KX_POLYPROXY
+
diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp
index 70333b33d2c..c9180bf3a80 100644
--- a/source/gameengine/Ketsji/KX_PolygonMaterial.cpp
+++ b/source/gameengine/Ketsji/KX_PolygonMaterial.cpp
@@ -35,10 +35,6 @@
#include "BKE_global.h"
#include "BKE_image.h"
-extern "C" {
-//XXX #include "BDR_drawmesh.h"
-}
-
#include "DNA_material_types.h"
#include "DNA_texture_types.h"
#include "DNA_image_types.h"
@@ -46,6 +42,8 @@ extern "C" {
#include "IMB_imbuf_types.h"
+#include "GPU_draw.h"
+
#include "MEM_guardedalloc.h"
#include "RAS_LightObject.h"
@@ -59,11 +57,10 @@ KX_PolygonMaterial::KX_PolygonMaterial(const STR_String &texname,
int tilexrep,
int tileyrep,
int mode,
- bool transparant,
+ int transp,
+ bool alpha,
bool zsort,
int lightlayer,
- bool bIsTriangle,
- void* clientobject,
struct MTFace* tface,
unsigned int* mcol,
PyTypeObject *T)
@@ -74,11 +71,10 @@ KX_PolygonMaterial::KX_PolygonMaterial(const STR_String &texname,
tilexrep,
tileyrep,
mode,
- transparant,
+ transp,
+ alpha,
zsort,
- lightlayer,
- bIsTriangle,
- clientobject),
+ lightlayer),
m_tface(tface),
m_mcol(mcol),
m_material(material),
@@ -138,38 +134,29 @@ void KX_PolygonMaterial::DefaultActivate(RAS_IRasterizer* rasty, TCachingInfo& c
if (GetCachingInfo() != cachingInfo)
{
if (!cachingInfo)
- {
- //XXX set_tpage(NULL);
- }
+ GPU_set_tpage(NULL);
+
cachingInfo = GetCachingInfo();
if ((m_drawingmode & 4)&& (rasty->GetDrawingMode() == RAS_IRasterizer::KX_TEXTURED))
{
- update_realtime_texture((struct MTFace*) m_tface, rasty->GetTime());
- //XXX set_tpage(m_tface);
- rasty->EnableTextures(true);
+ Image *ima = (Image*)m_tface->tpage;
+ GPU_update_image_time(ima, rasty->GetTime());
+ GPU_set_tpage(m_tface);
}
else
- {
- //XXX set_tpage(NULL);
- rasty->EnableTextures(false);
- }
+ GPU_set_tpage(NULL);
if(m_drawingmode & RAS_IRasterizer::KX_TWOSIDE)
- {
rasty->SetCullFace(false);
- }
else
- {
rasty->SetCullFace(true);
- }
- if (m_drawingmode & RAS_IRasterizer::KX_LINES) {
+ if ((m_drawingmode & RAS_IRasterizer::KX_LINES) ||
+ (rasty->GetDrawingMode() <= RAS_IRasterizer::KX_WIREFRAME))
rasty->SetLines(true);
- }
- else {
+ else
rasty->SetLines(false);
- }
}
rasty->SetSpecularity(m_specular[0],m_specular[1],m_specular[2],m_specularity);
@@ -245,13 +232,14 @@ PyObject* KX_PolygonMaterial::_getattr(const STR_String& attr)
if (attr == "drawingmode")
return PyInt_FromLong(m_drawingmode);
if (attr == "transparent")
- return PyInt_FromLong(m_transparant);
+ return PyInt_FromLong(m_alpha);
if (attr == "zsort")
return PyInt_FromLong(m_zsort);
if (attr == "lightlayer")
return PyInt_FromLong(m_lightlayer);
if (attr == "triangle")
- return PyInt_FromLong(m_bIsTriangle);
+ // deprecated, triangle/quads shouldn't have been a material property
+ return 0;
if (attr == "diffuse")
return PyObjectFrom(m_diffuse);
@@ -312,7 +300,7 @@ int KX_PolygonMaterial::_setattr(const STR_String &attr, PyObject *pyvalue)
if (attr == "transparent")
{
- m_transparant = value;
+ m_alpha = value;
return 0;
}
@@ -331,7 +319,7 @@ int KX_PolygonMaterial::_setattr(const STR_String &attr, PyObject *pyvalue)
// This probably won't work...
if (attr == "triangle")
{
- m_bIsTriangle = value;
+ // deprecated, triangle/quads shouldn't have been a material property
return 0;
}
}
@@ -384,7 +372,9 @@ KX_PYMETHODDEF_DOC(KX_PolygonMaterial, updateTexture, "updateTexture(tface, rast
{
MTFace *tface = (MTFace*) PyCObject_AsVoidPtr(pytface);
RAS_IRasterizer *rasty = (RAS_IRasterizer*) PyCObject_AsVoidPtr(pyrasty);
- update_realtime_texture(tface, rasty->GetTime());
+ Image *ima = (Image*)tface->tpage;
+ GPU_update_image_time(ima, rasty->GetTime());
+
Py_Return;
}
@@ -397,7 +387,7 @@ KX_PYMETHODDEF_DOC(KX_PolygonMaterial, setTexture, "setTexture(tface)")
if (PyArg_ParseTuple(args, "O!", &PyCObject_Type, &pytface))
{
MTFace *tface = (MTFace*) PyCObject_AsVoidPtr(pytface);
- //XXX set_tpage(tface);
+ GPU_set_tpage(tface);
Py_Return;
}
diff --git a/source/gameengine/Ketsji/KX_PolygonMaterial.h b/source/gameengine/Ketsji/KX_PolygonMaterial.h
index 19015494e06..fe116f757db 100644
--- a/source/gameengine/Ketsji/KX_PolygonMaterial.h
+++ b/source/gameengine/Ketsji/KX_PolygonMaterial.h
@@ -64,11 +64,10 @@ public:
int tilexrep,
int tileyrep,
int mode,
- bool transparant,
+ int transp,
+ bool alpha,
bool zsort,
int lightlayer,
- bool bIsTriangle,
- void* clientobject,
struct MTFace* tface,
unsigned int* mcol,
PyTypeObject *T = &Type);
diff --git a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
index 172882ff18d..fb37eded450 100644
--- a/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
+++ b/source/gameengine/Ketsji/KX_PyConstraintBinding.cpp
@@ -34,6 +34,8 @@
#include "PHY_IPhysicsController.h"
#include "PHY_IVehicle.h"
+#include "PyObjectPlus.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -82,13 +84,16 @@ static PyObject* gPySetGravity(PyObject* self,
PyObject* kwds)
{
float x,y,z;
- int len = PyTuple_Size(args);
- if ((len == 3) && PyArg_ParseTuple(args,"fff",&x,&y,&z))
+ if (PyArg_ParseTuple(args,"fff",&x,&y,&z))
{
if (PHY_GetActiveEnvironment())
PHY_GetActiveEnvironment()->setGravity(x,y,z);
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
}
static PyObject* gPySetDebugMode(PyObject* self,
@@ -105,7 +110,11 @@ static PyObject* gPySetDebugMode(PyObject* self,
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
}
@@ -122,7 +131,10 @@ static PyObject* gPySetNumTimeSubSteps(PyObject* self,
PHY_GetActiveEnvironment()->setNumTimeSubSteps(substep);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
@@ -138,7 +150,10 @@ static PyObject* gPySetNumIterations(PyObject* self,
PHY_GetActiveEnvironment()->setNumIterations(iter);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
@@ -155,7 +170,10 @@ static PyObject* gPySetDeactivationTime(PyObject* self,
PHY_GetActiveEnvironment()->setDeactivationTime(deactive_time);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
@@ -171,7 +189,10 @@ static PyObject* gPySetDeactivationLinearTreshold(PyObject* self,
PHY_GetActiveEnvironment()->setDeactivationLinearTreshold( linearDeactivationTreshold);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
@@ -187,7 +208,10 @@ static PyObject* gPySetDeactivationAngularTreshold(PyObject* self,
PHY_GetActiveEnvironment()->setDeactivationAngularTreshold( angularDeactivationTreshold);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
static PyObject* gPySetContactBreakingTreshold(PyObject* self,
@@ -202,7 +226,10 @@ static PyObject* gPySetContactBreakingTreshold(PyObject* self,
PHY_GetActiveEnvironment()->setContactBreakingTreshold( contactBreakingTreshold);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
@@ -218,7 +245,10 @@ static PyObject* gPySetCcdMode(PyObject* self,
PHY_GetActiveEnvironment()->setCcdMode( ccdMode);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
static PyObject* gPySetSorConstant(PyObject* self,
@@ -233,7 +263,10 @@ static PyObject* gPySetSorConstant(PyObject* self,
PHY_GetActiveEnvironment()->setSolverSorConstant( sor);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
static PyObject* gPySetSolverTau(PyObject* self,
@@ -248,7 +281,10 @@ static PyObject* gPySetSolverTau(PyObject* self,
PHY_GetActiveEnvironment()->setSolverTau( tau);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
@@ -264,7 +300,10 @@ static PyObject* gPySetSolverDamping(PyObject* self,
PHY_GetActiveEnvironment()->setSolverDamping( damping);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
static PyObject* gPySetLinearAirDamping(PyObject* self,
@@ -279,7 +318,10 @@ static PyObject* gPySetLinearAirDamping(PyObject* self,
PHY_GetActiveEnvironment()->setLinearAirDamping( damping);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
@@ -295,7 +337,10 @@ static PyObject* gPySetUseEpa(PyObject* self,
PHY_GetActiveEnvironment()->setUseEpa(epa);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
static PyObject* gPySetSolverType(PyObject* self,
PyObject* args,
@@ -309,7 +354,10 @@ static PyObject* gPySetSolverType(PyObject* self,
PHY_GetActiveEnvironment()->setSolverType(solverType);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
@@ -338,8 +386,11 @@ static PyObject* gPyGetVehicleConstraint(PyObject* self,
}
}
+ else {
+ return NULL;
+ }
- Py_INCREF(Py_None); return Py_None;
+ Py_RETURN_NONE;
}
@@ -384,7 +435,7 @@ static PyObject* gPyCreateConstraint(PyObject* self,
PHY_IPhysicsController* physctrl2 = (PHY_IPhysicsController*) physicsid2;
if (physctrl) //TODO:check for existance of this pointer!
{
- int constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ);
+ int constraintid = PHY_GetActiveEnvironment()->createConstraint(physctrl,physctrl2,(enum PHY_ConstraintType)constrainttype,pivotX,pivotY,pivotZ,axisX,axisY,axisZ,0);
KX_ConstraintWrapper* wrap = new KX_ConstraintWrapper((enum PHY_ConstraintType)constrainttype,constraintid,PHY_GetActiveEnvironment());
@@ -395,8 +446,11 @@ static PyObject* gPyCreateConstraint(PyObject* self,
}
}
+ else {
+ return NULL;
+ }
- Py_INCREF(Py_None); return Py_None;
+ Py_RETURN_NONE;
}
@@ -421,6 +475,9 @@ static PyObject* gPyGetAppliedImpulse(PyObject* self,
appliedImpulse = PHY_GetActiveEnvironment()->getAppliedImpulse(constraintid);
}
}
+ else {
+ return NULL;
+ }
return PyFloat_FromDouble(appliedImpulse);
}
@@ -443,60 +500,64 @@ static PyObject* gPyRemoveConstraint(PyObject* self,
PHY_GetActiveEnvironment()->removeConstraint(constraintid);
}
}
- Py_INCREF(Py_None); return Py_None;
+ else {
+ return NULL;
+ }
+
+ Py_RETURN_NONE;
}
static struct PyMethodDef physicsconstraints_methods[] = {
{"setGravity",(PyCFunction) gPySetGravity,
- METH_VARARGS, gPySetGravity__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetGravity__doc__},
{"setDebugMode",(PyCFunction) gPySetDebugMode,
- METH_VARARGS, gPySetDebugMode__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetDebugMode__doc__},
/// settings that influence quality of the rigidbody dynamics
{"setNumIterations",(PyCFunction) gPySetNumIterations,
- METH_VARARGS, gPySetNumIterations__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetNumIterations__doc__},
{"setNumTimeSubSteps",(PyCFunction) gPySetNumTimeSubSteps,
- METH_VARARGS, gPySetNumTimeSubSteps__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetNumTimeSubSteps__doc__},
{"setDeactivationTime",(PyCFunction) gPySetDeactivationTime,
- METH_VARARGS, gPySetDeactivationTime__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetDeactivationTime__doc__},
{"setDeactivationLinearTreshold",(PyCFunction) gPySetDeactivationLinearTreshold,
- METH_VARARGS, gPySetDeactivationLinearTreshold__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetDeactivationLinearTreshold__doc__},
{"setDeactivationAngularTreshold",(PyCFunction) gPySetDeactivationAngularTreshold,
- METH_VARARGS, gPySetDeactivationAngularTreshold__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetDeactivationAngularTreshold__doc__},
{"setContactBreakingTreshold",(PyCFunction) gPySetContactBreakingTreshold,
- METH_VARARGS, gPySetContactBreakingTreshold__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetContactBreakingTreshold__doc__},
{"setCcdMode",(PyCFunction) gPySetCcdMode,
- METH_VARARGS, gPySetCcdMode__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetCcdMode__doc__},
{"setSorConstant",(PyCFunction) gPySetSorConstant,
- METH_VARARGS, gPySetSorConstant__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetSorConstant__doc__},
{"setSolverTau",(PyCFunction) gPySetSolverTau,
- METH_VARARGS, gPySetSolverTau__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetSolverTau__doc__},
{"setSolverDamping",(PyCFunction) gPySetSolverDamping,
- METH_VARARGS, gPySetSolverDamping__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetSolverDamping__doc__},
{"setLinearAirDamping",(PyCFunction) gPySetLinearAirDamping,
- METH_VARARGS, gPySetLinearAirDamping__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetLinearAirDamping__doc__},
{"setUseEpa",(PyCFunction) gPySetUseEpa,
- METH_VARARGS, gPySetUseEpa__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetUseEpa__doc__},
{"setSolverType",(PyCFunction) gPySetSolverType,
- METH_VARARGS, gPySetSolverType__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPySetSolverType__doc__},
{"createConstraint",(PyCFunction) gPyCreateConstraint,
- METH_VARARGS, gPyCreateConstraint__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPyCreateConstraint__doc__},
{"getVehicleConstraint",(PyCFunction) gPyGetVehicleConstraint,
- METH_VARARGS, gPyGetVehicleConstraint__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPyGetVehicleConstraint__doc__},
{"removeConstraint",(PyCFunction) gPyRemoveConstraint,
- METH_VARARGS, gPyRemoveConstraint__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPyRemoveConstraint__doc__},
{"getAppliedImpulse",(PyCFunction) gPyGetAppliedImpulse,
- METH_VARARGS, gPyGetAppliedImpulse__doc__},
+ METH_VARARGS, (PY_METHODCHAR)gPyGetAppliedImpulse__doc__},
//sentinel
diff --git a/source/gameengine/Ketsji/KX_PyMath.h b/source/gameengine/Ketsji/KX_PyMath.h
index e1715c9275f..4e383e9b3d4 100644
--- a/source/gameengine/Ketsji/KX_PyMath.h
+++ b/source/gameengine/Ketsji/KX_PyMath.h
@@ -84,7 +84,10 @@ bool PyMatTo(PyObject* pymat, T& mat)
}
} else
noerror = false;
-
+
+ if (noerror==false)
+ PyErr_SetString(PyExc_TypeError, "could not be converted to a matrix (sequence of sequences)");
+
return noerror;
}
@@ -97,9 +100,13 @@ bool PyVecTo(PyObject* pyval, T& vec)
if (PySequence_Check(pyval))
{
unsigned int numitems = PySequence_Size(pyval);
- if (numitems != Size(vec))
+ if (numitems != Size(vec)) {
+ char err[128];
+ sprintf(err, "error setting vector, %d args, should be %d", numitems, Size(vec));
+ PyErr_SetString(PyExc_AttributeError, err);
return false;
-
+ }
+
for (unsigned int x = 0; x < numitems; x++)
{
PyObject *item = PySequence_GetItem(pyval, x); /* new ref */
@@ -107,7 +114,17 @@ bool PyVecTo(PyObject* pyval, T& vec)
Py_DECREF(item);
}
+ if (PyErr_Occurred()) {
+ PyErr_SetString(PyExc_AttributeError, "one or more of the items in the sequence was not a float");
+ return false;
+ }
+
return true;
+ } else
+ {
+ char err[128];
+ sprintf(err, "not a sequence type, expected a sequence of numbers size %d", Size(vec));
+ PyErr_SetString(PyExc_AttributeError, err);
}
return false;
diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp
index 681548fcc06..7ac817488fe 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.cpp
+++ b/source/gameengine/Ketsji/KX_PythonInit.cpp
@@ -28,24 +28,14 @@
* Initialize Python thingies.
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "GL/glew.h"
-#ifdef WIN32
-#include <windows.h>
-#endif // WIN32
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#include <OpenGL/glu.h>
-#else
-#include <GL/gl.h>
-#if defined(__sun__) && !defined(__sparc__)
-#include <mesa/glu.h>
+// directory header for py function getBlendFileList
+#include <stdlib.h>
+#ifndef WIN32
+ #include <dirent.h>
#else
-#include <GL/glu.h>
-#endif
+ #include "BLI_winstuff.h"
#endif
#ifdef WIN32
@@ -67,17 +57,28 @@
#include "BL_ActionActuator.h"
#include "RAS_IRasterizer.h"
#include "RAS_ICanvas.h"
+#include "RAS_BucketManager.h"
#include "MT_Vector3.h"
#include "MT_Point3.h"
#include "ListValue.h"
#include "KX_Scene.h"
#include "SND_DeviceManager.h"
-#include "RAS_OpenGLRasterizer/RAS_GLExtensionManager.h"
#include "BL_Shader.h"
#include "KX_PyMath.h"
+#include "PyObjectPlus.h"
+
+//XXX
+#if 0
+extern "C" {
+ #include "Mathutils.h" // Blender.Mathutils module copied here so the blenderlayer can use.
+}
+#endif
+
+#include "marshal.h" /* python header for loading/saving dicts */
+
#include "PHY_IPhysicsEnvironment.h"
// FIXME: Enable for access to blender python modules. This is disabled because
// python has dependencies on a lot of other modules and is a pain to link.
@@ -86,13 +87,20 @@
//#include "BPY_extern.h"
#endif
+#include "BKE_utildefines.h"
+#include "BKE_global.h"
+#include "BLI_blenlib.h"
+#include "GPU_material.h"
+
static void setSandbox(TPythonSecurityLevel level);
// 'local' copy of canvas ptr, for window height/width python scripts
static RAS_ICanvas* gp_Canvas = NULL;
static KX_Scene* gp_KetsjiScene = NULL;
+static KX_KetsjiEngine* gp_KetsjiEngine = NULL;
static RAS_IRasterizer* gp_Rasterizer = NULL;
+static char gp_GamePythonPath[FILE_MAXDIR + FILE_MAXFILE] = "";
void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)
{
@@ -115,36 +123,51 @@ void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,cons
static PyObject* ErrorObject;
STR_String gPyGetRandomFloat_doc="getRandomFloat returns a random floating point value in the range [0..1)";
-static PyObject* gPyGetRandomFloat(PyObject*,
- PyObject*,
- PyObject*)
+static PyObject* gPyGetRandomFloat(PyObject*)
{
return PyFloat_FromDouble(MT_random());
}
-static PyObject* gPySetGravity(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetGravity(PyObject*, PyObject* args)
{
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
- if (PyVecArgTo(args, vec))
- {
- if (gp_KetsjiScene)
- gp_KetsjiScene->SetGravity(vec);
-
- Py_Return;
- }
+ if (!PyVecArgTo(args, vec))
+ return NULL;
+
+ if (gp_KetsjiScene)
+ gp_KetsjiScene->SetGravity(vec);
- return NULL;
+ Py_RETURN_NONE;
+}
+
+static char gPyExpandPath_doc[] =
+"(path) - Converts a blender internal path into a proper file system path.\n\
+path - the string path to convert.\n\n\
+Use / as directory separator in path\n\
+You can use '//' at the start of the string to define a relative path;\n\
+Blender replaces that string by the directory of the startup .blend or runtime\n\
+file to make a full path name (doesn't change during the game, even if you load\n\
+other .blend).\n\
+The function also converts the directory separator to the local file system format.";
+
+static PyObject* gPyExpandPath(PyObject*, PyObject* args)
+{
+ char expanded[FILE_MAXDIR + FILE_MAXFILE];
+ char* filename;
+
+ if (!PyArg_ParseTuple(args,"s",&filename))
+ return NULL;
+
+ BLI_strncpy(expanded, filename, FILE_MAXDIR + FILE_MAXFILE);
+ BLI_convertstringcode(expanded, gp_GamePythonPath);
+ return PyString_FromString(expanded);
}
static bool usedsp = false;
// this gets a pointer to an array filled with floats
-static PyObject* gPyGetSpectrum(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyGetSpectrum(PyObject*)
{
SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
@@ -165,111 +188,145 @@ static PyObject* gPyGetSpectrum(PyObject*,
PyList_SetItem(resultlist, index, PyFloat_FromDouble(spectrum[index]));
}
}
+ else {
+ for (int index = 0; index < 512; index++)
+ {
+ PyList_SetItem(resultlist, index, PyFloat_FromDouble(0.0));
+ }
+ }
return resultlist;
}
-static PyObject* gPyStartDSP(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyStartDSP(PyObject*, PyObject* args)
{
SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
- if (audiodevice)
- {
- if (!usedsp)
- {
- audiodevice->StartUsingDSP();
- usedsp = true;
- Py_Return;
- }
+ if (!audiodevice) {
+ PyErr_SetString(PyExc_RuntimeError, "no audio device available");
+ return NULL;
}
- return NULL;
+
+ if (!usedsp) {
+ audiodevice->StartUsingDSP();
+ usedsp = true;
+ }
+
+ Py_RETURN_NONE;
}
-static PyObject* gPyStopDSP(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyStopDSP(PyObject*, PyObject* args)
{
SND_IAudioDevice* audiodevice = SND_DeviceManager::Instance();
- if (audiodevice)
- {
- if (usedsp)
- {
- audiodevice->StopUsingDSP();
- usedsp = false;
- Py_Return;
- }
+ if (!audiodevice) {
+ PyErr_SetString(PyExc_RuntimeError, "no audio device available");
+ return NULL;
}
- return NULL;
+
+ if (usedsp) {
+ audiodevice->StopUsingDSP();
+ usedsp = true;
+ }
+
+ Py_RETURN_NONE;
}
-static PyObject* gPySetLogicTicRate(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetLogicTicRate(PyObject*, PyObject* args)
{
float ticrate;
- if (PyArg_ParseTuple(args, "f", &ticrate))
- {
- KX_KetsjiEngine::SetTicRate(ticrate);
- Py_Return;
- }
+ if (!PyArg_ParseTuple(args, "f", &ticrate))
+ return NULL;
- return NULL;
+ KX_KetsjiEngine::SetTicRate(ticrate);
+ Py_RETURN_NONE;
}
-static PyObject* gPyGetLogicTicRate(PyObject*, PyObject*, PyObject*)
+static PyObject* gPyGetLogicTicRate(PyObject*)
{
return PyFloat_FromDouble(KX_KetsjiEngine::GetTicRate());
}
-static PyObject* gPySetPhysicsTicRate(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetPhysicsTicRate(PyObject*, PyObject* args)
{
float ticrate;
- if (PyArg_ParseTuple(args, "f", &ticrate))
- {
-
- PHY_GetActiveEnvironment()->setFixedTimeStep(true,ticrate);
- Py_Return;
- }
+ if (!PyArg_ParseTuple(args, "f", &ticrate))
+ return NULL;
- return NULL;
+ PHY_GetActiveEnvironment()->setFixedTimeStep(true,ticrate);
+ Py_RETURN_NONE;
}
-static PyObject* gPySetPhysicsDebug(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetPhysicsDebug(PyObject*, PyObject* args)
{
int debugMode;
- if (PyArg_ParseTuple(args, "i", &debugMode))
- {
- PHY_GetActiveEnvironment()->setDebugMode(debugMode);
- Py_Return;
- }
+ if (!PyArg_ParseTuple(args, "i", &debugMode))
+ return NULL;
- return NULL;
+ PHY_GetActiveEnvironment()->setDebugMode(debugMode);
+ Py_RETURN_NONE;
}
-static PyObject* gPyGetPhysicsTicRate(PyObject*, PyObject*, PyObject*)
+static PyObject* gPyGetPhysicsTicRate(PyObject*)
{
return PyFloat_FromDouble(PHY_GetActiveEnvironment()->getFixedTimeStep());
}
+static PyObject* gPyGetAverageFrameRate(PyObject*)
+{
+ return PyFloat_FromDouble(KX_KetsjiEngine::GetAverageFrameRate());
+}
+
+static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args)
+{
+ char cpath[sizeof(gp_GamePythonPath)];
+ char *searchpath = NULL;
+ PyObject* list, *value;
+
+ DIR *dp;
+ struct dirent *dirp;
+
+ if (!PyArg_ParseTuple(args, "|s", &searchpath))
+ return NULL;
+
+ list = PyList_New(0);
+
+ if (searchpath) {
+ BLI_strncpy(cpath, searchpath, FILE_MAXDIR + FILE_MAXFILE);
+ BLI_convertstringcode(cpath, gp_GamePythonPath);
+ } else {
+ /* Get the dir only */
+ BLI_split_dirfile_basic(gp_GamePythonPath, cpath, NULL);
+ }
+
+ if((dp = opendir(cpath)) == NULL) {
+ /* todo, show the errno, this shouldnt happen anyway if the blendfile is readable */
+ fprintf(stderr, "Could not read directoty (%s) failed, code %d (%s)\n", cpath, errno, strerror(errno));
+ return list;
+ }
+
+ while ((dirp = readdir(dp)) != NULL) {
+ if (BLI_testextensie(dirp->d_name, ".blend")) {
+ value = PyString_FromString(dirp->d_name);
+ PyList_Append(list, value);
+ Py_DECREF(value);
+ }
+ }
+
+ closedir(dp);
+ return list;
+}
+
static STR_String gPyGetCurrentScene_doc =
"getCurrentScene()\n"
"Gets a reference to the current scene.\n";
-static PyObject* gPyGetCurrentScene(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+static PyObject* gPyGetCurrentScene(PyObject* self)
{
Py_INCREF(gp_KetsjiScene);
return (PyObject*) gp_KetsjiScene;
@@ -278,17 +335,13 @@ static PyObject* gPyGetCurrentScene(PyObject* self,
static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *)
{
#define pprint(x) std::cout << x << std::endl;
- bgl::BL_EXTInfo ext = bgl::RAS_EXT_support;
bool count=0;
bool support=0;
pprint("Supported Extensions...");
-#ifdef GL_ARB_shader_objects
- pprint(" GL_ARB_shader_objects supported? "<< (ext._ARB_shader_objects?"yes.":"no."));
+ pprint(" GL_ARB_shader_objects supported? "<< (GLEW_ARB_shader_objects?"yes.":"no."));
count = 1;
-#endif
-#ifdef GL_ARB_vertex_shader
- support= ext._ARB_vertex_shader;
+ support= GLEW_ARB_vertex_shader;
pprint(" GL_ARB_vertex_shader supported? "<< (support?"yes.":"no."));
count = 1;
if(support){
@@ -307,9 +360,8 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *)
pprint(" Max combined texture units." << max);
pprint("");
}
-#endif
-#ifdef GL_ARB_fragment_shader
- support=ext._ARB_fragment_shader;
+
+ support=GLEW_ARB_fragment_shader;
pprint(" GL_ARB_fragment_shader supported? "<< (support?"yes.":"no."));
count = 1;
if(support){
@@ -319,9 +371,8 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *)
pprint(" Max uniform components." << max);
pprint("");
}
-#endif
-#ifdef GL_ARB_texture_cube_map
- support = ext._ARB_texture_cube_map;
+
+ support = GLEW_ARB_texture_cube_map;
pprint(" GL_ARB_texture_cube_map supported? "<< (support?"yes.":"no."));
count = 1;
if(support){
@@ -331,9 +382,8 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *)
pprint(" Max cubemap size." << size);
pprint("");
}
-#endif
-#ifdef GL_ARB_multitexture
- support = ext._ARB_multitexture;
+
+ support = GLEW_ARB_multitexture;
count = 1;
pprint(" GL_ARB_multitexture supported? "<< (support?"yes.":"no."));
if(support){
@@ -343,63 +393,52 @@ static PyObject *pyPrintExt(PyObject *,PyObject *,PyObject *)
pprint(" Max texture units available. " << units);
pprint("");
}
-#endif
-#ifdef GL_ARB_texture_env_combine
- pprint(" GL_ARB_texture_env_combine supported? "<< (ext._ARB_texture_env_combine?"yes.":"no."));
+
+ pprint(" GL_ARB_texture_env_combine supported? "<< (GLEW_ARB_texture_env_combine?"yes.":"no."));
count = 1;
-#endif
+
if(!count)
pprint("No extenstions are used in this build");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
static struct PyMethodDef game_methods[] = {
+ {"expandPath", (PyCFunction)gPyExpandPath, METH_VARARGS, (PY_METHODCHAR)gPyExpandPath_doc},
{"getCurrentController",
(PyCFunction) SCA_PythonController::sPyGetCurrentController,
- METH_VARARGS, SCA_PythonController::sPyGetCurrentController__doc__},
+ METH_NOARGS, (PY_METHODCHAR)SCA_PythonController::sPyGetCurrentController__doc__},
{"getCurrentScene", (PyCFunction) gPyGetCurrentScene,
- METH_VARARGS, gPyGetCurrentScene_doc.Ptr()},
+ METH_NOARGS, (PY_METHODCHAR)gPyGetCurrentScene_doc.Ptr()},
{"addActiveActuator",(PyCFunction) SCA_PythonController::sPyAddActiveActuator,
- METH_VARARGS, SCA_PythonController::sPyAddActiveActuator__doc__},
+ METH_VARARGS, (PY_METHODCHAR)SCA_PythonController::sPyAddActiveActuator__doc__},
{"getRandomFloat",(PyCFunction) gPyGetRandomFloat,
- METH_VARARGS,gPyGetRandomFloat_doc.Ptr()},
- {"setGravity",(PyCFunction) gPySetGravity, METH_VARARGS,"set Gravitation"},
- {"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_VARARGS,"get audio spectrum"},
- {"stopDSP",(PyCFunction) gPyStopDSP, METH_VARARGS,"stop using the audio dsp (for performance reasons)"},
- {"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_VARARGS, "Gets the logic tic rate"},
- {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, "Sets the logic tic rate"},
- {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_VARARGS, "Gets the physics tic rate"},
- {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, "Sets the physics tic rate"},
- {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, "Prints GL Extension Info"},
+ METH_NOARGS, (PY_METHODCHAR)gPyGetRandomFloat_doc.Ptr()},
+ {"setGravity",(PyCFunction) gPySetGravity, METH_VARARGS, (PY_METHODCHAR)"set Gravitation"},
+ {"getSpectrum",(PyCFunction) gPyGetSpectrum, METH_NOARGS, (PY_METHODCHAR)"get audio spectrum"},
+ {"stopDSP",(PyCFunction) gPyStopDSP, METH_VARARGS, (PY_METHODCHAR)"stop using the audio dsp (for performance reasons)"},
+ {"getLogicTicRate", (PyCFunction) gPyGetLogicTicRate, METH_NOARGS, (PY_METHODCHAR)"Gets the logic tic rate"},
+ {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, (PY_METHODCHAR)"Sets the logic tic rate"},
+ {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, (PY_METHODCHAR)"Gets the physics tic rate"},
+ {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, (PY_METHODCHAR)"Sets the physics tic rate"},
+ {"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, (PY_METHODCHAR)"Gets the estimated average frame rate"},
+ {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, (PY_METHODCHAR)"Gets a list of blend files in the same directory as the current blend file"},
+ {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (PY_METHODCHAR)"Prints GL Extension Info"},
{NULL, (PyCFunction) NULL, 0, NULL }
};
-static PyObject* gPyGetWindowHeight(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyGetWindowHeight(PyObject*, PyObject* args)
{
- int height = (gp_Canvas ? gp_Canvas->GetHeight() : 0);
-
- PyObject* heightval = PyInt_FromLong(height);
- return heightval;
+ return PyInt_FromLong((gp_Canvas ? gp_Canvas->GetHeight() : 0));
}
-static PyObject* gPyGetWindowWidth(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyGetWindowWidth(PyObject*, PyObject* args)
{
-
-
- int width = (gp_Canvas ? gp_Canvas->GetWidth() : 0);
-
- PyObject* widthval = PyInt_FromLong(width);
- return widthval;
+ return PyInt_FromLong((gp_Canvas ? gp_Canvas->GetWidth() : 0));
}
@@ -407,264 +446,403 @@ static PyObject* gPyGetWindowWidth(PyObject*,
// temporarility visibility thing, will be moved to rasterizer/renderer later
bool gUseVisibilityTemp = false;
-static PyObject* gPyEnableVisibility(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyEnableVisibility(PyObject*, PyObject* args)
{
int visible;
- if (PyArg_ParseTuple(args,"i",&visible))
- {
- gUseVisibilityTemp = (visible != 0);
- }
- else
- {
- Py_Return;
- }
- Py_Return;
+ if (!PyArg_ParseTuple(args,"i",&visible))
+ return NULL;
+
+ gUseVisibilityTemp = (visible != 0);
+ Py_RETURN_NONE;
}
-static PyObject* gPyShowMouse(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyShowMouse(PyObject*, PyObject* args)
{
int visible;
- if (PyArg_ParseTuple(args,"i",&visible))
+ if (!PyArg_ParseTuple(args,"i",&visible))
+ return NULL;
+
+ if (visible)
{
- if (visible)
- {
- if (gp_Canvas)
- gp_Canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
- } else
- {
- if (gp_Canvas)
- gp_Canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
- }
+ if (gp_Canvas)
+ gp_Canvas->SetMouseState(RAS_ICanvas::MOUSE_NORMAL);
+ } else
+ {
+ if (gp_Canvas)
+ gp_Canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
}
- Py_Return;
+ Py_RETURN_NONE;
}
-static PyObject* gPySetMousePosition(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetMousePosition(PyObject*, PyObject* args)
{
int x,y;
- if (PyArg_ParseTuple(args,"ii",&x,&y))
- {
- if (gp_Canvas)
- gp_Canvas->SetMousePosition(x,y);
- }
+ if (!PyArg_ParseTuple(args,"ii",&x,&y))
+ return NULL;
- Py_Return;
+ if (gp_Canvas)
+ gp_Canvas->SetMousePosition(x,y);
+
+ Py_RETURN_NONE;
}
-static PyObject* gPySetEyeSeparation(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetEyeSeparation(PyObject*, PyObject* args)
{
float sep;
- if (PyArg_ParseTuple(args, "f", &sep))
- {
- if (gp_Rasterizer)
- gp_Rasterizer->SetEyeSeparation(sep);
-
- Py_Return;
+ if (!PyArg_ParseTuple(args, "f", &sep))
+ return NULL;
+
+ if (!gp_Rasterizer) {
+ PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available");
+ return NULL;
}
- return NULL;
+ gp_Rasterizer->SetEyeSeparation(sep);
+
+ Py_RETURN_NONE;
}
static PyObject* gPyGetEyeSeparation(PyObject*, PyObject*, PyObject*)
{
- if (gp_Rasterizer)
- return PyFloat_FromDouble(gp_Rasterizer->GetEyeSeparation());
+ if (!gp_Rasterizer) {
+ PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available");
+ return NULL;
+ }
- return NULL;
+ return PyFloat_FromDouble(gp_Rasterizer->GetEyeSeparation());
}
-static PyObject* gPySetFocalLength(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetFocalLength(PyObject*, PyObject* args)
{
float focus;
- if (PyArg_ParseTuple(args, "f", &focus))
- {
- if (gp_Rasterizer)
- gp_Rasterizer->SetFocalLength(focus);
- Py_Return;
+ if (!PyArg_ParseTuple(args, "f", &focus))
+ return NULL;
+
+ if (!gp_Rasterizer) {
+ PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available");
+ return NULL;
}
+
+ gp_Rasterizer->SetFocalLength(focus);
- return NULL;
+ Py_RETURN_NONE;
}
static PyObject* gPyGetFocalLength(PyObject*, PyObject*, PyObject*)
{
- if (gp_Rasterizer)
- return PyFloat_FromDouble(gp_Rasterizer->GetFocalLength());
- return NULL;
+ if (!gp_Rasterizer) {
+ PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available");
+ return NULL;
+ }
+
+ return PyFloat_FromDouble(gp_Rasterizer->GetFocalLength());
+
+ Py_RETURN_NONE;
}
-static PyObject* gPySetBackgroundColor(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetBackgroundColor(PyObject*, PyObject* args)
{
MT_Vector4 vec = MT_Vector4(0., 0., 0.3, 0.);
- if (PyVecArgTo(args, vec))
+ if (!PyVecArgTo(args, vec))
+ return NULL;
+
+ if (gp_Canvas)
{
- if (gp_Canvas)
- {
- gp_Rasterizer->SetBackColor(vec[0], vec[1], vec[2], vec[3]);
- }
- Py_Return;
+ gp_Rasterizer->SetBackColor(vec[0], vec[1], vec[2], vec[3]);
}
-
- return NULL;
+ Py_RETURN_NONE;
}
-static PyObject* gPySetMistColor(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetMistColor(PyObject*, PyObject* args)
{
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
- if (PyVecArgTo(args, vec))
- {
- if (gp_Rasterizer)
- {
- gp_Rasterizer->SetFogColor(vec[0], vec[1], vec[2]);
- }
- Py_Return;
- }
+ if (!PyVecArgTo(args, vec))
+ return NULL;
- return NULL;
+ if (!gp_Rasterizer) {
+ PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available");
+ return NULL;
+ }
+ gp_Rasterizer->SetFogColor(vec[0], vec[1], vec[2]);
+
+ Py_RETURN_NONE;
}
-static PyObject* gPySetMistStart(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetMistStart(PyObject*, PyObject* args)
{
float miststart;
- if (PyArg_ParseTuple(args,"f",&miststart))
- {
- if (gp_Rasterizer)
- {
- gp_Rasterizer->SetFogStart(miststart);
- }
+ if (!PyArg_ParseTuple(args,"f",&miststart))
+ return NULL;
+
+ if (!gp_Rasterizer) {
+ PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available");
+ return NULL;
}
- Py_Return;
+
+ gp_Rasterizer->SetFogStart(miststart);
+
+ Py_RETURN_NONE;
}
-static PyObject* gPySetMistEnd(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetMistEnd(PyObject*, PyObject* args)
{
float mistend;
- if (PyArg_ParseTuple(args,"f",&mistend))
- {
- if (gp_Rasterizer)
- {
- gp_Rasterizer->SetFogEnd(mistend);
- }
+ if (!PyArg_ParseTuple(args,"f",&mistend))
+ return NULL;
+
+ if (!gp_Rasterizer) {
+ PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available");
+ return NULL;
}
- Py_Return;
+
+ gp_Rasterizer->SetFogEnd(mistend);
+
+ Py_RETURN_NONE;
}
-static PyObject* gPySetAmbientColor(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPySetAmbientColor(PyObject*, PyObject* args)
{
MT_Vector3 vec = MT_Vector3(0., 0., 0.);
- if (PyVecArgTo(args, vec))
- {
- if (gp_Rasterizer)
- {
- gp_Rasterizer->SetAmbientColor(vec[0], vec[1], vec[2]);
- }
- Py_Return;
- }
+ if (!PyVecArgTo(args, vec))
+ return NULL;
- return NULL;
+ if (!gp_Rasterizer) {
+ PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available");
+ return NULL;
+ }
+ gp_Rasterizer->SetAmbientColor(vec[0], vec[1], vec[2]);
+
+ Py_RETURN_NONE;
}
-static PyObject* gPyMakeScreenshot(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyMakeScreenshot(PyObject*, PyObject* args)
{
char* filename;
- if (PyArg_ParseTuple(args,"s",&filename))
+ if (!PyArg_ParseTuple(args,"s",&filename))
+ return NULL;
+
+ if (gp_Canvas)
{
- if (gp_Canvas)
- {
- gp_Canvas->MakeScreenShot(filename);
- }
+ gp_Canvas->MakeScreenShot(filename);
}
- Py_Return;
+
+ Py_RETURN_NONE;
}
-static PyObject* gPyEnableMotionBlur(PyObject*,
- PyObject* args,
- PyObject*)
+static PyObject* gPyEnableMotionBlur(PyObject*, PyObject* args)
{
float motionblurvalue;
- if (PyArg_ParseTuple(args,"f",&motionblurvalue))
- {
- if(gp_Rasterizer)
- {
- gp_Rasterizer->EnableMotionBlur(motionblurvalue);
+ if (!PyArg_ParseTuple(args,"f",&motionblurvalue))
+ return NULL;
+
+ if (!gp_Rasterizer) {
+ PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available");
+ return NULL;
+ }
+
+ gp_Rasterizer->EnableMotionBlur(motionblurvalue);
+
+ Py_RETURN_NONE;
+}
+
+static PyObject* gPyDisableMotionBlur(PyObject*, PyObject* args)
+{
+ if (!gp_Rasterizer) {
+ PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available");
+ return NULL;
+ }
+
+ gp_Rasterizer->DisableMotionBlur();
+
+ Py_RETURN_NONE;
+}
+
+int getGLSLSettingFlag(char *setting)
+{
+ if(strcmp(setting, "lights") == 0)
+ return G_FILE_GLSL_NO_LIGHTS;
+ else if(strcmp(setting, "shaders") == 0)
+ return G_FILE_GLSL_NO_SHADERS;
+ else if(strcmp(setting, "shadows") == 0)
+ return G_FILE_GLSL_NO_SHADOWS;
+ else if(strcmp(setting, "ramps") == 0)
+ return G_FILE_GLSL_NO_RAMPS;
+ else if(strcmp(setting, "nodes") == 0)
+ return G_FILE_GLSL_NO_NODES;
+ else if(strcmp(setting, "extra_textures") == 0)
+ return G_FILE_GLSL_NO_EXTRA_TEX;
+ else
+ return -1;
+}
+
+static PyObject* gPySetGLSLMaterialSetting(PyObject*,
+ PyObject* args,
+ PyObject*)
+{
+ char *setting;
+ int enable, flag, fileflags;
+
+ if (!PyArg_ParseTuple(args,"si",&setting,&enable))
+ return NULL;
+
+ flag = getGLSLSettingFlag(setting);
+
+ if (flag==-1) {
+ PyErr_SetString(PyExc_ValueError, "glsl setting is not known");
+ return NULL;
+ }
+
+ fileflags = G.fileflags;
+
+ if (enable)
+ G.fileflags &= ~flag;
+ else
+ G.fileflags |= flag;
+
+ /* display lists and GLSL materials need to be remade */
+ if(G.fileflags != fileflags) {
+ if(gp_KetsjiEngine) {
+ KX_SceneList *scenes = gp_KetsjiEngine->CurrentScenes();
+ KX_SceneList::iterator it;
+
+ for(it=scenes->begin(); it!=scenes->end(); it++)
+ if((*it)->GetBucketManager())
+ (*it)->GetBucketManager()->ReleaseDisplayLists();
}
+
+ GPU_materials_free();
+ }
+
+ Py_RETURN_NONE;
+}
+
+static PyObject* gPyGetGLSLMaterialSetting(PyObject*,
+ PyObject* args,
+ PyObject*)
+{
+ char *setting;
+ int enabled = 0, flag;
+
+ if (!PyArg_ParseTuple(args,"s",&setting))
+ return NULL;
+
+ flag = getGLSLSettingFlag(setting);
+
+ if (flag==-1) {
+ PyErr_SetString(PyExc_ValueError, "glsl setting is not known");
+ return NULL;
}
- Py_Return;
+
+ enabled = ((G.fileflags & flag) != 0);
+ return PyInt_FromLong(enabled);
}
-static PyObject* gPyDisableMotionBlur(PyObject*,
+#define KX_TEXFACE_MATERIAL 0
+#define KX_BLENDER_MULTITEX_MATERIAL 1
+#define KX_BLENDER_GLSL_MATERIAL 2
+
+static PyObject* gPySetMaterialType(PyObject*,
PyObject* args,
PyObject*)
{
- if(gp_Rasterizer)
- {
- gp_Rasterizer->DisableMotionBlur();
+ int flag, type;
+
+ if (!PyArg_ParseTuple(args,"i",&type))
+ return NULL;
+
+ if(type == KX_BLENDER_GLSL_MATERIAL)
+ flag = G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL;
+ else if(type == KX_BLENDER_MULTITEX_MATERIAL)
+ flag = G_FILE_GAME_MAT;
+ else if(type == KX_TEXFACE_MATERIAL)
+ flag = 0;
+ else {
+ PyErr_SetString(PyExc_ValueError, "material type is not known");
+ return NULL;
}
- Py_Return;
+
+ G.fileflags &= ~(G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL);
+ G.fileflags |= flag;
+
+ Py_RETURN_NONE;
}
-STR_String gPyGetWindowHeight__doc__="getWindowHeight doc";
-STR_String gPyGetWindowWidth__doc__="getWindowWidth doc";
-STR_String gPyEnableVisibility__doc__="enableVisibility doc";
-STR_String gPyMakeScreenshot__doc__="make Screenshot doc";
-STR_String gPyShowMouse__doc__="showMouse(bool visible)";
-STR_String gPySetMousePosition__doc__="setMousePosition(int x,int y)";
+static PyObject* gPyGetMaterialType(PyObject*)
+{
+ int flag;
+
+ if(G.fileflags & (G_FILE_GAME_MAT|G_FILE_GAME_MAT_GLSL))
+ flag = KX_BLENDER_GLSL_MATERIAL;
+ else if(G.fileflags & G_FILE_GAME_MAT)
+ flag = KX_BLENDER_MULTITEX_MATERIAL;
+ else
+ flag = KX_TEXFACE_MATERIAL;
+
+ return PyInt_FromLong(flag);
+}
+
+static PyObject* gPyDrawLine(PyObject*, PyObject* args)
+{
+ PyObject* ob_from;
+ PyObject* ob_to;
+ PyObject* ob_color;
+
+ if (!gp_Rasterizer) {
+ PyErr_SetString(PyExc_RuntimeError, "Rasterizer not available");
+ return NULL;
+ }
+
+ if (!PyArg_ParseTuple(args,"OOO",&ob_from,&ob_to,&ob_color))
+ return NULL;
+
+ MT_Vector3 from(0., 0., 0.);
+ MT_Vector3 to(0., 0., 0.);
+ MT_Vector3 color(0., 0., 0.);
+ if (!PyVecTo(ob_from, from))
+ return NULL;
+ if (!PyVecTo(ob_to, to))
+ return NULL;
+ if (!PyVecTo(ob_color, color))
+ return NULL;
+
+ gp_Rasterizer->DrawDebugLine(from,to,color);
+
+ Py_RETURN_NONE;
+}
static struct PyMethodDef rasterizer_methods[] = {
{"getWindowWidth",(PyCFunction) gPyGetWindowWidth,
- METH_VARARGS, gPyGetWindowWidth__doc__.Ptr()},
+ METH_VARARGS, "getWindowWidth doc"},
{"getWindowHeight",(PyCFunction) gPyGetWindowHeight,
- METH_VARARGS, gPyGetWindowHeight__doc__.Ptr()},
+ METH_VARARGS, "getWindowHeight doc"},
{"makeScreenshot",(PyCFunction)gPyMakeScreenshot,
- METH_VARARGS, gPyMakeScreenshot__doc__.Ptr()},
+ METH_VARARGS, "make Screenshot doc"},
{"enableVisibility",(PyCFunction) gPyEnableVisibility,
- METH_VARARGS, gPyEnableVisibility__doc__.Ptr()},
+ METH_VARARGS, "enableVisibility doc"},
{"showMouse",(PyCFunction) gPyShowMouse,
- METH_VARARGS, gPyShowMouse__doc__.Ptr()},
+ METH_VARARGS, "showMouse(bool visible)"},
{"setMousePosition",(PyCFunction) gPySetMousePosition,
- METH_VARARGS, gPySetMousePosition__doc__.Ptr()},
+ METH_VARARGS, "setMousePosition(int x,int y)"},
{"setBackgroundColor",(PyCFunction)gPySetBackgroundColor,METH_VARARGS,"set Background Color (rgb)"},
{"setAmbientColor",(PyCFunction)gPySetAmbientColor,METH_VARARGS,"set Ambient Color (rgb)"},
{"setMistColor",(PyCFunction)gPySetMistColor,METH_VARARGS,"set Mist Color (rgb)"},
@@ -678,11 +856,19 @@ static struct PyMethodDef rasterizer_methods[] = {
{"getEyeSeparation", (PyCFunction) gPyGetEyeSeparation, METH_VARARGS, "get the eye separation for stereo mode"},
{"setFocalLength", (PyCFunction) gPySetFocalLength, METH_VARARGS, "set the focal length for stereo mode"},
{"getFocalLength", (PyCFunction) gPyGetFocalLength, METH_VARARGS, "get the focal length for stereo mode"},
+ {"setMaterialMode",(PyCFunction) gPySetMaterialType,
+ METH_VARARGS, "set the material mode to use for OpenGL rendering"},
+ {"getMaterialMode",(PyCFunction) gPyGetMaterialType,
+ METH_NOARGS, "get the material mode being used for OpenGL rendering"},
+ {"setGLSLMaterialSetting",(PyCFunction) gPySetGLSLMaterialSetting,
+ METH_VARARGS, "set the state of a GLSL material setting"},
+ {"getGLSLMaterialSetting",(PyCFunction) gPyGetGLSLMaterialSetting,
+ METH_VARARGS, "get the state of a GLSL material setting"},
+ {"drawLine", (PyCFunction) gPyDrawLine,
+ METH_VARARGS, "draw a line on the screen"},
{ NULL, (PyCFunction) NULL, 0, NULL }
};
-
-
// Initialization function for the module (*must* be called initGameLogic)
static char GameLogic_module_documentation[] =
@@ -695,11 +881,12 @@ static char Rasterizer_module_documentation[] =
-PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook
+PyObject* initGameLogic(KX_KetsjiEngine *engine, KX_Scene* scene) // quick hack to get gravity hook
{
PyObject* m;
PyObject* d;
+ gp_KetsjiEngine = engine;
gp_KetsjiScene = scene;
gUseVisibilityTemp=false;
@@ -711,10 +898,14 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook
// Add some symbolic constants to the module
d = PyModule_GetDict(m);
+
+ // can be overwritten later for gameEngine instances that can load new blend files and re-initialize this module
+ // for now its safe to make sure it exists for other areas such as the web plugin
+ PyDict_SetItemString(d, "globalDict", PyDict_New());
ErrorObject = PyString_FromString("GameLogic.error");
PyDict_SetItemString(d, "error", ErrorObject);
-
+
// XXXX Add constants here
/* To use logic bricks, we need some sort of constants. Here, we associate */
/* constants and sumbolic names. Add them to dictionary d. */
@@ -737,6 +928,15 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook
KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ROTX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTX);
KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ROTY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTY);
KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ROTZ, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ROTZ);
+ KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRPX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPX);
+ KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRPY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPY);
+ KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRPY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRPY);
+ KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRNX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNX);
+ KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRNY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNY);
+ KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_DIRNY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_DIRNY);
+ KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ORIX, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIX);
+ KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ORIY, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIY);
+ KX_MACRO_addTypesToDict(d, KX_CONSTRAINTACT_ORIZ, KX_ConstraintActuator::KX_ACT_CONSTRAINT_ORIZ);
/* 4. Ipo actuator, simple part */
KX_MACRO_addTypesToDict(d, KX_IPOACT_PLAY, KX_IpoActuator::KX_ACT_IPO_PLAY);
@@ -803,37 +1003,75 @@ PyObject* initGameLogic(KX_Scene* scene) // quick hack to get gravity hook
KX_MACRO_addTypesToDict(d, CAM_POS, BL_Shader::CAM_POS);
KX_MACRO_addTypesToDict(d, CONSTANT_TIMER, BL_Shader::CONSTANT_TIMER);
+ /* 10 state actuator */
+ KX_MACRO_addTypesToDict(d, KX_STATE1, (1<<0));
+ KX_MACRO_addTypesToDict(d, KX_STATE2, (1<<1));
+ KX_MACRO_addTypesToDict(d, KX_STATE3, (1<<2));
+ KX_MACRO_addTypesToDict(d, KX_STATE4, (1<<3));
+ KX_MACRO_addTypesToDict(d, KX_STATE5, (1<<4));
+ KX_MACRO_addTypesToDict(d, KX_STATE6, (1<<5));
+ KX_MACRO_addTypesToDict(d, KX_STATE7, (1<<6));
+ KX_MACRO_addTypesToDict(d, KX_STATE8, (1<<7));
+ KX_MACRO_addTypesToDict(d, KX_STATE9, (1<<8));
+ KX_MACRO_addTypesToDict(d, KX_STATE10, (1<<9));
+ KX_MACRO_addTypesToDict(d, KX_STATE11, (1<<10));
+ KX_MACRO_addTypesToDict(d, KX_STATE12, (1<<11));
+ KX_MACRO_addTypesToDict(d, KX_STATE13, (1<<12));
+ KX_MACRO_addTypesToDict(d, KX_STATE14, (1<<13));
+ KX_MACRO_addTypesToDict(d, KX_STATE15, (1<<14));
+ KX_MACRO_addTypesToDict(d, KX_STATE16, (1<<15));
+ KX_MACRO_addTypesToDict(d, KX_STATE17, (1<<16));
+ KX_MACRO_addTypesToDict(d, KX_STATE18, (1<<17));
+ KX_MACRO_addTypesToDict(d, KX_STATE19, (1<<18));
+ KX_MACRO_addTypesToDict(d, KX_STATE20, (1<<19));
+ KX_MACRO_addTypesToDict(d, KX_STATE21, (1<<20));
+ KX_MACRO_addTypesToDict(d, KX_STATE22, (1<<21));
+ KX_MACRO_addTypesToDict(d, KX_STATE23, (1<<22));
+ KX_MACRO_addTypesToDict(d, KX_STATE24, (1<<23));
+ KX_MACRO_addTypesToDict(d, KX_STATE25, (1<<24));
+ KX_MACRO_addTypesToDict(d, KX_STATE26, (1<<25));
+ KX_MACRO_addTypesToDict(d, KX_STATE27, (1<<26));
+ KX_MACRO_addTypesToDict(d, KX_STATE28, (1<<27));
+ KX_MACRO_addTypesToDict(d, KX_STATE29, (1<<28));
+ KX_MACRO_addTypesToDict(d, KX_STATE30, (1<<29));
+
// Check for errors
if (PyErr_Occurred())
{
Py_FatalError("can't initialize module GameLogic");
}
- return d;
-}
-
-void dictionaryClearByHand(PyObject *dict)
-{
- // Clears the dictionary by hand:
- // This prevents, extra references to global variables
- // inside the GameLogic dictionary when the python interpreter is finalized.
- // which allows the scene to safely delete them :)
- // see: (space.c)->start_game
- if(dict) PyDict_Clear(dict);
+ return m;
}
-
// Python Sandbox code
// override builtin functions import() and open()
-PyObject *KXpy_open(PyObject *self, PyObject *args)
-{
+PyObject *KXpy_open(PyObject *self, PyObject *args) {
PyErr_SetString(PyExc_RuntimeError, "Sandbox: open() function disabled!\nGame Scripts should not use this function.");
return NULL;
}
+PyObject *KXpy_reload(PyObject *self, PyObject *args) {
+ PyErr_SetString(PyExc_RuntimeError, "Sandbox: reload() function disabled!\nGame Scripts should not use this function.");
+ return NULL;
+}
+
+PyObject *KXpy_file(PyObject *self, PyObject *args) {
+ PyErr_SetString(PyExc_RuntimeError, "Sandbox: file() function disabled!\nGame Scripts should not use this function.");
+ return NULL;
+}
+PyObject *KXpy_execfile(PyObject *self, PyObject *args) {
+ PyErr_SetString(PyExc_RuntimeError, "Sandbox: execfile() function disabled!\nGame Scripts should not use this function.");
+ return NULL;
+}
+
+PyObject *KXpy_compile(PyObject *self, PyObject *args) {
+ PyErr_SetString(PyExc_RuntimeError, "Sandbox: compile() function disabled!\nGame Scripts should not use this function.");
+ return NULL;
+}
PyObject *KXpy_import(PyObject *self, PyObject *args)
{
@@ -843,9 +1081,17 @@ PyObject *KXpy_import(PyObject *self, PyObject *args)
PyObject *fromlist = NULL;
PyObject *l, *m, *n;
+#if (PY_VERSION_HEX >= 0x02060000)
+ int dummy_val; /* what does this do?*/
+
+ if (!PyArg_ParseTuple(args, "s|OOOi:m_import",
+ &name, &globals, &locals, &fromlist, &dummy_val))
+ return NULL;
+#else
if (!PyArg_ParseTuple(args, "s|OOO:m_import",
&name, &globals, &locals, &fromlist))
return NULL;
+#endif
/* check for builtin modules */
m = PyImport_AddModule("sys");
@@ -859,7 +1105,7 @@ PyObject *KXpy_import(PyObject *self, PyObject *args)
/* quick hack for GamePython modules
TODO: register builtin modules properly by ExtendInittab */
if (!strcmp(name, "GameLogic") || !strcmp(name, "GameKeys") || !strcmp(name, "PhysicsConstraints") ||
- !strcmp(name, "Rasterizer")) {
+ !strcmp(name, "Rasterizer") || !strcmp(name, "Mathutils")) {
return PyImport_ImportModuleEx(name, globals, locals, fromlist);
}
@@ -869,40 +1115,67 @@ PyObject *KXpy_import(PyObject *self, PyObject *args)
}
+/* override python file type functions */
+#if 0
+static int
+file_init(PyObject *self, PyObject *args, PyObject *kwds)
+{
+ KXpy_file(NULL, NULL);
+ return -1;
+}
+static PyObject *
+file_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ return KXpy_file(NULL, NULL);
+}
+#endif
-static PyMethodDef meth_open[] = {
- { "open", KXpy_open, METH_VARARGS,
- "(disabled)"}
-};
-
-
-static PyMethodDef meth_import[] = {
- { "import", KXpy_import, METH_VARARGS,
- "our own import"}
-};
-
+static PyMethodDef meth_open[] = {{ "open", KXpy_open, METH_VARARGS, "(disabled)"}};
+static PyMethodDef meth_reload[] = {{ "reload", KXpy_reload, METH_VARARGS, "(disabled)"}};
+static PyMethodDef meth_file[] = {{ "file", KXpy_file, METH_VARARGS, "(disabled)"}};
+static PyMethodDef meth_execfile[] = {{ "execfile", KXpy_execfile, METH_VARARGS, "(disabled)"}};
+static PyMethodDef meth_compile[] = {{ "compile", KXpy_compile, METH_VARARGS, "(disabled)"}};
+static PyMethodDef meth_import[] = {{ "import", KXpy_import, METH_VARARGS, "our own import"}};
//static PyObject *g_oldopen = 0;
//static PyObject *g_oldimport = 0;
//static int g_security = 0;
-
void setSandbox(TPythonSecurityLevel level)
{
PyObject *m = PyImport_AddModule("__builtin__");
PyObject *d = PyModule_GetDict(m);
- PyObject *meth = PyCFunction_New(meth_open, NULL);
switch (level) {
case psl_Highest:
//if (!g_security) {
//g_oldopen = PyDict_GetItemString(d, "open");
- PyDict_SetItemString(d, "open", meth);
- meth = PyCFunction_New(meth_import, NULL);
- PyDict_SetItemString(d, "__import__", meth);
+
+ // functions we cant trust
+ PyDict_SetItemString(d, "open", PyCFunction_New(meth_open, NULL));
+ PyDict_SetItemString(d, "reload", PyCFunction_New(meth_reload, NULL));
+ PyDict_SetItemString(d, "file", PyCFunction_New(meth_file, NULL));
+ PyDict_SetItemString(d, "execfile", PyCFunction_New(meth_execfile, NULL));
+ PyDict_SetItemString(d, "compile", PyCFunction_New(meth_compile, NULL));
+
+ // our own import
+ PyDict_SetItemString(d, "__import__", PyCFunction_New(meth_import, NULL));
//g_security = level;
+
+ // Overiding file dosnt stop it being accessed if your sneaky
+ // f = [ t for t in (1).__class__.__mro__[-1].__subclasses__() if t.__name__ == 'file'][0]('/some_file.txt', 'w')
+ // f.write('...')
+ // so overwrite the file types functions. be very careful here still, since python uses python.
+ // ps - python devs frown deeply upon this.
+
+ /* this could mess up pythons internals, if we are serious about sandboxing
+ * issues like the one above need to be solved, possibly modify __subclasses__ is safer? */
+#if 0
+ PyFile_Type.tp_init = file_init;
+ PyFile_Type.tp_new = file_new;
+#endif
//}
break;
/*
@@ -985,6 +1258,11 @@ PyObject* initRasterizer(RAS_IRasterizer* rasty,RAS_ICanvas* canvas)
ErrorObject = PyString_FromString("Rasterizer.error");
PyDict_SetItemString(d, "error", ErrorObject);
+ /* needed for get/setMaterialType */
+ KX_MACRO_addTypesToDict(d, KX_TEXFACE_MATERIAL, KX_TEXFACE_MATERIAL);
+ KX_MACRO_addTypesToDict(d, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL);
+ KX_MACRO_addTypesToDict(d, KX_BLENDER_GLSL_MATERIAL, KX_BLENDER_GLSL_MATERIAL);
+
// XXXX Add constants here
// Check for errors
@@ -1006,9 +1284,38 @@ static char GameKeys_module_documentation[] =
"This modules provides defines for key-codes"
;
+static char gPyEventToString_doc[] =
+"Take a valid event from the GameKeys module or Keyboard Sensor and return a name"
+;
+static PyObject* gPyEventToString(PyObject*, PyObject* value)
+{
+ PyObject* mod, *dict, *key, *val, *ret = NULL;
+ Py_ssize_t pos = 0;
+
+ mod = PyImport_ImportModule( "GameKeys" );
+ if (!mod)
+ return NULL;
+
+ dict = PyModule_GetDict(mod);
+
+ while (PyDict_Next(dict, &pos, &key, &val)) {
+ if (PyObject_Compare(value, val)==0) {
+ ret = key;
+ break;
+ }
+ }
+
+ PyErr_Clear(); // incase there was an error clearing
+ Py_DECREF(mod);
+ if (!ret) PyErr_SetString(PyExc_ValueError, "expected a valid int keyboard event");
+ else Py_INCREF(ret);
+
+ return ret;
+}
static struct PyMethodDef gamekeys_methods[] = {
+ {"EventToString", (PyCFunction)gPyEventToString, METH_O, (PY_METHODCHAR)gPyEventToString_doc},
{ NULL, (PyCFunction) NULL, 0, NULL }
};
@@ -1152,7 +1459,111 @@ PyObject* initGameKeys()
return d;
}
-void PHY_SetActiveScene(class KX_Scene* scene)
+PyObject* initMathutils()
+{
+ return NULL; //XXX Mathutils_Init("Mathutils"); // Use as a top level module in BGE
+}
+
+void KX_SetActiveScene(class KX_Scene* scene)
{
gp_KetsjiScene = scene;
}
+
+class KX_Scene* KX_GetActiveScene()
+{
+ return gp_KetsjiScene;
+}
+
+class KX_KetsjiEngine* KX_GetActiveEngine()
+{
+ return gp_KetsjiEngine;
+}
+
+// utility function for loading and saving the globalDict
+int saveGamePythonConfig( char **marshal_buffer)
+{
+ int marshal_length = 0;
+ PyObject* gameLogic = PyImport_ImportModule("GameLogic");
+ if (gameLogic) {
+ PyObject* pyGlobalDict = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module
+ if (pyGlobalDict) {
+#ifdef Py_MARSHAL_VERSION
+ PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict, 2); // Py_MARSHAL_VERSION == 2 as of Py2.5
+#else
+ PyObject* pyGlobalDictMarshal = PyMarshal_WriteObjectToString( pyGlobalDict );
+#endif
+ if (pyGlobalDictMarshal) {
+ // for testing only
+ // PyObject_Print(pyGlobalDictMarshal, stderr, 0);
+
+ marshal_length= PyString_Size(pyGlobalDictMarshal);
+ *marshal_buffer = new char[marshal_length + 1];
+ memcpy(*marshal_buffer, PyString_AsString(pyGlobalDictMarshal), marshal_length);
+
+ Py_DECREF(pyGlobalDictMarshal);
+ } else {
+ printf("Error, GameLogic.globalDict could not be marshal'd\n");
+ }
+ } else {
+ printf("Error, GameLogic.globalDict was removed\n");
+ }
+ Py_DECREF(gameLogic);
+ } else {
+ PyErr_Clear();
+ printf("Error, GameLogic failed to import GameLogic.globalDict will be lost\n");
+ }
+ return marshal_length;
+}
+
+int loadGamePythonConfig(char *marshal_buffer, int marshal_length)
+{
+ /* Restore the dict */
+ if (marshal_buffer) {
+ PyObject* gameLogic = PyImport_ImportModule("GameLogic");
+
+ if (gameLogic) {
+ PyObject* pyGlobalDict = PyMarshal_ReadObjectFromString(marshal_buffer, marshal_length);
+ if (pyGlobalDict) {
+ PyObject* pyGlobalDict_orig = PyDict_GetItemString(PyModule_GetDict(gameLogic), "globalDict"); // Same as importing the module.
+ if (pyGlobalDict_orig) {
+ PyDict_Clear(pyGlobalDict_orig);
+ PyDict_Update(pyGlobalDict_orig, pyGlobalDict);
+ } else {
+ /* this should not happen, but cant find the original globalDict, just assign it then */
+ PyDict_SetItemString(PyModule_GetDict(gameLogic), "globalDict", pyGlobalDict); // Same as importing the module.
+ }
+ Py_DECREF(gameLogic);
+ Py_DECREF(pyGlobalDict);
+ return 1;
+ } else {
+ Py_DECREF(gameLogic);
+ PyErr_Clear();
+ printf("Error could not marshall string\n");
+ }
+ } else {
+ PyErr_Clear();
+ printf("Error, GameLogic failed to import GameLogic.globalDict will be lost\n");
+ }
+ }
+ return 0;
+}
+
+void pathGamePythonConfig( char *path )
+{
+ int len = strlen(gp_GamePythonPath);
+
+ BLI_strncpy(path, gp_GamePythonPath, sizeof(gp_GamePythonPath));
+
+ /* replace extension */
+ if (BLI_testextensie(path, ".blend")) {
+ strcpy(path+(len-6), ".bgeconf");
+ } else {
+ strcpy(path+len, ".bgeconf");
+ }
+}
+
+void setGamePythonPath(char *path)
+{
+ BLI_strncpy(gp_GamePythonPath, path, sizeof(gp_GamePythonPath));
+}
+
diff --git a/source/gameengine/Ketsji/KX_PythonInit.h b/source/gameengine/Ketsji/KX_PythonInit.h
index b2b66e70f5b..57ee0be9400 100644
--- a/source/gameengine/Ketsji/KX_PythonInit.h
+++ b/source/gameengine/Ketsji/KX_PythonInit.h
@@ -40,16 +40,27 @@ typedef enum {
extern bool gUseVisibilityTemp;
-PyObject* initGameLogic(class KX_Scene* ketsjiscene);
+PyObject* initGameLogic(class KX_KetsjiEngine *engine, class KX_Scene* ketsjiscene);
PyObject* initGameKeys();
PyObject* initRasterizer(class RAS_IRasterizer* rasty,class RAS_ICanvas* canvas);
PyObject* initGamePlayerPythonScripting(const STR_String& progname, TPythonSecurityLevel level);
+PyObject* initMathutils();
+PyObject* initVideoTexture(void);
void exitGamePlayerPythonScripting();
PyObject* initGamePythonScripting(const STR_String& progname, TPythonSecurityLevel level);
void exitGamePythonScripting();
-void dictionaryClearByHand(PyObject *dict);
-void PHY_SetActiveScene(class KX_Scene* scene);
+void setGamePythonPath(char *path);
+void pathGamePythonConfig( char *path );
+int saveGamePythonConfig( char **marshal_buffer);
+int loadGamePythonConfig(char *marshal_buffer, int marshal_length);
+
+class KX_KetsjiEngine;
+class KX_Scene;
+
+void KX_SetActiveScene(class KX_Scene* scene);
+class KX_Scene* KX_GetActiveScene();
+class KX_KetsjiEngine* KX_GetActiveEngine();
#include "MT_Vector3.h"
void KX_RasterizerDrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color);
diff --git a/source/gameengine/Ketsji/KX_RadarSensor.cpp b/source/gameengine/Ketsji/KX_RadarSensor.cpp
index 66ff1e1e7ca..244e9b75d8e 100644
--- a/source/gameengine/Ketsji/KX_RadarSensor.cpp
+++ b/source/gameengine/Ketsji/KX_RadarSensor.cpp
@@ -71,7 +71,6 @@ KX_RadarSensor::KX_RadarSensor(SCA_EventManager* eventmgr,
//sumoObj->setClientObject(&m_client_info);
}
-
KX_RadarSensor::~KX_RadarSensor()
{
@@ -81,10 +80,7 @@ CValue* KX_RadarSensor::GetReplica()
{
KX_RadarSensor* replica = new KX_RadarSensor(*this);
replica->m_colliders = new CListValue();
- replica->m_bCollision = false;
- replica->m_bTriggered= false;
- replica->m_hitObject = NULL;
- replica->m_bLastTriggered = false;
+ replica->Init();
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
@@ -93,6 +89,10 @@ CValue* KX_RadarSensor::GetReplica()
if (replica->m_physCtrl)
{
replica->m_physCtrl = replica->m_physCtrl->GetReplica();
+ if (replica->m_physCtrl)
+ {
+ replica->m_physCtrl->setNewClientInfo(replica->m_client_info);
+ }
}
//todo: make sure replication works fine!
@@ -124,27 +124,48 @@ void KX_RadarSensor::SynchronizeTransform()
// depends on the radar 'axis'
switch (m_axis)
{
- case 0: // X Axis
+ case 0: // +X Axis
{
MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(90));
trans.rotate(rotquatje);
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
break;
};
- case 1: // Y Axis
+ case 1: // +Y Axis
{
MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180));
trans.rotate(rotquatje);
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
break;
};
- case 2: // Z Axis
+ case 2: // +Z Axis
{
MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-90));
trans.rotate(rotquatje);
trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
break;
};
+ case 3: // -X Axis
+ {
+ MT_Quaternion rotquatje(MT_Vector3(0,0,1),MT_radians(-90));
+ trans.rotate(rotquatje);
+ trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
+ break;
+ };
+ case 4: // -Y Axis
+ {
+ //MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(-180));
+ //trans.rotate(rotquatje);
+ trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
+ break;
+ };
+ case 5: // -Z Axis
+ {
+ MT_Quaternion rotquatje(MT_Vector3(1,0,0),MT_radians(90));
+ trans.rotate(rotquatje);
+ trans.translate(MT_Vector3 (0, -m_coneheight/2.0 ,0));
+ break;
+ };
default:
{
}
@@ -155,8 +176,10 @@ void KX_RadarSensor::SynchronizeTransform()
if (m_physCtrl)
{
- m_physCtrl->setPosition(trans.getOrigin().x(),trans.getOrigin().y(),trans.getOrigin().z());
- m_physCtrl->setOrientation(trans.getRotation().x(),trans.getRotation().y(),trans.getRotation().z(),trans.getRotation().w());
+ MT_Quaternion orn = trans.getRotation();
+ MT_Point3 pos = trans.getOrigin();
+ m_physCtrl->setPosition(pos[0],pos[1],pos[2]);
+ m_physCtrl->setOrientation(orn[0],orn[1],orn[2],orn[3]);
m_physCtrl->calcXform();
}
@@ -198,11 +221,11 @@ PyParentObject KX_RadarSensor::Parents[] = {
PyMethodDef KX_RadarSensor::Methods[] = {
{"getConeOrigin", (PyCFunction) KX_RadarSensor::sPyGetConeOrigin,
- METH_VARARGS, GetConeOrigin_doc},
+ METH_VARARGS, (PY_METHODCHAR)GetConeOrigin_doc},
{"getConeTarget", (PyCFunction) KX_RadarSensor::sPyGetConeTarget,
- METH_VARARGS, GetConeTarget_doc},
+ METH_VARARGS, (PY_METHODCHAR)GetConeTarget_doc},
{"getConeHeight", (PyCFunction) KX_RadarSensor::sPyGetConeHeight,
- METH_VARARGS, GetConeHeight_doc},
+ METH_VARARGS, (PY_METHODCHAR)GetConeHeight_doc},
{NULL,NULL,NULL,NULL} //Sentinel
};
@@ -211,7 +234,7 @@ PyObject* KX_RadarSensor::_getattr(const STR_String& attr) {
}
/* getConeOrigin */
-char KX_RadarSensor::GetConeOrigin_doc[] =
+const char KX_RadarSensor::GetConeOrigin_doc[] =
"getConeOrigin()\n"
"\tReturns the origin of the cone with which to test. The origin\n"
"\tis in the middle of the cone.";
@@ -228,7 +251,7 @@ PyObject* KX_RadarSensor::PyGetConeOrigin(PyObject* self,
}
/* getConeOrigin */
-char KX_RadarSensor::GetConeTarget_doc[] =
+const char KX_RadarSensor::GetConeTarget_doc[] =
"getConeTarget()\n"
"\tReturns the center of the bottom face of the cone with which to test.\n";
PyObject* KX_RadarSensor::PyGetConeTarget(PyObject* self,
@@ -244,7 +267,7 @@ PyObject* KX_RadarSensor::PyGetConeTarget(PyObject* self,
}
/* getConeOrigin */
-char KX_RadarSensor::GetConeHeight_doc[] =
+const char KX_RadarSensor::GetConeHeight_doc[] =
"getConeHeight()\n"
"\tReturns the height of the cone with which to test.\n";
PyObject* KX_RadarSensor::PyGetConeHeight(PyObject* self,
diff --git a/source/gameengine/Ketsji/KX_RayCast.cpp b/source/gameengine/Ketsji/KX_RayCast.cpp
index 288a936e1b1..974d4b992a6 100644
--- a/source/gameengine/Ketsji/KX_RayCast.cpp
+++ b/source/gameengine/Ketsji/KX_RayCast.cpp
@@ -29,6 +29,7 @@
*/
#include <stdlib.h>
+#include <stdio.h>
#include "KX_RayCast.h"
@@ -39,7 +40,21 @@
#include "PHY_IPhysicsEnvironment.h"
#include "PHY_IPhysicsController.h"
-bool KX_RayCast::RayTest(KX_IPhysicsController* ignore_controller, PHY_IPhysicsEnvironment* physics_environment, const MT_Point3& _frompoint, const MT_Point3& topoint, MT_Point3& result_point, MT_Vector3& result_normal, const KX_RayCast& callback)
+KX_RayCast::KX_RayCast(KX_IPhysicsController* ignoreController, bool faceNormal)
+ :PHY_IRayCastFilterCallback(dynamic_cast<PHY_IPhysicsController*>(ignoreController), faceNormal)
+{
+}
+
+void KX_RayCast::reportHit(PHY_RayCastResult* result)
+{
+ m_hitFound = true;
+ m_hitPoint.setValue((const float*)result->m_hitPoint);
+ m_hitNormal.setValue((const float*)result->m_hitNormal);
+ m_hitMesh = result->m_meshObject;
+ m_hitPolygon = result->m_polygon;
+}
+
+bool KX_RayCast::RayTest(PHY_IPhysicsEnvironment* physics_environment, const MT_Point3& _frompoint, const MT_Point3& topoint, KX_RayCast& callback)
{
// Loops over all physics objects between frompoint and topoint,
// calling callback.RayHit for each one.
@@ -48,51 +63,52 @@ bool KX_RayCast::RayTest(KX_IPhysicsController* ignore_controller, PHY_IPhysicsE
//
// returns true if an object was found, false if not.
MT_Point3 frompoint(_frompoint);
- const MT_Vector3 todir( (topoint - frompoint).normalized() );
+ const MT_Vector3 todir( (topoint - frompoint).safe_normalized() );
+ MT_Point3 prevpoint(_frompoint+todir*(-1.f));
PHY_IPhysicsController* hit_controller;
- PHY__Vector3 phy_pos;
- PHY__Vector3 phy_normal;
- while((hit_controller = physics_environment->rayTest(dynamic_cast<PHY_IPhysicsController*>(ignore_controller),
+ while((hit_controller = physics_environment->rayTest(callback,
frompoint.x(),frompoint.y(),frompoint.z(),
- topoint.x(),topoint.y(),topoint.z(),
- phy_pos[0],phy_pos[1],phy_pos[2],
- phy_normal[0],phy_normal[1],phy_normal[2])))
+ topoint.x(),topoint.y(),topoint.z())) != NULL)
{
- result_point = MT_Point3(phy_pos);
- result_normal = MT_Vector3(phy_normal);
KX_ClientObjectInfo* info = static_cast<KX_ClientObjectInfo*>(hit_controller->getNewClientInfo());
if (!info)
{
printf("no info!\n");
MT_assert(info && "Physics controller with no client object info");
- return false;
+ break;
}
- if (callback.RayHit(info, result_point, result_normal))
- return true;
-
-
- // skip past the object and keep tracing
- /* We add 0.01 of fudge, so that if the margin && radius == 0., we don't endless loop. */
- MT_Scalar marg = 0.01 + hit_controller->GetMargin();
- marg += 2.f * hit_controller->GetMargin();
+ // The biggest danger to to endless loop, prevent this by checking that the
+ // hit point always progresses along the ray direction..
+ prevpoint -= callback.m_hitPoint;
+ if (prevpoint.length2() < MT_EPSILON)
+ break;
+
+ if (callback.RayHit(info))
+ // caller may decide to stop the loop and still cancel the hit
+ return callback.m_hitFound;
+
+ // Skip past the object and keep tracing.
+ // Note that retrieving in a single shot multiple hit points would be possible
+ // but it would require some change in Bullet.
+ prevpoint = callback.m_hitPoint;
+ /* We add 0.001 of fudge, so that if the margin && radius == 0., we don't endless loop. */
+ MT_Scalar marg = 0.001 + hit_controller->GetMargin();
+ marg *= 2.f;
/* Calculate the other side of this object */
- PHY__Vector3 hitpos;
- hit_controller->getPosition(hitpos);
- MT_Point3 hitObjPos(hitpos);
-
- MT_Vector3 hitvector = hitObjPos - result_point;
- if (hitvector.dot(hitvector) > MT_EPSILON)
- {
- hitvector.normalize();
- marg *= 2.*todir.dot(hitvector);
- }
- frompoint = result_point + marg * todir;
+ MT_Scalar h = MT_abs(todir.dot(callback.m_hitNormal));
+ if (h <= 0.01)
+ // the normal is almost orthogonal to the ray direction, cannot compute the other side
+ break;
+ marg /= h;
+ frompoint = callback.m_hitPoint + marg * todir;
+ // verify that we are not passed the to point
+ if ((topoint - frompoint).dot(todir) < 0.f)
+ break;
}
-
- return hit_controller;
+ return false;
}
diff --git a/source/gameengine/Ketsji/KX_RayCast.h b/source/gameengine/Ketsji/KX_RayCast.h
index 607dabd8afc..c3084c997a1 100644
--- a/source/gameengine/Ketsji/KX_RayCast.h
+++ b/source/gameengine/Ketsji/KX_RayCast.h
@@ -30,12 +30,14 @@
#ifndef __KX_RAYCAST_H__
#define __KX_RAYCAST_H__
-class MT_Point3;
-class MT_Vector3;
-class KX_IPhysicsController;
-class PHY_IPhysicsEnvironment;
+#include "PHY_IPhysicsEnvironment.h"
+#include "PHY_IPhysicsController.h"
+#include "MT_Point3.h"
+#include "MT_Vector3.h"
+class RAS_MeshObject;
struct KX_ClientObjectInfo;
+class KX_IPhysicsController;
/**
* Defines a function for doing a ray cast.
@@ -49,17 +51,27 @@ struct KX_ClientObjectInfo;
*
* Returns true if a client was accepted, false if nothing found.
*/
-class KX_RayCast
+class KX_RayCast : public PHY_IRayCastFilterCallback
{
-protected:
- KX_RayCast() {};
public:
+ bool m_hitFound;
+ MT_Point3 m_hitPoint;
+ MT_Vector3 m_hitNormal;
+ const RAS_MeshObject* m_hitMesh;
+ int m_hitPolygon;
+
+ KX_RayCast(KX_IPhysicsController* ignoreController, bool faceNormal);
virtual ~KX_RayCast() {}
+ /**
+ * The physic environment returns the ray casting result through this function
+ */
+ virtual void reportHit(PHY_RayCastResult* result);
+
/** ray test callback.
* either override this in your class, or use a callback wrapper.
*/
- virtual bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal) const = 0;
+ virtual bool RayHit(KX_ClientObjectInfo* client) = 0;
/**
* Callback wrapper.
@@ -71,13 +83,11 @@ public:
/// Public interface.
/// Implement bool RayHit in your class to receive ray callbacks.
- static bool RayTest(KX_IPhysicsController* physics_controller,
+ static bool RayTest(
PHY_IPhysicsEnvironment* physics_environment,
- const MT_Point3& _frompoint,
+ const MT_Point3& frompoint,
const MT_Point3& topoint,
- MT_Point3& result_point,
- MT_Vector3& result_normal,
- const KX_RayCast& callback);
+ KX_RayCast& callback);
};
@@ -86,18 +96,32 @@ template<class T> class KX_RayCast::Callback : public KX_RayCast
T *self;
void *data;
public:
- Callback(T *_self, void *_data = NULL)
- : self(_self),
+ Callback(T *_self, KX_IPhysicsController* controller=NULL, void *_data = NULL, bool faceNormal=false)
+ : KX_RayCast(controller, faceNormal),
+ self(_self),
data(_data)
{
}
~Callback() {}
-
- virtual bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal) const
+
+ virtual bool RayHit(KX_ClientObjectInfo* client)
{
- return self->RayHit(client, hit_point, hit_normal, data);
+ return self->RayHit(client, this, data);
}
+
+ virtual bool needBroadphaseRayCast(PHY_IPhysicsController* controller)
+ {
+ KX_ClientObjectInfo* info = static_cast<KX_ClientObjectInfo*>(controller->getNewClientInfo());
+
+ if (!info)
+ {
+ MT_assert(info && "Physics controller with no client object info");
+ return false;
+ }
+ return self->NeedRayCast(info);
+ }
+
};
diff --git a/source/gameengine/Ketsji/KX_RayEventManager.cpp b/source/gameengine/Ketsji/KX_RayEventManager.cpp
index 4101c6b547e..1af29151adf 100644
--- a/source/gameengine/Ketsji/KX_RayEventManager.cpp
+++ b/source/gameengine/Ketsji/KX_RayEventManager.cpp
@@ -44,14 +44,9 @@ using namespace std;
void KX_RayEventManager::NextFrame()
{
- for (vector<class SCA_ISensor*>::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++)
+ for (set<class SCA_ISensor*>::const_iterator i= m_sensors.begin();!(i==m_sensors.end());i++)
{
- SCA_ISensor *sensor = *i;
- sensor->Activate(m_logicmgr, NULL);
+ (*i)->Activate(m_logicmgr, NULL);
}
}
-void KX_RayEventManager::RegisterSensor(SCA_ISensor* sensor)
-{
- m_sensors.push_back(sensor);
-};
diff --git a/source/gameengine/Ketsji/KX_RayEventManager.h b/source/gameengine/Ketsji/KX_RayEventManager.h
index 3630f9682b9..b816d4d5250 100644
--- a/source/gameengine/Ketsji/KX_RayEventManager.h
+++ b/source/gameengine/Ketsji/KX_RayEventManager.h
@@ -45,7 +45,6 @@ public:
m_logicmgr(logicmgr)
{}
virtual void NextFrame();
- virtual void RegisterSensor(SCA_ISensor* sensor);
};
#endif //__KX_RAYEVENTMGR
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp
index 4ccb02d34ec..e24fb773eac 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.cpp
+++ b/source/gameengine/Ketsji/KX_RaySensor.cpp
@@ -51,6 +51,7 @@ KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr,
SCA_IObject* gameobj,
const STR_String& propname,
bool bFindMaterial,
+ bool bXRay,
double distance,
int axis,
KX_Scene* ketsjiScene,
@@ -58,19 +59,23 @@ KX_RaySensor::KX_RaySensor(class SCA_EventManager* eventmgr,
: SCA_ISensor(gameobj,eventmgr, T),
m_propertyname(propname),
m_bFindMaterial(bFindMaterial),
+ m_bXRay(bXRay),
m_distance(distance),
m_scene(ketsjiScene),
- m_bTriggered(false),
- m_axis(axis),
- m_rayHit(false),
- m_hitObject(NULL)
+ m_axis(axis)
{
-
+ Init();
}
-
+void KX_RaySensor::Init()
+{
+ m_bTriggered = (m_invert)?true:false;
+ m_rayHit = false;
+ m_hitObject = NULL;
+ m_reset = true;
+}
KX_RaySensor::~KX_RaySensor()
{
@@ -81,9 +86,10 @@ KX_RaySensor::~KX_RaySensor()
CValue* KX_RaySensor::GetReplica()
{
- CValue* replica = new KX_RaySensor(*this);
+ KX_RaySensor* replica = new KX_RaySensor(*this);
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
+ replica->Init();
return replica;
}
@@ -100,16 +106,10 @@ bool KX_RaySensor::IsPositiveTrigger()
return result;
}
-bool KX_RaySensor::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data)
+bool KX_RaySensor::RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data)
{
KX_GameObject* hitKXObj = client->m_gameobject;
-
- if (client->m_type > KX_ClientObjectInfo::ACTOR)
- {
- // false hit
- return false;
- }
bool bFound = false;
if (m_propertyname.Length() == 0)
@@ -135,20 +135,48 @@ bool KX_RaySensor::RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_
{
m_rayHit = true;
m_hitObject = hitKXObj;
- m_hitPosition = hit_point;
- m_hitNormal = hit_normal;
+ m_hitPosition = result->m_hitPoint;
+ m_hitNormal = result->m_hitNormal;
}
-
+ // no multi-hit search yet
return true;
-
}
-
+/* 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_RaySensor::NeedRayCast(KX_ClientObjectInfo* client)
+{
+ if (client->m_type > KX_ClientObjectInfo::ACTOR)
+ {
+ // Unknown type of object, skip it.
+ // Should not occur as the sensor objects are filtered in RayTest()
+ printf("Invalid client type %d found ray casting\n", client->m_type);
+ return false;
+ }
+ if (m_bXRay && m_propertyname.Length() != 0)
+ {
+ if (m_bFindMaterial)
+ {
+ // not quite correct: an object may have multiple material
+ // should check all the material and not only the first one
+ if (!client->m_auxilary_info || (m_propertyname != ((char*)client->m_auxilary_info)))
+ return false;
+ }
+ else
+ {
+ if (client->m_gameobject->GetProperty(m_propertyname) == NULL)
+ return false;
+ }
+ }
+ return true;
+}
bool KX_RaySensor::Evaluate(CValue* event)
{
bool result = false;
+ bool reset = m_reset && m_level;
m_rayHit = false;
m_hitObject = NULL;
m_hitPosition = MT_Vector3(0,0,0);
@@ -160,6 +188,7 @@ bool KX_RaySensor::Evaluate(CValue* event)
MT_Matrix3x3 invmat = matje.inverse();
MT_Vector3 todir;
+ m_reset = false;
switch (m_axis)
{
case 1: // X
@@ -209,8 +238,6 @@ bool KX_RaySensor::Evaluate(CValue* event)
m_rayDirection = todir;
MT_Point3 topoint = frompoint + (m_distance) * todir;
- MT_Point3 resultpoint;
- MT_Vector3 resultnormal;
PHY_IPhysicsEnvironment* pe = m_scene->GetPhysicsEnvironment();
if (!pe)
@@ -232,7 +259,8 @@ bool KX_RaySensor::Evaluate(CValue* event)
PHY_IPhysicsEnvironment* physics_environment = this->m_scene->GetPhysicsEnvironment();
- result = KX_RayCast::RayTest(spc, physics_environment, frompoint, topoint, resultpoint, resultnormal, KX_RayCast::Callback<KX_RaySensor>(this));
+ KX_RayCast::Callback<KX_RaySensor> callback(this, spc);
+ KX_RayCast::RayTest(physics_environment, frompoint, topoint, callback);
/* now pass this result to some controller */
@@ -259,9 +287,15 @@ bool KX_RaySensor::Evaluate(CValue* event)
// notify logicsystem that ray JUST left the Object
result = true;
}
+ else
+ {
+ result = false;
+ }
}
-
+ if (reset)
+ // force an event
+ result = true;
return result;
}
@@ -301,14 +335,14 @@ PyParentObject KX_RaySensor::Parents[] = {
};
PyMethodDef KX_RaySensor::Methods[] = {
- {"getHitObject",(PyCFunction) KX_RaySensor::sPyGetHitObject,METH_VARARGS, GetHitObject_doc},
- {"getHitPosition",(PyCFunction) KX_RaySensor::sPyGetHitPosition,METH_VARARGS, GetHitPosition_doc},
- {"getHitNormal",(PyCFunction) KX_RaySensor::sPyGetHitNormal,METH_VARARGS, GetHitNormal_doc},
- {"getRayDirection",(PyCFunction) KX_RaySensor::sPyGetRayDirection,METH_VARARGS, GetRayDirection_doc},
+ {"getHitObject",(PyCFunction) KX_RaySensor::sPyGetHitObject,METH_VARARGS, (PY_METHODCHAR)GetHitObject_doc},
+ {"getHitPosition",(PyCFunction) KX_RaySensor::sPyGetHitPosition,METH_VARARGS, (PY_METHODCHAR)GetHitPosition_doc},
+ {"getHitNormal",(PyCFunction) KX_RaySensor::sPyGetHitNormal,METH_VARARGS, (PY_METHODCHAR)GetHitNormal_doc},
+ {"getRayDirection",(PyCFunction) KX_RaySensor::sPyGetRayDirection,METH_VARARGS, (PY_METHODCHAR)GetRayDirection_doc},
{NULL,NULL} //Sentinel
};
-char KX_RaySensor::GetHitObject_doc[] =
+const char KX_RaySensor::GetHitObject_doc[] =
"getHitObject()\n"
"\tReturns the name of the object that was hit by this ray.\n";
PyObject* KX_RaySensor::PyGetHitObject(PyObject* self,
@@ -323,7 +357,7 @@ PyObject* KX_RaySensor::PyGetHitObject(PyObject* self,
}
-char KX_RaySensor::GetHitPosition_doc[] =
+const char KX_RaySensor::GetHitPosition_doc[] =
"getHitPosition()\n"
"\tReturns the position (in worldcoordinates) where the object was hit by this ray.\n";
PyObject* KX_RaySensor::PyGetHitPosition(PyObject* self,
@@ -343,7 +377,7 @@ PyObject* KX_RaySensor::PyGetHitPosition(PyObject* self,
}
-char KX_RaySensor::GetRayDirection_doc[] =
+const char KX_RaySensor::GetRayDirection_doc[] =
"getRayDirection()\n"
"\tReturns the direction from the ray (in worldcoordinates) .\n";
PyObject* KX_RaySensor::PyGetRayDirection(PyObject* self,
@@ -363,7 +397,7 @@ PyObject* KX_RaySensor::PyGetRayDirection(PyObject* self,
}
-char KX_RaySensor::GetHitNormal_doc[] =
+const char KX_RaySensor::GetHitNormal_doc[] =
"getHitNormal()\n"
"\tReturns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.\n";
PyObject* KX_RaySensor::PyGetHitNormal(PyObject* self,
diff --git a/source/gameengine/Ketsji/KX_RaySensor.h b/source/gameengine/Ketsji/KX_RaySensor.h
index 8a317ffaa07..02a755fedc1 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.h
+++ b/source/gameengine/Ketsji/KX_RaySensor.h
@@ -36,12 +36,14 @@
#include "MT_Point3.h"
struct KX_ClientObjectInfo;
+class KX_RayCast;
class KX_RaySensor : public SCA_ISensor
{
Py_Header;
STR_String m_propertyname;
bool m_bFindMaterial;
+ bool m_bXRay;
double m_distance;
class KX_Scene* m_scene;
bool m_bTriggered;
@@ -56,7 +58,8 @@ public:
KX_RaySensor(class SCA_EventManager* eventmgr,
SCA_IObject* gameobj,
const STR_String& propname,
- bool fFindMaterial,
+ bool bFindMaterial,
+ bool bXRay,
double distance,
int axis,
class KX_Scene* ketsjiScene,
@@ -66,8 +69,10 @@ public:
virtual bool Evaluate(CValue* event);
virtual bool IsPositiveTrigger();
+ virtual void Init();
- bool RayHit(KX_ClientObjectInfo* client, MT_Point3& hit_point, MT_Vector3& hit_normal, void * const data);
+ bool RayHit(KX_ClientObjectInfo* client, KX_RayCast* result, void * const data);
+ bool NeedRayCast(KX_ClientObjectInfo* client);
KX_PYMETHOD_DOC(KX_RaySensor,GetHitObject);
KX_PYMETHOD_DOC(KX_RaySensor,GetHitPosition);
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
index b31fe16d05d..5777f54b799 100644
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.cpp
@@ -39,6 +39,8 @@
#include "KX_GameObject.h"
#include "KX_IPhysicsController.h"
+#include "PyObjectPlus.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -48,19 +50,28 @@
/* ------------------------------------------------------------------------- */
KX_SCA_AddObjectActuator::KX_SCA_AddObjectActuator(SCA_IObject *gameobj,
- CValue* original,
+ SCA_IObject *original,
int time,
SCA_IScene* scene,
const MT_Vector3& linvel,
- bool local,
+ bool linv_local,
+ const MT_Vector3& angvel,
+ bool angv_local,
PyTypeObject* T)
:
SCA_IActuator(gameobj, T),
m_OriginalObject(original),
m_scene(scene),
+
m_linear_velocity(linvel),
- m_localFlag(local)
+ m_localLinvFlag(linv_local),
+
+ m_angular_velocity(angvel),
+ m_localAngvFlag(angv_local)
{
+ if (m_OriginalObject)
+ m_OriginalObject->RegisterActuator(this);
+
m_lastCreatedObject = NULL;
m_timeProp = time;
}
@@ -69,6 +80,8 @@ KX_SCA_AddObjectActuator::KX_SCA_AddObjectActuator(SCA_IObject *gameobj,
KX_SCA_AddObjectActuator::~KX_SCA_AddObjectActuator()
{
+ if (m_OriginalObject)
+ m_OriginalObject->UnregisterActuator(this);
if (m_lastCreatedObject)
m_lastCreatedObject->Release();
}
@@ -108,12 +121,40 @@ CValue* KX_SCA_AddObjectActuator::GetReplica()
// this will copy properties and so on...
replica->ProcessReplica();
- replica->m_lastCreatedObject=NULL;
CValue::AddDataToReplica(replica);
return replica;
}
+void KX_SCA_AddObjectActuator::ProcessReplica()
+{
+ if (m_OriginalObject)
+ m_OriginalObject->RegisterActuator(this);
+ m_lastCreatedObject=NULL;
+ SCA_IActuator::ProcessReplica();
+}
+
+bool KX_SCA_AddObjectActuator::UnlinkObject(SCA_IObject* clientobj)
+{
+ if (clientobj == m_OriginalObject)
+ {
+ // this object is being deleted, we cannot continue to track it.
+ m_OriginalObject = NULL;
+ return true;
+ }
+ return false;
+}
+
+void KX_SCA_AddObjectActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
+{
+ void **h_obj = (*obj_map)[m_OriginalObject];
+ if (h_obj) {
+ if (m_OriginalObject)
+ m_OriginalObject->UnregisterActuator(this);
+ m_OriginalObject = (SCA_IObject*)(*h_obj);
+ m_OriginalObject->RegisterActuator(this);
+ }
+}
/* ------------------------------------------------------------------------- */
@@ -147,14 +188,16 @@ PyParentObject KX_SCA_AddObjectActuator::Parents[] = {
NULL
};
PyMethodDef KX_SCA_AddObjectActuator::Methods[] = {
- {"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_VARARGS, SetObject_doc},
- {"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_VARARGS, SetTime_doc},
- {"getObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetObject, METH_VARARGS, GetObject_doc},
- {"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_VARARGS, GetTime_doc},
- {"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_VARARGS, GetLinearVelocity_doc},
- {"setLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetLinearVelocity, METH_VARARGS, SetLinearVelocity_doc},
- {"getLastCreatedObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLastCreatedObject, METH_VARARGS,"getLastCreatedObject() : get the object handle to the last created object\n"},
- {"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_VARARGS,"instantAddObject() : immediately add object without delay\n"},
+ {"setObject", (PyCFunction) KX_SCA_AddObjectActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc},
+ {"setTime", (PyCFunction) KX_SCA_AddObjectActuator::sPySetTime, METH_O, (PY_METHODCHAR)SetTime_doc},
+ {"getObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc},
+ {"getTime", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetTime, METH_NOARGS, (PY_METHODCHAR)GetTime_doc},
+ {"getLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLinearVelocity, METH_NOARGS, (PY_METHODCHAR)GetLinearVelocity_doc},
+ {"setLinearVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetLinearVelocity, METH_VARARGS, (PY_METHODCHAR)SetLinearVelocity_doc},
+ {"getAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetAngularVelocity, METH_NOARGS, (PY_METHODCHAR)GetAngularVelocity_doc},
+ {"setAngularVelocity", (PyCFunction) KX_SCA_AddObjectActuator::sPySetAngularVelocity, METH_VARARGS, (PY_METHODCHAR)SetAngularVelocity_doc},
+ {"getLastCreatedObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyGetLastCreatedObject, METH_NOARGS,"getLastCreatedObject() : get the object handle to the last created object\n"},
+ {"instantAddObject", (PyCFunction) KX_SCA_AddObjectActuator::sPyInstantAddObject, METH_NOARGS,"instantAddObject() : immediately add object without delay\n"},
{NULL,NULL} //Sentinel
};
@@ -166,114 +209,101 @@ PyObject* KX_SCA_AddObjectActuator::_getattr(const STR_String& attr)
}
/* 1. setObject */
-char KX_SCA_AddObjectActuator::SetObject_doc[] =
-"setObject(name)\n"
-"\t- name: string\n"
+const char KX_SCA_AddObjectActuator::SetObject_doc[] =
+"setObject(object)\n"
+"\t- object: KX_GameObject, string or None\n"
"\tSets the object that will be added. There has to be an object\n"
"\tof this name. If not, this function does nothing.\n";
-
-
-
-PyObject* KX_SCA_AddObjectActuator::PySetObject(PyObject* self,
- PyObject* args,
- PyObject* kwds)
-{
- PyObject* gameobj;
- if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj))
- {
- m_OriginalObject = (CValue*)gameobj;
- Py_Return;
- }
- PyErr_Clear();
+PyObject* KX_SCA_AddObjectActuator::PySetObject(PyObject* self, PyObject* value)
+{
+ KX_GameObject *gameobj;
- char* objectname;
- if (PyArg_ParseTuple(args, "s", &objectname))
- {
- m_OriginalObject= (CValue*)SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname));;
-
- Py_Return;
- }
+ if (!ConvertPythonToGameObject(value, &gameobj, true))
+ return NULL; // ConvertPythonToGameObject sets the error
+
+ if (m_OriginalObject != NULL)
+ m_OriginalObject->UnregisterActuator(this);
+
+ m_OriginalObject = (SCA_IObject*)gameobj;
+ if (m_OriginalObject)
+ m_OriginalObject->RegisterActuator(this);
- return NULL;
+ Py_RETURN_NONE;
}
/* 2. setTime */
-char KX_SCA_AddObjectActuator::SetTime_doc[] =
+const char KX_SCA_AddObjectActuator::SetTime_doc[] =
"setTime(duration)\n"
"\t- duration: integer\n"
"\tSets the lifetime of the object that will be added, in frames. \n"
"\tIf the duration is negative, it is set to 0.\n";
-PyObject* KX_SCA_AddObjectActuator::PySetTime(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_SCA_AddObjectActuator::PySetTime(PyObject* self, PyObject* value)
{
- int deltatime;
-
- if (!PyArg_ParseTuple(args, "i", &deltatime))
+ int deltatime = PyInt_AsLong(value);
+ if (deltatime==-1 && PyErr_Occurred()) {
+ PyErr_SetString(PyExc_TypeError, "expected an int");
return NULL;
+ }
m_timeProp = deltatime;
if (m_timeProp < 0) m_timeProp = 0;
- Py_Return;
+ Py_RETURN_NONE;
}
/* 3. getTime */
-char KX_SCA_AddObjectActuator::GetTime_doc[] =
+const char KX_SCA_AddObjectActuator::GetTime_doc[] =
"GetTime()\n"
"\tReturns the lifetime of the object that will be added.\n";
-PyObject* KX_SCA_AddObjectActuator::PyGetTime(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_SCA_AddObjectActuator::PyGetTime(PyObject* self)
{
return PyInt_FromLong(m_timeProp);
}
/* 4. getObject */
-char KX_SCA_AddObjectActuator::GetObject_doc[] =
-"getObject()\n"
+const char KX_SCA_AddObjectActuator::GetObject_doc[] =
+"getObject(name_only = 1)\n"
+"name_only - optional arg, when true will return the KX_GameObject rather then its name\n"
"\tReturns the name of the object that will be added.\n";
-
-
-
-PyObject* KX_SCA_AddObjectActuator::PyGetObject(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_SCA_AddObjectActuator::PyGetObject(PyObject* self, PyObject* args)
{
+ int ret_name_only = 1;
+ if (!PyArg_ParseTuple(args, "|i", &ret_name_only))
+ return NULL;
+
if (!m_OriginalObject)
- Py_Return;
-
- return PyString_FromString(m_OriginalObject->GetName());
+ Py_RETURN_NONE;
+
+ if (ret_name_only)
+ return PyString_FromString(m_OriginalObject->GetName());
+ else
+ return m_OriginalObject->AddRef();
}
/* 5. getLinearVelocity */
-char KX_SCA_AddObjectActuator::GetLinearVelocity_doc[] =
+const char KX_SCA_AddObjectActuator::GetLinearVelocity_doc[] =
"GetLinearVelocity()\n"
"\tReturns the linear velocity that will be assigned to \n"
"\tthe created object.\n";
-
-
-PyObject* KX_SCA_AddObjectActuator::PyGetLinearVelocity(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_SCA_AddObjectActuator::PyGetLinearVelocity(PyObject* self)
{
PyObject *retVal = PyList_New(3);
- PyList_SetItem(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0]));
- PyList_SetItem(retVal, 1, PyFloat_FromDouble(m_linear_velocity[1]));
- PyList_SetItem(retVal, 2, PyFloat_FromDouble(m_linear_velocity[2]));
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_linear_velocity[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_linear_velocity[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_linear_velocity[2]));
return retVal;
}
@@ -281,17 +311,15 @@ PyObject* KX_SCA_AddObjectActuator::PyGetLinearVelocity(PyObject* self,
/* 6. setLinearVelocity */
-char KX_SCA_AddObjectActuator::SetLinearVelocity_doc[] =
+const char KX_SCA_AddObjectActuator::SetLinearVelocity_doc[] =
"setLinearVelocity(vx, vy, vz)\n"
"\t- vx: float\n"
"\t- vy: float\n"
"\t- vz: float\n"
+"\t- local: bool\n"
"\tAssign this velocity to the created object. \n";
-
-PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* self, PyObject* args)
{
float vecArg[3];
@@ -299,7 +327,46 @@ PyObject* KX_SCA_AddObjectActuator::PySetLinearVelocity(PyObject* self,
return NULL;
m_linear_velocity.setValue(vecArg);
- Py_Return;
+ Py_RETURN_NONE;
+}
+
+/* 7. getAngularVelocity */
+const char KX_SCA_AddObjectActuator::GetAngularVelocity_doc[] =
+"GetAngularVelocity()\n"
+"\tReturns the angular velocity that will be assigned to \n"
+"\tthe created object.\n";
+
+PyObject* KX_SCA_AddObjectActuator::PyGetAngularVelocity(PyObject* self)
+{
+ PyObject *retVal = PyList_New(3);
+
+ PyList_SET_ITEM(retVal, 0, PyFloat_FromDouble(m_angular_velocity[0]));
+ PyList_SET_ITEM(retVal, 1, PyFloat_FromDouble(m_angular_velocity[1]));
+ PyList_SET_ITEM(retVal, 2, PyFloat_FromDouble(m_angular_velocity[2]));
+
+ return retVal;
+}
+
+
+
+/* 8. setAngularVelocity */
+const char KX_SCA_AddObjectActuator::SetAngularVelocity_doc[] =
+"setAngularVelocity(vx, vy, vz)\n"
+"\t- vx: float\n"
+"\t- vy: float\n"
+"\t- vz: float\n"
+"\t- local: bool\n"
+"\tAssign this angular velocity to the created object. \n";
+
+PyObject* KX_SCA_AddObjectActuator::PySetAngularVelocity(PyObject* self, PyObject* args)
+{
+
+ float vecArg[3];
+ if (!PyArg_ParseTuple(args, "fff", &vecArg[0], &vecArg[1], &vecArg[2]))
+ return NULL;
+
+ m_angular_velocity.setValue(vecArg);
+ Py_RETURN_NONE;
}
void KX_SCA_AddObjectActuator::InstantAddObject()
@@ -310,8 +377,9 @@ void KX_SCA_AddObjectActuator::InstantAddObject()
// Now it needs to be added to the current scene.
SCA_IObject* replica = m_scene->AddReplicaObject(m_OriginalObject,GetParent(),m_timeProp );
KX_GameObject * game_obj = static_cast<KX_GameObject *>(replica);
- game_obj->setLinearVelocity(m_linear_velocity,m_localFlag);
- game_obj->ResolveCombinedVelocities(m_linear_velocity, MT_Vector3(0., 0., 0.), m_localFlag, false);
+ game_obj->setLinearVelocity(m_linear_velocity,m_localLinvFlag);
+ game_obj->setAngularVelocity(m_angular_velocity,m_localAngvFlag);
+ game_obj->ResolveCombinedVelocities(m_linear_velocity, m_angular_velocity, m_localLinvFlag, m_localAngvFlag);
// keep a copy of the last object, to allow python scripters to change it
if (m_lastCreatedObject)
@@ -323,36 +391,37 @@ void KX_SCA_AddObjectActuator::InstantAddObject()
m_lastCreatedObject = replica;
m_lastCreatedObject->AddRef();
+ // finished using replica? then release it
+ replica->Release();
}
}
-PyObject* KX_SCA_AddObjectActuator::PyInstantAddObject(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_SCA_AddObjectActuator::PyInstantAddObject(PyObject* self)
{
InstantAddObject();
- Py_Return;
+ Py_RETURN_NONE;
}
/* 7. GetLastCreatedObject */
-char KX_SCA_AddObjectActuator::GetLastCreatedObject_doc[] =
+const char KX_SCA_AddObjectActuator::GetLastCreatedObject_doc[] =
"getLastCreatedObject()\n"
"\tReturn the last created object. \n";
-PyObject* KX_SCA_AddObjectActuator::PyGetLastCreatedObject(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_SCA_AddObjectActuator::PyGetLastCreatedObject(PyObject* self)
{
SCA_IObject* result = this->GetLastCreatedObject();
- if (result)
+
+ // if result->GetSGNode() is NULL
+ // it means the object has ended, The BGE python api crashes in many places if the object is returned.
+ if (result && (static_cast<KX_GameObject *>(result))->GetSGNode())
{
result->AddRef();
return result;
}
// don't return NULL to python anymore, it gives trouble in the scripts
- Py_Return;
+ Py_RETURN_NONE;
}
diff --git a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
index 2126a646303..278d4180284 100644
--- a/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_AddObjectActuator.h
@@ -53,16 +53,20 @@ class KX_SCA_AddObjectActuator : public SCA_IActuator
int m_timeProp;
/// Original object reference (object to replicate)
- CValue* m_OriginalObject;
+ SCA_IObject* m_OriginalObject;
/// Object will be added to the following scene
SCA_IScene* m_scene;
/// Linear velocity upon creation of the object.
MT_Vector3 m_linear_velocity;
+
+ /// Angular velocity upon creation of the object.
+ MT_Vector3 m_angular_velocity;
/// Apply the velocity locally
- bool m_localFlag;
+ bool m_localLinvFlag;
+ bool m_localAngvFlag;
SCA_IObject* m_lastCreatedObject;
@@ -75,11 +79,13 @@ public:
KX_SCA_AddObjectActuator(
SCA_IObject *gameobj,
- CValue* original,
+ SCA_IObject *original,
int time,
SCA_IScene* scene,
const MT_Vector3& linvel,
- bool local,
+ bool linv_local,
+ const MT_Vector3& angvel,
+ bool angv_local,
PyTypeObject* T=&Type
);
@@ -89,6 +95,15 @@ public:
GetReplica(
) ;
+ virtual void
+ ProcessReplica();
+
+ virtual bool
+ UnlinkObject(SCA_IObject* clientobj);
+
+ virtual void
+ Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map);
+
virtual bool
Update();
@@ -104,21 +119,25 @@ public:
void InstantAddObject();
/* 1. setObject */
- KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,SetObject);
+ KX_PYMETHOD_DOC_O(KX_SCA_AddObjectActuator,SetObject);
/* 2. setTime */
- KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,SetTime);
+ KX_PYMETHOD_DOC_O(KX_SCA_AddObjectActuator,SetTime);
/* 3. getTime */
- KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetTime);
+ KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,GetTime);
/* 4. getObject */
- KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetObject);
+ KX_PYMETHOD_DOC_VARARGS(KX_SCA_AddObjectActuator,GetObject);
/* 5. getLinearVelocity */
- KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetLinearVelocity);
+ KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,GetLinearVelocity);
/* 6. setLinearVelocity */
- KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,SetLinearVelocity);
- /* 7. getLastCreatedObject */
- KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,GetLastCreatedObject);
- /* 8. instantAddObject*/
- KX_PYMETHOD_DOC(KX_SCA_AddObjectActuator,InstantAddObject);
+ KX_PYMETHOD_DOC_VARARGS(KX_SCA_AddObjectActuator,SetLinearVelocity);
+ /* 7. getAngularVelocity */
+ KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,GetAngularVelocity);
+ /* 8. setAngularVelocity */
+ KX_PYMETHOD_DOC_VARARGS(KX_SCA_AddObjectActuator,SetAngularVelocity);
+ /* 9. getLastCreatedObject */
+ KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,GetLastCreatedObject);
+ /* 10. instantAddObject*/
+ KX_PYMETHOD_DOC_NOARGS(KX_SCA_AddObjectActuator,InstantAddObject);
}; /* end of class KX_SCA_AddObjectActuator : public KX_EditObjectActuator */
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
new file mode 100644
index 00000000000..d44ab477749
--- /dev/null
+++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.cpp
@@ -0,0 +1,206 @@
+//
+// Adjust dynamics settins for this object
+//
+// $Id$
+//
+// ***** BEGIN GPL LICENSE BLOCK *****
+//
+// 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
+// of the License, or (at your option) any later version.
+//
+// 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,
+// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// 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.
+//
+// ***** END GPL LICENSE BLOCK *****
+
+//
+// Previously existed as:
+
+// \source\gameengine\GameLogic\SCA_DynamicActuator.cpp
+
+// Please look here for revision history.
+
+#include "KX_SCA_DynamicActuator.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/* ------------------------------------------------------------------------- */
+/* Python functions */
+/* ------------------------------------------------------------------------- */
+
+/* Integration hooks ------------------------------------------------------- */
+
+ PyTypeObject
+
+KX_SCA_DynamicActuator::
+
+Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "KX_SCA_DynamicActuator",
+ sizeof(KX_SCA_DynamicActuator),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0,
+ __repr,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject KX_SCA_DynamicActuator::Parents[] = {
+ &KX_SCA_DynamicActuator::Type,
+ &SCA_IActuator::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+
+PyMethodDef KX_SCA_DynamicActuator::Methods[] = {
+ KX_PYMETHODTABLE(KX_SCA_DynamicActuator, setOperation),
+ KX_PYMETHODTABLE(KX_SCA_DynamicActuator, getOperation),
+ {NULL,NULL} //Sentinel
+};
+
+
+
+PyObject* KX_SCA_DynamicActuator::_getattr(const STR_String& attr)
+{
+ _getattr_up(SCA_IActuator);
+}
+
+
+
+/* 1. setOperation */
+KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, setOperation,
+"setOperation(operation?)\n"
+"\t - operation? : type of dynamic operation\n"
+"\t 0 = restore dynamics\n"
+"\t 1 = disable dynamics\n"
+"\t 2 = enable rigid body\n"
+"\t 3 = disable rigid body\n"
+"Change the dynamic status of the parent object.\n")
+{
+ int dyn_operation;
+
+ if (!PyArg_ParseTuple(args, "i", &dyn_operation))
+ {
+ return NULL;
+ }
+ if (dyn_operation <0 || dyn_operation>3) {
+ PyErr_SetString(PyExc_IndexError, "Dynamic Actuator's setOperation() range must be between 0 and 3");
+ return NULL;
+ }
+ m_dyn_operation= dyn_operation;
+ Py_Return;
+}
+
+KX_PYMETHODDEF_DOC(KX_SCA_DynamicActuator, getOperation,
+"getOperation() -> integer\n"
+"Returns the operation type of this actuator.\n"
+)
+{
+ return PyInt_FromLong((long)m_dyn_operation);
+}
+
+
+/* ------------------------------------------------------------------------- */
+/* Native functions */
+/* ------------------------------------------------------------------------- */
+
+KX_SCA_DynamicActuator::KX_SCA_DynamicActuator(SCA_IObject *gameobj,
+ short dyn_operation,
+ PyTypeObject* T) :
+
+ SCA_IActuator(gameobj, T),
+ m_dyn_operation(dyn_operation)
+{
+} /* End of constructor */
+
+
+KX_SCA_DynamicActuator::~KX_SCA_DynamicActuator()
+{
+ // there's nothing to be done here, really....
+} /* end of destructor */
+
+
+
+bool KX_SCA_DynamicActuator::Update()
+{
+ // bool result = false; /*unused*/
+ KX_GameObject *obj = (KX_GameObject*) GetParent();
+ bool bNegativeEvent = IsNegativeEvent();
+ KX_IPhysicsController* controller;
+ RemoveAllEvents();
+
+ if (bNegativeEvent)
+ return false; // do nothing on negative events
+
+ if (!obj)
+ return false; // object not accessible, shouldnt happen
+ controller = obj->GetPhysicsController();
+ if (!controller)
+ return false; // no physic object
+
+ switch (m_dyn_operation)
+ {
+ case 0:
+ obj->RestoreDynamics();
+ break;
+ case 1:
+ obj->SuspendDynamics();
+ break;
+ case 2:
+ controller->setRigidBody(true);
+ break;
+ case 3:
+ controller->setRigidBody(false);
+ break;
+ }
+
+ return false;
+}
+
+
+
+CValue* KX_SCA_DynamicActuator::GetReplica()
+{
+ KX_SCA_DynamicActuator* replica =
+ new KX_SCA_DynamicActuator(*this);
+
+ if (replica == NULL)
+ return NULL;
+
+ replica->ProcessReplica();
+
+ // this will copy properties and so on...
+ CValue::AddDataToReplica(replica);
+
+ return replica;
+};
+
+
+/* eof */
diff --git a/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
new file mode 100644
index 00000000000..b47c3a511d9
--- /dev/null
+++ b/source/gameengine/Ketsji/KX_SCA_DynamicActuator.h
@@ -0,0 +1,76 @@
+//
+// Add object to the game world on action of this actuator
+//
+// $Id$
+//
+// ***** BEGIN GPL LICENSE BLOCK *****
+//
+// 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
+// of the License, or (at your option) any later version.
+//
+// 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,
+// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// 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): Campbell Barton
+//
+// ***** END GPL LICENSE BLOCK *****
+//
+
+#ifndef __KX_SCA_DYNAMICACTUATOR
+#define __KX_SCA_DYNAMICACTUATOR
+
+#include "SCA_IActuator.h"
+#include "SCA_PropertyActuator.h"
+#include "SCA_LogicManager.h"
+
+#include "KX_GameObject.h"
+#include "KX_IPhysicsController.h"
+
+class KX_SCA_DynamicActuator : public SCA_IActuator
+{
+ Py_Header;
+
+ // dynamics operation to apply to the game object
+ short m_dyn_operation;
+ public:
+ KX_SCA_DynamicActuator(
+ SCA_IObject* gameobj,
+ short dyn_operation,
+ PyTypeObject* T=&Type
+ );
+
+ ~KX_SCA_DynamicActuator(
+ );
+
+ CValue*
+ GetReplica(
+ );
+
+ virtual bool
+ Update();
+
+ virtual PyObject*
+ _getattr(
+ const STR_String& attr
+ );
+
+ /* 1. setOperation */
+ KX_PYMETHOD_DOC(KX_SCA_DynamicActuator,setOperation);
+ KX_PYMETHOD_DOC(KX_SCA_DynamicActuator,getOperation);
+
+};
+
+#endif
diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
index 630df2d21d9..261d9ec8f0c 100644
--- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.cpp
@@ -37,6 +37,8 @@
#include "KX_SCA_ReplaceMeshActuator.h"
+#include "PyObjectPlus.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -80,7 +82,7 @@ PyParentObject KX_SCA_ReplaceMeshActuator::Parents[] = {
PyMethodDef KX_SCA_ReplaceMeshActuator::Methods[] = {
- {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_VARARGS, SetMesh_doc},
+ {"setMesh", (PyCFunction) KX_SCA_ReplaceMeshActuator::sPySetMesh, METH_O, (PY_METHODCHAR)SetMesh_doc},
KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, instantReplaceMesh),
KX_PYMETHODTABLE(KX_SCA_ReplaceMeshActuator, getMesh),
@@ -97,30 +99,31 @@ PyObject* KX_SCA_ReplaceMeshActuator::_getattr(const STR_String& attr)
/* 1. setMesh */
-char KX_SCA_ReplaceMeshActuator::SetMesh_doc[] =
+const char KX_SCA_ReplaceMeshActuator::SetMesh_doc[] =
"setMesh(name)\n"
- "\t- name: string\n"
+ "\t- name: string or None\n"
"\tSet the mesh that will be substituted for the current one.\n";
-PyObject* KX_SCA_ReplaceMeshActuator::PySetMesh(PyObject* self,
- PyObject* args,
- PyObject* kwds)
+PyObject* KX_SCA_ReplaceMeshActuator::PySetMesh(PyObject* self, PyObject* value)
{
- char* meshname;
-
- if (!PyArg_ParseTuple(args, "s", &meshname))
- {
- return NULL;
- }
-
- void* mesh = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname));
-
- if (mesh) {
+ if (value == Py_None) {
+ m_mesh = NULL;
+ } else {
+ char* meshname = PyString_AsString(value);
+ if (!meshname) {
+ PyErr_SetString(PyExc_ValueError, "Expected the name of a mesh or None");
+ return NULL;
+ }
+ void* mesh = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(STR_String(meshname));
+
+ if (mesh==NULL) {
+ PyErr_SetString(PyExc_ValueError, "The mesh name given does not exist");
+ return NULL;
+ }
m_mesh= (class RAS_MeshObject*)mesh;
- Py_Return;
}
- return NULL;
+ Py_RETURN_NONE;
}
KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, getMesh,
@@ -129,7 +132,7 @@ KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, getMesh,
)
{
if (!m_mesh)
- Py_Return;
+ Py_RETURN_NONE;
return PyString_FromString(const_cast<char *>(m_mesh->GetName().ReadPtr()));
}
@@ -139,7 +142,7 @@ KX_PYMETHODDEF_DOC(KX_SCA_ReplaceMeshActuator, instantReplaceMesh,
"instantReplaceMesh() : immediately replace mesh without delay\n")
{
InstantReplaceMesh();
- Py_Return;
+ Py_RETURN_NONE;
}
/* ------------------------------------------------------------------------- */
diff --git a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
index 5ba0a099b14..1da154cc222 100644
--- a/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
+++ b/source/gameengine/Ketsji/KX_SCA_ReplaceMeshActuator.h
@@ -76,7 +76,7 @@ class KX_SCA_ReplaceMeshActuator : public SCA_IActuator
void InstantReplaceMesh();
/* 1. setMesh */
- KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,SetMesh);
+ KX_PYMETHOD_DOC_O(KX_SCA_ReplaceMeshActuator,SetMesh);
KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,getMesh);
KX_PYMETHOD_DOC(KX_SCA_ReplaceMeshActuator,instantReplaceMesh);
diff --git a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
index f085ff435dc..d651373869a 100644
--- a/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
+++ b/source/gameengine/Ketsji/KX_SG_BoneParentNodeRelationship.cpp
@@ -78,7 +78,7 @@ UpdateChildCoordinates(
if (parent)
{
- const BL_ArmatureObject *armature = (const BL_ArmatureObject*)(parent->GetSGClientObject());
+ BL_ArmatureObject *armature = (BL_ArmatureObject*)(parent->GetSGClientObject());
if (armature)
{
MT_Matrix4x4 parent_matrix;
diff --git a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h
index d83fb79ee25..faa650106c8 100644
--- a/source/gameengine/Ketsji/KX_SG_NodeRelationships.h
+++ b/source/gameengine/Ketsji/KX_SG_NodeRelationships.h
@@ -129,6 +129,12 @@ public :
~KX_VertexParentRelation(
);
+ bool
+ IsVertexRelation(
+ ) {
+ return true;
+ }
+
private :
KX_VertexParentRelation(
@@ -171,8 +177,23 @@ public :
NewCopy(
);
+ MT_Scalar
+ GetTimeOffset(
+ ) { return m_relax; }
+
+ void
+ SetTimeOffset(
+ MT_Scalar relaxation
+ ) { m_relax = relaxation; }
+
~KX_SlowParentRelation(
);
+
+ bool
+ IsSlowRelation(
+ ) {
+ return true;
+ }
private :
diff --git a/source/gameengine/Ketsji/KX_Scene.cpp b/source/gameengine/Ketsji/KX_Scene.cpp
index 7f7558b0ab7..caa71441b1d 100644
--- a/source/gameengine/Ketsji/KX_Scene.cpp
+++ b/source/gameengine/Ketsji/KX_Scene.cpp
@@ -32,10 +32,12 @@
#pragma warning (disable : 4786)
#endif //WIN32
+
#include "KX_Scene.h"
#include "MT_assert.h"
#include "KX_KetsjiEngine.h"
+#include "KX_BlenderMaterial.h"
#include "RAS_IPolygonMaterial.h"
#include "ListValue.h"
#include "SCA_LogicManager.h"
@@ -47,6 +49,7 @@
#include "SCA_KeyboardManager.h"
#include "SCA_MouseManager.h"
#include "SCA_PropertyEventManager.h"
+#include "SCA_ActuatorEventManager.h"
#include "KX_Camera.h"
#include "SCA_JoystickManager.h"
@@ -64,6 +67,9 @@
#include "SG_Controller.h"
#include "SG_IObject.h"
#include "SG_Tree.h"
+#include "DNA_group_types.h"
+#include "DNA_scene_types.h"
+#include "BKE_anim.h"
#include "KX_SG_NodeRelationships.h"
@@ -71,15 +77,26 @@
#include "NG_NetworkScene.h"
#include "PHY_IPhysicsEnvironment.h"
#include "KX_IPhysicsController.h"
+#include "KX_BlenderSceneConverter.h"
-#include "BL_SkinDeformer.h"
+#include "BL_ShapeDeformer.h"
#include "BL_DeformableGameObject.h"
+// to get USE_BULLET!
+#include "KX_ConvertPhysicsObject.h"
+
+#ifdef USE_BULLET
+#include "CcdPhysicsEnvironment.h"
+#include "CcdPhysicsController.h"
+#endif
void* KX_SceneReplicationFunc(SG_IObject* node,void* gameobj,void* scene)
{
KX_GameObject* replica = ((KX_Scene*)scene)->AddNodeReplicaObject(node,(KX_GameObject*)gameobj);
+ if(replica)
+ replica->Release();
+
return (void*)replica;
}
@@ -100,16 +117,19 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
class SCA_IInputDevice* mousedevice,
class NG_NetworkDeviceInterface *ndi,
class SND_IAudioDevice* adi,
- const STR_String& sceneName):
+ const STR_String& sceneName,
+ Scene *scene):
PyObjectPlus(&KX_Scene::Type),
m_keyboardmgr(NULL),
m_mousemgr(NULL),
+ m_sceneConverter(NULL),
m_physicsEnvironment(0),
m_sceneName(sceneName),
m_adi(adi),
m_networkDeviceInterface(ndi),
m_active_camera(NULL),
- m_ueberExecutionPriority(0)
+ m_ueberExecutionPriority(0),
+ m_blenderScene(scene)
{
m_suspendedtime = 0.0;
m_suspendeddelta = 0.0;
@@ -121,6 +141,7 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
m_objectlist = new CListValue();
m_parentlist = new CListValue();
m_lightlist= new CListValue();
+ m_inactivelist = new CListValue();
m_euthanasyobjects = new CListValue();
m_delayReleaseObjects = new CListValue();
@@ -132,22 +153,32 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
SCA_AlwaysEventManager* alwaysmgr = new SCA_AlwaysEventManager(m_logicmgr);
SCA_PropertyEventManager* propmgr = new SCA_PropertyEventManager(m_logicmgr);
+ SCA_ActuatorEventManager* actmgr = new SCA_ActuatorEventManager(m_logicmgr);
SCA_RandomEventManager* rndmgr = new SCA_RandomEventManager(m_logicmgr);
KX_RayEventManager* raymgr = new KX_RayEventManager(m_logicmgr);
KX_NetworkEventManager* netmgr = new KX_NetworkEventManager(m_logicmgr, ndi);
- SCA_JoystickManager *joymgr = new SCA_JoystickManager(m_logicmgr);
+
m_logicmgr->RegisterEventManager(alwaysmgr);
m_logicmgr->RegisterEventManager(propmgr);
+ m_logicmgr->RegisterEventManager(actmgr);
m_logicmgr->RegisterEventManager(m_keyboardmgr);
m_logicmgr->RegisterEventManager(m_mousemgr);
m_logicmgr->RegisterEventManager(m_timemgr);
m_logicmgr->RegisterEventManager(rndmgr);
m_logicmgr->RegisterEventManager(raymgr);
m_logicmgr->RegisterEventManager(netmgr);
- m_logicmgr->RegisterEventManager(joymgr);
+
+
+ SYS_SystemHandle hSystem = SYS_GetSystem();
+ bool nojoystick= SYS_GetCommandLineInt(hSystem,"nojoystick",0);
+ if (!nojoystick)
+ {
+ SCA_JoystickManager *joymgr = new SCA_JoystickManager(m_logicmgr);
+ m_logicmgr->RegisterEventManager(joymgr);
+ }
m_soundScene = new SND_Scene(adi);
MT_assert (m_networkDeviceInterface != NULL);
@@ -167,13 +198,14 @@ KX_Scene::KX_Scene(class SCA_IInputDevice* keyboarddevice,
KX_Scene::~KX_Scene()
{
-
-// int numobj = m_objectlist->GetCount();
+ // The release of debug properties used to be in SCA_IScene::~SCA_IScene
+ // It's still there but we remove all properties here otherwise some
+ // reference might be hanging and causing late release of objects
+ RemoveAllDebugProperties();
- //int numrootobjects = GetRootParentList()->GetCount();
- for (int i = 0; i < GetRootParentList()->GetCount(); i++)
+ while (GetRootParentList()->GetCount() > 0)
{
- KX_GameObject* parentobj = (KX_GameObject*) GetRootParentList()->GetValue(i);
+ KX_GameObject* parentobj = (KX_GameObject*) GetRootParentList()->GetValue(0);
this->RemoveObject(parentobj);
}
@@ -183,6 +215,9 @@ KX_Scene::~KX_Scene()
if (m_parentlist)
m_parentlist->Release();
+ if (m_inactivelist)
+ m_inactivelist->Release();
+
if (m_lightlist)
m_lightlist->Release();
@@ -210,13 +245,9 @@ KX_Scene::~KX_Scene()
{
delete m_bucketmanager;
}
-
//Py_DECREF(m_attrlist);
}
-
-
-
void KX_Scene::SetProjectionMatrix(MT_CmMatrix4x4& pmat)
{
m_projectionmat = pmat;
@@ -243,6 +274,11 @@ CListValue* KX_Scene::GetRootParentList()
return m_parentlist;
}
+CListValue* KX_Scene::GetInactiveList()
+{
+ return m_inactivelist;
+}
+
CListValue* KX_Scene::GetLightList()
@@ -263,7 +299,7 @@ SCA_TimeEventManager* KX_Scene::GetTimeEventManager()
-set<class KX_Camera*>* KX_Scene::GetCameras()
+list<class KX_Camera*>* KX_Scene::GetCameras()
{
return &m_cameras;
}
@@ -364,14 +400,26 @@ void KX_Scene::EnableZBufferClearing(bool isclearingZbuffer)
void KX_Scene::RemoveNodeDestructObject(class SG_IObject* node,class CValue* gameobj)
{
KX_GameObject* orgobj = (KX_GameObject*)gameobj;
- NewRemoveObject(orgobj);
-
+ if (NewRemoveObject(orgobj) != 0)
+ {
+ // object is not yet deleted (this can happen when it hangs in an add object actuator
+ // last object created reference. It's a bad situation, don't know how to fix it exactly
+ // The least I can do, is remove the reference to the node in the object as the node
+ // will in any case be deleted. This ensures that the object will not try to use the node
+ // when it is finally deleted (see KX_GameObject destructor)
+ orgobj->SetSGNode(NULL);
+ }
if (node)
delete node;
}
KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CValue* gameobj)
{
+ // for group duplication, limit the duplication of the hierarchy to the
+ // objects that are part of the group.
+ if (!IsObjectInGroup(gameobj))
+ return NULL;
+
KX_GameObject* orgobj = (KX_GameObject*)gameobj;
KX_GameObject* newobj = (KX_GameObject*)orgobj->GetReplica();
m_map_gameobject_to_replica.insert(orgobj, newobj);
@@ -415,8 +463,8 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
replicanode->SetSGClientObject(newobj);
// this is the list of object that are send to the graphics pipeline
- m_objectlist->Add(newobj);
- newobj->Bucketize();
+ m_objectlist->Add(newobj->AddRef());
+ newobj->AddMeshUser();
// logic cannot be replicated, until the whole hierarchy is replicated.
m_logicHierarchicalGameObjects.push_back(newobj);
@@ -449,6 +497,11 @@ KX_GameObject* KX_Scene::AddNodeReplicaObject(class SG_IObject* node, class CVal
// hierarchy that's because first ALL bricks must exist in the new
// replica of the hierarchy in order to make cross-links work properly
// !
+// It is VERY important that the order of sensors and actuators in
+// the replicated object is preserved: it is is used to reconnect the logic.
+// This method is more robust then using the bricks name in case of complex
+// group replication. The replication of logic bricks is done in
+// SCA_IObject::ReParentLogic(), make sure it preserves the order of the bricks.
void KX_Scene::ReplicateLogic(KX_GameObject* newobj)
{
// also relink the controller to sensors/actuators
@@ -471,37 +524,38 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj)
for (vector<SCA_ISensor*>::iterator its = linkedsensors.begin();!(its==linkedsensors.end());its++)
{
SCA_ISensor* oldsensor = (*its);
- STR_String name = oldsensor->GetName();
- //find this name in the list
- SCA_ISensor* newsensor = newobj->FindSensor(name);
+ SCA_IObject* oldsensorobj = oldsensor->GetParent();
+ SCA_IObject* newsensorobj = NULL;
- if (newsensor)
+ // the original owner of the sensor has been replicated?
+ void **h_obj = m_map_gameobject_to_replica[oldsensorobj];
+ if (h_obj)
+ newsensorobj = (SCA_IObject*)(*h_obj);
+ if (!newsensorobj)
{
- // relink this newsensor to the controller
- m_logicmgr->RegisterToSensor(cont,newsensor);
+ // no, then the sensor points outside the hierachy, keep it the same
+ if (m_objectlist->SearchValue(oldsensorobj))
+ // only replicate links that points to active objects
+ m_logicmgr->RegisterToSensor(cont,oldsensor);
}
else
{
- // it can be linked somewhere in the hierarchy or...
- for (vector<KX_GameObject*>::iterator git = m_logicHierarchicalGameObjects.begin();
- !(git==m_logicHierarchicalGameObjects.end());++git)
- {
- newsensor = (*git)->FindSensor(name);
- if (newsensor)
- break;
- }
+ // yes, then the new sensor has the same position
+ SCA_SensorList& sensorlist = oldsensorobj->GetSensors();
+ SCA_SensorList::iterator sit;
+ SCA_ISensor* newsensor = NULL;
+ int sensorpos;
- if (newsensor)
- {
- // relink this newsensor to the controller somewhere else within this
- // hierarchy
- m_logicmgr->RegisterToSensor(cont,newsensor);
- }
- else
+ for (sensorpos=0, sit=sensorlist.begin(); sit!=sensorlist.end(); sit++, sensorpos++)
{
- // must be an external sensor, so...
- m_logicmgr->RegisterToSensor(cont,oldsensor);
+ if ((*sit) == oldsensor)
+ {
+ newsensor = newsensorobj->GetSensors().at(sensorpos);
+ break;
+ }
}
+ assert(newsensor != NULL);
+ m_logicmgr->RegisterToSensor(cont,newsensor);
}
}
@@ -509,43 +563,189 @@ void KX_Scene::ReplicateLogic(KX_GameObject* newobj)
for (vector<SCA_IActuator*>::iterator ita = linkedactuators.begin();!(ita==linkedactuators.end());ita++)
{
SCA_IActuator* oldactuator = (*ita);
- STR_String name = oldactuator->GetName();
- //find this name in the list
- SCA_IActuator* newactuator = newobj->FindActuator(name);
- if (newactuator)
+ SCA_IObject* oldactuatorobj = oldactuator->GetParent();
+ SCA_IObject* newactuatorobj = NULL;
+
+ // the original owner of the sensor has been replicated?
+ void **h_obj = m_map_gameobject_to_replica[oldactuatorobj];
+ if (h_obj)
+ newactuatorobj = (SCA_IObject*)(*h_obj);
+
+ if (!newactuatorobj)
{
- // relink this newsensor to the controller
- m_logicmgr->RegisterToActuator(cont,newactuator);
- newactuator->SetUeberExecutePriority(m_ueberExecutionPriority);
+ // no, then the sensor points outside the hierachy, keep it the same
+ if (m_objectlist->SearchValue(oldactuatorobj))
+ // only replicate links that points to active objects
+ m_logicmgr->RegisterToActuator(cont,oldactuator);
}
else
{
- // it can be linked somewhere in the hierarchy or...
- for (vector<KX_GameObject*>::iterator git = m_logicHierarchicalGameObjects.begin();
- !(git==m_logicHierarchicalGameObjects.end());++git)
- {
- newactuator= (*git)->FindActuator(name);
- if (newactuator)
- break;
- }
+ // yes, then the new sensor has the same position
+ SCA_ActuatorList& actuatorlist = oldactuatorobj->GetActuators();
+ SCA_ActuatorList::iterator ait;
+ SCA_IActuator* newactuator = NULL;
+ int actuatorpos;
- if (newactuator)
+ for (actuatorpos=0, ait=actuatorlist.begin(); ait!=actuatorlist.end(); ait++, actuatorpos++)
{
- // relink this actuator to the controller somewhere else within this
- // hierarchy
- m_logicmgr->RegisterToActuator(cont,newactuator);
- newactuator->SetUeberExecutePriority(m_ueberExecutionPriority);
- }
- else
- {
- // must be an external actuator, so...
- m_logicmgr->RegisterToActuator(cont,oldactuator);
+ if ((*ait) == oldactuator)
+ {
+ newactuator = newactuatorobj->GetActuators().at(actuatorpos);
+ break;
+ }
}
+ assert(newactuator != NULL);
+ m_logicmgr->RegisterToActuator(cont,newactuator);
+ newactuator->SetUeberExecutePriority(m_ueberExecutionPriority);
}
}
}
+ // ready to set initial state
+ newobj->ResetState();
}
+void KX_Scene::DupliGroupRecurse(CValue* obj, int level)
+{
+ KX_GameObject* groupobj = (KX_GameObject*) obj;
+ KX_GameObject* replica;
+ KX_GameObject* gameobj;
+ Object* blgroupobj = groupobj->GetBlenderObject();
+ Group* group;
+ GroupObject *go;
+ vector<KX_GameObject*> duplilist;
+
+ if (!groupobj->GetSGNode() ||
+ !groupobj->IsDupliGroup() ||
+ level>MAX_DUPLI_RECUR)
+ return;
+
+ // we will add one group at a time
+ m_logicHierarchicalGameObjects.clear();
+ m_map_gameobject_to_replica.clear();
+ m_ueberExecutionPriority++;
+ // for groups will do something special:
+ // we will force the creation of objects to those in the group only
+ // Again, this is match what Blender is doing (it doesn't care of parent relationship)
+ m_groupGameObjects.clear();
+
+ group = blgroupobj->dup_group;
+ for(go=(GroupObject*)group->gobject.first; go; go=(GroupObject*)go->next)
+ {
+ Object* blenderobj = go->ob;
+ if (blgroupobj == blenderobj)
+ // this check is also in group_duplilist()
+ continue;
+
+ gameobj = (KX_GameObject*)m_logicmgr->FindGameObjByBlendObj(blenderobj);
+ if (gameobj == NULL)
+ {
+ // this object has not been converted!!!
+ // Should not happen as dupli group are created automatically
+ continue;
+ }
+
+ gameobj->SetBlenderGroupObject(blgroupobj);
+
+ if ((blenderobj->lay & group->layer)==0)
+ {
+ // object is not visible in the 3D view, will not be instantiated
+ continue;
+ }
+ m_groupGameObjects.insert(gameobj);
+ }
+
+ set<CValue*>::iterator oit;
+ for (oit=m_groupGameObjects.begin(); oit != m_groupGameObjects.end(); oit++)
+ {
+ gameobj = (KX_GameObject*)(*oit);
+
+ KX_GameObject *parent = gameobj->GetParent();
+ if (parent != NULL)
+ {
+ parent->Release(); // GetParent() increased the refcount
+
+ // this object is not a top parent. Either it is the child of another
+ // object in the group and it will be added automatically when the parent
+ // is added. Or it is the child of an object outside the group and the group
+ // is inconsistent, skip it anyway
+ continue;
+ }
+ replica = (KX_GameObject*) AddNodeReplicaObject(NULL,gameobj);
+ // add to 'rootparent' list (this is the list of top hierarchy objects, updated each frame)
+ m_parentlist->Add(replica->AddRef());
+
+ // recurse replication into children nodes
+ NodeList& children = gameobj->GetSGNode()->GetSGChildren();
+
+ replica->GetSGNode()->ClearSGChildren();
+ for (NodeList::iterator childit = children.begin();!(childit==children.end());++childit)
+ {
+ SG_Node* orgnode = (*childit);
+ SG_Node* childreplicanode = orgnode->GetSGReplica();
+ if (childreplicanode)
+ replica->GetSGNode()->AddChild(childreplicanode);
+ }
+ // don't replicate logic now: we assume that the objects in the group can have
+ // logic relationship, even outside parent relationship
+ // In order to match 3D view, the position of groupobj is used as a
+ // transformation matrix instead of the new position. This means that
+ // the group reference point is 0,0,0
+
+ // get the rootnode's scale
+ MT_Vector3 newscale = groupobj->NodeGetWorldScaling();
+ // set the replica's relative scale with the rootnode's scale
+ replica->NodeSetRelativeScale(newscale);
+
+ MT_Matrix3x3 newori = groupobj->NodeGetWorldOrientation() * gameobj->NodeGetWorldOrientation();
+ replica->NodeSetLocalOrientation(newori);
+
+ MT_Point3 newpos = groupobj->NodeGetWorldPosition() +
+ newscale*(groupobj->NodeGetWorldOrientation() * gameobj->NodeGetWorldPosition());
+ replica->NodeSetLocalPosition(newpos);
+
+ replica->GetSGNode()->UpdateWorldData(0);
+ replica->GetSGNode()->SetBBox(gameobj->GetSGNode()->BBox());
+ replica->GetSGNode()->SetRadius(gameobj->GetSGNode()->Radius());
+ // done with replica
+ replica->Release();
+ }
+
+ // the logic must be replicated first because we need
+ // the new logic bricks before relinking
+ vector<KX_GameObject*>::iterator git;
+ for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
+ {
+ (*git)->ReParentLogic();
+ }
+
+ // relink any pointers as necessary, sort of a temporary solution
+ for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
+ {
+ // this will also relink the actuator to objects within the hierarchy
+ (*git)->Relink(&m_map_gameobject_to_replica);
+ // add the object in the layer of the parent
+ (*git)->SetLayer(groupobj->GetLayer());
+ }
+
+ // replicate crosslinks etc. between logic bricks
+ for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
+ {
+ ReplicateLogic((*git));
+ }
+
+ // now look if object in the hierarchy have dupli group and recurse
+ for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
+ {
+ if ((*git) != groupobj && (*git)->IsDupliGroup())
+ // can't instantiate group immediately as it destroys m_logicHierarchicalGameObjects
+ duplilist.push_back((*git));
+ }
+
+ for (git = duplilist.begin(); !(git == duplilist.end()); ++git)
+ {
+ DupliGroupRecurse((*git), level+1);
+ }
+}
SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject,
@@ -555,6 +755,7 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject,
m_logicHierarchicalGameObjects.clear();
m_map_gameobject_to_replica.clear();
+ m_groupGameObjects.clear();
// todo: place a timebomb in the object, for temporarily objects :)
// lifespan of zero means 'this object lives forever'
@@ -571,7 +772,9 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject,
// add a timebomb to this object
// for now, convert between so called frames and realtime
m_tempObjectList->Add(replica->AddRef());
- replica->SetProperty("::timebomb",new CFloatValue(lifespan*0.02));
+ CValue *fval = new CFloatValue(lifespan*0.02);
+ replica->SetProperty("::timebomb",fval);
+ fval->Release();
}
// add to 'rootparent' list (this is the list of top hierarchy objects, updated each frame)
@@ -586,22 +789,26 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject,
{
SG_Node* orgnode = (*childit);
SG_Node* childreplicanode = orgnode->GetSGReplica();
- replica->GetSGNode()->AddChild(childreplicanode);
+ if (childreplicanode)
+ replica->GetSGNode()->AddChild(childreplicanode);
}
- // relink any pointers as necessary, sort of a temporary solution
+ // now replicate logic
vector<KX_GameObject*>::iterator git;
for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
{
- (*git)->Relink(&m_map_gameobject_to_replica);
+ (*git)->ReParentLogic();
}
-
- // now replicate logic
+
+ // relink any pointers as necessary, sort of a temporary solution
for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
{
- (*git)->ReParentLogic();
+ // this will also relink the actuators in the hierarchy
+ (*git)->Relink(&m_map_gameobject_to_replica);
+ // add the object in the layer of the parent
+ (*git)->SetLayer(parentobj->GetLayer());
}
-
+
// replicate crosslinks etc. between logic bricks
for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
{
@@ -620,21 +827,24 @@ SCA_IObject* KX_Scene::AddReplicaObject(class CValue* originalobject,
// set the replica's relative scale with the rootnode's scale
replica->NodeSetRelativeScale(newscale);
- if (replica->GetPhysicsController())
- {
- replica->GetPhysicsController()->setPosition(newpos);
- replica->GetPhysicsController()->setOrientation(newori.getRotation());
- replica->GetPhysicsController()->setScaling(newscale);
- }
-
- // here we want to set the relative scale: the rootnode's scale will override all other
- // scalings, so lets better prepare for it
-
-
replica->GetSGNode()->UpdateWorldData(0);
replica->GetSGNode()->SetBBox(originalobj->GetSGNode()->BBox());
replica->GetSGNode()->SetRadius(originalobj->GetSGNode()->Radius());
-
+ // check if there are objects with dupligroup in the hierarchy
+ vector<KX_GameObject*> duplilist;
+ for (git = m_logicHierarchicalGameObjects.begin();!(git==m_logicHierarchicalGameObjects.end());++git)
+ {
+ if ((*git)->IsDupliGroup())
+ {
+ // separate list as m_logicHierarchicalGameObjects is also used by DupliGroupRecurse()
+ duplilist.push_back(*git);
+ }
+ }
+ for (git = duplilist.begin();!(git==duplilist.end());++git)
+ {
+ DupliGroupRecurse(*git, 0);
+ }
+ // don't release replica here because we are returning it, not done with it...
return replica;
}
@@ -654,7 +864,8 @@ void KX_Scene::RemoveObject(class CValue* gameobj)
// recursively destruct
node->Destruct();
}
- newobj->SetSGNode(0);
+ //no need to do that: the object is destroyed and memory released
+ //newobj->SetSGNode(0);
}
void KX_Scene::DelayedReleaseObject(CValue* gameobj)
@@ -674,10 +885,17 @@ void KX_Scene::DelayedRemoveObject(class CValue* gameobj)
-void KX_Scene::NewRemoveObject(class CValue* gameobj)
+int KX_Scene::NewRemoveObject(class CValue* gameobj)
{
+ int ret;
KX_GameObject* newobj = (KX_GameObject*) gameobj;
+ // keep the blender->game object association up to date
+ // note that all the replicas of an object will have the same
+ // blender object, that's why we need to check the game object
+ // as only the deletion of the original object must be recorded
+ m_logicmgr->UnregisterGameObj(newobj->GetBlenderObject(), gameobj);
+
//todo: look at this
//GetPhysicsEnvironment()->RemovePhysicsController(gameobj->getPhysicsController());
@@ -694,8 +912,7 @@ void KX_Scene::NewRemoveObject(class CValue* gameobj)
for (SCA_ControllerList::iterator itc = controllers.begin();
!(itc==controllers.end());itc++)
{
- (*itc)->UnlinkAllSensors();
- (*itc)->UnlinkAllActuators();
+ m_logicmgr->RemoveController(*itc);
}
SCA_ActuatorList& actuators = newobj->GetActuators();
@@ -704,6 +921,7 @@ void KX_Scene::NewRemoveObject(class CValue* gameobj)
{
m_logicmgr->RemoveDestroyedActuator(*ita);
}
+ // the sensors/controllers/actuators must also be released, this is done in ~SCA_IObject
// now remove the timer properties from the time manager
int numprops = newobj->GetPropertyCount();
@@ -718,113 +936,138 @@ void KX_Scene::NewRemoveObject(class CValue* gameobj)
}
newobj->RemoveMeshes();
+ ret = 1;
+ if (m_lightlist->RemoveValue(newobj)) // TODO - use newobj->IsLight() test when its merged in from apricot. - Campbell
+ ret = newobj->Release();
if (m_objectlist->RemoveValue(newobj))
- newobj->Release();
+ ret = newobj->Release();
if (m_tempObjectList->RemoveValue(newobj))
- newobj->Release();
+ ret = newobj->Release();
if (m_parentlist->RemoveValue(newobj))
- newobj->Release();
+ ret = newobj->Release();
+ if (m_inactivelist->RemoveValue(newobj))
+ ret = newobj->Release();
if (m_euthanasyobjects->RemoveValue(newobj))
- newobj->Release();
+ ret = newobj->Release();
if (newobj == m_active_camera)
{
- m_active_camera->Release();
+ //no AddRef done on m_active_camera so no Release
+ //m_active_camera->Release();
m_active_camera = NULL;
}
+
+ // in case this is a camera
+ m_cameras.remove((KX_Camera*)newobj);
+
+ if (m_sceneConverter)
+ m_sceneConverter->UnregisterGameObject(newobj);
+ // return value will be 0 if the object is actually deleted (all reference gone)
+ return ret;
}
-void KX_Scene::ReplaceMesh(class CValue* gameobj,void* meshobj)
+void KX_Scene::ReplaceMesh(class CValue* obj,void* meshobj)
{
- KX_GameObject* newobj = static_cast<KX_GameObject*>(gameobj);
+ KX_GameObject* gameobj = static_cast<KX_GameObject*>(obj);
RAS_MeshObject* mesh = static_cast<RAS_MeshObject*>(meshobj);
- const STR_String origMeshName = newobj->GetMesh(0)->GetName();
-
- if( !newobj || !mesh )
+ if(!gameobj || !mesh)
{
std::cout << "warning: invalid object, mesh will not be replaced" << std::endl;
return;
}
- newobj->RemoveMeshes();
- newobj->AddMesh(mesh);
-
- bool isDeformer = (newobj->m_isDeformable && mesh->m_class == 1);
- if(isDeformer)
- {
- /* FindBlendObjByGameObj() can return 0...
- In the case of 0 here,
- the replicated object that is calling this function
- is some how not in the map. (which is strange because it's added)
- So we will search the map by the first mesh name
- to try to locate it there. If its still not found
- spit some message rather than crash
- */
- Object* blendobj = static_cast<struct Object*>(m_logicmgr->FindBlendObjByGameObj(newobj));
- Object* oldblendobj = static_cast<struct Object*>(m_logicmgr->FindBlendObjByGameMeshName(mesh->GetName()));
+ gameobj->RemoveMeshes();
+ gameobj->AddMesh(mesh);
- bool parSkin = blendobj && blendobj->parent && blendobj->parent->type == OB_ARMATURE && blendobj->partype==PARSKEL;
- bool releaseParent = true;
- KX_GameObject* parentobj = newobj->GetParent();
-
-
- // lookup by mesh name if blendobj is 0
- if( !blendobj && parentobj )
+ if (gameobj->m_isDeformable)
+ {
+ BL_DeformableGameObject* newobj = static_cast<BL_DeformableGameObject*>( gameobj );
+
+ if (newobj->GetDeformer())
{
- blendobj = static_cast<struct Object*>(m_logicmgr->FindBlendObjByGameMeshName(origMeshName));
-
- // replace the mesh on the parent armature
- if( blendobj )
- parSkin = parentobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE;
-
- // can't do it
- else
- std::cout << "warning: child object for " << parentobj->GetName().ReadPtr()
- << " not found, and can't create!" << std::endl;
+ delete newobj->GetDeformer();
+ newobj->SetDeformer(NULL);
}
- if( blendobj && oldblendobj )
+ if (mesh->IsDeformed())
{
- isDeformer = (static_cast<Mesh*>(blendobj->data)->dvert != 0);
- BL_DeformableGameObject* deformIter =0;
-
- // armature parent
- if( parSkin && isDeformer )
+ // we must create a new deformer but which one?
+ KX_GameObject* parentobj = newobj->GetParent();
+ // this always return the original game object (also for replicate)
+ Object* blendobj = newobj->GetBlenderObject();
+ // object that owns the new mesh
+ Object* oldblendobj = static_cast<struct Object*>(m_logicmgr->FindBlendObjByGameMeshName(mesh->GetName()));
+ Mesh* blendmesh = mesh->GetMesh();
+
+ bool bHasShapeKey = blendmesh->key != NULL && blendmesh->key->type==KEY_RELATIVE;
+ bool bHasDvert = blendmesh->dvert != NULL;
+ bool bHasArmature =
+ parentobj && // current parent is armature
+ parentobj->GetGameObjectType() == SCA_IObject::OBJ_ARMATURE &&
+ oldblendobj && // needed for mesh deform
+ blendobj->parent && // original object had armature (not sure this test is needed)
+ blendobj->parent->type == OB_ARMATURE &&
+ blendobj->partype==PARSKEL &&
+ blendmesh->dvert!=NULL; // mesh has vertex group
+ bool releaseParent = true;
+
+ if (bHasShapeKey)
+ {
+ BL_ShapeDeformer* shapeDeformer;
+ if (bHasArmature)
+ {
+ shapeDeformer = new BL_ShapeDeformer(
+ newobj,
+ oldblendobj, blendobj,
+ static_cast<BL_SkinMeshObject*>(mesh),
+ true,
+ static_cast<BL_ArmatureObject*>( parentobj )
+ );
+ releaseParent= false;
+ shapeDeformer->LoadShapeDrivers(blendobj->parent);
+ }
+ else
+ {
+ shapeDeformer = new BL_ShapeDeformer(
+ newobj,
+ oldblendobj, blendobj,
+ static_cast<BL_SkinMeshObject*>(mesh),
+ false,
+ NULL
+ );
+ }
+ newobj->SetDeformer( shapeDeformer);
+ }
+ else if (bHasArmature)
{
- deformIter = static_cast<BL_DeformableGameObject*>( newobj );
- delete deformIter->m_pDeformer;
-
BL_SkinDeformer* skinDeformer = new BL_SkinDeformer(
+ newobj,
oldblendobj, blendobj,
static_cast<BL_SkinMeshObject*>(mesh),
true,
static_cast<BL_ArmatureObject*>( parentobj )
);
releaseParent= false;
- deformIter->m_pDeformer = skinDeformer;
+ newobj->SetDeformer(skinDeformer);
}
-
- // normal deformer
- if( !parSkin && isDeformer)
+ else if (bHasDvert)
{
- deformIter = static_cast<BL_DeformableGameObject*>( newobj );
- delete deformIter->m_pDeformer;
-
BL_MeshDeformer* meshdeformer = new BL_MeshDeformer(
- oldblendobj, static_cast<BL_SkinMeshObject*>(mesh)
+ newobj, oldblendobj, static_cast<BL_SkinMeshObject*>(mesh)
);
-
- deformIter->m_pDeformer = meshdeformer;
+ newobj->SetDeformer(meshdeformer);
}
+
+ // release parent reference if its not being used
+ if( releaseParent && parentobj)
+ parentobj->Release();
}
- // release parent reference if its not being used
- if( releaseParent && parentobj)
- parentobj->Release();
}
- newobj->Bucketize();
+
+ gameobj->AddMeshUser();
}
@@ -847,7 +1090,7 @@ MT_CmMatrix4x4& KX_Scene::GetProjectionMatrix()
KX_Camera* KX_Scene::FindCamera(KX_Camera* cam)
{
- set<KX_Camera*>::iterator it = m_cameras.begin();
+ list<KX_Camera*>::iterator it = m_cameras.begin();
while ( (it != m_cameras.end())
&& ((*it) != cam) ) {
@@ -860,7 +1103,7 @@ KX_Camera* KX_Scene::FindCamera(KX_Camera* cam)
KX_Camera* KX_Scene::FindCamera(STR_String& name)
{
- set<KX_Camera*>::iterator it = m_cameras.begin();
+ list<KX_Camera*>::iterator it = m_cameras.begin();
while ( (it != m_cameras.end())
&& ((*it)->GetName() != name) ) {
@@ -872,9 +1115,11 @@ KX_Camera* KX_Scene::FindCamera(STR_String& name)
void KX_Scene::AddCamera(KX_Camera* cam)
{
- m_cameras.insert(cam);
+ if (!FindCamera(cam))
+ m_cameras.push_back(cam);
}
+
KX_Camera* KX_Scene::GetActiveCamera()
{
// NULL if not defined
@@ -893,6 +1138,17 @@ void KX_Scene::SetActiveCamera(KX_Camera* cam)
m_active_camera = cam;
}
+void KX_Scene::SetCameraOnTop(KX_Camera* cam)
+{
+ if (!FindCamera(cam)){
+ // adding is always done at the back, so that's all that needs to be done
+ AddCamera(cam);
+ if (cam) std::cout << "Added cam " << cam->GetName() << std::endl;
+ } else {
+ m_cameras.remove(cam);
+ m_cameras.push_back(cam);
+ }
+}
void KX_Scene::UpdateMeshTransformations()
@@ -906,12 +1162,13 @@ void KX_Scene::UpdateMeshTransformations()
}
}
-void KX_Scene::MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera* cam)
+void KX_Scene::MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera* cam, int layer)
{
int intersect = KX_Camera::INTERSECT;
KX_GameObject *gameobj = node->Client()?(KX_GameObject*) node->Client()->GetSGClientObject():NULL;
- bool dotest = (gameobj && gameobj->GetVisible()) || node->Left() || node->Right();
-
+ bool visible = (gameobj && gameobj->GetVisible() && (!layer || (gameobj->GetLayer() & layer)));
+ bool dotest = visible || node->Left() || node->Right();
+
/* If the camera is inside the box, assume intersect. */
if (dotest && !node->inside( cam->NodeGetWorldPosition()))
{
@@ -935,19 +1192,19 @@ void KX_Scene::MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera* cam
break;
case KX_Camera::INTERSECT:
if (gameobj)
- MarkVisible(rasty, gameobj,cam);
+ MarkVisible(rasty, gameobj, cam, layer);
if (node->Left())
- MarkVisible(node->Left(), rasty,cam);
+ MarkVisible(node->Left(), rasty, cam, layer);
if (node->Right())
- MarkVisible(node->Right(), rasty,cam);
+ MarkVisible(node->Right(), rasty, cam, layer);
break;
case KX_Camera::INSIDE:
- MarkSubTreeVisible(node, rasty, true,cam);
+ MarkSubTreeVisible(node, rasty, true, cam, layer);
break;
}
}
-void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool visible,KX_Camera* cam)
+void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool visible, KX_Camera* cam, int layer)
{
if (node->Client())
{
@@ -957,29 +1214,35 @@ void KX_Scene::MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool vi
if (visible)
{
int nummeshes = gameobj->GetMeshCount();
- MT_Transform t( cam->GetWorldToCamera() * gameobj->GetSGNode()->GetWorldTransform());
-
+ // this adds the vertices to the display list
for (int m=0;m<nummeshes;m++)
- {
- // this adds the vertices to the display list
- (gameobj->GetMesh(m))->SchedulePolygons(t, rasty->GetDrawingMode());
- }
+ (gameobj->GetMesh(m))->SchedulePolygons(rasty->GetDrawingMode());
}
- gameobj->MarkVisible(visible);
+
+ gameobj->SetCulled(!visible);
+ gameobj->UpdateBuckets(false);
}
}
if (node->Left())
- MarkSubTreeVisible(node->Left(), rasty, visible,cam);
+ MarkSubTreeVisible(node->Left(), rasty, visible, cam, layer);
if (node->Right())
- MarkSubTreeVisible(node->Right(), rasty, visible,cam);
+ MarkSubTreeVisible(node->Right(), rasty, visible, cam, layer);
}
-void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Camera* cam)
+void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Camera* cam,int layer)
{
// User (Python/Actuator) has forced object invisible...
- if (!gameobj->GetVisible())
+ if (!gameobj->GetSGNode() || !gameobj->GetVisible())
+ return;
+
+ // Shadow lamp layers
+ if(layer && !(gameobj->GetLayer() & layer)) {
+ gameobj->SetCulled(true);
+ gameobj->UpdateBuckets(false);
return;
+ }
+
// If Frustum culling is off, the object is always visible.
bool vis = !cam->GetFrustumCulling();
@@ -1014,35 +1277,36 @@ void KX_Scene::MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj,KX_Cam
if (vis)
{
int nummeshes = gameobj->GetMeshCount();
- MT_Transform t(cam->GetWorldToCamera() * gameobj->GetSGNode()->GetWorldTransform());
for (int m=0;m<nummeshes;m++)
{
// this adds the vertices to the display list
- (gameobj->GetMesh(m))->SchedulePolygons(t, rasty->GetDrawingMode());
+ (gameobj->GetMesh(m))->SchedulePolygons(rasty->GetDrawingMode());
}
// Visibility/ non-visibility are marked
// elsewhere now.
- gameobj->MarkVisible();
+ gameobj->SetCulled(false);
+ gameobj->UpdateBuckets(false);
} else {
- gameobj->MarkVisible(false);
+ gameobj->SetCulled(true);
+ gameobj->UpdateBuckets(false);
}
}
-void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam)
+void KX_Scene::CalculateVisibleMeshes(RAS_IRasterizer* rasty,KX_Camera* cam, int layer)
{
// FIXME: When tree is operational
#if 1
// do this incrementally in the future
for (int i = 0; i < m_objectlist->GetCount(); i++)
{
- MarkVisible(rasty, static_cast<KX_GameObject*>(m_objectlist->GetValue(i)), cam);
+ MarkVisible(rasty, static_cast<KX_GameObject*>(m_objectlist->GetValue(i)), cam, layer);
}
#else
if (cam->GetFrustumCulling())
- MarkVisible(m_objecttree, rasty, cam);
+ MarkVisible(m_objecttree, rasty, cam, layer);
else
- MarkSubTreeVisible(m_objecttree, rasty, true, cam);
+ MarkSubTreeVisible(m_objecttree, rasty, true, cam, layer);
#endif
}
@@ -1096,6 +1360,8 @@ void KX_Scene::LogicEndFrame()
for (i = numobj - 1; i >= 0; i--)
{
KX_GameObject* gameobj = (KX_GameObject*)m_euthanasyobjects->GetValue(i);
+ // KX_Scene::RemoveObject will also remove the object from this list
+ // that's why we start from the end
this->RemoveObject(gameobj);
}
@@ -1103,11 +1369,11 @@ void KX_Scene::LogicEndFrame()
for (i = numobj-1;i>=0;i--)
{
KX_GameObject* gameobj = (KX_GameObject*)m_delayReleaseObjects->GetValue(i);
- m_delayReleaseObjects->RemoveValue(gameobj);
-
+ // This list is not for object removal, but just object release
+ gameobj->Release();
}
-
-
+ // empty the list as we have removed all references
+ m_delayReleaseObjects->Resize(0);
}
@@ -1128,9 +1394,9 @@ void KX_Scene::UpdateParents(double curtime)
-RAS_MaterialBucket* KX_Scene::FindBucket(class RAS_IPolyMaterial* polymat)
+RAS_MaterialBucket* KX_Scene::FindBucket(class RAS_IPolyMaterial* polymat, bool &bucketCreated)
{
- return m_bucketmanager->RAS_BucketManagerFindBucket(polymat);
+ return m_bucketmanager->FindBucket(polymat, bucketCreated);
}
@@ -1140,10 +1406,9 @@ void KX_Scene::RenderBuckets(const MT_Transform & cameratransform,
class RAS_IRenderTools* rendertools)
{
m_bucketmanager->Renderbuckets(cameratransform,rasty,rendertools);
+ KX_BlenderMaterial::EndFrame();
}
-
-
void KX_Scene::UpdateObjectActivity(void)
{
if (m_activity_culling) {
@@ -1212,6 +1477,11 @@ void KX_Scene::SetNodeTree(SG_Tree* root)
m_objecttree = root;
}
+void KX_Scene::SetSceneConverter(class KX_BlenderSceneConverter* sceneConverter)
+{
+ m_sceneConverter = sceneConverter;
+}
+
void KX_Scene::SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* physEnv)
{
m_physicsEnvironment = physEnv;
diff --git a/source/gameengine/Ketsji/KX_Scene.h b/source/gameengine/Ketsji/KX_Scene.h
index dbe04a18e0f..5f7e1167e27 100644
--- a/source/gameengine/Ketsji/KX_Scene.h
+++ b/source/gameengine/Ketsji/KX_Scene.h
@@ -36,6 +36,7 @@
#include <vector>
#include <set>
+#include <list>
#include "GEN_Map.h"
#include "GEN_HashedPtr.h"
@@ -53,6 +54,7 @@
*/
struct SM_MaterialProps;
struct SM_ShapeProps;
+struct Scene;
class GEN_HashedPtr;
class CListValue;
@@ -81,6 +83,8 @@ class RAS_IPolyMaterial;
class RAS_IRasterizer;
class RAS_IRenderTools;
class SCA_JoystickManager;
+class btCollisionShape;
+class KX_BlenderSceneConverter;
/**
* The KX_Scene holds all data for an independent scene. It relates
* KX_Objects to the specific objects in the modules.
@@ -107,6 +111,7 @@ protected:
CListValue* m_objectlist;
CListValue* m_parentlist; // all 'root' parents
CListValue* m_lightlist;
+ CListValue* m_inactivelist; // all objects that are not in the active layer
/**
* The tree of objects in the scene.
@@ -116,8 +121,7 @@ protected:
/**
* The set of cameras for this scene
*/
- set<class KX_Camera*> m_cameras;
-
+ list<class KX_Camera*> m_cameras;
/**
* Various SCA managers used by the scene
*/
@@ -126,10 +130,12 @@ protected:
SCA_MouseManager* m_mousemgr;
SCA_TimeEventManager* m_timemgr;
+ // Scene converter where many scene entities are registered
+ // Used to deregister objects that are deleted
+ class KX_BlenderSceneConverter* m_sceneConverter;
/**
* physics engine abstraction
*/
-
//e_PhysicsEngine m_physicsEngine; //who needs this ?
class PHY_IPhysicsEnvironment* m_physicsEnvironment;
@@ -206,6 +212,16 @@ protected:
*/
std::vector<KX_GameObject*> m_logicHierarchicalGameObjects;
+ /**
+ * This temporary variable will contain the list of
+ * object that can be added during group instantiation.
+ * objects outside this list will not be added (can
+ * happen with children that are outside the group).
+ * Used in AddReplicaObject. If the list is empty, it
+ * means don't care.
+ */
+ std::set<CValue*> m_groupGameObjects;
+
/**
* Pointer to system variable passed in in constructor
* only used in constructor so we do not need to keep it
@@ -250,9 +266,9 @@ protected:
/**
* Visibility testing functions.
*/
- void MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera*cam);
- void MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool visible, KX_Camera*cam);
- void MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj, KX_Camera*cam);
+ void MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera*cam,int layer=0);
+ void MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool visible, KX_Camera*cam,int layer=0);
+ void MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj, KX_Camera*cam, int layer=0);
double m_suspendedtime;
double m_suspendeddelta;
@@ -262,18 +278,21 @@ protected:
*/
PyObject* m_attrlist;
+ struct Scene* m_blenderScene;
+
public:
KX_Scene(class SCA_IInputDevice* keyboarddevice,
class SCA_IInputDevice* mousedevice,
class NG_NetworkDeviceInterface* ndi,
class SND_IAudioDevice* adi,
- const STR_String& scenename );
+ const STR_String& scenename,
+ struct Scene* scene);
virtual
~KX_Scene();
RAS_BucketManager* GetBucketManager();
- RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial* polymat);
+ RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial* polymat, bool &bucketCreated);
void RenderBuckets(const MT_Transform& cameratransform,
RAS_IRasterizer* rasty,
RAS_IRenderTools* rendertools);
@@ -281,6 +300,12 @@ public:
* Update all transforms according to the scenegraph.
*/
void UpdateParents(double curtime);
+ void DupliGroupRecurse(CValue* gameobj, int level);
+ bool IsObjectInGroup(CValue* gameobj)
+ {
+ return (m_groupGameObjects.empty() ||
+ m_groupGameObjects.find(gameobj) != m_groupGameObjects.end());
+ }
SCA_IObject* AddReplicaObject(CValue* gameobj,
CValue* locationobj,
int lifespan=0);
@@ -293,7 +318,7 @@ public:
void DelayedReleaseObject(CValue* gameobj);
- void NewRemoveObject(CValue* gameobj);
+ int NewRemoveObject(CValue* gameobj);
void ReplaceMesh(CValue* gameobj,
void* meshobj);
/**
@@ -312,6 +337,10 @@ public:
);
CListValue*
+ GetInactiveList(
+ );
+
+ CListValue*
GetRootParentList(
);
@@ -327,7 +356,7 @@ public:
GetTimeEventManager(
);
- set<class KX_Camera*>*
+ list<class KX_Camera*>*
GetCameras(
);
@@ -365,6 +394,15 @@ public:
class KX_Camera*
);
+ /**
+ * Move this camera to the end of the list so that it is rendered last.
+ * If the camera is not on the list, it will be added
+ */
+ void
+ SetCameraOnTop(
+ class KX_Camera*
+ );
+
/** Return the viewmatrix as used by the last frame. */
MT_CmMatrix4x4&
GetViewMatrix(
@@ -459,7 +497,7 @@ public:
void SetNetworkScene(NG_NetworkScene *newScene);
void SetWorldInfo(class KX_WorldInfo* wi);
KX_WorldInfo* GetWorldInfo();
- void CalculateVisibleMeshes(RAS_IRasterizer* rasty, KX_Camera *cam);
+ void CalculateVisibleMeshes(RAS_IRasterizer* rasty, KX_Camera *cam, int layer=0);
void UpdateMeshTransformations();
KX_Camera* GetpCamera();
SND_Scene* GetSoundScene();
@@ -493,6 +531,8 @@ public:
bool IsClearingZBuffer();
void EnableZBufferClearing(bool isclearingZbuffer);
+ void SetSceneConverter(class KX_BlenderSceneConverter* sceneConverter);
+
class PHY_IPhysicsEnvironment* GetPhysicsEnvironment()
{
return m_physicsEnvironment;
@@ -546,6 +586,10 @@ public:
* was running and not suspended) and the "curtime"
*/
double getSuspendedDelta();
+ /**
+ * Returns the Blender scene this was made from
+ */
+ struct Scene *GetBlenderScene() { return m_blenderScene; }
};
typedef std::vector<KX_Scene*> KX_SceneList;
diff --git a/source/gameengine/Ketsji/KX_SceneActuator.cpp b/source/gameengine/Ketsji/KX_SceneActuator.cpp
index ce357cd708a..35484699b17 100644
--- a/source/gameengine/Ketsji/KX_SceneActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SceneActuator.cpp
@@ -58,13 +58,16 @@ KX_SceneActuator::KX_SceneActuator(SCA_IObject *gameobj,
m_KetsjiEngine=ketsjiEngine;
m_camera = camera;
m_nextSceneName = nextSceneName;
+ if (m_camera)
+ m_camera->RegisterActuator(this);
} /* End of constructor */
KX_SceneActuator::~KX_SceneActuator()
{
- // there's nothing to be done here, really....
+ if (m_camera)
+ m_camera->UnregisterActuator(this);
} /* end of destructor */
@@ -79,6 +82,34 @@ CValue* KX_SceneActuator::GetReplica()
return replica;
}
+void KX_SceneActuator::ProcessReplica()
+{
+ if (m_camera)
+ m_camera->RegisterActuator(this);
+ SCA_IActuator::ProcessReplica();
+}
+
+bool KX_SceneActuator::UnlinkObject(SCA_IObject* clientobj)
+{
+ if (clientobj == (SCA_IObject*)m_camera)
+ {
+ // this object is being deleted, we cannot continue to track it.
+ m_camera = NULL;
+ return true;
+ }
+ return false;
+}
+
+void KX_SceneActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
+{
+ void **h_obj = (*obj_map)[m_camera];
+ if (h_obj) {
+ if (m_camera)
+ m_camera->UnregisterActuator(this);
+ m_camera = (KX_Camera*)(*h_obj);
+ m_camera->RegisterActuator(this);
+ }
+}
bool KX_SceneActuator::Update()
@@ -102,6 +133,15 @@ bool KX_SceneActuator::Update()
{
m_scene->SetActiveCamera(m_camera);
}
+ else
+ {
+ // if no camera is set and the parent object is a camera, use it as the camera
+ SCA_IObject* parent = GetParent();
+ if (parent->isA(&KX_Camera::Type))
+ {
+ m_scene->SetActiveCamera((KX_Camera*)parent);
+ }
+ }
break;
default:
break;
@@ -219,12 +259,12 @@ PyParentObject KX_SceneActuator::Parents[] =
PyMethodDef KX_SceneActuator::Methods[] =
{
- {"setUseRestart", (PyCFunction) KX_SceneActuator::sPySetUseRestart, METH_VARARGS, SetUseRestart_doc},
- {"setScene", (PyCFunction) KX_SceneActuator::sPySetScene, METH_VARARGS, SetScene_doc},
- {"setCamera", (PyCFunction) KX_SceneActuator::sPySetCamera, METH_VARARGS, SetCamera_doc},
- {"getUseRestart", (PyCFunction) KX_SceneActuator::sPyGetUseRestart, METH_VARARGS, GetUseRestart_doc},
- {"getScene", (PyCFunction) KX_SceneActuator::sPyGetScene, METH_VARARGS, GetScene_doc},
- {"getCamera", (PyCFunction) KX_SceneActuator::sPyGetCamera, METH_VARARGS, GetCamera_doc},
+ {"setUseRestart", (PyCFunction) KX_SceneActuator::sPySetUseRestart, METH_VARARGS, (PY_METHODCHAR)SetUseRestart_doc},
+ {"setScene", (PyCFunction) KX_SceneActuator::sPySetScene, METH_VARARGS, (PY_METHODCHAR)SetScene_doc},
+ {"setCamera", (PyCFunction) KX_SceneActuator::sPySetCamera, METH_VARARGS, (PY_METHODCHAR)SetCamera_doc},
+ {"getUseRestart", (PyCFunction) KX_SceneActuator::sPyGetUseRestart, METH_VARARGS, (PY_METHODCHAR)GetUseRestart_doc},
+ {"getScene", (PyCFunction) KX_SceneActuator::sPyGetScene, METH_VARARGS, (PY_METHODCHAR)GetScene_doc},
+ {"getCamera", (PyCFunction) KX_SceneActuator::sPyGetCamera, METH_VARARGS, (PY_METHODCHAR)GetCamera_doc},
{NULL,NULL} //Sentinel
};
@@ -238,7 +278,7 @@ PyObject* KX_SceneActuator::_getattr(const STR_String& attr)
/* 2. setUseRestart--------------------------------------------------------- */
-char KX_SceneActuator::SetUseRestart_doc[] =
+const char KX_SceneActuator::SetUseRestart_doc[] =
"setUseRestart(flag)\n"
"\t- flag: 0 or 1.\n"
"\tSet flag to 1 to restart the scene.\n" ;
@@ -261,7 +301,7 @@ PyObject* KX_SceneActuator::PySetUseRestart(PyObject* self,
/* 3. getUseRestart: */
-char KX_SceneActuator::GetUseRestart_doc[] =
+const char KX_SceneActuator::GetUseRestart_doc[] =
"getUseRestart()\n"
"\tReturn whether the scene will be restarted.\n" ;
PyObject* KX_SceneActuator::PyGetUseRestart(PyObject* self,
@@ -274,7 +314,7 @@ PyObject* KX_SceneActuator::PyGetUseRestart(PyObject* self,
/* 4. set scene------------------------------------------------------------- */
-char KX_SceneActuator::SetScene_doc[] =
+const char KX_SceneActuator::SetScene_doc[] =
"setScene(scene)\n"
"\t- scene: string\n"
"\tSet the name of scene the actuator will switch to.\n" ;
@@ -299,7 +339,7 @@ PyObject* KX_SceneActuator::PySetScene(PyObject* self,
/* 5. getScene: */
-char KX_SceneActuator::GetScene_doc[] =
+const char KX_SceneActuator::GetScene_doc[] =
"getScene()\n"
"\tReturn the name of the scene the actuator wants to switch to.\n" ;
PyObject* KX_SceneActuator::PyGetScene(PyObject* self,
@@ -312,7 +352,7 @@ PyObject* KX_SceneActuator::PyGetScene(PyObject* self,
/* 6. set camera------------------------------------------------------------ */
-char KX_SceneActuator::SetCamera_doc[] =
+const char KX_SceneActuator::SetCamera_doc[] =
"setCamera(camera)\n"
"\t- camera: string\n"
"\tSet the camera to switch to.\n" ;
@@ -323,7 +363,11 @@ PyObject* KX_SceneActuator::PySetCamera(PyObject* self,
PyObject *cam;
if (PyArg_ParseTuple(args, "O!", &KX_Camera::Type, &cam))
{
+ if (m_camera)
+ m_camera->UnregisterActuator(this);
m_camera = (KX_Camera*) cam;
+ if (m_camera)
+ m_camera->RegisterActuator(this);
Py_Return;
}
PyErr_Clear();
@@ -336,7 +380,13 @@ PyObject* KX_SceneActuator::PySetCamera(PyObject* self,
}
KX_Camera *camOb = FindCamera(camName);
- if (camOb) m_camera = camOb;
+ if (camOb)
+ {
+ if (m_camera)
+ m_camera->UnregisterActuator(this);
+ m_camera = camOb;
+ m_camera->RegisterActuator(this);
+ }
Py_Return;
}
@@ -344,7 +394,7 @@ PyObject* KX_SceneActuator::PySetCamera(PyObject* self,
/* 7. getCamera: */
-char KX_SceneActuator::GetCamera_doc[] =
+const char KX_SceneActuator::GetCamera_doc[] =
"getCamera()\n"
"\tReturn the name of the camera to switch to.\n" ;
PyObject* KX_SceneActuator::PyGetCamera(PyObject* self,
diff --git a/source/gameengine/Ketsji/KX_SceneActuator.h b/source/gameengine/Ketsji/KX_SceneActuator.h
index cfc79b93f8e..55aaf629d7c 100644
--- a/source/gameengine/Ketsji/KX_SceneActuator.h
+++ b/source/gameengine/Ketsji/KX_SceneActuator.h
@@ -82,6 +82,9 @@ class KX_SceneActuator : public SCA_IActuator
virtual ~KX_SceneActuator();
virtual CValue* GetReplica();
+ virtual void ProcessReplica();
+ virtual bool UnlinkObject(SCA_IObject* clientobj);
+ virtual void Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map);
virtual bool Update();
diff --git a/source/gameengine/Ketsji/KX_SoundActuator.cpp b/source/gameengine/Ketsji/KX_SoundActuator.cpp
index 949156571a7..afa5af3bc04 100644
--- a/source/gameengine/Ketsji/KX_SoundActuator.cpp
+++ b/source/gameengine/Ketsji/KX_SoundActuator.cpp
@@ -69,11 +69,11 @@ KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
KX_SoundActuator::~KX_SoundActuator()
{
- //m_soundScene->RemoveObject(this->m_soundObject);
- //(this->m_soundObject)->DeleteWhenFinished();
- m_soundScene->RemoveActiveObject(m_soundObject);
-// m_soundScene->DeleteObjectWhenFinished(m_soundObject);
- m_soundScene->DeleteObject(m_soundObject);
+ if (m_soundObject)
+ {
+ m_soundScene->RemoveActiveObject(m_soundObject);
+ m_soundScene->DeleteObject(m_soundObject);
+ }
}
@@ -82,9 +82,12 @@ CValue* KX_SoundActuator::GetReplica()
{
KX_SoundActuator* replica = new KX_SoundActuator(*this);
replica->ProcessReplica();
- SND_SoundObject* soundobj = new SND_SoundObject(*m_soundObject);
- replica->setSoundObject(soundobj);
- m_soundScene->AddObject(soundobj);
+ if (m_soundObject)
+ {
+ SND_SoundObject* soundobj = new SND_SoundObject(*m_soundObject);
+ replica->setSoundObject(soundobj);
+ m_soundScene->AddObject(soundobj);
+ }
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
@@ -104,6 +107,12 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
RemoveAllEvents();
+ if (!m_soundObject)
+ return false;
+
+ // actual audio device playing state
+ bool isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED) ? true : false;
+
if (m_pino)
{
bNegativeEvent = true;
@@ -113,30 +122,40 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
if (bNegativeEvent)
{
// here must be a check if it is still playing
- m_isplaying = false;
-
- switch (m_type)
+ if (m_isplaying && isplaying)
{
- case KX_SOUNDACT_PLAYSTOP:
- case KX_SOUNDACT_LOOPSTOP:
- case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
- {
- m_soundScene->RemoveActiveObject(m_soundObject);
- break;
- }
- case KX_SOUNDACT_PLAYEND:
+ switch (m_type)
{
- m_soundObject->SetPlaystate(SND_MUST_STOP_WHEN_FINISHED);
+ case KX_SOUNDACT_PLAYSTOP:
+ case KX_SOUNDACT_LOOPSTOP:
+ case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
+ {
+ m_soundScene->RemoveActiveObject(m_soundObject);
+ break;
+ }
+ case KX_SOUNDACT_PLAYEND:
+ {
+ m_soundObject->SetPlaystate(SND_MUST_STOP_WHEN_FINISHED);
+ break;
+ }
+ case KX_SOUNDACT_LOOPEND:
+ case KX_SOUNDACT_LOOPBIDIRECTIONAL:
+ {
+ m_soundObject->SetLoopMode(SND_LOOP_OFF);
+ m_soundObject->SetPlaystate(SND_MUST_STOP_WHEN_FINISHED);
+ break;
+ }
+ default:
+ // implement me !!
break;
}
- default:
- // implement me !!
- break;
}
+ // remember that we tried to stop the actuator
+ m_isplaying = false;
}
else
{
- if (m_soundObject && !m_isplaying)
+ if (!m_isplaying)
{
switch (m_type)
{
@@ -173,8 +192,10 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
}
}
}
+ // verify that the sound is still playing
+ isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED) ? true : false;
- if (m_isplaying)
+ if (isplaying)
{
m_soundObject->SetPosition(((KX_GameObject*)this->GetParent())->NodeGetWorldPosition());
m_soundObject->SetVelocity(((KX_GameObject*)this->GetParent())->GetLinearVelocity());
@@ -183,14 +204,15 @@ bool KX_SoundActuator::Update(double curtime, bool frame)
}
else
{
+ m_isplaying = false;
result = false;
}
-
+ /*
if (result && (m_soundObject->IsLifeSpanOver(curtime)) && ((m_type == KX_SOUNDACT_PLAYEND) || (m_type == KX_SOUNDACT_PLAYSTOP)))
{
m_pino = true;
}
-
+ */
return result;
}
@@ -287,11 +309,16 @@ PyObject* KX_SoundActuator::PySetFilename(PyObject* self, PyObject* args, PyObje
PyObject* KX_SoundActuator::PyGetFilename(PyObject* self, PyObject* args, PyObject* kwds)
{
+ if (!m_soundObject)
+ {
+ return PyString_FromString("");
+ }
STR_String objectname = m_soundObject->GetObjectName();
char* name = objectname.Ptr();
if (!name) {
- Py_Return; /* internal error */
+ PyErr_SetString(PyExc_RuntimeError, "Unable to get sound filename");
+ return NULL;
} else
return PyString_FromString(name);
}
@@ -300,7 +327,11 @@ PyObject* KX_SoundActuator::PyGetFilename(PyObject* self, PyObject* args, PyObje
PyObject* KX_SoundActuator::PyStartSound(PyObject* self, PyObject* args, PyObject* kwds)
{
- m_soundObject->StartSound();
+ if (m_soundObject)
+ // This has no effect if the actuator is not active.
+ // To start the sound you must activate the actuator.
+ // This function is to restart the sound.
+ m_soundObject->StartSound();
Py_Return;
}
@@ -308,7 +339,9 @@ PyObject* KX_SoundActuator::PyStartSound(PyObject* self, PyObject* args, PyObjec
PyObject* KX_SoundActuator::PyPauseSound(PyObject* self, PyObject* args, PyObject* kwds)
{
- m_soundObject->PauseSound();
+ if (m_soundObject)
+ // unfortunately, openal does not implement pause correctly, it is equivalent to a stop
+ m_soundObject->PauseSound();
Py_Return;
}
@@ -316,7 +349,8 @@ PyObject* KX_SoundActuator::PyPauseSound(PyObject* self, PyObject* args, PyObjec
PyObject* KX_SoundActuator::PyStopSound(PyObject* self, PyObject* args, PyObject* kwds)
{
- m_soundObject->StopSound();
+ if (m_soundObject)
+ m_soundObject->StopSound();
Py_Return;
}
@@ -328,7 +362,8 @@ PyObject* KX_SoundActuator::PySetGain(PyObject* self, PyObject* args, PyObject*
if (!PyArg_ParseTuple(args, "f", &gain))
return NULL;
- m_soundObject->SetGain(gain);
+ if (m_soundObject)
+ m_soundObject->SetGain(gain);
Py_Return;
}
@@ -337,7 +372,7 @@ PyObject* KX_SoundActuator::PySetGain(PyObject* self, PyObject* args, PyObject*
PyObject* KX_SoundActuator::PyGetGain(PyObject* self, PyObject* args, PyObject* kwds)
{
- float gain = m_soundObject->GetGain();
+ float gain = (m_soundObject) ? m_soundObject->GetGain() : 1.0f;
PyObject* result = PyFloat_FromDouble(gain);
return result;
@@ -351,7 +386,8 @@ PyObject* KX_SoundActuator::PySetPitch(PyObject* self, PyObject* args, PyObject*
if (!PyArg_ParseTuple(args, "f", &pitch))
return NULL;
- m_soundObject->SetPitch(pitch);
+ if (m_soundObject)
+ m_soundObject->SetPitch(pitch);
Py_Return;
}
@@ -360,7 +396,7 @@ PyObject* KX_SoundActuator::PySetPitch(PyObject* self, PyObject* args, PyObject*
PyObject* KX_SoundActuator::PyGetPitch(PyObject* self, PyObject* args, PyObject* kwds)
{
- float pitch = m_soundObject->GetPitch();
+ float pitch = (m_soundObject) ? m_soundObject->GetPitch() : 1.0;
PyObject* result = PyFloat_FromDouble(pitch);
return result;
@@ -374,7 +410,8 @@ PyObject* KX_SoundActuator::PySetRollOffFactor(PyObject* self, PyObject* args, P
if (!PyArg_ParseTuple(args, "f", &rollofffactor))
return NULL;
- m_soundObject->SetRollOffFactor(rollofffactor);
+ if (m_soundObject)
+ m_soundObject->SetRollOffFactor(rollofffactor);
Py_Return;
}
@@ -383,7 +420,7 @@ PyObject* KX_SoundActuator::PySetRollOffFactor(PyObject* self, PyObject* args, P
PyObject* KX_SoundActuator::PyGetRollOffFactor(PyObject* self, PyObject* args, PyObject* kwds)
{
- float rollofffactor = m_soundObject->GetRollOffFactor();
+ float rollofffactor = (m_soundObject) ? m_soundObject->GetRollOffFactor() : 1.0;
PyObject* result = PyFloat_FromDouble(rollofffactor);
return result;
@@ -397,7 +434,8 @@ PyObject* KX_SoundActuator::PySetLooping(PyObject* self, PyObject* args, PyObjec
if (!PyArg_ParseTuple(args, "i", &looping))
return NULL;
- m_soundObject->SetLoopMode(looping);
+ if (m_soundObject)
+ m_soundObject->SetLoopMode(looping);
Py_Return;
}
@@ -406,7 +444,7 @@ PyObject* KX_SoundActuator::PySetLooping(PyObject* self, PyObject* args, PyObjec
PyObject* KX_SoundActuator::PyGetLooping(PyObject* self, PyObject* args, PyObject* kwds)
{
- int looping = m_soundObject->GetLoopMode();
+ int looping = (m_soundObject) ? m_soundObject->GetLoopMode() : SND_LOOP_OFF;
PyObject* result = PyInt_FromLong(looping);
return result;
@@ -424,7 +462,8 @@ PyObject* KX_SoundActuator::PySetPosition(PyObject* self, PyObject* args, PyObje
if (!PyArg_ParseTuple(args, "fff", &pos[0], &pos[1], &pos[2]))
return NULL;
- m_soundObject->SetPosition(pos);
+ if (m_soundObject)
+ m_soundObject->SetPosition(pos);
Py_Return;
}
@@ -441,7 +480,8 @@ PyObject* KX_SoundActuator::PySetVelocity(PyObject* self, PyObject* args, PyObje
if (!PyArg_ParseTuple(args, "fff", &vel[0], &vel[1], &vel[2]))
return NULL;
- m_soundObject->SetVelocity(vel);
+ if (m_soundObject)
+ m_soundObject->SetVelocity(vel);
Py_Return;
}
@@ -464,7 +504,8 @@ PyObject* KX_SoundActuator::PySetOrientation(PyObject* self, PyObject* args, PyO
if (!PyArg_ParseTuple(args, "fffffffff", &ori[0][0], &ori[0][1], &ori[0][2], &ori[1][0], &ori[1][1], &ori[1][2], &ori[2][0], &ori[2][1], &ori[2][2]))
return NULL;
- m_soundObject->SetOrientation(ori);
+ if (m_soundObject)
+ m_soundObject->SetOrientation(ori);
Py_Return;
}
diff --git a/source/gameengine/Ketsji/KX_StateActuator.cpp b/source/gameengine/Ketsji/KX_StateActuator.cpp
new file mode 100644
index 00000000000..e360c4bac1f
--- /dev/null
+++ b/source/gameengine/Ketsji/KX_StateActuator.cpp
@@ -0,0 +1,207 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * Actuator to toggle visibility/invisibility of objects
+ */
+
+#include "KX_StateActuator.h"
+#include "KX_GameObject.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+KX_StateActuator::KX_StateActuator(
+ SCA_IObject* gameobj,
+ int operation,
+ unsigned int mask,
+ PyTypeObject* T
+ )
+ : SCA_IActuator(gameobj,T),
+ m_operation(operation),
+ m_mask(mask)
+{
+ // intentionally empty
+}
+
+KX_StateActuator::~KX_StateActuator(
+ void
+ )
+{
+ // intentionally empty
+}
+
+CValue*
+KX_StateActuator::GetReplica(
+ void
+ )
+{
+ KX_StateActuator* replica = new KX_StateActuator(*this);
+ replica->ProcessReplica();
+ // this will copy properties and so on...
+ CValue::AddDataToReplica(replica);
+ return replica;
+}
+
+bool
+KX_StateActuator::Update()
+{
+ bool bNegativeEvent = IsNegativeEvent();
+ unsigned int objMask;
+
+ RemoveAllEvents();
+ if (bNegativeEvent) return false;
+
+ KX_GameObject *obj = (KX_GameObject*) GetParent();
+
+ objMask = obj->GetState();
+ switch (m_operation)
+ {
+ case OP_CPY:
+ objMask = m_mask;
+ break;
+ case OP_SET:
+ objMask |= m_mask;
+ break;
+ case OP_CLR:
+ objMask &= ~m_mask;
+ break;
+ case OP_NEG:
+ objMask ^= m_mask;
+ break;
+ default:
+ // unsupported operation, no nothing
+ return false;
+ }
+ obj->SetState(objMask);
+ return false;
+}
+
+/* ------------------------------------------------------------------------- */
+/* Python functions */
+/* ------------------------------------------------------------------------- */
+
+
+
+/* Integration hooks ------------------------------------------------------- */
+PyTypeObject
+KX_StateActuator::Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "KX_StateActuator",
+ sizeof(KX_StateActuator),
+ 0,
+ PyDestructor,
+ 0,
+ __getattr,
+ __setattr,
+ 0, //&MyPyCompare,
+ __repr,
+ 0, //&cvalue_as_number,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+PyParentObject
+KX_StateActuator::Parents[] = {
+ &KX_StateActuator::Type,
+ &SCA_IActuator::Type,
+ &SCA_ILogicBrick::Type,
+ &CValue::Type,
+ NULL
+};
+
+PyMethodDef
+KX_StateActuator::Methods[] = {
+ {"setOperation", (PyCFunction) KX_StateActuator::sPySetOperation,
+ METH_VARARGS, (PY_METHODCHAR)SetOperation_doc},
+ {"setMask", (PyCFunction) KX_StateActuator::sPySetMask,
+ METH_VARARGS, (PY_METHODCHAR)SetMask_doc},
+ {NULL,NULL} //Sentinel
+};
+
+PyObject*
+KX_StateActuator::_getattr(
+ const STR_String& attr
+ )
+{
+ _getattr_up(SCA_IActuator);
+};
+
+
+
+/* set operation ---------------------------------------------------------- */
+const char
+KX_StateActuator::SetOperation_doc[] =
+"setOperation(op)\n"
+"\t - op : bit operation (0=Copy, 1=Set, 2=Clear, 3=Negate)"
+"\tSet the type of bit operation to be applied on object state mask.\n"
+"\tUse setMask() to specify the bits that will be modified.\n";
+PyObject*
+
+KX_StateActuator::PySetOperation(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ int oper;
+
+ if(!PyArg_ParseTuple(args, "i", &oper)) {
+ return NULL;
+ }
+
+ m_operation = oper;
+
+ Py_Return;
+}
+
+/* set mask ---------------------------------------------------------- */
+const char
+KX_StateActuator::SetMask_doc[] =
+"setMask(mask)\n"
+"\t - mask : bits that will be modified"
+"\tSet the value that defines the bits that will be modified by the operation.\n"
+"\tThe bits that are 1 in the value will be updated in the object state,\n"
+"\tthe bits that are 0 are will be left unmodified expect for the Copy operation\n"
+"\twhich copies the value to the object state.\n";
+PyObject*
+
+KX_StateActuator::PySetMask(PyObject* self,
+ PyObject* args,
+ PyObject* kwds) {
+ int mask;
+
+ if(!PyArg_ParseTuple(args, "i", &mask)) {
+ return NULL;
+ }
+
+ m_mask = mask;
+
+ Py_Return;
+}
+
+
diff --git a/source/gameengine/Ketsji/KX_StateActuator.h b/source/gameengine/Ketsji/KX_StateActuator.h
new file mode 100644
index 00000000000..8698e51b2c1
--- /dev/null
+++ b/source/gameengine/Ketsji/KX_StateActuator.h
@@ -0,0 +1,83 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ * Actuator to toggle visibility/invisibility of objects
+ */
+
+#ifndef __KX_STATEACTUATOR
+#define __KX_STATEACTUATOR
+
+#include "SCA_IActuator.h"
+
+class KX_StateActuator : public SCA_IActuator
+{
+ Py_Header;
+
+ /** Make visible? */
+ enum {
+ OP_CPY = 0,
+ OP_SET,
+ OP_CLR,
+ OP_NEG
+ };
+ int m_operation;
+ unsigned int m_mask;
+
+ public:
+
+ KX_StateActuator(
+ SCA_IObject* gameobj,
+ int operation,
+ unsigned int mask,
+ PyTypeObject* T=&Type
+ );
+
+ virtual
+ ~KX_StateActuator(
+ void
+ );
+
+ virtual CValue*
+ GetReplica(
+ void
+ );
+
+ virtual bool
+ Update();
+
+ /* --------------------------------------------------------------------- */
+ /* Python interface ---------------------------------------------------- */
+ /* --------------------------------------------------------------------- */
+
+ virtual PyObject* _getattr(const STR_String& attr);
+ //KX_PYMETHOD_DOC
+ KX_PYMETHOD_DOC(KX_StateActuator,SetOperation);
+ KX_PYMETHOD_DOC(KX_StateActuator,SetMask);
+};
+
+#endif
+
diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp
index 6ea5461dbaa..c842ca1ee14 100644
--- a/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp
+++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.cpp
@@ -101,7 +101,7 @@ void KX_SumoPhysicsController::SetSumoTransform(bool nondynaonly)
}
-void KX_SumoPhysicsController::SuspendDynamics()
+void KX_SumoPhysicsController::SuspendDynamics(bool)
{
SumoPhysicsController::SuspendDynamics();
}
@@ -170,8 +170,9 @@ void KX_SumoPhysicsController::setMargin(float collisionMargin)
}
-void KX_SumoPhysicsController::setOrientation(const MT_Quaternion& orn)
+void KX_SumoPhysicsController::setOrientation(const MT_Matrix3x3& rot)
{
+ MT_Quaternion orn = rot.getRotation();
SumoPhysicsController::setOrientation(
orn[0],orn[1],orn[2],orn[3]);
@@ -204,6 +205,11 @@ MT_Scalar KX_SumoPhysicsController::GetMass()
return SumoPhysicsController::getMass();
}
+MT_Scalar KX_SumoPhysicsController::GetRadius()
+{
+ return SumoPhysicsController::GetRadius();
+}
+
MT_Vector3 KX_SumoPhysicsController::getReactionForce()
{
float force[3];
diff --git a/source/gameengine/Ketsji/KX_SumoPhysicsController.h b/source/gameengine/Ketsji/KX_SumoPhysicsController.h
index 868465c8f10..abe48d99043 100644
--- a/source/gameengine/Ketsji/KX_SumoPhysicsController.h
+++ b/source/gameengine/Ketsji/KX_SumoPhysicsController.h
@@ -68,20 +68,23 @@ public:
void ApplyTorque(const MT_Vector3& torque,bool local);
void ApplyForce(const MT_Vector3& force,bool local);
MT_Vector3 GetLinearVelocity();
+ MT_Vector3 GetAngularVelocity() // to keep compiler happy
+ { return MT_Vector3(0.0,0.0,0.0); }
MT_Vector3 GetVelocity(const MT_Point3& pos);
void SetAngularVelocity(const MT_Vector3& ang_vel,bool local);
void SetLinearVelocity(const MT_Vector3& lin_vel,bool local);
void resolveCombinedVelocities(float linvelX,float linvelY,float linvelZ,float angVelX,float angVelY,float angVelZ);
- void SuspendDynamics();
+ void SuspendDynamics(bool);
void RestoreDynamics();
virtual void getOrientation(MT_Quaternion& orn);
- virtual void setOrientation(const MT_Quaternion& orn);
+ virtual void setOrientation(const MT_Matrix3x3& orn);
virtual void setPosition(const MT_Point3& pos);
virtual void setScaling(const MT_Vector3& scaling);
virtual MT_Scalar GetMass();
+ virtual MT_Scalar GetRadius();
virtual MT_Vector3 getReactionForce();
virtual void setRigidBody(bool rigid);
diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.cpp b/source/gameengine/Ketsji/KX_TouchEventManager.cpp
index 2da899c62cb..48d4cf59a2b 100644
--- a/source/gameengine/Ketsji/KX_TouchEventManager.cpp
+++ b/source/gameengine/Ketsji/KX_TouchEventManager.cpp
@@ -51,6 +51,7 @@ KX_TouchEventManager::KX_TouchEventManager(class SCA_LogicManager* logicmgr,
m_physEnv->addTouchCallback(PHY_OBJECT_RESPONSE, KX_TouchEventManager::newCollisionResponse, this);
m_physEnv->addTouchCallback(PHY_SENSOR_RESPONSE, KX_TouchEventManager::newCollisionResponse, this);
+ m_physEnv->addTouchCallback(PHY_BROADPH_RESPONSE, KX_TouchEventManager::newBroadphaseResponse, this);
}
@@ -76,19 +77,47 @@ bool KX_TouchEventManager::newCollisionResponse(void *client_data,
return false;
}
+bool KX_TouchEventManager::newBroadphaseResponse(void *client_data,
+ void *object1,
+ void *object2,
+ const PHY_CollData *coll_data)
+{
+ PHY_IPhysicsController* ctrl = static_cast<PHY_IPhysicsController*>(object1);
+ KX_ClientObjectInfo* info = (ctrl) ? static_cast<KX_ClientObjectInfo*>(ctrl->getNewClientInfo()) : NULL;
+ // This call back should only be called for controllers of Near and Radar sensor
+ if (info &&
+ info->m_sensors.size() == 1 &&
+ (info->m_type == KX_ClientObjectInfo::NEAR ||
+ info->m_type == KX_ClientObjectInfo::RADAR))
+ {
+ // only one sensor for this type of object
+ KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(*info->m_sensors.begin());
+ return touchsensor->BroadPhaseFilterCollision(object1,object2);
+ }
+ return true;
+}
+
void KX_TouchEventManager::RegisterSensor(SCA_ISensor* sensor)
{
KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(sensor);
- m_sensors.push_back(touchsensor);
+ if (m_sensors.insert(touchsensor).second)
+ // the sensor was effectively inserted, register it
+ touchsensor->RegisterSumo(this);
+}
- touchsensor->RegisterSumo(this);
+void KX_TouchEventManager::RemoveSensor(SCA_ISensor* sensor)
+{
+ KX_TouchSensor* touchsensor = static_cast<KX_TouchSensor*>(sensor);
+ if (m_sensors.erase(touchsensor))
+ // the sensor was effectively removed, unregister it
+ touchsensor->UnregisterSumo(this);
}
void KX_TouchEventManager::EndFrame()
{
- vector<SCA_ISensor*>::iterator it;
+ set<SCA_ISensor*>::iterator it;
for ( it = m_sensors.begin();
!(it==m_sensors.end());it++)
{
@@ -103,7 +132,7 @@ void KX_TouchEventManager::NextFrame()
{
if (m_sensors.size() > 0)
{
- vector<SCA_ISensor*>::iterator it;
+ set<SCA_ISensor*>::iterator it;
for (it = m_sensors.begin();!(it==m_sensors.end());++it)
static_cast<KX_TouchSensor*>(*it)->SynchronizeTransform();
@@ -116,14 +145,18 @@ void KX_TouchEventManager::NextFrame()
// KX_GameObject* gameOb1 = ctrl1->getClientInfo();
KX_ClientObjectInfo *client_info = static_cast<KX_ClientObjectInfo *>(ctrl1->getNewClientInfo());
-
list<SCA_ISensor*>::iterator sit;
- for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit)
- static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision((*cit).first, (*cit).second, NULL);
-
+ if (client_info) {
+ for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) {
+ static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision((*cit).first, (*cit).second, NULL);
+ }
+ }
client_info = static_cast<KX_ClientObjectInfo *>((*cit).second->getNewClientInfo());
- for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit)
- static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision((*cit).second, (*cit).first, NULL);
+ if (client_info) {
+ for ( sit = client_info->m_sensors.begin(); sit != client_info->m_sensors.end(); ++sit) {
+ static_cast<KX_TouchSensor*>(*sit)->NewHandleCollision((*cit).second, (*cit).first, NULL);
+ }
+ }
}
m_newCollisions.clear();
@@ -132,20 +165,3 @@ void KX_TouchEventManager::NextFrame()
(*it)->Activate(m_logicmgr,NULL);
}
}
-
-
-
-void KX_TouchEventManager::RemoveSensor(class SCA_ISensor* sensor)
-{
- std::vector<SCA_ISensor*>::iterator i =
- std::find(m_sensors.begin(), m_sensors.end(), sensor);
- if (!(i == m_sensors.end()))
- {
- std::swap(*i, m_sensors.back());
- m_sensors.pop_back();
- }
-
- // remove the sensor forever :)
- SCA_EventManager::RemoveSensor(sensor);
-}
-
diff --git a/source/gameengine/Ketsji/KX_TouchEventManager.h b/source/gameengine/Ketsji/KX_TouchEventManager.h
index d15128284da..cc77bccfc31 100644
--- a/source/gameengine/Ketsji/KX_TouchEventManager.h
+++ b/source/gameengine/Ketsji/KX_TouchEventManager.h
@@ -53,7 +53,12 @@ class KX_TouchEventManager : public SCA_EventManager
void *object1,
void *object2,
const PHY_CollData *coll_data);
-
+
+ static bool newBroadphaseResponse(void *client_data,
+ void *object1,
+ void *object2,
+ const PHY_CollData *coll_data);
+
virtual bool NewHandleCollision(void* obj1,void* obj2,
const PHY_CollData * coll_data);
@@ -66,8 +71,8 @@ public:
PHY_IPhysicsEnvironment* physEnv);
virtual void NextFrame();
virtual void EndFrame();
- virtual void RemoveSensor(class SCA_ISensor* sensor);
virtual void RegisterSensor(SCA_ISensor* sensor);
+ virtual void RemoveSensor(SCA_ISensor* sensor);
SCA_LogicManager* GetLogicManager() { return m_logicmgr;}
PHY_IPhysicsEnvironment *GetPhysicsEnvironment() { return m_physEnv; }
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.cpp b/source/gameengine/Ketsji/KX_TouchSensor.cpp
index 62e400a7049..1935a0bde39 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.cpp
+++ b/source/gameengine/Ketsji/KX_TouchSensor.cpp
@@ -48,30 +48,30 @@
void KX_TouchSensor::SynchronizeTransform()
{
-
- if (m_physCtrl)
- {
-
- KX_GameObject* parent = ((KX_GameObject*)GetParent());
- MT_Vector3 pos = parent->NodeGetWorldPosition();
- MT_Quaternion orn = parent->NodeGetWorldOrientation().getRotation();
- m_physCtrl->setPosition(pos.x(),pos.y(),pos.z());
- m_physCtrl->setOrientation(orn.x(),orn.y(),orn.z(),orn.w());
- m_physCtrl->calcXform();
- }
-
+ // the touch sensor does not require any synchronization: it uses
+ // the same physical object which is already synchronized by Blender
}
void KX_TouchSensor::EndFrame() {
m_colliders->ReleaseAndRemoveAll();
+ m_hitObject = NULL;
m_bTriggered = false;
}
+void KX_TouchSensor::UnregisterToManager()
+{
+ // before unregistering the sensor, make sure we release all references
+ EndFrame();
+ m_eventmgr->RemoveSensor(this);
+}
+
bool KX_TouchSensor::Evaluate(CValue* event)
{
bool result = false;
+ bool reset = m_reset && m_level;
+ m_reset = false;
if (m_bTriggered != m_bLastTriggered)
{
m_bLastTriggered = m_bTriggered;
@@ -79,7 +79,9 @@ bool KX_TouchSensor::Evaluate(CValue* event)
m_hitObject = NULL;
result = true;
}
-
+ if (reset)
+ // force an event
+ result = true;
return result;
}
@@ -87,18 +89,14 @@ KX_TouchSensor::KX_TouchSensor(SCA_EventManager* eventmgr,KX_GameObject* gameobj
:SCA_ISensor(gameobj,eventmgr,T),
m_touchedpropname(touchedpropname),
m_bFindMaterial(bFindMaterial),
-m_eventmgr(eventmgr),
+m_eventmgr(eventmgr)
/*m_sumoObj(sumoObj),*/
-m_bCollision(false),
-m_bTriggered(false),
-m_bLastTriggered(false)
{
// KX_TouchEventManager* touchmgr = (KX_TouchEventManager*) eventmgr;
// m_resptable = touchmgr->GetResponseTable();
// m_solidHandle = m_sumoObj->getObjectHandle();
- m_hitObject = NULL;
m_colliders = new CListValue();
KX_ClientObjectInfo *client_info = gameobj->getClientInfo();
@@ -108,8 +106,17 @@ m_bLastTriggered(false)
m_physCtrl = dynamic_cast<PHY_IPhysicsController*>(gameobj->GetPhysicsController());
MT_assert( !gameobj->GetPhysicsController() || m_physCtrl );
+ Init();
}
+void KX_TouchSensor::Init()
+{
+ m_bCollision = false;
+ m_bTriggered = false;
+ m_bLastTriggered = (m_invert)?true:false;
+ m_hitObject = NULL;
+ m_reset = true;
+}
KX_TouchSensor::~KX_TouchSensor()
{
@@ -121,10 +128,7 @@ CValue* KX_TouchSensor::GetReplica()
{
KX_TouchSensor* replica = new KX_TouchSensor(*this);
replica->m_colliders = new CListValue();
- replica->m_bCollision = false;
- replica->m_bTriggered= false;
- replica->m_hitObject = NULL;
- replica->m_bLastTriggered = false;
+ replica->Init();
// this will copy properties and so on...
CValue::AddDataToReplica(replica);
return replica;
@@ -157,6 +161,14 @@ void KX_TouchSensor::RegisterSumo(KX_TouchEventManager *touchman)
}
}
+void KX_TouchSensor::UnregisterSumo(KX_TouchEventManager* touchman)
+{
+ if (m_physCtrl)
+ {
+ touchman->GetPhysicsEnvironment()->removeCollisionCallback(m_physCtrl);
+ }
+}
+
bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_CollData* colldata)
{
// KX_TouchEventManager* toucheventmgr = (KX_TouchEventManager*)m_eventmgr;
@@ -172,7 +184,10 @@ bool KX_TouchSensor::NewHandleCollision(void*object1,void*object2,const PHY_Coll
client_info->m_gameobject :
NULL);
- if (gameobj && (gameobj != parent) && client_info->isActor())
+ // add the same check as in SCA_ISensor::Activate(),
+ // we don't want to record collision when the sensor is not active.
+ if (m_links && !m_suspended &&
+ gameobj && (gameobj != parent) && client_info->isActor())
{
if (!m_colliders->SearchValue(gameobj))
m_colliders->Add(gameobj->AddRef());
@@ -236,13 +251,13 @@ PyParentObject KX_TouchSensor::Parents[] = {
PyMethodDef KX_TouchSensor::Methods[] = {
{"setProperty",
- (PyCFunction) KX_TouchSensor::sPySetProperty, METH_VARARGS, SetProperty_doc},
+ (PyCFunction) KX_TouchSensor::sPySetProperty, METH_VARARGS, (PY_METHODCHAR)SetProperty_doc},
{"getProperty",
- (PyCFunction) KX_TouchSensor::sPyGetProperty, METH_VARARGS, GetProperty_doc},
+ (PyCFunction) KX_TouchSensor::sPyGetProperty, METH_VARARGS, (PY_METHODCHAR)GetProperty_doc},
{"getHitObject",
- (PyCFunction) KX_TouchSensor::sPyGetHitObject, METH_VARARGS, GetHitObject_doc},
+ (PyCFunction) KX_TouchSensor::sPyGetHitObject, METH_VARARGS, (PY_METHODCHAR)GetHitObject_doc},
{"getHitObjectList",
- (PyCFunction) KX_TouchSensor::sPyGetHitObjectList, METH_VARARGS, GetHitObjectList_doc},
+ (PyCFunction) KX_TouchSensor::sPyGetHitObjectList, METH_VARARGS, (PY_METHODCHAR)GetHitObjectList_doc},
{NULL,NULL} //Sentinel
};
@@ -253,7 +268,7 @@ PyObject* KX_TouchSensor::_getattr(const STR_String& attr) {
/* Python API */
/* 1. setProperty */
-char KX_TouchSensor::SetProperty_doc[] =
+const char KX_TouchSensor::SetProperty_doc[] =
"setProperty(name)\n"
"\t- name: string\n"
"\tSet the property or material to collide with. Use\n"
@@ -271,15 +286,15 @@ PyObject* KX_TouchSensor::PySetProperty(PyObject* self,
if (!prop->IsError()) {
m_touchedpropname = nameArg;
- prop->Release();
} else {
; /* not found ... */
}
+ prop->Release();
Py_Return;
}
/* 2. getProperty */
-char KX_TouchSensor::GetProperty_doc[] =
+const char KX_TouchSensor::GetProperty_doc[] =
"getProperty(name)\n"
"\tReturns the property or material to collide with. Use\n"
"\tgetTouchMaterial() to find out whether this sensor\n"
@@ -290,7 +305,7 @@ PyObject* KX_TouchSensor::PyGetProperty(PyObject* self,
return PyString_FromString(m_touchedpropname);
}
-char KX_TouchSensor::GetHitObject_doc[] =
+const char KX_TouchSensor::GetHitObject_doc[] =
"getHitObject()\n"
;
PyObject* KX_TouchSensor::PyGetHitObject(PyObject* self,
@@ -306,7 +321,7 @@ PyObject* KX_TouchSensor::PyGetHitObject(PyObject* self,
Py_Return;
}
-char KX_TouchSensor::GetHitObjectList_doc[] =
+const char KX_TouchSensor::GetHitObjectList_doc[] =
"getHitObjectList()\n"
"\tReturn a list of the objects this object collided with,\n"
"\tbut only those matching the property/material condition.\n";
@@ -348,8 +363,8 @@ PyObject* KX_TouchSensor::PyGetHitObjectList(PyObject* self,
CValue* val = m_colliders->GetValue(i)->FindIdentifier(m_touchedpropname);
if (!val->IsError()) {
newList->Add(m_colliders->GetValue(i)->AddRef());
- val->Release();
}
+ val->Release();
}
i++;
@@ -360,7 +375,7 @@ PyObject* KX_TouchSensor::PyGetHitObjectList(PyObject* self,
}
/* 5. getTouchMaterial */
-char KX_TouchSensor::GetTouchMaterial_doc[] =
+const char KX_TouchSensor::GetTouchMaterial_doc[] =
"getTouchMaterial()\n"
"\tReturns KX_TRUE if this sensor looks for a specific material,\n"
"\tKX_FALSE if it looks for a specific property.\n" ;
@@ -372,7 +387,7 @@ PyObject* KX_TouchSensor::PyGetTouchMaterial(PyObject* self,
}
/* 6. setTouchMaterial */
-char KX_TouchSensor::SetTouchMaterial_doc[] =
+const char KX_TouchSensor::SetTouchMaterial_doc[] =
"setTouchMaterial(flag)\n"
"\t- flag: KX_TRUE or KX_FALSE.\n"
"\tSet flag to KX_TRUE to switch on positive pulse mode,\n"
diff --git a/source/gameengine/Ketsji/KX_TouchSensor.h b/source/gameengine/Ketsji/KX_TouchSensor.h
index dd869fa69c9..8fbb1c676ba 100644
--- a/source/gameengine/Ketsji/KX_TouchSensor.h
+++ b/source/gameengine/Ketsji/KX_TouchSensor.h
@@ -54,8 +54,6 @@ protected:
class SCA_EventManager* m_eventmgr;
class PHY_IPhysicsController* m_physCtrl;
- class PHY_ResponseTable* m_responstTable;
- class PHY_PhysicsController* m_responsObject;
bool m_bCollision;
bool m_bTriggered;
@@ -74,16 +72,23 @@ public:
virtual CValue* GetReplica();
virtual void SynchronizeTransform();
virtual bool Evaluate(CValue* event);
+ virtual void Init();
virtual void ReParent(SCA_IObject* parent);
virtual void RegisterSumo(KX_TouchEventManager* touchman);
+ virtual void UnregisterSumo(KX_TouchEventManager* touchman);
+ virtual void UnregisterToManager();
// virtual DT_Bool HandleCollision(void* obj1,void* obj2,
// const DT_CollData * coll_data);
virtual bool NewHandleCollision(void*obj1,void*obj2,const PHY_CollData* colldata);
- PHY_PhysicsController* GetPhysicsController() { return m_responsObject;}
+ // Allows to do pre-filtering and save computation time
+ // obj1 = sensor physical controller, obj2 = physical controller of second object
+ // return value = true if collision should be checked on pair of object
+ virtual bool BroadPhaseFilterCollision(void*obj1,void*obj2) { return true; }
+
virtual bool IsPositiveTrigger() {
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
index dc637bf0837..acc4a6ab5d7 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
@@ -42,6 +42,8 @@
#include <iostream>
#include "KX_GameObject.h"
+#include "PyObjectPlus.h"
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -69,12 +71,19 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj,
m_upflag = upflag;
m_parentobj = 0;
- if (m_object){
- KX_GameObject* curobj = (KX_GameObject*) GetParent();
+ if (m_object)
+ m_object->RegisterActuator(this);
- m_parentobj = curobj->GetParent(); // check if the object is parented
- if (m_parentobj) { // if so, store the initial local rotation
- m_parentlocalmat = m_parentobj->GetSGNode()->GetLocalOrientation();
+ if (gameobj->isA(&KX_GameObject::Type))
+ {
+ // if the object is vertex parented, don't check parent orientation as the link is broken
+ if (!((KX_GameObject*)gameobj)->IsVertexParent()){
+ m_parentobj = ((KX_GameObject*)gameobj)->GetParent(); // check if the object is parented
+ if (m_parentobj) {
+ // if so, store the initial local rotation
+ // this is needed to revert the effect of the parent inverse node (TBC)
+ m_parentlocalmat = m_parentobj->GetSGNode()->GetLocalOrientation();
+ }
}
}
@@ -139,19 +148,19 @@ void compatible_eulFast(float *eul, float *oldrot)
{
float dx, dy, dz;
- /* verschillen van ong 360 graden corrigeren */
+ /* angular difference of 360 degrees */
dx= eul[0] - oldrot[0];
dy= eul[1] - oldrot[1];
dz= eul[2] - oldrot[2];
- if( fabs(dx) > 5.1) {
+ if( fabs(dx) > MT_PI) {
if(dx > 0.0) eul[0] -= MT_2_PI; else eul[0]+= MT_2_PI;
}
- if( fabs(dy) > 5.1) {
+ if( fabs(dy) > MT_PI) {
if(dy > 0.0) eul[1] -= MT_2_PI; else eul[1]+= MT_2_PI;
}
- if( fabs(dz) > 5.1 ) {
+ if( fabs(dz) > MT_PI ) {
if(dz > 0.0) eul[2] -= MT_2_PI; else eul[2]+= MT_2_PI;
}
}
@@ -176,10 +185,53 @@ MT_Matrix3x3 matrix3x3_interpol(MT_Matrix3x3 oldmat, MT_Matrix3x3 mat, int m_tim
KX_TrackToActuator::~KX_TrackToActuator()
-{
- // there's nothing to be done here, really....
+{
+ if (m_object)
+ m_object->UnregisterActuator(this);
+ if (m_parentobj)
+ m_parentobj->Release();
} /* end of destructor */
+void KX_TrackToActuator::ProcessReplica()
+{
+ // the replica is tracking the same object => register it
+ if (m_object)
+ m_object->RegisterActuator(this);
+ if (m_parentobj)
+ m_parentobj->AddRef();
+ SCA_IActuator::ProcessReplica();
+}
+
+
+bool KX_TrackToActuator::UnlinkObject(SCA_IObject* clientobj)
+{
+ if (clientobj == m_object)
+ {
+ // this object is being deleted, we cannot continue to track it.
+ m_object = NULL;
+ return true;
+ }
+ return false;
+}
+
+void KX_TrackToActuator::Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map)
+{
+ void **h_obj = (*obj_map)[m_object];
+ if (h_obj) {
+ if (m_object)
+ m_object->UnregisterActuator(this);
+ m_object = (SCA_IObject*)(*h_obj);
+ m_object->RegisterActuator(this);
+ }
+
+ void **h_parobj = (*obj_map)[m_parentobj];
+ if (h_parobj) {
+ if (m_parentobj)
+ m_parentobj->Release();
+ m_parentobj= (KX_GameObject*)(*h_parobj);
+ m_parentobj->AddRef();
+ }
+}
bool KX_TrackToActuator::Update(double curtime, bool frame)
@@ -196,7 +248,8 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
{
KX_GameObject* curobj = (KX_GameObject*) GetParent();
MT_Vector3 dir = ((KX_GameObject*)m_object)->NodeGetWorldPosition() - curobj->NodeGetWorldPosition();
- dir.normalize();
+ if (dir.length2())
+ dir.normalize();
MT_Vector3 up(0,0,1);
@@ -222,12 +275,12 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
#endif
if (m_allow3D)
{
- up = (up - up.dot(dir) * dir).normalized();
+ up = (up - up.dot(dir) * dir).safe_normalized();
}
else
{
- dir = (dir - up.dot(dir)*up).normalized();
+ dir = (dir - up.dot(dir)*up).safe_normalized();
}
MT_Vector3 left;
@@ -238,8 +291,8 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
case 0: // TRACK X
{
// (1.0 , 0.0 , 0.0 ) x direction is forward, z (0.0 , 0.0 , 1.0 ) up
- left = dir.normalized();
- dir = (left.cross(up)).normalized();
+ left = dir.safe_normalized();
+ dir = (left.cross(up)).safe_normalized();
mat.setValue (
left[0], dir[0],up[0],
left[1], dir[1],up[1],
@@ -251,7 +304,7 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
case 1: // TRACK Y
{
// (0.0 , 1.0 , 0.0 ) y direction is forward, z (0.0 , 0.0 , 1.0 ) up
- left = (dir.cross(up)).normalized();
+ left = (dir.cross(up)).safe_normalized();
mat.setValue (
left[0], dir[0],up[0],
left[1], dir[1],up[1],
@@ -263,10 +316,10 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
case 2: // track Z
{
- left = up.normalized();
- up = dir.normalized();
+ left = up.safe_normalized();
+ up = dir.safe_normalized();
dir = left;
- left = (dir.cross(up)).normalized();
+ left = (dir.cross(up)).safe_normalized();
mat.setValue (
left[0], dir[0],up[0],
left[1], dir[1],up[1],
@@ -278,8 +331,8 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
case 3: // TRACK -X
{
// (1.0 , 0.0 , 0.0 ) x direction is forward, z (0.0 , 0.0 , 1.0 ) up
- left = -dir.normalized();
- dir = -(left.cross(up)).normalized();
+ left = -dir.safe_normalized();
+ dir = -(left.cross(up)).safe_normalized();
mat.setValue (
left[0], dir[0],up[0],
left[1], dir[1],up[1],
@@ -291,7 +344,7 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
case 4: // TRACK -Y
{
// (0.0 , -1.0 , 0.0 ) -y direction is forward, z (0.0 , 0.0 , 1.0 ) up
- left = (-dir.cross(up)).normalized();
+ left = (-dir.cross(up)).safe_normalized();
mat.setValue (
left[0], -dir[0],up[0],
left[1], -dir[1],up[1],
@@ -301,10 +354,10 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
}
case 5: // track -Z
{
- left = up.normalized();
- up = -dir.normalized();
+ left = up.safe_normalized();
+ up = -dir.safe_normalized();
dir = left;
- left = (dir.cross(up)).normalized();
+ left = (dir.cross(up)).safe_normalized();
mat.setValue (
left[0], dir[0],up[0],
left[1], dir[1],up[1],
@@ -317,8 +370,8 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
default:
{
// (1.0 , 0.0 , 0.0 ) -x direction is forward, z (0.0 , 0.0 , 1.0 ) up
- left = -dir.normalized();
- dir = -(left.cross(up)).normalized();
+ left = -dir.safe_normalized();
+ dir = -(left.cross(up)).safe_normalized();
mat.setValue (
left[0], dir[0],up[0],
left[1], dir[1],up[1],
@@ -403,12 +456,12 @@ PyParentObject KX_TrackToActuator::Parents[] = {
PyMethodDef KX_TrackToActuator::Methods[] = {
- {"setObject", (PyCFunction) KX_TrackToActuator::sPySetObject, METH_VARARGS, SetObject_doc},
- {"getObject", (PyCFunction) KX_TrackToActuator::sPyGetObject, METH_VARARGS, GetObject_doc},
- {"setTime", (PyCFunction) KX_TrackToActuator::sPySetTime, METH_VARARGS, SetTime_doc},
- {"getTime", (PyCFunction) KX_TrackToActuator::sPyGetTime, METH_VARARGS, GetTime_doc},
- {"setUse3D", (PyCFunction) KX_TrackToActuator::sPySetUse3D, METH_VARARGS, SetUse3D_doc},
- {"getUse3D", (PyCFunction) KX_TrackToActuator::sPyGetUse3D, METH_VARARGS, GetUse3D_doc},
+ {"setObject", (PyCFunction) KX_TrackToActuator::sPySetObject, METH_O, (PY_METHODCHAR)SetObject_doc},
+ {"getObject", (PyCFunction) KX_TrackToActuator::sPyGetObject, METH_VARARGS, (PY_METHODCHAR)GetObject_doc},
+ {"setTime", (PyCFunction) KX_TrackToActuator::sPySetTime, METH_VARARGS, (PY_METHODCHAR)SetTime_doc},
+ {"getTime", (PyCFunction) KX_TrackToActuator::sPyGetTime, METH_VARARGS, (PY_METHODCHAR)GetTime_doc},
+ {"setUse3D", (PyCFunction) KX_TrackToActuator::sPySetUse3D, METH_VARARGS, (PY_METHODCHAR)SetUse3D_doc},
+ {"getUse3D", (PyCFunction) KX_TrackToActuator::sPyGetUse3D, METH_VARARGS, (PY_METHODCHAR)GetUse3D_doc},
{NULL,NULL} //Sentinel
};
@@ -422,49 +475,53 @@ PyObject* KX_TrackToActuator::_getattr(const STR_String& attr)
/* 1. setObject */
-char KX_TrackToActuator::SetObject_doc[] =
+const char KX_TrackToActuator::SetObject_doc[] =
"setObject(object)\n"
-"\t- object: string\n"
+"\t- object: KX_GameObject, string or None\n"
"\tSet the object to track with the parent of this actuator.\n";
-PyObject* KX_TrackToActuator::PySetObject(PyObject* self, PyObject* args, PyObject* kwds) {
- PyObject* gameobj;
- if (PyArg_ParseTuple(args, "O!", &KX_GameObject::Type, &gameobj))
- {
- m_object = (SCA_IObject*)gameobj;
-
- Py_Return;
- }
- PyErr_Clear();
+PyObject* KX_TrackToActuator::PySetObject(PyObject* self, PyObject* value)
+{
+ KX_GameObject *gameobj;
- char* objectname;
- if (PyArg_ParseTuple(args, "s", &objectname))
- {
- m_object= static_cast<SCA_IObject*>(SCA_ILogicBrick::m_sCurrentLogicManager->GetGameObjectByName(STR_String(objectname)));
-
- Py_Return;
- }
+ if (!ConvertPythonToGameObject(value, &gameobj, true))
+ return NULL; // ConvertPythonToGameObject sets the error
+
+ if (m_object != NULL)
+ m_object->UnregisterActuator(this);
+
+ m_object = (SCA_IObject*)gameobj;
+ if (m_object)
+ m_object->RegisterActuator(this);
- return NULL;
+ Py_RETURN_NONE;
}
/* 2. getObject */
-char KX_TrackToActuator::GetObject_doc[] =
-"getObject()\n"
-"\tReturns the object to track with the parent of this actuator.\n";
-PyObject* KX_TrackToActuator::PyGetObject(PyObject* self, PyObject* args, PyObject* kwds)
+const char KX_TrackToActuator::GetObject_doc[] =
+"getObject(name_only = 1)\n"
+"name_only - optional arg, when true will return the KX_GameObject rather then its name\n"
+"\tReturns the object to track with the parent of this actuator\n";
+PyObject* KX_TrackToActuator::PyGetObject(PyObject* self, PyObject* args)
{
+ int ret_name_only = 1;
+ if (!PyArg_ParseTuple(args, "|i", &ret_name_only))
+ return NULL;
+
if (!m_object)
- Py_Return;
-
- return PyString_FromString(m_object->GetName());
+ Py_RETURN_NONE;
+
+ if (ret_name_only)
+ return PyString_FromString(m_object->GetName());
+ else
+ return m_object->AddRef();
}
/* 3. setTime */
-char KX_TrackToActuator::SetTime_doc[] =
+const char KX_TrackToActuator::SetTime_doc[] =
"setTime(time)\n"
"\t- time: integer\n"
"\tSet the time in frames with which to delay the tracking motion.\n";
@@ -485,7 +542,7 @@ PyObject* KX_TrackToActuator::PySetTime(PyObject* self, PyObject* args, PyObject
/* 4.getTime */
-char KX_TrackToActuator::GetTime_doc[] =
+const char KX_TrackToActuator::GetTime_doc[] =
"getTime()\n"
"\t- time: integer\n"
"\tReturn the time in frames with which the tracking motion is delayed.\n";
@@ -497,7 +554,7 @@ PyObject* KX_TrackToActuator::PyGetTime(PyObject* self, PyObject* args, PyObject
/* 5. getUse3D */
-char KX_TrackToActuator::GetUse3D_doc[] =
+const char KX_TrackToActuator::GetUse3D_doc[] =
"getUse3D()\n"
"\tReturns 1 if the motion is allowed to extend in the z-direction.\n";
PyObject* KX_TrackToActuator::PyGetUse3D(PyObject* self, PyObject* args, PyObject* kwds)
@@ -508,7 +565,7 @@ PyObject* KX_TrackToActuator::PyGetUse3D(PyObject* self, PyObject* args, PyObjec
/* 6. setUse3D */
-char KX_TrackToActuator::SetUse3D_doc[] =
+const char KX_TrackToActuator::SetUse3D_doc[] =
"setUse3D(value)\n"
"\t- value: 0 or 1\n"
"\tSet to 1 to allow the tracking motion to extend in the z-direction,\n"
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h
index 944eaadf025..445132a6094 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.h
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.h
@@ -66,15 +66,18 @@ class KX_TrackToActuator : public SCA_IActuator
return replica;
};
+ virtual void ProcessReplica();
+ virtual bool UnlinkObject(SCA_IObject* clientobj);
+ virtual void Relink(GEN_Map<GEN_HashedPtr, void*> *obj_map);
virtual bool Update(double curtime, bool frame);
/* Python part */
virtual PyObject* _getattr(const STR_String& attr);
/* 1. setObject */
- KX_PYMETHOD_DOC(KX_TrackToActuator,SetObject);
+ KX_PYMETHOD_DOC_O(KX_TrackToActuator,SetObject);
/* 2. getObject */
- KX_PYMETHOD_DOC(KX_TrackToActuator,GetObject);
+ KX_PYMETHOD_DOC_VARARGS(KX_TrackToActuator,GetObject);
/* 3. setTime */
KX_PYMETHOD_DOC(KX_TrackToActuator,SetTime);
/* 4. getTime */
diff --git a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
index fba2ecc223b..028f96f6c5b 100644
--- a/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
+++ b/source/gameengine/Ketsji/KX_VehicleWrapper.cpp
@@ -1,6 +1,8 @@
#include <Python.h>
+#include "PyObjectPlus.h"
+
#include "KX_VehicleWrapper.h"
#include "PHY_IPhysicsEnvironment.h"
#include "PHY_IVehicle.h"
@@ -47,30 +49,34 @@ PyObject* KX_VehicleWrapper::PyAddWheel(PyObject* self,
if (PyArg_ParseTuple(args,"OOOOffi",&wheelGameObject,&pylistPos,&pylistDir,&pylistAxleDir,&suspensionRestLength,&wheelRadius,&hasSteering))
{
KX_GameObject* gameOb = (KX_GameObject*) wheelGameObject;
+
+ if (gameOb->GetSGNode())
+ {
+ PHY_IMotionState* motionState = new KX_MotionState(gameOb->GetSGNode());
+
+ MT_Vector3 attachPos,attachDir,attachAxle;
+ PyVecTo(pylistPos,attachPos);
+ PyVecTo(pylistDir,attachDir);
+ PyVecTo(pylistAxleDir,attachAxle);
+ PHY__Vector3 aPos,aDir,aAxle;
+ aPos[0] = attachPos[0];
+ aPos[1] = attachPos[1];
+ aPos[2] = attachPos[2];
+ aDir[0] = attachDir[0];
+ aDir[1] = attachDir[1];
+ aDir[2] = attachDir[2];
+ aAxle[0] = -attachAxle[0];//someone reverse some conventions inside Bullet (axle winding)
+ aAxle[1] = -attachAxle[1];
+ aAxle[2] = -attachAxle[2];
+
+ printf("attempt for addWheel: suspensionRestLength%f wheelRadius %f, hasSteering:%d\n",suspensionRestLength,wheelRadius,hasSteering);
+ m_vehicle->AddWheel(motionState,aPos,aDir,aAxle,suspensionRestLength,wheelRadius,hasSteering);
+ }
- PHY_IMotionState* motionState = new KX_MotionState(gameOb->GetSGNode());
-
- MT_Vector3 attachPos,attachDir,attachAxle;
- PyVecTo(pylistPos,attachPos);
- PyVecTo(pylistDir,attachDir);
- PyVecTo(pylistAxleDir,attachAxle);
- PHY__Vector3 aPos,aDir,aAxle;
- aPos[0] = attachPos[0];
- aPos[1] = attachPos[1];
- aPos[2] = attachPos[2];
- aDir[0] = attachDir[0];
- aDir[1] = attachDir[1];
- aDir[2] = attachDir[2];
- aAxle[0] = -attachAxle[0];//someone reverse some conventions inside Bullet (axle winding)
- aAxle[1] = -attachAxle[1];
- aAxle[2] = -attachAxle[2];
-
- printf("attempt for addWheel: suspensionRestLength%f wheelRadius %f, hasSteering:%d\n",suspensionRestLength,wheelRadius,hasSteering);
- m_vehicle->AddWheel(motionState,aPos,aDir,aAxle,suspensionRestLength,wheelRadius,hasSteering);
-
+ } else {
+ return NULL;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
@@ -90,8 +96,7 @@ PyObject* KX_VehicleWrapper::PyGetWheelPosition(PyObject* self,
MT_Vector3 pos(position[0],position[1],position[2]);
return PyObjectFrom(pos);
}
- Py_INCREF(Py_None);
- return Py_None;
+ return NULL;
}
PyObject* KX_VehicleWrapper::PyGetWheelRotation(PyObject* self,
@@ -103,8 +108,7 @@ PyObject* KX_VehicleWrapper::PyGetWheelRotation(PyObject* self,
{
return PyFloat_FromDouble(m_vehicle->GetWheelRotation(wheelIndex));
}
- Py_INCREF(Py_None);
- return Py_None;
+ return NULL;
}
PyObject* KX_VehicleWrapper::PyGetWheelOrientationQuaternion(PyObject* self,
@@ -120,8 +124,7 @@ PyObject* KX_VehicleWrapper::PyGetWheelOrientationQuaternion(PyObject* self,
MT_Matrix3x3 ornmat(quatorn);
return PyObjectFrom(ornmat);
}
- Py_INCREF(Py_None);
- return Py_None;
+ return NULL;
}
@@ -155,8 +158,10 @@ PyObject* KX_VehicleWrapper::PyApplyEngineForce(PyObject* self,
force *= -1.f;//someone reverse some conventions inside Bullet (axle winding)
m_vehicle->ApplyEngineForce(force,wheelIndex);
}
- Py_INCREF(Py_None);
- return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
PyObject* KX_VehicleWrapper::PySetTyreFriction(PyObject* self,
@@ -170,8 +175,10 @@ PyObject* KX_VehicleWrapper::PySetTyreFriction(PyObject* self,
{
m_vehicle->SetWheelFriction(wheelFriction,wheelIndex);
}
- Py_INCREF(Py_None);
- return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
PyObject* KX_VehicleWrapper::PySetSuspensionStiffness(PyObject* self,
@@ -185,8 +192,10 @@ PyObject* KX_VehicleWrapper::PySetSuspensionStiffness(PyObject* self,
{
m_vehicle->SetSuspensionStiffness(suspensionStiffness,wheelIndex);
}
- Py_INCREF(Py_None);
- return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
PyObject* KX_VehicleWrapper::PySetSuspensionDamping(PyObject* self,
@@ -199,9 +208,10 @@ PyObject* KX_VehicleWrapper::PySetSuspensionDamping(PyObject* self,
if (PyArg_ParseTuple(args,"fi",&suspensionDamping,&wheelIndex))
{
m_vehicle->SetSuspensionDamping(suspensionDamping,wheelIndex);
+ } else {
+ return NULL;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyObject* KX_VehicleWrapper::PySetSuspensionCompression(PyObject* self,
@@ -214,9 +224,10 @@ PyObject* KX_VehicleWrapper::PySetSuspensionCompression(PyObject* self,
if (PyArg_ParseTuple(args,"fi",&suspensionCompression,&wheelIndex))
{
m_vehicle->SetSuspensionCompression(suspensionCompression,wheelIndex);
+ } else {
+ return NULL;
}
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
}
PyObject* KX_VehicleWrapper::PySetRollInfluence(PyObject* self,
@@ -230,8 +241,10 @@ PyObject* KX_VehicleWrapper::PySetRollInfluence(PyObject* self,
{
m_vehicle->SetRollInfluence(rollInfluence,wheelIndex);
}
- Py_INCREF(Py_None);
- return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
@@ -246,8 +259,10 @@ PyObject* KX_VehicleWrapper::PyApplyBraking(PyObject* self,
{
m_vehicle->ApplyBraking(braking,wheelIndex);
}
- Py_INCREF(Py_None);
- return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
@@ -264,8 +279,10 @@ PyObject* KX_VehicleWrapper::PySetSteeringValue(PyObject* self,
{
m_vehicle->SetSteeringValue(steeringValue,wheelIndex);
}
- Py_INCREF(Py_None);
- return Py_None;
+ else {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
diff --git a/source/gameengine/Ketsji/KX_VertexProxy.cpp b/source/gameengine/Ketsji/KX_VertexProxy.cpp
index 5cec65dff1c..25205714308 100644
--- a/source/gameengine/Ketsji/KX_VertexProxy.cpp
+++ b/source/gameengine/Ketsji/KX_VertexProxy.cpp
@@ -82,7 +82,7 @@ PyObject*
KX_VertexProxy::_getattr(const STR_String& attr)
{
if (attr == "XYZ")
- return PyObjectFrom(MT_Vector3(m_vertex->getLocalXYZ()));
+ return PyObjectFrom(MT_Vector3(m_vertex->getXYZ()));
if (attr == "UV")
return PyObjectFrom(MT_Point2(m_vertex->getUV1()));
@@ -102,11 +102,11 @@ KX_VertexProxy::_getattr(const STR_String& attr)
// pos
if (attr == "x")
- return PyFloat_FromDouble(m_vertex->getLocalXYZ()[0]);
+ return PyFloat_FromDouble(m_vertex->getXYZ()[0]);
if (attr == "y")
- return PyFloat_FromDouble(m_vertex->getLocalXYZ()[1]);
+ return PyFloat_FromDouble(m_vertex->getXYZ()[1]);
if (attr == "z")
- return PyFloat_FromDouble(m_vertex->getLocalXYZ()[2]);
+ return PyFloat_FromDouble(m_vertex->getXYZ()[2]);
// Col
if (attr == "r")
@@ -184,7 +184,7 @@ int KX_VertexProxy::_setattr(const STR_String& attr, PyObject *pyvalue)
{
float val = PyFloat_AsDouble(pyvalue);
// pos
- MT_Point3 pos(m_vertex->getLocalXYZ());
+ MT_Point3 pos(m_vertex->getXYZ());
if (attr == "x")
{
pos.x() = val;
@@ -312,7 +312,7 @@ PyObject* KX_VertexProxy::PyGetXYZ(PyObject*,
PyObject*,
PyObject*)
{
- return PyObjectFrom(MT_Point3(m_vertex->getLocalXYZ()));
+ return PyObjectFrom(MT_Point3(m_vertex->getXYZ()));
}
PyObject* KX_VertexProxy::PySetXYZ(PyObject*,
@@ -426,7 +426,7 @@ PyObject* KX_VertexProxy::PySetUV2(PyObject*,
{
if (PyVecTo(list, vec))
{
- m_vertex->SetFlag((m_vertex->getFlag()|TV_2NDUV));
+ m_vertex->SetFlag((m_vertex->getFlag()|RAS_TexVert::SECOND_UV));
m_vertex->SetUnit(unit);
m_vertex->SetUV2(vec);
m_mesh->SetMeshModified(true);
diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp
index b4693a7a7db..4b0db5a7953 100644
--- a/source/gameengine/Ketsji/KX_VisibilityActuator.cpp
+++ b/source/gameengine/Ketsji/KX_VisibilityActuator.cpp
@@ -38,10 +38,12 @@
KX_VisibilityActuator::KX_VisibilityActuator(
SCA_IObject* gameobj,
bool visible,
+ bool recursive,
PyTypeObject* T
)
: SCA_IActuator(gameobj,T),
- m_visible(visible)
+ m_visible(visible),
+ m_recursive(recursive)
{
// intentionally empty
}
@@ -75,10 +77,10 @@ KX_VisibilityActuator::Update()
KX_GameObject *obj = (KX_GameObject*) GetParent();
- obj->SetVisible(m_visible);
- obj->MarkVisible();
+ obj->SetVisible(m_visible, m_recursive);
+ obj->UpdateBuckets(m_recursive);
- return true;
+ return false;
}
/* ------------------------------------------------------------------------- */
@@ -120,7 +122,7 @@ KX_VisibilityActuator::Parents[] = {
PyMethodDef
KX_VisibilityActuator::Methods[] = {
{"set", (PyCFunction) KX_VisibilityActuator::sPySetVisible,
- METH_VARARGS, SetVisible_doc},
+ METH_VARARGS, (PY_METHODCHAR)SetVisible_doc},
{NULL,NULL} //Sentinel
};
@@ -135,7 +137,7 @@ KX_VisibilityActuator::_getattr(
/* set visibility ---------------------------------------------------------- */
-char
+const char
KX_VisibilityActuator::SetVisible_doc[] =
"setVisible(visible?)\n"
"\t - visible? : Make the object visible? (KX_TRUE, KX_FALSE)"
diff --git a/source/gameengine/Ketsji/KX_VisibilityActuator.h b/source/gameengine/Ketsji/KX_VisibilityActuator.h
index 9b4753033fb..d1b85ab998c 100644
--- a/source/gameengine/Ketsji/KX_VisibilityActuator.h
+++ b/source/gameengine/Ketsji/KX_VisibilityActuator.h
@@ -39,12 +39,14 @@ class KX_VisibilityActuator : public SCA_IActuator
/** Make visible? */
bool m_visible;
+ bool m_recursive;
public:
KX_VisibilityActuator(
SCA_IObject* gameobj,
bool visible,
+ bool recursive,
PyTypeObject* T=&Type
);
diff --git a/source/gameengine/Ketsji/Makefile b/source/gameengine/Ketsji/Makefile
index fe226f22635..bdc0b335b02 100644
--- a/source/gameengine/Ketsji/Makefile
+++ b/source/gameengine/Ketsji/Makefile
@@ -35,9 +35,13 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
+CPPFLAGS += $(NAN_SDLCFLAGS)
CPPFLAGS += $(OGL_CPPFLAGS)
+CPPFLAGS += -I$(NAN_GLEW)/include
CPPFLAGS += -I$(OPENGL_HEADERS)
-CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION) -I../../blender/python
+CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
+CPPFLAGS += -I../../blender/python
+CPPFLAGS += -I../../blender/python/api2_2x
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
CPPFLAGS += -I$(NAN_FUZZICS)/include -I$(NAN_SUMO) -I$(NAN_MOTO)/include
@@ -60,6 +64,7 @@ CPPFLAGS += -I../../blender/blenlib
CPPFLAGS += -I../../blender/editors/include
CPPFLAGS += -I../../blender/makesdna
CPPFLAGS += -I../../blender/imbuf
+CPPFLAGS += -I../../blender/gpu
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
###########################
diff --git a/source/gameengine/Ketsji/SConscript b/source/gameengine/Ketsji/SConscript
index f9f7920d244..7d2cfb403c0 100644
--- a/source/gameengine/Ketsji/SConscript
+++ b/source/gameengine/Ketsji/SConscript
@@ -5,7 +5,22 @@ Import ('env')
sources = env.Glob('*.cpp')
-incs = '. #source/kernel/gen_system #intern/string #intern/guardedalloc'
+#XXX
+# Mathutils C files.
+#sources.extend([\
+# '#source/blender/python/api2_2x/Mathutils.c',\
+# '#source/blender/python/api2_2x/constant.c',\
+# '#source/blender/python/api2_2x/euler.c',\
+# '#source/blender/python/api2_2x/gen_utils.c',\
+# '#source/blender/python/api2_2x/matrix.c',\
+# '#source/blender/python/api2_2x/point.c',\
+# '#source/blender/python/api2_2x/quat.c',\
+# '#source/blender/python/api2_2x/vector.c',\
+#])
+
+incs = '. #source/blender/python/api2_2x' # Only for Mathutils! - no other deps
+
+incs += ' #source/kernel/gen_system #intern/string #intern/guardedalloc'
incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer #intern/bmfont'
incs += ' #intern/SoundSystem #intern/SoundSystem/include #intern/SoundSystem/openal'
incs += ' #intern/SoundSystem/dummy #intern/SoundSystem/intern #source/gameengine/Converter'
@@ -18,7 +33,7 @@ incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common #sourc
incs += ' #source/gameengine/Physics/BlOde #source/gameengine/Physics/Dummy'
incs += ' #source/gameengine/Physics/Sumo #source/gameengine/Physics/Sumo/include'
incs += ' #source/gameengine/Physics/Sumo/Fuzzics/include #source/gameengine/Network/LoopBackNetwork'
-incs += ' #source/blender/misc #source/blender/blenloader'
+incs += ' #source/blender/misc #source/blender/blenloader #extern/glew/include #source/blender/gpu'
cflags = []
if env['OURPLATFORM'] == 'win32-vc':
@@ -27,8 +42,10 @@ if env['OURPLATFORM'] == 'win32-vc':
incs += ' ' + env['BF_SOLID_INC']
incs += ' ' + env['BF_PYTHON_INC']
-incs += ' ' + env['BF_SDL_INC']
incs += ' ' + env['BF_BULLET_INC']
incs += ' ' + env['BF_OPENGL_INC']
+if env['WITH_BF_SDL']:
+ incs += ' ' + env['BF_SDL_INC']
+
env.BlenderLib ( 'bf_ketsji', sources, Split(incs), [], libtype=['game','player'], priority=[25, 60], compileflags = cflags )
diff --git a/source/gameengine/Makefile b/source/gameengine/Makefile
index 1d3bc8c2058..51bc0f7d39f 100644
--- a/source/gameengine/Makefile
+++ b/source/gameengine/Makefile
@@ -35,7 +35,7 @@ DIR = $(OCGDIR)/gameengine
DIRS = BlenderRoutines
DIRS += Converter
DIRS += Expressions GameLogic Ketsji Rasterizer SceneGraph
-DIRS += Network Physics
+DIRS += Network Physics VideoTexture
ifeq ($(WITH_BF_BLENDERGAMEENGINE),true)
DIRS += GamePlayer
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsController.h b/source/gameengine/Physics/BlOde/OdePhysicsController.h
index d3eb443ed3a..925f5b6686a 100644
--- a/source/gameengine/Physics/BlOde/OdePhysicsController.h
+++ b/source/gameengine/Physics/BlOde/OdePhysicsController.h
@@ -111,6 +111,8 @@ public:
virtual void calcXform(){}
virtual void SetMargin(float margin) {}
virtual float GetMargin() const {return 0.f;}
+ virtual float GetRadius() const {return 0.f;}
+ virtual void SetRadius(float margin) {}
// clientinfo for raycasts for example
virtual void* getNewClientInfo() { return m_clientInfo;}
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp
index a04560aaf09..2e8ee31058f 100644
--- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.cpp
@@ -198,7 +198,7 @@ int ODEPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
}
-void ODEPhysicsEnvironment::removeConstraint(int constraintid)
+void ODEPhysicsEnvironment::removeConstraint(void *constraintid)
{
if (constraintid)
{
@@ -206,8 +206,7 @@ void ODEPhysicsEnvironment::removeConstraint(int constraintid)
}
}
-PHY_IPhysicsController* ODEPhysicsEnvironment::rayTest(PHY_IPhysicsController* ignoreClient,float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
- float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ)
+PHY_IPhysicsController* ODEPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
{
//m_OdeWorld
diff --git a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
index ec1b7702ffd..dcc87d614c0 100644
--- a/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
+++ b/source/gameengine/Physics/BlOde/OdePhysicsEnvironment.h
@@ -54,8 +54,7 @@ public:
float axisX,float axisY,float axisZ);
virtual void removeConstraint(void * constraintid);
- virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient,float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
- float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);
+ virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
//gamelogic callbacks
@@ -65,6 +64,7 @@ public:
{
}
virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl) {}
+ virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl) {}
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) {return 0;}
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight) { return 0;}
diff --git a/source/gameengine/Physics/BlOde/SConscript b/source/gameengine/Physics/BlOde/SConscript
index 0ffeb1dad62..90e949d2d86 100644
--- a/source/gameengine/Physics/BlOde/SConscript
+++ b/source/gameengine/Physics/BlOde/SConscript
@@ -5,11 +5,11 @@ Import ('library_env')
phy_ode_env = library_env.Copy ()
source_files = ['OdePhysicsController.cpp',
- 'OdePhysicsEnvironment.cpp']
+ 'OdePhysicsEnvironment.cpp']
phy_ode_env.Append (CPPPATH=['.',
- '../common',
- ])
+ '../common',
+ ])
phy_ode_env.Append (CPPPATH=user_options_dict['ODE_INCLUDE'])
phy_ode_env.Library (target='#'+user_options_dict['BUILD_DIR']+'/lib/PHY_Ode', source=source_files)
diff --git a/source/gameengine/Physics/Bullet/CMakeLists.txt b/source/gameengine/Physics/Bullet/CMakeLists.txt
index b610fd1bbb0..6c733786caf 100644
--- a/source/gameengine/Physics/Bullet/CMakeLists.txt
+++ b/source/gameengine/Physics/Bullet/CMakeLists.txt
@@ -30,6 +30,10 @@ SET(INC
.
../common
../../../../extern/bullet2/src
+ ../../../../intern/moto/include
+ ../../../kernel/gen_system
+ ../../../../intern/string
+ ../../Rasterizer
)
BLENDERLIB(bf_bullet "${SRC}" "${INC}")
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
index 5a45ce020cc..c9c30c1b450 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
@@ -15,10 +15,18 @@ subject to the following restrictions:
#include "CcdPhysicsController.h"
#include "btBulletDynamicsCommon.h"
-
+#include "BulletCollision/CollisionShapes/btScaledBvhTriangleMeshShape.h"
#include "PHY_IMotionState.h"
#include "CcdPhysicsEnvironment.h"
+#include "RAS_MeshObject.h"
+#include "BulletSoftBody/btSoftBody.h"
+#include "BulletSoftBody//btSoftBodyInternals.h"
+#include "BulletSoftBody/btSoftBodyHelpers.h"
+#include "LinearMath/btConvexHull.h"
+#include "BulletCollision/Gimpact/btGImpactShape.h"
+
+#include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
class BP_Proxy;
@@ -36,24 +44,40 @@ float gAngularSleepingTreshold = 1.0f;
btVector3 startVel(0,0,0);//-10000);
+
CcdPhysicsController::CcdPhysicsController (const CcdConstructionInfo& ci)
:m_cci(ci)
{
+ m_prototypeTransformInitialized = false;
+ m_softbodyMappingDone = false;
m_collisionDelay = 0;
m_newClientInfo = 0;
-
+ m_registerCount = 0;
+ m_softBodyTransformInitialized = false;
+ m_parentCtrl = 0;
+ // copy pointers locally to allow smart release
m_MotionState = ci.m_MotionState;
+ m_collisionShape = ci.m_collisionShape;
+ // apply scaling before creating rigid body
+ m_collisionShape->setLocalScaling(m_cci.m_scaling);
+ if (m_cci.m_mass)
+ m_collisionShape->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor);
+ // shape info is shared, increment ref count
+ m_shapeInfo = ci.m_shapeInfo;
+ if (m_shapeInfo)
+ m_shapeInfo->AddRef();
+
m_bulletMotionState = 0;
CreateRigidbody();
-
- #ifdef WIN32
- if (m_body->getInvMass())
- m_body->setLinearVelocity(startVel);
- #endif
+///???
+#ifdef WIN32
+ if (GetRigidBody() && !GetRigidBody()->isStaticObject())
+ GetRigidBody()->setLinearVelocity(startVel);
+#endif
}
@@ -105,34 +129,395 @@ public:
};
-void CcdPhysicsController::CreateRigidbody()
+btRigidBody* CcdPhysicsController::GetRigidBody()
+{
+ return btRigidBody::upcast(m_object);
+}
+btCollisionObject* CcdPhysicsController::GetCollisionObject()
+{
+ return m_object;
+}
+btSoftBody* CcdPhysicsController::GetSoftBody()
{
+ return btSoftBody::upcast(m_object);
+}
+
+#include "BulletSoftBody/btSoftBodyHelpers.h"
+
- btTransform trans = GetTransformFromMotionState(m_MotionState);
+void CcdPhysicsController::CreateRigidbody()
+{
+
+ //btTransform trans = GetTransformFromMotionState(m_MotionState);
m_bulletMotionState = new BlenderBulletMotionState(m_MotionState);
- m_body = new btRigidBody(m_cci.m_mass,
- m_bulletMotionState,
- m_cci.m_collisionShape,
- m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor,
- m_cci.m_linearDamping,m_cci.m_angularDamping,
- m_cci.m_friction,m_cci.m_restitution);
+ ///either create a btCollisionObject, btRigidBody or btSoftBody
+
+ //create a collision object
+
+ int shapeType = m_cci.m_collisionShape ? m_cci.m_collisionShape->getShapeType() : 0;
+
+ //disable soft body until first sneak preview is ready
+ if (m_cci.m_bSoft && m_cci.m_collisionShape &&
+ (shapeType == CONVEX_HULL_SHAPE_PROXYTYPE)|
+ (shapeType == TRIANGLE_MESH_SHAPE_PROXYTYPE) |
+ (shapeType == SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE))
+ {
+ btRigidBody::btRigidBodyConstructionInfo rbci(m_cci.m_mass,m_bulletMotionState,m_collisionShape,m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
+ rbci.m_linearDamping = m_cci.m_linearDamping;
+ rbci.m_angularDamping = m_cci.m_angularDamping;
+ rbci.m_friction = m_cci.m_friction;
+ rbci.m_restitution = m_cci.m_restitution;
+
+
+ int nodecount = 0;
+
+ int numtriangles = 1;
+
+ btVector3 p(0,0,0);// = getOrigin();
+ btScalar h = 1.f;
+
+ btSoftRigidDynamicsWorld* softDynaWorld = (btSoftRigidDynamicsWorld*)m_cci.m_physicsEnv->getDynamicsWorld();
+
+ PHY__Vector3 grav;
+ grav[0] = softDynaWorld->getGravity().getX();
+ grav[1] = softDynaWorld->getGravity().getY();
+ grav[2] = softDynaWorld->getGravity().getZ();
+ softDynaWorld->getWorldInfo().m_gravity.setValue(grav[0],grav[1],grav[2]); //??
+
+
+ //btSoftBody* psb=btSoftBodyHelpers::CreateRope(sbi, btVector3(-10,0,i*0.25),btVector3(10,0,i*0.25), 16,1+2);
+
+ btSoftBody* psb = 0;
+
+ if (m_cci.m_collisionShape->getShapeType() == CONVEX_HULL_SHAPE_PROXYTYPE)
+ {
+ btConvexHullShape* convexHull = (btConvexHullShape* )m_cci.m_collisionShape;
+
+ //psb = btSoftBodyHelpers::CreateFromConvexHull(sbi,&transformedVertices[0],convexHull->getNumPoints());
+
+ {
+ int nvertices = convexHull->getNumPoints();
+ const btVector3* vertices = convexHull->getPoints();
+ btSoftBodyWorldInfo& worldInfo = softDynaWorld->getWorldInfo();
+
+ HullDesc hdsc(QF_TRIANGLES,nvertices,vertices);
+ HullResult hres;
+ HullLibrary hlib;/*??*/
+ hdsc.mMaxVertices=nvertices;
+ hlib.CreateConvexHull(hdsc,hres);
+
+ psb=new btSoftBody(&worldInfo,(int)hres.mNumOutputVertices,
+ &hres.m_OutputVertices[0],0);
+ for(int i=0;i<(int)hres.mNumFaces;++i)
+ {
+ const int idx[]={ hres.m_Indices[i*3+0],
+ hres.m_Indices[i*3+1],
+ hres.m_Indices[i*3+2]};
+ if(idx[0]<idx[1]) psb->appendLink( idx[0],idx[1]);
+ if(idx[1]<idx[2]) psb->appendLink( idx[1],idx[2]);
+ if(idx[2]<idx[0]) psb->appendLink( idx[2],idx[0]);
+ psb->appendFace(idx[0],idx[1],idx[2]);
+ }
+
+
+
+ hlib.ReleaseResult(hres);
+
+
+ }
+
+
+
+
+
+
+ } else
+ {
+
+ btSoftBodyWorldInfo& sbi= softDynaWorld->getWorldInfo();
+
+ if (m_cci.m_collisionShape->getShapeType() ==SCALED_TRIANGLE_MESH_SHAPE_PROXYTYPE)
+ {
+ btScaledBvhTriangleMeshShape* scaledtrimeshshape = (btScaledBvhTriangleMeshShape*) m_cci.m_collisionShape;
+ btBvhTriangleMeshShape* trimeshshape = scaledtrimeshshape->getChildShape();
+
+ ///only deal with meshes that have 1 sub part/component, for now
+ if (trimeshshape->getMeshInterface()->getNumSubParts()==1)
+ {
+ unsigned char* vertexBase;
+ PHY_ScalarType vertexType;
+ int numverts;
+ int vertexstride;
+ unsigned char* indexbase;
+ int indexstride;
+ int numtris;
+ PHY_ScalarType indexType;
+ trimeshshape->getMeshInterface()->getLockedVertexIndexBase(&vertexBase,numverts,vertexType,vertexstride,&indexbase,indexstride,numtris,indexType);
+
+ psb = btSoftBodyHelpers::CreateFromTriMesh(sbi,(const btScalar*)vertexBase,(const int*)indexbase,numtris);
+ }
+ } else
+ {
+ btBvhTriangleMeshShape* trimeshshape = (btBvhTriangleMeshShape*) m_cci.m_collisionShape;
+ ///only deal with meshes that have 1 sub part/component, for now
+ if (trimeshshape->getMeshInterface()->getNumSubParts()==1)
+ {
+ unsigned char* vertexBase;
+ PHY_ScalarType vertexType;
+ int numverts;
+ int vertexstride;
+ unsigned char* indexbase;
+ int indexstride;
+ int numtris;
+ PHY_ScalarType indexType;
+ trimeshshape->getMeshInterface()->getLockedVertexIndexBase(&vertexBase,numverts,vertexType,vertexstride,&indexbase,indexstride,numtris,indexType);
+
+ psb = btSoftBodyHelpers::CreateFromTriMesh(sbi,(const btScalar*)vertexBase,(const int*)indexbase,numtris);
+ }
+
+
+ //psb = btSoftBodyHelpers::CreateFromTriMesh(sbi,&pts[0].getX(),triangles,numtriangles);
+ }
+
+ }
+
+ m_object = psb;
+
+ //psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS;//btSoftBody::fCollision::CL_SS+ btSoftBody::fCollision::CL_RS;
+
+ //psb->m_cfg.collisions = btSoftBody::fCollision::SDF_RS + btSoftBody::fCollision::VF_SS;//CL_SS;
+
+
+ //btSoftBody::Material* pm=psb->appendMaterial();
+ btSoftBody::Material* pm=psb->m_materials[0];
+ pm->m_kLST = m_cci.m_soft_linStiff;
+ pm->m_kAST = m_cci.m_soft_angStiff;
+ pm->m_kVST = m_cci.m_soft_volume;
+ psb->m_cfg.collisions = 0;
+
+ if (m_cci.m_soft_collisionflags & CCD_BSB_COL_CL_RS)
+ {
+ psb->m_cfg.collisions += btSoftBody::fCollision::CL_RS;
+ } else
+ {
+ psb->m_cfg.collisions += btSoftBody::fCollision::SDF_RS;
+ }
+ if (m_cci.m_soft_collisionflags & CCD_BSB_COL_CL_SS)
+ {
+ psb->m_cfg.collisions += btSoftBody::fCollision::CL_SS;
+ } else
+ {
+ psb->m_cfg.collisions += btSoftBody::fCollision::VF_SS;
+ }
+
+
+ psb->m_cfg.kSRHR_CL = m_cci.m_soft_kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */
+ psb->m_cfg.kSKHR_CL = m_cci.m_soft_kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */
+ psb->m_cfg.kSSHR_CL = m_cci.m_soft_kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */
+ psb->m_cfg.kSR_SPLT_CL = m_cci.m_soft_kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+
+ psb->m_cfg.kSK_SPLT_CL = m_cci.m_soft_kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+ psb->m_cfg.kSS_SPLT_CL = m_cci.m_soft_kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+ psb->m_cfg.kVCF = m_cci.m_soft_kVCF; /* Velocities correction factor (Baumgarte) */
+ psb->m_cfg.kDP = m_cci.m_soft_kDP; /* Damping coefficient [0,1] */
+
+ psb->m_cfg.kDG = m_cci.m_soft_kDG; /* Drag coefficient [0,+inf] */
+ psb->m_cfg.kLF = m_cci.m_soft_kLF; /* Lift coefficient [0,+inf] */
+ psb->m_cfg.kPR = m_cci.m_soft_kPR; /* Pressure coefficient [-inf,+inf] */
+ psb->m_cfg.kVC = m_cci.m_soft_kVC; /* Volume conversation coefficient [0,+inf] */
+
+ psb->m_cfg.kDF = m_cci.m_soft_kDF; /* Dynamic friction coefficient [0,1] */
+ psb->m_cfg.kMT = m_cci.m_soft_kMT; /* Pose matching coefficient [0,1] */
+ psb->m_cfg.kCHR = m_cci.m_soft_kCHR; /* Rigid contacts hardness [0,1] */
+ psb->m_cfg.kKHR = m_cci.m_soft_kKHR; /* Kinetic contacts hardness [0,1] */
+
+ psb->m_cfg.kSHR = m_cci.m_soft_kSHR; /* Soft contacts hardness [0,1] */
+ psb->m_cfg.kAHR = m_cci.m_soft_kAHR; /* Anchors hardness [0,1] */
+
+
+
+ if (m_cci.m_gamesoftFlag & CCD_BSB_BENDING_CONSTRAINTS)//OB_SB_GOAL)
+ {
+ psb->generateBendingConstraints(2,pm);
+ }
+
+ psb->m_cfg.piterations = m_cci.m_soft_piterations;
+ psb->m_cfg.viterations = m_cci.m_soft_viterations;
+ psb->m_cfg.diterations = m_cci.m_soft_diterations;
+ psb->m_cfg.citerations = m_cci.m_soft_citerations;
+
+ if (m_cci.m_gamesoftFlag & CCD_BSB_SHAPE_MATCHING)//OB_SB_GOAL)
+ {
+ psb->setPose(false,true);//
+ } else
+ {
+ psb->setPose(true,false);
+ }
+
+
+
+ psb->randomizeConstraints();
+ if (m_cci.m_soft_collisionflags & (CCD_BSB_COL_CL_RS+CCD_BSB_COL_CL_SS))
+ {
+ psb->generateClusters(m_cci.m_soft_numclusteriterations);
+ }
+
+// psb->activate();
+// psb->setActivationState(1);
+// psb->setDeactivationTime(1.f);
+
+ //psb->m_materials[0]->m_kLST = 0.1+(i/(btScalar)(n-1))*0.9;
+ psb->setTotalMass(m_cci.m_mass);
+
+ psb->setCollisionFlags(0);
+
+ ///create a mapping between graphics mesh vertices and soft body vertices
+ {
+ RAS_MeshObject* rasMesh= GetShapeInfo()->GetMesh();
+
+ if (rasMesh && !m_softbodyMappingDone)
+ {
+
+ //printf("apply\n");
+ RAS_MeshSlot::iterator it;
+ RAS_MeshMaterial *mmat;
+ RAS_MeshSlot *slot;
+ size_t i;
+
+ //for each material
+ for (int m=0;m<rasMesh->NumMaterials();m++)
+ {
+ // The vertex cache can only be updated for this deformer:
+ // Duplicated objects with more than one ploymaterial (=multiple mesh slot per object)
+ // share the same mesh (=the same cache). As the rendering is done per polymaterial
+ // cycling through the objects, the entire mesh cache cannot be updated in one shot.
+ mmat = rasMesh->GetMeshMaterial(m);
+
+ slot = mmat->m_baseslot;
+ for(slot->begin(it); !slot->end(it); slot->next(it))
+ {
+ int index = 0;
+ for(i=it.startvertex; i<it.endvertex; i++,index++)
+ {
+ RAS_TexVert* vertex = &it.vertex[i];
+
+
+ //search closest index, and store it in vertex
+ vertex->setSoftBodyIndex(0);
+ btScalar maxDistSqr = 1e30;
+ btSoftBody::tNodeArray& nodes(psb->m_nodes);
+ btVector3 xyz = btVector3(vertex->getXYZ()[0],vertex->getXYZ()[1],vertex->getXYZ()[2]);
+ for (int n=0;n<nodes.size();n++)
+ {
+ btScalar distSqr = (nodes[n].m_x - xyz).length2();
+ if (distSqr<maxDistSqr)
+ {
+ maxDistSqr = distSqr;
+
+ vertex->setSoftBodyIndex(n);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ m_softbodyMappingDone = true;
+
+
+
+
+
+
+// m_object->setCollisionShape(rbci.m_collisionShape);
+ btTransform startTrans;
+
+ if (rbci.m_motionState)
+ {
+ rbci.m_motionState->getWorldTransform(startTrans);
+ } else
+ {
+ startTrans = rbci.m_startWorldTransform;
+ }
+ //startTrans.setIdentity();
+
+ //m_object->setWorldTransform(startTrans);
+ //m_object->setInterpolationWorldTransform(startTrans);
+ m_MotionState->setWorldPosition(startTrans.getOrigin().getX(),startTrans.getOrigin().getY(),startTrans.getOrigin().getZ());
+ m_MotionState->setWorldOrientation(0,0,0,1);
+
+ if (!m_prototypeTransformInitialized)
+ {
+ m_prototypeTransformInitialized = true;
+ m_softBodyTransformInitialized = true;
+ GetSoftBody()->transform(startTrans);
+ }
+
+// btVector3 wp = m_softBody->getWorldTransform().getOrigin();
+// MT_Point3 center(wp.getX(),wp.getY(),wp.getZ());
+// m_gameobj->NodeSetWorldPosition(center);
+
+
+ } else
+ {
+ btRigidBody::btRigidBodyConstructionInfo rbci(m_cci.m_mass,m_bulletMotionState,m_collisionShape,m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
+ rbci.m_linearDamping = m_cci.m_linearDamping;
+ rbci.m_angularDamping = m_cci.m_angularDamping;
+ rbci.m_friction = m_cci.m_friction;
+ rbci.m_restitution = m_cci.m_restitution;
+ m_object = new btRigidBody(rbci);
+ }
+
//
// init the rigidbody properly
//
//setMassProps this also sets collisionFlags
//convert collision flags!
+ //special case: a near/radar sensor controller should not be defined static or it will
+ //generate loads of static-static collision messages on the console
+ if ((m_cci.m_collisionFilterGroup & CcdConstructionInfo::SensorFilter) != 0)
+ {
+ // reset the flags that have been set so far
+ GetCollisionObject()->setCollisionFlags(0);
+ }
+ GetCollisionObject()->setCollisionFlags(m_object->getCollisionFlags() | m_cci.m_collisionFlags);
+ btRigidBody* body = GetRigidBody();
- m_body->setCollisionFlags(m_body->getCollisionFlags() | m_cci.m_collisionFlags);
-
- m_body->setGravity( m_cci.m_gravity);
- m_body->setDamping(m_cci.m_linearDamping, m_cci.m_angularDamping);
+ if (body)
+ {
+ body->setGravity( m_cci.m_gravity);
+ body->setDamping(m_cci.m_linearDamping, m_cci.m_angularDamping);
+ if (!m_cci.m_bRigid)
+ {
+ body->setAngularFactor(0.f);
+ }
+ }
+ if (m_object && m_cci.m_do_anisotropic)
+ {
+ m_object->setAnisotropicFriction(m_cci.m_anisotropicFriction);
+ }
+
+}
+
+static void DeleteBulletShape(btCollisionShape* shape)
+{
+ if (shape->getShapeType() == TRIANGLE_MESH_SHAPE_PROXYTYPE)
+ {
+ // shapes based on meshes use an interface that contains the vertices.
+ btTriangleMeshShape* meshShape = static_cast<btTriangleMeshShape*>(shape);
+ btStridingMeshInterface* meshInterface = meshShape->getMeshInterface();
+ if (meshInterface)
+ delete meshInterface;
+ }
+ delete shape;
}
CcdPhysicsController::~CcdPhysicsController()
@@ -141,12 +526,35 @@ CcdPhysicsController::~CcdPhysicsController()
if (m_cci.m_physicsEnv)
m_cci.m_physicsEnv->removeCcdPhysicsController(this);
- delete m_MotionState;
+ if (m_MotionState)
+ delete m_MotionState;
if (m_bulletMotionState)
delete m_bulletMotionState;
- delete m_body;
+ delete m_object;
+
+ if (m_collisionShape)
+ {
+ // collision shape is always unique to the controller, can delete it here
+ if (m_collisionShape->isCompound())
+ {
+ // bullet does not delete the child shape, must do it here
+ btCompoundShape* compoundShape = (btCompoundShape*)m_collisionShape;
+ int numChild = compoundShape->getNumChildShapes();
+ for (int i=numChild-1 ; i >= 0; i--)
+ {
+ btCollisionShape* childShape = compoundShape->getChildShape(i);
+ DeleteBulletShape(childShape);
+ }
+ }
+ DeleteBulletShape(m_collisionShape);
+ }
+ if (m_shapeInfo)
+ {
+ m_shapeInfo->Release();
+ }
}
+
/**
SynchronizeMotionStates ynchronizes dynas, kinematic and deformable entities (and do 'late binding')
*/
@@ -154,12 +562,26 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time)
{
//sync non-static to motionstate, and static from motionstate (todo: add kinematic etc.)
- if (!m_body->isStaticObject())
+ btSoftBody* sb = GetSoftBody();
+ if (sb)
{
- const btVector3& worldPos = m_body->getCenterOfMassPosition();
+ btVector3 aabbMin,aabbMax;
+ sb->getAabb(aabbMin,aabbMax);
+ btVector3 worldPos = (aabbMax+aabbMin)*0.5f;
+ m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
+ m_MotionState->calculateWorldTransformations();
+ return true;
+ }
+
+ btRigidBody* body = GetRigidBody();
+
+ if (body && !body->isStaticObject())
+ {
+
+ const btVector3& worldPos = body->getCenterOfMassPosition();
m_MotionState->setWorldPosition(worldPos[0],worldPos[1],worldPos[2]);
- const btQuaternion& worldquat = m_body->getOrientation();
+ const btQuaternion& worldquat = body->getOrientation();
m_MotionState->setWorldOrientation(worldquat[0],worldquat[1],worldquat[2],worldquat[3]);
m_MotionState->calculateWorldTransformations();
@@ -178,7 +600,7 @@ bool CcdPhysicsController::SynchronizeMotionStates(float time)
btTransform oldTrans = m_body->getCenterOfMassTransform();
btTransform newTrans(worldquat,worldPos);
- m_body->setCenterOfMassTransform(newTrans);
+ SetCenterOfMassTransform(newTrans);
//need to keep track of previous position for friction effects...
m_MotionState->calculateWorldTransformations();
@@ -206,13 +628,41 @@ void CcdPhysicsController::WriteDynamicsToMotionState()
// controller replication
void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionstate,class PHY_IPhysicsController* parentctrl)
{
+
+ m_softBodyTransformInitialized=false;
m_MotionState = motionstate;
+ m_registerCount = 0;
+ m_collisionShape = NULL;
-
+ // always create a new shape to avoid scaling bug
+ if (m_shapeInfo)
+ {
+ m_shapeInfo->AddRef();
+ m_collisionShape = m_shapeInfo->CreateBulletShape();
- m_body = 0;
+ if (m_collisionShape)
+ {
+ // new shape has no scaling, apply initial scaling
+ m_collisionShape->setMargin(m_cci.m_margin);
+ m_collisionShape->setLocalScaling(m_cci.m_scaling);
+
+ if (m_cci.m_mass)
+ m_collisionShape->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor);
+ }
+ }
+
+ m_object = 0;
CreateRigidbody();
-
+
+ btRigidBody* body = GetRigidBody();
+
+ if (body)
+ {
+ if (m_cci.m_mass)
+ {
+ body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
+ }
+ }
m_cci.m_physicsEnv->addCcdPhysicsController(this);
@@ -248,60 +698,95 @@ void CcdPhysicsController::PostProcessReplica(class PHY_IMotionState* motionsta
}
+
+void CcdPhysicsController::SetCenterOfMassTransform(btTransform& xform)
+{
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ {
+ body->setCenterOfMassTransform(xform);
+ } else
+ {
+ //either collision object or soft body?
+ if (GetSoftBody())
+ {
+
+ } else
+ {
+
+ if (m_object->isStaticOrKinematicObject())
+ {
+ m_object->setInterpolationWorldTransform(m_object->getWorldTransform());
+ } else
+ {
+ m_object->setInterpolationWorldTransform(xform);
+ }
+ if (body)
+ {
+ body->setInterpolationLinearVelocity(body->getLinearVelocity());
+ body->setInterpolationAngularVelocity(body->getAngularVelocity());
+ body->updateInertiaTensor();
+ }
+ m_object->setWorldTransform(xform);
+ }
+ }
+}
+
// kinematic methods
void CcdPhysicsController::RelativeTranslate(float dlocX,float dlocY,float dlocZ,bool local)
{
- if (m_body)
+ if (m_object)
{
- m_body->activate(true);
- if (m_body->isStaticObject())
+ m_object->activate(true);
+ if (m_object->isStaticObject())
{
- m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
}
+ btRigidBody* body = GetRigidBody();
btVector3 dloc(dlocX,dlocY,dlocZ);
- btTransform xform = m_body->getCenterOfMassTransform();
-
+ btTransform xform = m_object->getWorldTransform();
+
if (local)
{
dloc = xform.getBasis()*dloc;
}
xform.setOrigin(xform.getOrigin() + dloc);
- m_body->setCenterOfMassTransform(xform);
+ SetCenterOfMassTransform(xform);
}
}
void CcdPhysicsController::RelativeRotate(const float rotval[9],bool local)
{
- if (m_body )
+ if (m_object)
{
- m_body->activate(true);
- if (m_body->isStaticObject())
+ m_object->activate(true);
+ if (m_object->isStaticObject())
{
- m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
}
- btMatrix3x3 drotmat( rotval[0],rotval[1],rotval[2],
- rotval[4],rotval[5],rotval[6],
- rotval[8],rotval[9],rotval[10]);
+ btMatrix3x3 drotmat( rotval[0],rotval[4],rotval[8],
+ rotval[1],rotval[5],rotval[9],
+ rotval[2],rotval[6],rotval[10]);
btMatrix3x3 currentOrn;
GetWorldOrientation(currentOrn);
- btTransform xform = m_body->getCenterOfMassTransform();
-
+ btTransform xform = m_object->getWorldTransform();
+
xform.setBasis(xform.getBasis()*(local ?
drotmat : (currentOrn.inverse() * drotmat * currentOrn)));
- m_body->setCenterOfMassTransform(xform);
+ SetCenterOfMassTransform(xform);
}
-
}
+
void CcdPhysicsController::GetWorldOrientation(btMatrix3x3& mat)
{
float orn[4];
@@ -312,7 +797,7 @@ void CcdPhysicsController::GetWorldOrientation(btMatrix3x3& mat)
void CcdPhysicsController::getOrientation(float &quatImag0,float &quatImag1,float &quatImag2,float &quatReal)
{
- btQuaternion q = m_body->getCenterOfMassTransform().getRotation();
+ btQuaternion q = m_object->getWorldTransform().getRotation();
quatImag0 = q[0];
quatImag1 = q[1];
quatImag2 = q[2];
@@ -320,33 +805,75 @@ void CcdPhysicsController::getOrientation(float &quatImag0,float &quatImag1,flo
}
void CcdPhysicsController::setOrientation(float quatImag0,float quatImag1,float quatImag2,float quatReal)
{
- m_body->activate(true);
- if (m_body->isStaticObject())
+ if (m_object)
{
- m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ m_object->activate(true);
+ if (m_object->isStaticObject())
+ {
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ }
+ // not required
+ //m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal);
+ btTransform xform = m_object->getWorldTransform();
+ xform.setRotation(btQuaternion(quatImag0,quatImag1,quatImag2,quatReal));
+ SetCenterOfMassTransform(xform);
+ // not required
+ //m_bulletMotionState->setWorldTransform(xform);
+
+
+
}
- m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal);
- btTransform xform = m_body->getCenterOfMassTransform();
- xform.setRotation(btQuaternion(quatImag0,quatImag1,quatImag2,quatReal));
- m_body->setCenterOfMassTransform(xform);
- m_bulletMotionState->setWorldTransform(xform);
+}
+
+void CcdPhysicsController::setWorldOrientation(const btMatrix3x3& orn)
+{
+ if (m_object)
+ {
+ m_object->activate(true);
+ if (m_object->isStaticObject())
+ {
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ }
+ // not required
+ //m_MotionState->setWorldOrientation(quatImag0,quatImag1,quatImag2,quatReal);
+ btTransform xform = m_object->getWorldTransform();
+ xform.setBasis(orn);
+ SetCenterOfMassTransform(xform);
+ // not required
+ //m_bulletMotionState->setWorldTransform(xform);
+ //only once!
+ if (!m_softBodyTransformInitialized && GetSoftBody())
+ {
+ m_softbodyStartTrans.setBasis(orn);
+ xform.setOrigin(m_softbodyStartTrans.getOrigin());
+ GetSoftBody()->transform(xform);
+ m_softBodyTransformInitialized = true;
+ }
+
+ }
}
void CcdPhysicsController::setPosition(float posX,float posY,float posZ)
{
- m_body->activate(true);
- if (m_body->isStaticObject())
+ if (m_object)
{
- m_body->setCollisionFlags(m_body->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ m_object->activate(true);
+ if (m_object->isStaticObject())
+ {
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ }
+ // not required, this function is only used to update the physic controller
+ //m_MotionState->setWorldPosition(posX,posY,posZ);
+ btTransform xform = m_object->getWorldTransform();
+ xform.setOrigin(btVector3(posX,posY,posZ));
+ SetCenterOfMassTransform(xform);
+ if (!m_softBodyTransformInitialized)
+ m_softbodyStartTrans.setOrigin(xform.getOrigin());
+ // not required
+ //m_bulletMotionState->setWorldTransform(xform);
}
-
- m_MotionState->setWorldPosition(posX,posY,posZ);
- btTransform xform = m_body->getCenterOfMassTransform();
- xform.setOrigin(btVector3(posX,posY,posZ));
- m_body->setCenterOfMassTransform(xform);
- m_bulletMotionState->setWorldTransform(xform);
}
@@ -356,7 +883,7 @@ void CcdPhysicsController::resolveCombinedVelocities(float linvelX,float linvel
void CcdPhysicsController::getPosition(PHY__Vector3& pos) const
{
- const btTransform& xform = m_body->getCenterOfMassTransform();
+ const btTransform& xform = m_object->getWorldTransform();
pos[0] = xform.getOrigin().x();
pos[1] = xform.getOrigin().y();
pos[2] = xform.getOrigin().z();
@@ -370,15 +897,16 @@ void CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ)
{
m_cci.m_scaling = btVector3(scaleX,scaleY,scaleZ);
- if (m_body && m_body->getCollisionShape())
+ if (m_object && m_object->getCollisionShape())
{
- m_body->getCollisionShape()->setLocalScaling(m_cci.m_scaling);
+ m_object->getCollisionShape()->setLocalScaling(m_cci.m_scaling);
//printf("no inertia recalc for fixed objects with mass=0\n");
- if (m_cci.m_mass)
+ btRigidBody* body = GetRigidBody();
+ if (body && m_cci.m_mass)
{
- m_body->getCollisionShape()->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor);
- m_body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
+ body->getCollisionShape()->calculateLocalInertia(m_cci.m_mass, m_cci.m_localInertiaTensor);
+ body->setMassProps(m_cci.m_mass, m_cci.m_localInertiaTensor * m_cci.m_inertiaFactor);
}
}
@@ -389,51 +917,81 @@ void CcdPhysicsController::setScaling(float scaleX,float scaleY,float scaleZ)
void CcdPhysicsController::ApplyTorque(float torqueX,float torqueY,float torqueZ,bool local)
{
btVector3 torque(torqueX,torqueY,torqueZ);
- btTransform xform = m_body->getCenterOfMassTransform();
- if (torque.length2() > (SIMD_EPSILON*SIMD_EPSILON))
- {
- m_body->activate();
- }
- if (local)
+ btTransform xform = m_object->getWorldTransform();
+
+
+ if (m_object && torque.length2() > (SIMD_EPSILON*SIMD_EPSILON))
{
- torque = xform.getBasis()*torque;
+ btRigidBody* body = GetRigidBody();
+ m_object->activate();
+ if (m_object->isStaticObject())
+ {
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ }
+ if (local)
+ {
+ torque = xform.getBasis()*torque;
+ }
+ if (body)
+ body->applyTorque(torque);
}
- m_body->applyTorque(torque);
}
void CcdPhysicsController::ApplyForce(float forceX,float forceY,float forceZ,bool local)
{
btVector3 force(forceX,forceY,forceZ);
- if (force.length2() > (SIMD_EPSILON*SIMD_EPSILON))
- {
- m_body->activate();
- }
-
- btTransform xform = m_body->getCenterOfMassTransform();
- if (local)
+ if (m_object && force.length2() > (SIMD_EPSILON*SIMD_EPSILON))
{
- force = xform.getBasis()*force;
+ m_object->activate();
+ if (m_object->isStaticObject())
+ {
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ }
+
+ {
+ btTransform xform = m_object->getWorldTransform();
+
+ if (local)
+ {
+ force = xform.getBasis()*force;
+ }
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ body->applyCentralForce(force);
+ btSoftBody* soft = GetSoftBody();
+ if (soft)
+ {
+ // the force is applied on each node, must reduce it in the same extend
+ if (soft->m_nodes.size() > 0)
+ force /= soft->m_nodes.size();
+ soft->addForce(force);
+ }
+ }
}
- m_body->applyCentralForce(force);
}
void CcdPhysicsController::SetAngularVelocity(float ang_velX,float ang_velY,float ang_velZ,bool local)
{
btVector3 angvel(ang_velX,ang_velY,ang_velZ);
- if (angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON))
- {
- m_body->activate(true);
- }
-
+ if (m_object && angvel.length2() > (SIMD_EPSILON*SIMD_EPSILON))
{
- btTransform xform = m_body->getCenterOfMassTransform();
- if (local)
+ m_object->activate(true);
+ if (m_object->isStaticObject())
{
- angvel = xform.getBasis()*angvel;
- }
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ } else
+ {
+ btTransform xform = m_object->getWorldTransform();
+ if (local)
+ {
+ angvel = xform.getBasis()*angvel;
+ }
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ body->setAngularVelocity(angvel);
- m_body->setAngularVelocity(angvel);
+ }
}
}
@@ -441,33 +999,53 @@ void CcdPhysicsController::SetLinearVelocity(float lin_velX,float lin_velY,floa
{
btVector3 linVel(lin_velX,lin_velY,lin_velZ);
- if (linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON))
- {
- m_body->activate(true);
- }
-
+ if (m_object/* && linVel.length2() > (SIMD_EPSILON*SIMD_EPSILON)*/)
{
- btTransform xform = m_body->getCenterOfMassTransform();
- if (local)
+ m_object->activate(true);
+ if (m_object->isStaticObject())
{
- linVel = xform.getBasis()*linVel;
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ return;
+ }
+
+ btSoftBody* soft = GetSoftBody();
+ if (soft)
+ {
+ if (local)
+ {
+ linVel = m_softbodyStartTrans.getBasis()*linVel;
+ }
+ soft->setVelocity(linVel);
+ } else
+ {
+ btTransform xform = m_object->getWorldTransform();
+ if (local)
+ {
+ linVel = xform.getBasis()*linVel;
+ }
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ body->setLinearVelocity(linVel);
}
- m_body->setLinearVelocity(linVel);
}
}
void CcdPhysicsController::applyImpulse(float attachX,float attachY,float attachZ, float impulseX,float impulseY,float impulseZ)
{
btVector3 impulse(impulseX,impulseY,impulseZ);
- if (impulse.length2() > (SIMD_EPSILON*SIMD_EPSILON))
+ if (m_object && impulse.length2() > (SIMD_EPSILON*SIMD_EPSILON))
{
- m_body->activate();
+ m_object->activate();
+ if (m_object->isStaticObject())
+ {
+ m_object->setCollisionFlags(m_object->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT);
+ }
btVector3 pos(attachX,attachY,attachZ);
-
- m_body->activate();
-
- m_body->applyImpulse(impulse,pos);
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ body->applyImpulse(impulse,pos);
+
}
}
@@ -477,29 +1055,55 @@ void CcdPhysicsController::SetActive(bool active)
// reading out information from physics
void CcdPhysicsController::GetLinearVelocity(float& linvX,float& linvY,float& linvZ)
{
- const btVector3& linvel = this->m_body->getLinearVelocity();
- linvX = linvel.x();
- linvY = linvel.y();
- linvZ = linvel.z();
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ {
+ const btVector3& linvel = body->getLinearVelocity();
+ linvX = linvel.x();
+ linvY = linvel.y();
+ linvZ = linvel.z();
+ } else
+ {
+ linvX = 0.f;
+ linvY = 0.f;
+ linvZ = 0.f;
+ }
}
void CcdPhysicsController::GetAngularVelocity(float& angVelX,float& angVelY,float& angVelZ)
{
- const btVector3& angvel= m_body->getAngularVelocity();
- angVelX = angvel.x();
- angVelY = angvel.y();
- angVelZ = angvel.z();
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ {
+ const btVector3& angvel= body->getAngularVelocity();
+ angVelX = angvel.x();
+ angVelY = angvel.y();
+ angVelZ = angvel.z();
+ } else
+ {
+ angVelX = 0.f;
+ angVelY = 0.f;
+ angVelZ = 0.f;
+ }
}
void CcdPhysicsController::GetVelocity(const float posX,const float posY,const float posZ,float& linvX,float& linvY,float& linvZ)
{
btVector3 pos(posX,posY,posZ);
- btVector3 rel_pos = pos-m_body->getCenterOfMassPosition();
- btVector3 linvel = m_body->getVelocityInLocalPoint(rel_pos);
- linvX = linvel.x();
- linvY = linvel.y();
- linvZ = linvel.z();
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ {
+ btVector3 linvel = body->getVelocityInLocalPoint(pos);
+ linvX = linvel.x();
+ linvY = linvel.y();
+ linvZ = linvel.z();
+ } else
+ {
+ linvX = 0.f;
+ linvY = 0.f;
+ linvZ = 0.f;
+ }
}
void CcdPhysicsController::getReactionForce(float& forceX,float& forceY,float& forceZ)
{
@@ -510,11 +1114,15 @@ void CcdPhysicsController::setRigidBody(bool rigid)
{
if (!rigid)
{
- //fake it for now
- btVector3 inertia = m_body->getInvInertiaDiagLocal();
- inertia[1] = 0.f;
- m_body->setInvInertiaDiagLocal(inertia);
- m_body->updateInertiaTensor();
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ {
+ //fake it for now
+ btVector3 inertia = body->getInvInertiaDiagLocal();
+ inertia[1] = 0.f;
+ body->setInvInertiaDiagLocal(inertia);
+ body->updateInertiaTensor();
+ }
}
}
@@ -531,40 +1139,52 @@ void CcdPhysicsController::setNewClientInfo(void* clientinfo)
void CcdPhysicsController::UpdateDeactivation(float timeStep)
{
- m_body->updateDeactivation( timeStep);
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ {
+ body->updateDeactivation( timeStep);
+ }
}
bool CcdPhysicsController::wantsSleeping()
{
-
- return m_body->wantsSleeping();
+ btRigidBody* body = GetRigidBody();
+ if (body)
+ {
+ return body->wantsSleeping();
+ }
+ //check it out
+ return true;
}
PHY_IPhysicsController* CcdPhysicsController::GetReplica()
{
- //very experimental, shape sharing is not implemented yet.
- //just support btSphereShape/ConeShape for now
-
+ // This is used only to replicate Near and Radar sensor controllers
+ // The replication of object physics controller is done in KX_BulletPhysicsController::GetReplica()
CcdConstructionInfo cinfo = m_cci;
- if (cinfo.m_collisionShape)
+ if (m_shapeInfo)
+ {
+ // This situation does not normally happen
+ cinfo.m_collisionShape = m_shapeInfo->CreateBulletShape();
+ }
+ else if (m_collisionShape)
{
- switch (cinfo.m_collisionShape->getShapeType())
+ switch (m_collisionShape->getShapeType())
{
case SPHERE_SHAPE_PROXYTYPE:
{
- btSphereShape* orgShape = (btSphereShape*)cinfo.m_collisionShape;
+ btSphereShape* orgShape = (btSphereShape*)m_collisionShape;
cinfo.m_collisionShape = new btSphereShape(*orgShape);
break;
}
- case CONE_SHAPE_PROXYTYPE:
+ case CONE_SHAPE_PROXYTYPE:
{
- btConeShape* orgShape = (btConeShape*)cinfo.m_collisionShape;
+ btConeShape* orgShape = (btConeShape*)m_collisionShape;
cinfo.m_collisionShape = new btConeShape(*orgShape);
break;
}
-
default:
{
return 0;
@@ -573,6 +1193,7 @@ PHY_IPhysicsController* CcdPhysicsController::GetReplica()
}
cinfo.m_MotionState = new DefaultMotionState();
+ cinfo.m_shapeInfo = m_shapeInfo;
CcdPhysicsController* replica = new CcdPhysicsController(cinfo);
return replica;
@@ -634,3 +1255,273 @@ void DefaultMotionState::calculateWorldTransformations()
}
+// Shape constructor
+std::map<RAS_MeshObject*, CcdShapeConstructionInfo*> CcdShapeConstructionInfo::m_meshShapeMap;
+
+CcdShapeConstructionInfo* CcdShapeConstructionInfo::FindMesh(RAS_MeshObject* mesh, bool polytope)
+{
+ if (polytope)
+ // not yet supported
+ return NULL;
+
+ std::map<RAS_MeshObject*,CcdShapeConstructionInfo*>::const_iterator mit = m_meshShapeMap.find(mesh);
+ if (mit != m_meshShapeMap.end())
+ return mit->second;
+ return NULL;
+}
+
+bool CcdShapeConstructionInfo::SetMesh(RAS_MeshObject* meshobj, bool polytope,bool useGimpact)
+{
+ m_useGimpact = useGimpact;
+
+ // assume no shape information
+ // no support for dynamic change of shape yet
+ assert(m_meshObject == NULL);
+ m_shapeType = PHY_SHAPE_NONE;
+ m_vertexArray.clear();
+ m_polygonIndexArray.clear();
+ m_meshObject = NULL;
+
+ if (!meshobj)
+ return false;
+
+ // Mesh has no polygons!
+ int numpolys = meshobj->NumPolygons();
+ if (!numpolys)
+ {
+ return false;
+ }
+
+ // check that we have at least one colliding polygon
+ int numvalidpolys = 0;
+
+ for (int p=0; p<numpolys; p++)
+ {
+ RAS_Polygon* poly = meshobj->GetPolygon(p);
+
+ // only add polygons that have the collisionflag set
+ if (poly->IsCollider())
+ {
+ numvalidpolys++;
+ break;
+ }
+ }
+
+ // No collision polygons
+ if (numvalidpolys < 1)
+ return false;
+
+ m_shapeType = (polytope) ? PHY_SHAPE_POLYTOPE : PHY_SHAPE_MESH;
+
+ numvalidpolys = 0;
+
+ for (int p2=0; p2<numpolys; p2++)
+ {
+ RAS_Polygon* poly = meshobj->GetPolygon(p2);
+
+ // only add polygons that have the collisionflag set
+ if (poly->IsCollider())
+ {
+ //Bullet can raycast any shape, so
+ if (polytope)
+ {
+ for (int i=0;i<poly->VertexCount();i++)
+ {
+ const float* vtx = poly->GetVertex(i)->getXYZ();
+ btPoint3 point(vtx[0],vtx[1],vtx[2]);
+ //avoid duplicates (could better directly use vertex offsets, rather than a vertex compare)
+ bool found = false;
+ for (int j=0;j<m_vertexArray.size();j++)
+ {
+ if (m_vertexArray[j]==point)
+ {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ m_vertexArray.push_back(point);
+
+ numvalidpolys++;
+ }
+ } else
+ {
+ {
+ const float* vtx = poly->GetVertex(2)->getXYZ();
+ btPoint3 vertex0(vtx[0],vtx[1],vtx[2]);
+
+ vtx = poly->GetVertex(1)->getXYZ();
+ btPoint3 vertex1(vtx[0],vtx[1],vtx[2]);
+
+ vtx = poly->GetVertex(0)->getXYZ();
+ btPoint3 vertex2(vtx[0],vtx[1],vtx[2]);
+
+ m_vertexArray.push_back(vertex0);
+ m_vertexArray.push_back(vertex1);
+ m_vertexArray.push_back(vertex2);
+ m_polygonIndexArray.push_back(p2);
+ numvalidpolys++;
+ }
+ if (poly->VertexCount() == 4)
+ {
+ const float* vtx = poly->GetVertex(3)->getXYZ();
+ btPoint3 vertex0(vtx[0],vtx[1],vtx[2]);
+
+ vtx = poly->GetVertex(2)->getXYZ();
+ btPoint3 vertex1(vtx[0],vtx[1],vtx[2]);
+
+ vtx = poly->GetVertex(0)->getXYZ();
+ btPoint3 vertex2(vtx[0],vtx[1],vtx[2]);
+
+ m_vertexArray.push_back(vertex0);
+ m_vertexArray.push_back(vertex1);
+ m_vertexArray.push_back(vertex2);
+ m_polygonIndexArray.push_back(p2);
+ numvalidpolys++;
+ }
+ }
+ }
+ }
+
+ if (!numvalidpolys)
+ {
+ // should not happen
+ m_shapeType = PHY_SHAPE_NONE;
+ return false;
+ }
+ m_meshObject = meshobj;
+ if (!polytope)
+ {
+ // triangle shape can be shared, store the mesh object in the map
+ m_meshShapeMap.insert(std::pair<RAS_MeshObject*,CcdShapeConstructionInfo*>(meshobj,this));
+ }
+ return true;
+}
+
+btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape()
+{
+ btCollisionShape* collisionShape = 0;
+ btTriangleMeshShape* concaveShape = 0;
+ btTriangleMesh* collisionMeshData = 0;
+ btCompoundShape* compoundShape = 0;
+ CcdShapeConstructionInfo* nextShapeInfo;
+
+ switch (m_shapeType)
+ {
+ case PHY_SHAPE_NONE:
+ break;
+
+ case PHY_SHAPE_BOX:
+ collisionShape = new btBoxShape(m_halfExtend);
+ break;
+
+ case PHY_SHAPE_SPHERE:
+ collisionShape = new btSphereShape(m_radius);
+ break;
+
+ case PHY_SHAPE_CYLINDER:
+ collisionShape = new btCylinderShapeZ(m_halfExtend);
+ break;
+
+ case PHY_SHAPE_CONE:
+ collisionShape = new btConeShapeZ(m_radius, m_height);
+ break;
+
+ case PHY_SHAPE_POLYTOPE:
+ collisionShape = new btConvexHullShape(&m_vertexArray.begin()->getX(), m_vertexArray.size());
+ break;
+
+ case PHY_SHAPE_MESH:
+ // Let's use the latest btScaledBvhTriangleMeshShape: it allows true sharing of
+ // triangle mesh information between duplicates => drastic performance increase when
+ // duplicating complex mesh objects.
+ // BUT it causes a small performance decrease when sharing is not required:
+ // 9 multiplications/additions and one function call for each triangle that passes the mid phase filtering
+ // One possible optimization is to use directly the btBvhTriangleMeshShape when the scale is 1,1,1
+ // and btScaledBvhTriangleMeshShape otherwise.
+ if (m_useGimpact)
+ {
+ collisionMeshData = new btTriangleMesh();
+
+
+ // m_vertexArray is necessarily a multiple of 3
+ for (std::vector<btPoint3>::iterator it=m_vertexArray.begin(); it != m_vertexArray.end(); )
+ {
+ collisionMeshData->addTriangle(*it++,*it++,*it++);
+ }
+ btGImpactMeshShape* gimpactShape = new btGImpactMeshShape(collisionMeshData);
+
+ collisionShape = gimpactShape;
+ gimpactShape->updateBound();
+
+ } else
+ {
+ if (!m_unscaledShape)
+ {
+ collisionMeshData = new btTriangleMesh(true,false);
+ collisionMeshData->m_weldingThreshold = m_weldingThreshold;
+
+ // m_vertexArray is necessarily a multiple of 3
+ for (std::vector<btPoint3>::iterator it=m_vertexArray.begin(); it != m_vertexArray.end(); )
+ {
+ collisionMeshData->addTriangle(*it++,*it++,*it++);
+ }
+ // this shape will be shared and not deleted until shapeInfo is deleted
+ m_unscaledShape = new btBvhTriangleMeshShape( collisionMeshData, true );
+ m_unscaledShape->recalcLocalAabb();
+ }
+ collisionShape = new btScaledBvhTriangleMeshShape(m_unscaledShape, btVector3(1.0f,1.0f,1.0f));
+ }
+ break;
+
+ case PHY_SHAPE_COMPOUND:
+ if (m_shapeArray.size() > 0)
+ {
+ compoundShape = new btCompoundShape();
+ for (std::vector<CcdShapeConstructionInfo*>::iterator sit = m_shapeArray.begin();
+ sit != m_shapeArray.end();
+ sit++)
+ {
+ collisionShape = (*sit)->CreateBulletShape();
+ if (collisionShape)
+ {
+ collisionShape->setLocalScaling((*sit)->m_childScale);
+ compoundShape->addChildShape((*sit)->m_childTrans, collisionShape);
+ }
+ }
+ collisionShape = compoundShape;
+ }
+ }
+ return collisionShape;
+}
+
+void CcdShapeConstructionInfo::AddShape(CcdShapeConstructionInfo* shapeInfo)
+{
+ m_shapeArray.push_back(shapeInfo);
+}
+
+CcdShapeConstructionInfo::~CcdShapeConstructionInfo()
+{
+ for (std::vector<CcdShapeConstructionInfo*>::iterator sit = m_shapeArray.begin();
+ sit != m_shapeArray.end();
+ sit++)
+ {
+ (*sit)->Release();
+ }
+ m_shapeArray.clear();
+ if (m_unscaledShape)
+ {
+ DeleteBulletShape(m_unscaledShape);
+ }
+ m_vertexArray.clear();
+ if (m_shapeType == PHY_SHAPE_MESH && m_meshObject != NULL)
+ {
+ std::map<RAS_MeshObject*,CcdShapeConstructionInfo*>::iterator mit = m_meshShapeMap.find(m_meshObject);
+ if (mit != m_meshShapeMap.end() && mit->second == this)
+ {
+ m_meshShapeMap.erase(mit);
+ }
+ }
+}
+
+
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsController.h b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
index 11fef56401f..054ec91122a 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsController.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsController.h
@@ -17,11 +17,15 @@ subject to the following restrictions:
#ifndef BULLET2_PHYSICSCONTROLLER_H
#define BULLET2_PHYSICSCONTROLLER_H
+#include <vector>
+#include <map>
+
#include "PHY_IPhysicsController.h"
/// PHY_IPhysicsController is the abstract simplified Interface to a physical object.
/// It contains the IMotionState and IDeformableMesh Interfaces.
#include "btBulletDynamicsCommon.h"
+#include "LinearMath/btTransform.h"
#include "PHY_IMotionState.h"
@@ -31,8 +35,119 @@ extern float gAngularSleepingTreshold;
extern bool gDisableDeactivation;
class CcdPhysicsEnvironment;
class btMotionState;
+class RAS_MeshObject;
+class btCollisionShape;
+
+
+#define CCD_BSB_SHAPE_MATCHING 2
+#define CCD_BSB_BENDING_CONSTRAINTS 8
+#define CCD_BSB_AERO_VPOINT 16 /* aero model, Vertex normals are oriented toward velocity*/
+#define CCD_BSB_AERO_VTWOSIDE 32 /* aero model, Vertex normals are flipped to match velocity */
+
+/* BulletSoftBody.collisionflags */
+#define CCD_BSB_COL_SDF_RS 2 /* SDF based rigid vs soft */
+#define CCD_BSB_COL_CL_RS 4 /* Cluster based rigid vs soft */
+#define CCD_BSB_COL_CL_SS 8 /* Cluster based soft vs soft */
+#define CCD_BSB_COL_VF_SS 16 /* Vertex/Face based soft vs soft */
+
+
+
+// Shape contructor
+// It contains all the information needed to create a simple bullet shape at runtime
+class CcdShapeConstructionInfo
+{
+public:
+
+
+ static CcdShapeConstructionInfo* FindMesh(RAS_MeshObject* mesh, bool polytope);
+
+ CcdShapeConstructionInfo() :
+ m_shapeType(PHY_SHAPE_NONE),
+ m_radius(1.0),
+ m_height(1.0),
+ m_halfExtend(0.f,0.f,0.f),
+ m_childScale(1.0f,1.0f,1.0f),
+ m_refCount(1),
+ m_meshObject(NULL),
+ m_unscaledShape(NULL),
+ m_useGimpact(false),
+ m_weldingThreshold(0.f)
+ {
+ m_childTrans.setIdentity();
+ }
+
+ ~CcdShapeConstructionInfo();
+
+ CcdShapeConstructionInfo* AddRef()
+ {
+ m_refCount++;
+ return this;
+ }
+ int Release()
+ {
+ if (--m_refCount > 0)
+ return m_refCount;
+ delete this;
+ return 0;
+ }
+ void AddShape(CcdShapeConstructionInfo* shapeInfo);
+
+ btTriangleMeshShape* GetMeshShape(void)
+ {
+ return m_unscaledShape;
+ }
+ CcdShapeConstructionInfo* GetChildShape(int i)
+ {
+ if (i < 0 || i >= m_shapeArray.size())
+ return NULL;
+
+ return m_shapeArray.at(i);
+ }
+
+ bool SetMesh(RAS_MeshObject* mesh, bool polytope,bool useGimpact);
+ RAS_MeshObject* GetMesh(void)
+ {
+ return m_meshObject;
+ }
+
+ btCollisionShape* CreateBulletShape();
+
+ // member variables
+ PHY_ShapeType m_shapeType;
+ btScalar m_radius;
+ btScalar m_height;
+ btVector3 m_halfExtend;
+ btTransform m_childTrans;
+ btVector3 m_childScale;
+ std::vector<btPoint3> m_vertexArray; // Contains both vertex array for polytope shape and
+ // triangle array for concave mesh shape.
+ // In this case a triangle is made of 3 consecutive points
+ std::vector<int> m_polygonIndexArray; // Contains the array of polygon index in the
+ // original mesh that correspond to shape triangles.
+ // only set for concave mesh shape.
+
+ void setVertexWeldingThreshold(float threshold)
+ {
+ m_weldingThreshold = threshold;
+ }
+ float getVertexWeldingThreshold() const
+ {
+ return m_weldingThreshold;
+ }
+protected:
+ static std::map<RAS_MeshObject*, CcdShapeConstructionInfo*> m_meshShapeMap;
+ int m_refCount; // this class is shared between replicas
+ // keep track of users so that we can release it
+ RAS_MeshObject* m_meshObject; // Keep a pointer to the original mesh
+ btBvhTriangleMeshShape* m_unscaledShape;// holds the shared unscale BVH mesh shape,
+ // the actual shape is of type btScaledBvhTriangleMeshShape
+ std::vector<CcdShapeConstructionInfo*> m_shapeArray; // for compound shapes
+ bool m_useGimpact; //use gimpact for concave dynamic/moving collision detection
+ float m_weldingThreshold; //welding closeby vertices together can improve softbody stability etc.
+
+};
struct CcdConstructionInfo
{
@@ -46,24 +161,34 @@ struct CcdConstructionInfo
StaticFilter = 2,
KinematicFilter = 4,
DebrisFilter = 8,
- AllFilter = DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter,
+ SensorFilter = 16,
+ AllFilter = DefaultFilter | StaticFilter | KinematicFilter | DebrisFilter | SensorFilter,
};
CcdConstructionInfo()
- : m_gravity(0,0,0),
+ : m_localInertiaTensor(1.f, 1.f, 1.f),
+ m_gravity(0,0,0),
m_scaling(1.f,1.f,1.f),
m_mass(0.f),
m_restitution(0.1f),
m_friction(0.5f),
m_linearDamping(0.1f),
m_angularDamping(0.1f),
+ m_margin(0.06f),
+ m_gamesoftFlag(0),
m_collisionFlags(0),
+ m_bRigid(false),
+ m_bSoft(false),
m_collisionFilterGroup(DefaultFilter),
m_collisionFilterMask(AllFilter),
+ m_collisionShape(0),
m_MotionState(0),
+ m_shapeInfo(0),
m_physicsEnv(0),
- m_inertiaFactor(1.f)
+ m_inertiaFactor(1.f),
+ m_do_anisotropic(false),
+ m_anisotropicFriction(1.f,1.f,1.f)
{
}
@@ -75,7 +200,50 @@ struct CcdConstructionInfo
btScalar m_friction;
btScalar m_linearDamping;
btScalar m_angularDamping;
+ btScalar m_margin;
+
+ ////////////////////
+ int m_gamesoftFlag;
+ float m_soft_linStiff; /* linear stiffness 0..1 */
+ float m_soft_angStiff; /* angular stiffness 0..1 */
+ float m_soft_volume; /* volume preservation 0..1 */
+
+ int m_soft_viterations; /* Velocities solver iterations */
+ int m_soft_piterations; /* Positions solver iterations */
+ int m_soft_diterations; /* Drift solver iterations */
+ int m_soft_citerations; /* Cluster solver iterations */
+
+ float m_soft_kSRHR_CL; /* Soft vs rigid hardness [0,1] (cluster only) */
+ float m_soft_kSKHR_CL; /* Soft vs kinetic hardness [0,1] (cluster only) */
+ float m_soft_kSSHR_CL; /* Soft vs soft hardness [0,1] (cluster only) */
+ float m_soft_kSR_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+
+ float m_soft_kSK_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+ float m_soft_kSS_SPLT_CL; /* Soft vs rigid impulse split [0,1] (cluster only) */
+ float m_soft_kVCF; /* Velocities correction factor (Baumgarte) */
+ float m_soft_kDP; /* Damping coefficient [0,1] */
+
+ float m_soft_kDG; /* Drag coefficient [0,+inf] */
+ float m_soft_kLF; /* Lift coefficient [0,+inf] */
+ float m_soft_kPR; /* Pressure coefficient [-inf,+inf] */
+ float m_soft_kVC; /* Volume conversation coefficient [0,+inf] */
+
+ float m_soft_kDF; /* Dynamic friction coefficient [0,1] */
+ float m_soft_kMT; /* Pose matching coefficient [0,1] */
+ float m_soft_kCHR; /* Rigid contacts hardness [0,1] */
+ float m_soft_kKHR; /* Kinetic contacts hardness [0,1] */
+
+ float m_soft_kSHR; /* Soft contacts hardness [0,1] */
+ float m_soft_kAHR; /* Anchors hardness [0,1] */
+ int m_soft_collisionflags; /* Vertex/Face or Signed Distance Field(SDF) or Clusters, Soft versus Soft or Rigid */
+ int m_soft_numclusteriterations; /* number of iterations to refine collision clusters*/
+///////////////////
+
+
+
int m_collisionFlags;
+ bool m_bRigid;
+ bool m_bSoft;
///optional use of collision group/mask:
///only collision with object goups that match the collision mask.
@@ -85,32 +253,73 @@ struct CcdConstructionInfo
short int m_collisionFilterGroup;
short int m_collisionFilterMask;
-
- btCollisionShape* m_collisionShape;
- class PHY_IMotionState* m_MotionState;
+ ///these pointers are used as argument passing for the CcdPhysicsController constructor
+ ///and not anymore after that
+ class btCollisionShape* m_collisionShape;
+ class PHY_IMotionState* m_MotionState;
+ class CcdShapeConstructionInfo* m_shapeInfo;
CcdPhysicsEnvironment* m_physicsEnv; //needed for self-replication
float m_inertiaFactor;//tweak the inertia (hooked up to Blender 'formfactor'
+ bool m_do_anisotropic;
+ btVector3 m_anisotropicFriction;
+
+ bool m_do_fh; ///< Should the object have a linear Fh spring?
+ bool m_do_rot_fh; ///< Should the object have an angular Fh spring?
+ btScalar m_fh_spring; ///< Spring constant (both linear and angular)
+ btScalar m_fh_damping; ///< Damping factor (linear and angular) in range [0, 1]
+ btScalar m_fh_distance; ///< The range above the surface where Fh is active.
+ bool m_fh_normal; ///< Should the object slide off slopes?
+ float m_radius;//for fh backwards compatibility
+
};
class btRigidBody;
+class btCollisionObject;
+class btSoftBody;
///CcdPhysicsController is a physics object that supports continuous collision detection and time of impact based physics resolution.
class CcdPhysicsController : public PHY_IPhysicsController
{
- btRigidBody* m_body;
- class PHY_IMotionState* m_MotionState;
+
+ btCollisionObject* m_object;
+
+
+ class PHY_IMotionState* m_MotionState;
btMotionState* m_bulletMotionState;
+ class btCollisionShape* m_collisionShape;
+ class CcdShapeConstructionInfo* m_shapeInfo;
+ friend class CcdPhysicsEnvironment; // needed when updating the controller
+
+ //some book keeping for replication
+ bool m_softbodyMappingDone;
+ bool m_softBodyTransformInitialized;
+ bool m_prototypeTransformInitialized;
+ btTransform m_softbodyStartTrans;
- void* m_newClientInfo;
+ void* m_newClientInfo;
+ int m_registerCount; // needed when multiple sensors use the same controller
CcdConstructionInfo m_cci;//needed for replication
+
+ CcdPhysicsController* m_parentCtrl;
+
void GetWorldOrientation(btMatrix3x3& mat);
void CreateRigidbody();
+ bool Register() {
+ return (m_registerCount++ == 0) ? true : false;
+ }
+ bool Unregister() {
+ return (--m_registerCount == 0) ? true : false;
+ }
+
+ protected:
+ void setWorldOrientation(const btMatrix3x3& mat);
+
public:
int m_collisionDelay;
@@ -120,11 +329,24 @@ class CcdPhysicsController : public PHY_IPhysicsController
virtual ~CcdPhysicsController();
+ CcdConstructionInfo& getConstructionInfo()
+ {
+ return m_cci;
+ }
+ const CcdConstructionInfo& getConstructionInfo() const
+ {
+ return m_cci;
+ }
+
- btRigidBody* GetRigidBody() { return m_body;}
+ btRigidBody* GetRigidBody();
+ btCollisionObject* GetCollisionObject();
+ btSoftBody* GetSoftBody();
+
+ CcdShapeConstructionInfo* GetShapeInfo() { return m_shapeInfo; }
btCollisionShape* GetCollisionShape() {
- return m_body->getCollisionShape();
+ return m_object->getCollisionShape();
}
////////////////////////////////////
// PHY_IPhysicsController interface
@@ -190,16 +412,38 @@ class CcdPhysicsController : public PHY_IPhysicsController
return m_cci.m_collisionFilterMask;
}
-
virtual void calcXform() {} ;
- virtual void SetMargin(float margin) {};
- virtual float GetMargin() const {return 0.f;};
+ virtual void SetMargin(float margin)
+ {
+ if (m_collisionShape)
+ m_collisionShape->setMargin(btScalar(margin));
+ }
+ virtual float GetMargin() const
+ {
+ return (m_collisionShape) ? m_collisionShape->getMargin() : 0.f;
+ }
+ virtual float GetRadius() const
+ {
+ // this is not the actual shape radius, it's only used for Fh support
+ return m_cci.m_radius;
+ }
+ virtual void SetRadius(float margin)
+ {
+ if (m_collisionShape && m_collisionShape->getShapeType() == SPHERE_SHAPE_PROXYTYPE)
+ {
+ btSphereShape* sphereShape = static_cast<btSphereShape*>(m_collisionShape);
+ sphereShape->setUnscaledRadius(margin);
+ }
+ m_cci.m_radius = margin;
+ }
bool wantsSleeping();
void UpdateDeactivation(float timeStep);
+ void SetCenterOfMassTransform(btTransform& xform);
+
static btTransform GetTransformFromMotionState(PHY_IMotionState* motionState);
void setAabb(const btVector3& aabbMin,const btVector3& aabbMax);
@@ -215,7 +459,28 @@ class CcdPhysicsController : public PHY_IPhysicsController
return m_MotionState;
}
+ class CcdPhysicsEnvironment* GetPhysicsEnvironment()
+ {
+ return m_cci.m_physicsEnv;
+ }
+ void setParentCtrl(CcdPhysicsController* parentCtrl)
+ {
+ m_parentCtrl = parentCtrl;
+ }
+
+ CcdPhysicsController* getParentCtrl()
+ {
+ return m_parentCtrl;
+ }
+
+ const CcdPhysicsController* getParentCtrl() const
+ {
+ return m_parentCtrl;
+ }
+
+
+
};
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
index 99c3e5f77c7..4fe35630784 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
@@ -23,6 +23,9 @@ subject to the following restrictions:
#include "btBulletDynamicsCommon.h"
#include "LinearMath/btIDebugDraw.h"
#include "BulletCollision/CollisionDispatch/btSimulationIslandManager.h"
+#include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
+#include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h"
+#include "BulletCollision/Gimpact/btGImpactCollisionAlgorithm.h"
//profiling/timings
#include "LinearMath/btQuickprof.h"
@@ -30,6 +33,7 @@ subject to the following restrictions:
#include "PHY_IMotionState.h"
+#define CCD_CONSTRAINT_DISABLE_LINKED_COLLISION 0x80
bool useIslands = true;
@@ -53,6 +57,7 @@ void DrawRasterizerLine(const float* from,const float* to,int color);
#include <stdio.h>
+#include <string.h> // for memset
#ifdef NEW_BULLET_VEHICLE_SUPPORT
class WrapperVehicle : public PHY_IVehicle
@@ -251,6 +256,22 @@ public:
};
#endif //NEW_BULLET_VEHICLE_SUPPORT
+class CcdOverlapFilterCallBack : public btOverlapFilterCallback
+{
+private:
+ class CcdPhysicsEnvironment* m_physEnv;
+public:
+ CcdOverlapFilterCallBack(CcdPhysicsEnvironment* env) :
+ m_physEnv(env)
+ {
+ }
+ virtual ~CcdOverlapFilterCallBack()
+ {
+ }
+ // return true when pairs need collision
+ virtual bool needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const;
+};
+
void CcdPhysicsEnvironment::setDebugDrawer(btIDebugDraw* debugDrawer)
{
@@ -302,33 +323,40 @@ m_numTimeSubSteps(1),
m_ccdMode(0),
m_solverType(-1),
m_profileTimings(0),
-m_enableSatCollisionDetection(false)
+m_enableSatCollisionDetection(false),
+m_solver(NULL),
+m_ownPairCache(NULL),
+m_ownDispatcher(NULL),
+m_filterCallback(NULL)
{
for (int i=0;i<PHY_NUM_RESPONSE;i++)
{
m_triggerCallbacks[i] = 0;
}
- if (!dispatcher)
- dispatcher = new btCollisionDispatcher();
+// m_collisionConfiguration = new btDefaultCollisionConfiguration();
+ m_collisionConfiguration = new btSoftBodyRigidBodyCollisionConfiguration();
- if(!pairCache)
+ if (!dispatcher)
{
-
- //todo: calculate/let user specify this world sizes
- btVector3 worldMin(-10000,-10000,-10000);
- btVector3 worldMax(10000,10000,10000);
-
- pairCache = new btAxisSweep3(worldMin,worldMax);
-
- //broadphase = new btSimpleBroadphase();
+ btCollisionDispatcher* disp = new btCollisionDispatcher(m_collisionConfiguration);
+ dispatcher = disp;
+ btGImpactCollisionAlgorithm::registerAlgorithm(disp);
+ m_ownDispatcher = dispatcher;
}
+ //m_broadphase = new btAxisSweep3(btVector3(-1000,-1000,-1000),btVector3(1000,1000,1000));
+ //m_broadphase = new btSimpleBroadphase();
+ m_broadphase = new btDbvtBroadphase();
+
+ m_filterCallback = new CcdOverlapFilterCallBack(this);
+ m_broadphase->getOverlappingPairCache()->setOverlapFilterCallback(m_filterCallback);
setSolverType(1);//issues with quickstep and memory allocations
+// m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
+ m_dynamicsWorld = new btSoftRigidDynamicsWorld(dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
- m_dynamicsWorld = new btDiscreteDynamicsWorld(dispatcher,pairCache,new btSequentialImpulseConstraintSolver());
m_debugDrawer = 0;
m_gravity = btVector3(0.f,-10.f,0.f);
m_dynamicsWorld->setGravity(m_gravity);
@@ -339,23 +367,42 @@ m_enableSatCollisionDetection(false)
void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl)
{
btRigidBody* body = ctrl->GetRigidBody();
+ btCollisionObject* obj = ctrl->GetCollisionObject();
//this m_userPointer is just used for triggers, see CallbackTriggers
- body->setUserPointer(ctrl);
+ obj->setUserPointer(ctrl);
+ if (body)
+ body->setGravity( m_gravity );
- body->setGravity( m_gravity );
- m_controllers.push_back(ctrl);
+ m_controllers.insert(ctrl);
- m_dynamicsWorld->addRigidBody(body);
- if (body->isStaticOrKinematicObject())
+ if (body)
+ {
+ //use explicit group/filter for finer control over collision in bullet => near/radar sensor
+ m_dynamicsWorld->addRigidBody(body, ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask());
+ } else
+ {
+ if (ctrl->GetSoftBody())
+ {
+ btSoftBody* softBody = ctrl->GetSoftBody();
+ m_dynamicsWorld->addSoftBody(softBody);
+ } else
+ {
+ if (obj->getCollisionShape())
+ {
+ m_dynamicsWorld->addCollisionObject(obj,ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask());
+ }
+ }
+ }
+ if (obj->isStaticOrKinematicObject())
{
- body->setActivationState(ISLAND_SLEEPING);
+ obj->setActivationState(ISLAND_SLEEPING);
}
//CollisionObject(body,ctrl->GetCollisionFilterGroup(),ctrl->GetCollisionFilterMask());
- assert(body->getBroadphaseHandle());
+ assert(obj->getBroadphaseHandle());
btBroadphaseInterface* scene = getBroadphase();
@@ -364,7 +411,7 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl)
assert(shapeinterface);
- const btTransform& t = ctrl->GetRigidBody()->getCenterOfMassTransform();
+ const btTransform& t = ctrl->GetCollisionObject()->getWorldTransform();
btPoint3 minAabb,maxAabb;
@@ -376,69 +423,123 @@ void CcdPhysicsEnvironment::addCcdPhysicsController(CcdPhysicsController* ctrl)
//extent it with the motion
- btVector3 linMotion = body->getLinearVelocity()*timeStep;
-
- float maxAabbx = maxAabb.getX();
- float maxAabby = maxAabb.getY();
- float maxAabbz = maxAabb.getZ();
- float minAabbx = minAabb.getX();
- float minAabby = minAabb.getY();
- float minAabbz = minAabb.getZ();
-
- if (linMotion.x() > 0.f)
- maxAabbx += linMotion.x();
- else
- minAabbx += linMotion.x();
- if (linMotion.y() > 0.f)
- maxAabby += linMotion.y();
- else
- minAabby += linMotion.y();
- if (linMotion.z() > 0.f)
- maxAabbz += linMotion.z();
- else
- minAabbz += linMotion.z();
-
-
- minAabb = btVector3(minAabbx,minAabby,minAabbz);
- maxAabb = btVector3(maxAabbx,maxAabby,maxAabbz);
-
+ if (body)
+ {
+ btVector3 linMotion = body->getLinearVelocity()*timeStep;
+
+ float maxAabbx = maxAabb.getX();
+ float maxAabby = maxAabb.getY();
+ float maxAabbz = maxAabb.getZ();
+ float minAabbx = minAabb.getX();
+ float minAabby = minAabb.getY();
+ float minAabbz = minAabb.getZ();
+
+ if (linMotion.x() > 0.f)
+ maxAabbx += linMotion.x();
+ else
+ minAabbx += linMotion.x();
+ if (linMotion.y() > 0.f)
+ maxAabby += linMotion.y();
+ else
+ minAabby += linMotion.y();
+ if (linMotion.z() > 0.f)
+ maxAabbz += linMotion.z();
+ else
+ minAabbz += linMotion.z();
+
+
+ minAabb = btVector3(minAabbx,minAabby,minAabbz);
+ maxAabb = btVector3(maxAabbx,maxAabby,maxAabbz);
+ }
}
+
+
void CcdPhysicsEnvironment::removeCcdPhysicsController(CcdPhysicsController* ctrl)
{
-
//also remove constraint
-
-
-
- m_dynamicsWorld->removeRigidBody(ctrl->GetRigidBody());
-
-
+ btRigidBody* body = ctrl->GetRigidBody();
+ if (body)
+ {
+ m_dynamicsWorld->removeRigidBody(ctrl->GetRigidBody());
+ } else
{
- std::vector<CcdPhysicsController*>::iterator i =
- std::find(m_controllers.begin(), m_controllers.end(), ctrl);
- if (!(i == m_controllers.end()))
+ //if a softbody
+ if (ctrl->GetSoftBody())
{
- std::swap(*i, m_controllers.back());
- m_controllers.pop_back();
+ m_dynamicsWorld->removeSoftBody(ctrl->GetSoftBody());
+ } else
+ {
+ m_dynamicsWorld->removeCollisionObject(ctrl->GetCollisionObject());
}
}
+ m_controllers.erase(ctrl);
+
+ if (ctrl->m_registerCount != 0)
+ printf("Warning: removing controller with non-zero m_registerCount: %d\n", ctrl->m_registerCount);
//remove it from the triggers
+ m_triggerControllers.erase(ctrl);
+}
+
+void CcdPhysicsEnvironment::updateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask)
+{
+ // this function is used when the collisionning group of a controller is changed
+ // remove and add the collistioning object
+ btRigidBody* body = ctrl->GetRigidBody();
+ btCollisionObject* obj = ctrl->GetCollisionObject();
+ if (obj)
{
- std::vector<CcdPhysicsController*>::iterator i =
- std::find(m_triggerControllers.begin(), m_triggerControllers.end(), ctrl);
- if (!(i == m_triggerControllers.end()))
+ btVector3 inertia(0.0,0.0,0.0);
+ m_dynamicsWorld->removeCollisionObject(obj);
+ obj->setCollisionFlags(newCollisionFlags);
+ if (body)
{
- std::swap(*i, m_triggerControllers.back());
- m_triggerControllers.pop_back();
+ if (newMass)
+ body->getCollisionShape()->calculateLocalInertia(newMass, inertia);
+ body->setMassProps(newMass, inertia);
}
+ m_dynamicsWorld->addCollisionObject(obj, newCollisionGroup, newCollisionMask);
}
+ // to avoid nasty interaction, we must update the property of the controller as well
+ ctrl->m_cci.m_mass = newMass;
+ ctrl->m_cci.m_collisionFilterGroup = newCollisionGroup;
+ ctrl->m_cci.m_collisionFilterMask = newCollisionMask;
+ ctrl->m_cci.m_collisionFlags = newCollisionFlags;
+}
+void CcdPhysicsEnvironment::enableCcdPhysicsController(CcdPhysicsController* ctrl)
+{
+ if (m_controllers.insert(ctrl).second)
+ {
+ btCollisionObject* obj = ctrl->GetCollisionObject();
+ obj->setUserPointer(ctrl);
+ m_dynamicsWorld->addCollisionObject(obj,
+ ctrl->GetCollisionFilterGroup(), ctrl->GetCollisionFilterMask());
+ }
+}
+void CcdPhysicsEnvironment::disableCcdPhysicsController(CcdPhysicsController* ctrl)
+{
+ if (m_controllers.erase(ctrl))
+ {
+ btRigidBody* body = ctrl->GetRigidBody();
+ if (body)
+ {
+ m_dynamicsWorld->removeRigidBody(body);
+ } else
+ {
+ if (ctrl->GetSoftBody())
+ {
+ } else
+ {
+ m_dynamicsWorld->removeCollisionObject(body);
+ }
+ }
+ }
}
@@ -450,25 +551,31 @@ void CcdPhysicsEnvironment::beginFrame()
bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
{
+ std::set<CcdPhysicsController*>::iterator it;
+ int i;
- int i,numCtrl = GetNumControllers();
- for (i=0;i<numCtrl;i++)
+ for (it=m_controllers.begin(); it!=m_controllers.end(); it++)
{
- CcdPhysicsController* ctrl = GetPhysicsController(i);
- ctrl->SynchronizeMotionStates(timeStep);
+ (*it)->SynchronizeMotionStates(timeStep);
}
+ processFhSprings(curTime,timeStep);
+
float subStep = timeStep / float(m_numTimeSubSteps);
for (i=0;i<m_numTimeSubSteps;i++)
{
- m_dynamicsWorld->stepSimulation(subStep,0);//perform always a full simulation step
+// m_dynamicsWorld->stepSimulation(subStep,20,1./240.);//perform always a full simulation step
+ m_dynamicsWorld->stepSimulation(subStep,0);//perform always a full simulation step
}
- numCtrl = GetNumControllers();
- for (i=0;i<numCtrl;i++)
+ for (it=m_controllers.begin(); it!=m_controllers.end(); it++)
{
- CcdPhysicsController* ctrl = GetPhysicsController(i);
- ctrl->SynchronizeMotionStates(timeStep);
+ (*it)->SynchronizeMotionStates(timeStep);
+ }
+
+ for (it=m_controllers.begin(); it!=m_controllers.end(); it++)
+ {
+ (*it)->SynchronizeMotionStates(timeStep);
}
for (i=0;i<m_wrapperVehicles.size();i++)
@@ -477,11 +584,181 @@ bool CcdPhysicsEnvironment::proceedDeltaTime(double curTime,float timeStep)
veh->SyncWheels();
}
+ if (m_dynamicsWorld->getDebugDrawer() && m_dynamicsWorld->getDebugDrawer()->getDebugMode() >0)
+ m_dynamicsWorld->debugDrawWorld();
+
+
CallbackTriggers();
return true;
}
+class ClosestRayResultCallbackNotMe : public btCollisionWorld::ClosestRayResultCallback
+{
+ btCollisionObject* m_owner;
+ btCollisionObject* m_parent;
+
+public:
+ ClosestRayResultCallbackNotMe(const btVector3& rayFromWorld,const btVector3& rayToWorld,btCollisionObject* owner,btCollisionObject* parent)
+ :btCollisionWorld::ClosestRayResultCallback(rayFromWorld,rayToWorld),
+ m_owner(owner)
+ {
+
+ }
+
+ virtual bool needsCollision(btBroadphaseProxy* proxy0) const
+ {
+ //don't collide with self
+ if (proxy0->m_clientObject == m_owner)
+ return false;
+
+ if (proxy0->m_clientObject == m_parent)
+ return false;
+
+ return btCollisionWorld::ClosestRayResultCallback::needsCollision(proxy0);
+ }
+
+};
+
+void CcdPhysicsEnvironment::processFhSprings(double curTime,float timeStep)
+{
+ std::set<CcdPhysicsController*>::iterator it;
+
+ for (it=m_controllers.begin(); it!=m_controllers.end(); it++)
+ {
+ CcdPhysicsController* ctrl = (*it);
+ btRigidBody* body = ctrl->GetRigidBody();
+
+ if (body && (ctrl->getConstructionInfo().m_do_fh || ctrl->getConstructionInfo().m_do_rot_fh))
+ {
+ //printf("has Fh or RotFh\n");
+ //re-implement SM_FhObject.cpp using btCollisionWorld::rayTest and info from ctrl->getConstructionInfo()
+ //send a ray from {0.0, 0.0, 0.0} towards {0.0, 0.0, -10.0}, in local coordinates
+
+
+ CcdPhysicsController* parentCtrl = ctrl->getParentCtrl();
+ btRigidBody* parentBody = parentCtrl?parentCtrl->GetRigidBody() : 0;
+ btRigidBody* cl_object = parentBody ? parentBody : body;
+
+ if (body->isStaticOrKinematicObject())
+ continue;
+
+ btVector3 rayDirLocal(0,0,-10);
+
+ //m_dynamicsWorld
+ //ctrl->GetRigidBody();
+ btVector3 rayFromWorld = body->getCenterOfMassPosition();
+ //btVector3 rayToWorld = rayFromWorld + body->getCenterOfMassTransform().getBasis() * rayDirLocal;
+ //ray always points down the z axis in world space...
+ btVector3 rayToWorld = rayFromWorld + rayDirLocal;
+
+ ClosestRayResultCallbackNotMe resultCallback(rayFromWorld,rayToWorld,body,parentBody);
+
+ m_dynamicsWorld->rayTest(rayFromWorld,rayToWorld,resultCallback);
+ if (resultCallback.hasHit())
+ {
+ //we hit this one: resultCallback.m_collisionObject;
+ CcdPhysicsController* controller = static_cast<CcdPhysicsController*>(resultCallback.m_collisionObject->getUserPointer());
+
+ if (controller)
+ {
+ if (controller->getConstructionInfo().m_fh_distance < SIMD_EPSILON)
+ continue;
+
+ btRigidBody* hit_object = controller->GetRigidBody();
+ if (!hit_object)
+ continue;
+
+ CcdConstructionInfo& hitObjShapeProps = controller->getConstructionInfo();
+
+ float distance = resultCallback.m_closestHitFraction*rayDirLocal.length()-ctrl->getConstructionInfo().m_radius;
+ if (distance >= hitObjShapeProps.m_fh_distance)
+ continue;
+
+
+
+ //btVector3 ray_dir = cl_object->getCenterOfMassTransform().getBasis()* rayDirLocal.normalized();
+ btVector3 ray_dir = rayDirLocal.normalized();
+ btVector3 normal = resultCallback.m_hitNormalWorld;
+ normal.normalize();
+
+
+ if (ctrl->getConstructionInfo().m_do_fh)
+ {
+ btVector3 lspot = cl_object->getCenterOfMassPosition()
+ + rayDirLocal * resultCallback.m_closestHitFraction;
+
+
+
+
+ lspot -= hit_object->getCenterOfMassPosition();
+ btVector3 rel_vel = cl_object->getLinearVelocity() - hit_object->getVelocityInLocalPoint(lspot);
+ btScalar rel_vel_ray = ray_dir.dot(rel_vel);
+ btScalar spring_extent = 1.0 - distance / hitObjShapeProps.m_fh_distance;
+
+ btScalar i_spring = spring_extent * hitObjShapeProps.m_fh_spring;
+ btScalar i_damp = rel_vel_ray * hitObjShapeProps.m_fh_damping;
+
+ cl_object->setLinearVelocity(cl_object->getLinearVelocity() + (-(i_spring + i_damp) * ray_dir));
+ if (hitObjShapeProps.m_fh_normal)
+ {
+ cl_object->setLinearVelocity(cl_object->getLinearVelocity()+(i_spring + i_damp) *(normal - normal.dot(ray_dir) * ray_dir));
+ }
+
+ btVector3 lateral = rel_vel - rel_vel_ray * ray_dir;
+
+
+ if (ctrl->getConstructionInfo().m_do_anisotropic) {
+ //Bullet basis contains no scaling/shear etc.
+ const btMatrix3x3& lcs = cl_object->getCenterOfMassTransform().getBasis();
+ btVector3 loc_lateral = lateral * lcs;
+ const btVector3& friction_scaling = cl_object->getAnisotropicFriction();
+ loc_lateral *= friction_scaling;
+ lateral = lcs * loc_lateral;
+ }
+
+ btScalar rel_vel_lateral = lateral.length();
+
+ if (rel_vel_lateral > SIMD_EPSILON) {
+ btScalar friction_factor = hit_object->getFriction();//cl_object->getFriction();
+
+ btScalar max_friction = friction_factor * btMax(btScalar(0.0), i_spring);
+
+ btScalar rel_mom_lateral = rel_vel_lateral / cl_object->getInvMass();
+
+ btVector3 friction = (rel_mom_lateral > max_friction) ?
+ -lateral * (max_friction / rel_vel_lateral) :
+ -lateral;
+
+ cl_object->applyCentralImpulse(friction);
+ }
+ }
+
+
+ if (ctrl->getConstructionInfo().m_do_rot_fh) {
+ btVector3 up2 = cl_object->getWorldTransform().getBasis().getColumn(2);
+
+ btVector3 t_spring = up2.cross(normal) * hitObjShapeProps.m_fh_spring;
+ btVector3 ang_vel = cl_object->getAngularVelocity();
+
+ // only rotations that tilt relative to the normal are damped
+ ang_vel -= ang_vel.dot(normal) * normal;
+
+ btVector3 t_damp = ang_vel * hitObjShapeProps.m_fh_damping;
+
+ cl_object->setAngularVelocity(cl_object->getAngularVelocity() + (t_spring - t_damp));
+ }
+
+ }
+
+
+ }
+
+
+ }
+ }
+
+}
void CcdPhysicsEnvironment::setDebugMode(int debugMode)
{
@@ -537,7 +814,7 @@ void CcdPhysicsEnvironment::setSolverDamping(float damping)
void CcdPhysicsEnvironment::setLinearAirDamping(float damping)
{
- gLinearAirDamping = damping;
+ //gLinearAirDamping = damping;
}
void CcdPhysicsEnvironment::setUseEpa(bool epa)
@@ -556,7 +833,7 @@ void CcdPhysicsEnvironment::setSolverType(int solverType)
{
m_solver = new btSequentialImpulseConstraintSolver();
-
+// ((btSequentialImpulseConstraintSolver*)m_solver)->setSolverMode(btSequentialImpulseConstraintSolver::SOLVER_USE_WARMSTARTING | btSequentialImpulseConstraintSolver::SOLVER_RANDMIZE_ORDER);
break;
}
}
@@ -577,7 +854,13 @@ void CcdPhysicsEnvironment::setSolverType(int solverType)
-
+void CcdPhysicsEnvironment::getGravity(PHY__Vector3& grav)
+{
+ const btVector3& gravity = m_dynamicsWorld->getGravity();
+ grav[0] = gravity.getX();
+ grav[1] = gravity.getY();
+ grav[2] = gravity.getZ();
+}
void CcdPhysicsEnvironment::setGravity(float x,float y,float z)
@@ -600,13 +883,16 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint(
const btVector3& linearMinLimits,
const btVector3& linearMaxLimits,
const btVector3& angularMinLimits,
- const btVector3& angularMaxLimits
+ const btVector3& angularMaxLimits,int flags
)
{
+ bool disableCollisionBetweenLinkedBodies = (0!=(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION));
+
//we could either add some logic to recognize ball-socket and hinge, or let that up to the user
//perhaps some warning or hint that hinge/ball-socket is more efficient?
+
btGeneric6DofConstraint* genericConstraint = 0;
CcdPhysicsController* ctrl0 = (CcdPhysicsController*) ctrlRef;
CcdPhysicsController* ctrl1 = (CcdPhysicsController*) ctrlOther;
@@ -618,9 +904,10 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint(
{
+ bool useReferenceFrameA = true;
genericConstraint = new btGeneric6DofConstraint(
*rb0,*rb1,
- frameInA,frameInB);
+ frameInA,frameInB,useReferenceFrameA);
genericConstraint->setLinearLowerLimit(linearMinLimits);
genericConstraint->setLinearUpperLimit(linearMaxLimits);
genericConstraint->setAngularLowerLimit(angularMinLimits);
@@ -635,7 +922,7 @@ int CcdPhysicsEnvironment::createUniversalD6Constraint(
if (genericConstraint)
{
// m_constraints.push_back(genericConstraint);
- m_dynamicsWorld->addConstraint(genericConstraint);
+ m_dynamicsWorld->addConstraint(genericConstraint,disableCollisionBetweenLinkedBodies);
genericConstraint->setUserConstraintId(gConstraintUid++);
genericConstraint->setUserConstraintType(PHY_GENERIC_6DOF_CONSTRAINT);
@@ -668,35 +955,54 @@ void CcdPhysicsEnvironment::removeConstraint(int constraintId)
struct FilterClosestRayResultCallback : public btCollisionWorld::ClosestRayResultCallback
{
- PHY_IPhysicsController* m_ignoreClient;
+ PHY_IRayCastFilterCallback& m_phyRayFilter;
+ const btCollisionShape* m_hitTriangleShape;
+ int m_hitTriangleIndex;
- FilterClosestRayResultCallback (PHY_IPhysicsController* ignoreClient,const btVector3& rayFrom,const btVector3& rayTo)
+ FilterClosestRayResultCallback (PHY_IRayCastFilterCallback& phyRayFilter,const btVector3& rayFrom,const btVector3& rayTo)
: btCollisionWorld::ClosestRayResultCallback(rayFrom,rayTo),
- m_ignoreClient(ignoreClient)
+ m_phyRayFilter(phyRayFilter),
+ m_hitTriangleShape(NULL),
+ m_hitTriangleIndex(0)
{
-
}
virtual ~FilterClosestRayResultCallback()
{
}
- virtual float AddSingleResult( btCollisionWorld::LocalRayResult& rayResult)
+ virtual bool needsCollision(btBroadphaseProxy* proxy0) const
+ {
+ if (!(proxy0->m_collisionFilterGroup & m_collisionFilterMask))
+ return false;
+ if (!(m_collisionFilterGroup & proxy0->m_collisionFilterMask))
+ return false;
+ btCollisionObject* object = (btCollisionObject*)proxy0->m_clientObject;
+ CcdPhysicsController* phyCtrl = static_cast<CcdPhysicsController*>(object->getUserPointer());
+ if (phyCtrl == m_phyRayFilter.m_ignoreController)
+ return false;
+ return m_phyRayFilter.needBroadphaseRayCast(phyCtrl);
+ }
+
+ virtual btScalar addSingleResult(btCollisionWorld::LocalRayResult& rayResult,bool normalInWorldSpace)
{
CcdPhysicsController* curHit = static_cast<CcdPhysicsController*>(rayResult.m_collisionObject->getUserPointer());
- //ignore client...
- if (curHit != m_ignoreClient)
- {
- //if valid
- return ClosestRayResultCallback::AddSingleResult(rayResult);
+ // save shape information as ClosestRayResultCallback::AddSingleResult() does not do it
+ if (rayResult.m_localShapeInfo)
+ {
+ m_hitTriangleShape = rayResult.m_collisionObject->getCollisionShape();
+ m_hitTriangleIndex = rayResult.m_localShapeInfo->m_triangleIndex;
+ } else
+ {
+ m_hitTriangleShape = NULL;
+ m_hitTriangleIndex = 0;
}
- return m_closestHitFraction;
+ return ClosestRayResultCallback::addSingleResult(rayResult,normalInWorldSpace);
}
};
-PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
- float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ)
+PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
{
@@ -710,19 +1016,101 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* i
//Either Ray Cast with or without filtering
//btCollisionWorld::ClosestRayResultCallback rayCallback(rayFrom,rayTo);
- FilterClosestRayResultCallback rayCallback(ignoreClient,rayFrom,rayTo);
+ FilterClosestRayResultCallback rayCallback(filterCallback,rayFrom,rayTo);
+
+ PHY_RayCastResult result;
+ memset(&result, 0, sizeof(result));
- PHY_IPhysicsController* nearestHit = 0;
+ // don't collision with sensor object
+ rayCallback.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter;
+ //, ,filterCallback.m_faceNormal);
m_dynamicsWorld->rayTest(rayFrom,rayTo,rayCallback);
- if (rayCallback.HasHit())
+ if (rayCallback.hasHit())
{
- nearestHit = static_cast<CcdPhysicsController*>(rayCallback.m_collisionObject->getUserPointer());
- hitX = rayCallback.m_hitPointWorld.getX();
- hitY = rayCallback.m_hitPointWorld.getY();
- hitZ = rayCallback.m_hitPointWorld.getZ();
+ CcdPhysicsController* controller = static_cast<CcdPhysicsController*>(rayCallback.m_collisionObject->getUserPointer());
+ result.m_controller = controller;
+ result.m_hitPoint[0] = rayCallback.m_hitPointWorld.getX();
+ result.m_hitPoint[1] = rayCallback.m_hitPointWorld.getY();
+ result.m_hitPoint[2] = rayCallback.m_hitPointWorld.getZ();
+
+ if (rayCallback.m_hitTriangleShape != NULL)
+ {
+ // identify the mesh polygon
+ CcdShapeConstructionInfo* shapeInfo = controller->m_shapeInfo;
+ if (shapeInfo)
+ {
+ btCollisionShape* shape = controller->GetCollisionObject()->getCollisionShape();
+ if (shape->isCompound())
+ {
+ btCompoundShape* compoundShape = (btCompoundShape*)shape;
+ CcdShapeConstructionInfo* compoundShapeInfo = shapeInfo;
+ // need to search which sub-shape has been hit
+ for (int i=0; i<compoundShape->getNumChildShapes(); i++)
+ {
+ shapeInfo = compoundShapeInfo->GetChildShape(i);
+ shape=compoundShape->getChildShape(i);
+ if (shape == rayCallback.m_hitTriangleShape)
+ break;
+ }
+ }
+ if (shape == rayCallback.m_hitTriangleShape &&
+ rayCallback.m_hitTriangleIndex < shapeInfo->m_polygonIndexArray.size())
+ {
+ result.m_meshObject = shapeInfo->GetMesh();
+ result.m_polygon = shapeInfo->m_polygonIndexArray.at(rayCallback.m_hitTriangleIndex);
+ // Bullet returns the normal from "outside".
+ // If the user requests the real normal, compute it now
+ if (filterCallback.m_faceNormal)
+ {
+ // mesh shapes are shared and stored in the shapeInfo
+ btTriangleMeshShape* triangleShape = shapeInfo->GetMeshShape();
+ if (triangleShape)
+ {
+ // this code is copied from Bullet
+ btVector3 triangle[3];
+ const unsigned char *vertexbase;
+ int numverts;
+ PHY_ScalarType type;
+ int stride;
+ const unsigned char *indexbase;
+ int indexstride;
+ int numfaces;
+ PHY_ScalarType indicestype;
+ btStridingMeshInterface* meshInterface = triangleShape->getMeshInterface();
+
+ meshInterface->getLockedReadOnlyVertexIndexBase(
+ &vertexbase,
+ numverts,
+ type,
+ stride,
+ &indexbase,
+ indexstride,
+ numfaces,
+ indicestype,
+ 0);
+
+ unsigned int* gfxbase = (unsigned int*)(indexbase+rayCallback.m_hitTriangleIndex*indexstride);
+ const btVector3& meshScaling = shape->getLocalScaling();
+ for (int j=2;j>=0;j--)
+ {
+ int graphicsindex = indicestype==PHY_SHORT?((unsigned short*)gfxbase)[j]:gfxbase[j];
+
+ btScalar* graphicsbase = (btScalar*)(vertexbase+graphicsindex*stride);
+
+ triangle[j] = btVector3(graphicsbase[0]*meshScaling.getX(),graphicsbase[1]*meshScaling.getY(),graphicsbase[2]*meshScaling.getZ());
+ }
+ meshInterface->unLockReadOnlyVertexBase(0);
+ btVector3 triangleNormal;
+ triangleNormal = (triangle[1]-triangle[0]).cross(triangle[2]-triangle[0]);
+ rayCallback.m_hitNormalWorld = rayCallback.m_collisionObject->getWorldTransform().getBasis()*triangleNormal;
+ }
+ }
+ }
+ }
+ }
if (rayCallback.m_hitNormalWorld.length2() > (SIMD_EPSILON*SIMD_EPSILON))
{
rayCallback.m_hitNormalWorld.normalize();
@@ -730,14 +1118,14 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::rayTest(PHY_IPhysicsController* i
{
rayCallback.m_hitNormalWorld.setValue(1,0,0);
}
- normalX = rayCallback.m_hitNormalWorld.getX();
- normalY = rayCallback.m_hitNormalWorld.getY();
- normalZ = rayCallback.m_hitNormalWorld.getZ();
-
+ result.m_hitNormal[0] = rayCallback.m_hitNormalWorld.getX();
+ result.m_hitNormal[1] = rayCallback.m_hitNormalWorld.getY();
+ result.m_hitNormal[2] = rayCallback.m_hitNormalWorld.getZ();
+ filterCallback.reportHit(&result);
}
- return nearestHit;
+ return result.m_controller;
}
@@ -760,6 +1148,13 @@ btBroadphaseInterface* CcdPhysicsEnvironment::getBroadphase()
return m_dynamicsWorld->getBroadphase();
}
+btDispatcher* CcdPhysicsEnvironment::getDispatcher()
+{
+ return m_dynamicsWorld->getDispatcher();
+}
+
+
+
@@ -778,22 +1173,27 @@ CcdPhysicsEnvironment::~CcdPhysicsEnvironment()
delete m_dynamicsWorld;
+ if (NULL != m_ownPairCache)
+ delete m_ownPairCache;
-}
-
+ if (NULL != m_ownDispatcher)
+ delete m_ownDispatcher;
-int CcdPhysicsEnvironment::GetNumControllers()
-{
- return m_controllers.size();
-}
+ if (NULL != m_solver)
+ delete m_solver;
+ if (NULL != m_debugDrawer)
+ delete m_debugDrawer;
-CcdPhysicsController* CcdPhysicsEnvironment::GetPhysicsController( int index)
-{
- return m_controllers[index];
-}
+ if (NULL != m_filterCallback)
+ delete m_filterCallback;
+ if (NULL != m_collisionConfiguration)
+ delete m_collisionConfiguration;
+ if (NULL != m_broadphase)
+ delete m_broadphase;
+}
void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float value0,float value1)
@@ -805,7 +1205,7 @@ void CcdPhysicsEnvironment::setConstraintParam(int constraintId,int param,float
{
//param = 1..12, min0,max0,min1,max1...min6,max6
btGeneric6DofConstraint* genCons = (btGeneric6DofConstraint*)typedConstraint;
- genCons->SetLimit(param,value0,value1);
+ genCons->setLimit(param,value0,value1);
break;
};
default:
@@ -835,15 +1235,18 @@ void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl)
{
CcdPhysicsController* ctrl1 = (CcdPhysicsController* )ctrl;
- std::vector<CcdPhysicsController*>::iterator i =
- std::find(m_controllers.begin(), m_controllers.end(), ctrl);
- if ((i == m_controllers.end()))
- {
- addCcdPhysicsController(ctrl1);
- }
+ // addSensor() is a "light" function for bullet because it is used
+ // dynamically when the sensor is activated. Use enableCcdPhysicsController() instead
+ //if (m_controllers.insert(ctrl1).second)
+ //{
+ // addCcdPhysicsController(ctrl1);
+ //}
+ enableCcdPhysicsController(ctrl1);
+
+ //Collision filter/mask is now set at the time of the creation of the controller
//force collision detection with everything, including static objects (might hurt performance!)
- ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterMask = btBroadphaseProxy::AllFilter;
- ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterGroup = btBroadphaseProxy::AllFilter;
+ //ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterMask = btBroadphaseProxy::AllFilter ^ btBroadphaseProxy::SensorTrigger;
+ //ctrl1->GetRigidBody()->getBroadphaseHandle()->m_collisionFilterGroup = btBroadphaseProxy::SensorTrigger;
//todo: make this 'sensor'!
requestCollisionCallback(ctrl);
@@ -852,21 +1255,19 @@ void CcdPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl)
void CcdPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
{
- std::vector<CcdPhysicsController*>::iterator i =
- std::find(m_triggerControllers.begin(), m_triggerControllers.end(), ctrl);
- if (!(i == m_triggerControllers.end()))
- {
- std::swap(*i, m_triggerControllers.back());
- m_triggerControllers.pop_back();
- }
+ CcdPhysicsController* ccdCtrl = (CcdPhysicsController*)ctrl;
+ if (ccdCtrl->Unregister())
+ m_triggerControllers.erase(ccdCtrl);
}
void CcdPhysicsEnvironment::removeSensor(PHY_IPhysicsController* ctrl)
{
removeCollisionCallback(ctrl);
- //printf("removeSensor\n");
+
+ disableCcdPhysicsController((CcdPhysicsController*)ctrl);
}
+
void CcdPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)
{
/* printf("addTouchCallback\n(response class = %i)\n",response_class);
@@ -903,11 +1304,10 @@ void CcdPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ctr
{
CcdPhysicsController* ccdCtrl = static_cast<CcdPhysicsController*>(ctrl);
- //printf("requestCollisionCallback\n");
- m_triggerControllers.push_back(ccdCtrl);
+ if (ccdCtrl->Register())
+ m_triggerControllers.insert(ccdCtrl);
}
-
void CcdPhysicsEnvironment::CallbackTriggers()
{
@@ -916,13 +1316,16 @@ void CcdPhysicsEnvironment::CallbackTriggers()
if (m_triggerCallbacks[PHY_OBJECT_RESPONSE] || (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints)))
{
//walk over all overlapping pairs, and if one of the involved bodies is registered for trigger callback, perform callback
- int numManifolds = m_dynamicsWorld->getDispatcher()->getNumManifolds();
+ btDispatcher* dispatcher = m_dynamicsWorld->getDispatcher();
+ int numManifolds = dispatcher->getNumManifolds();
for (int i=0;i<numManifolds;i++)
{
- btPersistentManifold* manifold = m_dynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i);
+ btPersistentManifold* manifold = dispatcher->getManifoldByIndexInternal(i);
int numContacts = manifold->getNumContacts();
if (numContacts)
{
+ btRigidBody* rb0 = static_cast<btRigidBody*>(manifold->getBody0());
+ btRigidBody* rb1 = static_cast<btRigidBody*>(manifold->getBody1());
if (m_debugDrawer && (m_debugDrawer->getDebugMode() & btIDebugDraw::DBG_DrawContactPoints))
{
for (int j=0;j<numContacts;j++)
@@ -933,18 +1336,17 @@ void CcdPhysicsEnvironment::CallbackTriggers()
m_debugDrawer->drawContactPoint(cp.m_positionWorldOnB,cp.m_normalWorldOnB,cp.getDistance(),cp.getLifeTime(),color);
}
}
- btRigidBody* obj0 = static_cast<btRigidBody* >(manifold->getBody0());
- btRigidBody* obj1 = static_cast<btRigidBody* >(manifold->getBody1());
+ btRigidBody* obj0 = rb0;
+ btRigidBody* obj1 = rb1;
//m_internalOwner is set in 'addPhysicsController'
CcdPhysicsController* ctrl0 = static_cast<CcdPhysicsController*>(obj0->getUserPointer());
CcdPhysicsController* ctrl1 = static_cast<CcdPhysicsController*>(obj1->getUserPointer());
- std::vector<CcdPhysicsController*>::iterator i =
- std::find(m_triggerControllers.begin(), m_triggerControllers.end(), ctrl0);
+ std::set<CcdPhysicsController*>::const_iterator i = m_triggerControllers.find(ctrl0);
if (i == m_triggerControllers.end())
{
- i = std::find(m_triggerControllers.begin(), m_triggerControllers.end(), ctrl1);
+ i = m_triggerControllers.find(ctrl1);
}
if (!(i == m_triggerControllers.end()))
@@ -952,6 +1354,15 @@ void CcdPhysicsEnvironment::CallbackTriggers()
m_triggerCallbacks[PHY_OBJECT_RESPONSE](m_triggerCallbacksUserPtrs[PHY_OBJECT_RESPONSE],
ctrl0,ctrl1,0);
}
+ // Bullet does not refresh the manifold contact point for object without contact response
+ // may need to remove this when a newer Bullet version is integrated
+ if (!dispatcher->needsResponse(rb0, rb1))
+ {
+ // Refresh algorithm fails sometimes when there is penetration
+ // (usuall the case with ghost and sensor objects)
+ // Let's just clear the manifold, in any case, it is recomputed on each frame.
+ manifold->clearManifold(); //refreshContactPoints(rb0->getCenterOfMassTransform(),rb1->getCenterOfMassTransform());
+ }
}
}
@@ -962,9 +1373,47 @@ void CcdPhysicsEnvironment::CallbackTriggers()
}
-
-
-
+// This call back is called before a pair is added in the cache
+// Handy to remove objects that must be ignored by sensors
+bool CcdOverlapFilterCallBack::needBroadphaseCollision(btBroadphaseProxy* proxy0,btBroadphaseProxy* proxy1) const
+{
+ btCollisionObject *colObj0, *colObj1;
+ CcdPhysicsController *sensorCtrl, *objCtrl;
+ bool collides;
+ // first check the filters
+ collides = (proxy0->m_collisionFilterGroup & proxy1->m_collisionFilterMask) != 0;
+ collides = collides && (proxy1->m_collisionFilterGroup & proxy0->m_collisionFilterMask);
+ if (!collides)
+ return false;
+
+ // additional check for sensor object
+ if (proxy0->m_collisionFilterGroup & btBroadphaseProxy::SensorTrigger)
+ {
+ // this is a sensor object, the other one can't be a sensor object because
+ // they exclude each other in the above test
+ assert(!(proxy1->m_collisionFilterGroup & btBroadphaseProxy::SensorTrigger));
+ colObj0 = (btCollisionObject*)proxy0->m_clientObject;
+ colObj1 = (btCollisionObject*)proxy1->m_clientObject;
+ }
+ else if (proxy1->m_collisionFilterGroup & btBroadphaseProxy::SensorTrigger)
+ {
+ colObj0 = (btCollisionObject*)proxy1->m_clientObject;
+ colObj1 = (btCollisionObject*)proxy0->m_clientObject;
+ }
+ else
+ {
+ return true;
+ }
+ if (!colObj0 || !colObj1)
+ return false;
+ sensorCtrl = static_cast<CcdPhysicsController*>(colObj0->getUserPointer());
+ objCtrl = static_cast<CcdPhysicsController*>(colObj1->getUserPointer());
+ if (m_physEnv->m_triggerCallbacks[PHY_BROADPH_RESPONSE])
+ {
+ return m_physEnv->m_triggerCallbacks[PHY_BROADPH_RESPONSE](m_physEnv->m_triggerCallbacksUserPtrs[PHY_BROADPH_RESPONSE], sensorCtrl, objCtrl, 0);
+ }
+ return true;
+}
#ifdef NEW_BULLET_VEHICLE_SUPPORT
@@ -998,29 +1447,58 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radi
{
CcdConstructionInfo cinfo;
+ // memory leak! The shape is not deleted by Bullet and we cannot add it to the KX_Scene.m_shapes list
cinfo.m_collisionShape = new btSphereShape(radius);
cinfo.m_MotionState = 0;
cinfo.m_physicsEnv = this;
- cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE | btCollisionObject::CF_KINEMATIC_OBJECT;
+ // declare this object as Dyamic rather then static!!
+ // The reason as it is designed to detect all type of object, including static object
+ // It would cause static-static message to be printed on the console otherwise
+ cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE/* | btCollisionObject::CF_KINEMATIC_OBJECT*/;
DefaultMotionState* motionState = new DefaultMotionState();
cinfo.m_MotionState = motionState;
+ // we will add later the possibility to select the filter from option
+ cinfo.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter;
+ cinfo.m_collisionFilterGroup = CcdConstructionInfo::SensorFilter;
motionState->m_worldTransform.setIdentity();
motionState->m_worldTransform.setOrigin(btVector3(position[0],position[1],position[2]));
CcdPhysicsController* sphereController = new CcdPhysicsController(cinfo);
-
return sphereController;
}
+int findClosestNode(btSoftBody* sb,const btVector3& worldPoint);
+int findClosestNode(btSoftBody* sb,const btVector3& worldPoint)
+{
+ int node = -1;
+
+ btSoftBody::tNodeArray& nodes(sb->m_nodes);
+ float maxDistSqr = 1e30f;
+
+ for (int n=0;n<nodes.size();n++)
+ {
+ btScalar distSqr = (nodes[n].m_x - worldPoint).length2();
+ if (distSqr<maxDistSqr)
+ {
+ maxDistSqr = distSqr;
+ node = n;
+ }
+ }
+ return node;
+}
+
int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl0,class PHY_IPhysicsController* ctrl1,PHY_ConstraintType type,
float pivotX,float pivotY,float pivotZ,
float axisX,float axisY,float axisZ,
float axis1X,float axis1Y,float axis1Z,
- float axis2X,float axis2Y,float axis2Z
+ float axis2X,float axis2Y,float axis2Z,int flags
)
{
+ bool disableCollisionBetweenLinkedBodies = (0!=(flags & CCD_CONSTRAINT_DISABLE_LINKED_COLLISION));
+
+
CcdPhysicsController* c0 = (CcdPhysicsController*)ctrl0;
CcdPhysicsController* c1 = (CcdPhysicsController*)ctrl1;
@@ -1028,14 +1506,166 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
btRigidBody* rb0 = c0 ? c0->GetRigidBody() : 0;
btRigidBody* rb1 = c1 ? c1->GetRigidBody() : 0;
+
+
+
bool rb0static = rb0 ? rb0->isStaticOrKinematicObject() : true;
bool rb1static = rb1 ? rb1->isStaticOrKinematicObject() : true;
+
+ btCollisionObject* colObj0 = c0->GetCollisionObject();
+ if (!colObj0)
+ {
+ return 0;
+ }
+
+ btVector3 pivotInA(pivotX,pivotY,pivotZ);
+
+ //it might be a soft body, let's try
+ btSoftBody* sb0 = c0 ? c0->GetSoftBody() : 0;
+ btSoftBody* sb1 = c1 ? c1->GetSoftBody() : 0;
+ if (sb0 && sb1)
+ {
+ //not between two soft bodies?
+ return 0;
+ }
+
+ if (sb0)
+ {
+ //either cluster or node attach, let's find closest node first
+ //the soft body doesn't have a 'real' world transform, so get its initial world transform for now
+ btVector3 pivotPointSoftWorld = sb0->m_initialWorldTransform(pivotInA);
+ int node=findClosestNode(sb0,pivotPointSoftWorld);
+ if (node >=0)
+ {
+ bool clusterconstaint = false;
+/*
+ switch (type)
+ {
+ case PHY_LINEHINGE_CONSTRAINT:
+ {
+ if (sb0->clusterCount() && rb1)
+ {
+ btSoftBody::LJoint::Specs ls;
+ ls.erp=0.5f;
+ ls.position=sb0->clusterCom(0);
+ sb0->appendLinearJoint(ls,rb1);
+ clusterconstaint = true;
+ break;
+ }
+ }
+ case PHY_GENERIC_6DOF_CONSTRAINT:
+ {
+ if (sb0->clusterCount() && rb1)
+ {
+ btSoftBody::AJoint::Specs as;
+ as.erp = 1;
+ as.cfm = 1;
+ as.axis.setValue(axisX,axisY,axisZ);
+ sb0->appendAngularJoint(as,rb1);
+ clusterconstaint = true;
+ break;
+ }
+
+ break;
+ }
+ default:
+ {
+
+ }
+ };
+ */
+
+ if (!clusterconstaint)
+ {
+ if (rb1)
+ {
+ sb0->appendAnchor(node,rb1,disableCollisionBetweenLinkedBodies);
+ } else
+ {
+ sb0->setMass(node,0.f);
+ }
+ }
+
+
+ }
+ return 0;//can't remove soft body anchors yet
+ }
+
+ if (sb1)
+ {
+ btVector3 pivotPointAWorld = colObj0->getWorldTransform()(pivotInA);
+ int node=findClosestNode(sb1,pivotPointAWorld);
+ if (node >=0)
+ {
+ bool clusterconstaint = false;
+
+ /*
+ switch (type)
+ {
+ case PHY_LINEHINGE_CONSTRAINT:
+ {
+ if (sb1->clusterCount() && rb0)
+ {
+ btSoftBody::LJoint::Specs ls;
+ ls.erp=0.5f;
+ ls.position=sb1->clusterCom(0);
+ sb1->appendLinearJoint(ls,rb0);
+ clusterconstaint = true;
+ break;
+ }
+ }
+ case PHY_GENERIC_6DOF_CONSTRAINT:
+ {
+ if (sb1->clusterCount() && rb0)
+ {
+ btSoftBody::AJoint::Specs as;
+ as.erp = 1;
+ as.cfm = 1;
+ as.axis.setValue(axisX,axisY,axisZ);
+ sb1->appendAngularJoint(as,rb0);
+ clusterconstaint = true;
+ break;
+ }
+
+ break;
+ }
+ default:
+ {
+
+
+ }
+ };*/
+
+
+ if (!clusterconstaint)
+ {
+ if (rb0)
+ {
+ sb1->appendAnchor(node,rb0,disableCollisionBetweenLinkedBodies);
+ } else
+ {
+ sb1->setMass(node,0.f);
+ }
+ }
+
+
+ }
+ return 0;//can't remove soft body anchors yet
+ }
+
if (rb0static && rb1static)
+ {
+
return 0;
+ }
+
- btVector3 pivotInA(pivotX,pivotY,pivotZ);
+ if (!rb0)
+ return 0;
+
+
btVector3 pivotInB = rb1 ? rb1->getCenterOfMassTransform().inverse()(rb0->getCenterOfMassTransform()(pivotInA)) :
rb0->getCenterOfMassTransform() * pivotInA;
btVector3 axisInA(axisX,axisY,axisZ);
@@ -1060,7 +1690,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
pivotInA);
}
- m_dynamicsWorld->addConstraint(p2p);
+ m_dynamicsWorld->addConstraint(p2p,disableCollisionBetweenLinkedBodies);
// m_constraints.push_back(p2p);
p2p->setUserConstraintId(gConstraintUid++);
@@ -1096,10 +1726,11 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
btTransform globalFrameA = rb0->getCenterOfMassTransform() * frameInA;
frameInB = inv * globalFrameA;
-
+ bool useReferenceFrameA = true;
+
genericConstraint = new btGeneric6DofConstraint(
*rb0,*rb1,
- frameInA,frameInB);
+ frameInA,frameInB,useReferenceFrameA);
} else
@@ -1120,15 +1751,16 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
///frameInB in worldspace
frameInB = rb0->getCenterOfMassTransform() * frameInA;
+ bool useReferenceFrameA = true;
genericConstraint = new btGeneric6DofConstraint(
*rb0,s_fixedObject2,
- frameInA,frameInB);
+ frameInA,frameInB,useReferenceFrameA);
}
if (genericConstraint)
{
//m_constraints.push_back(genericConstraint);
- m_dynamicsWorld->addConstraint(genericConstraint);
+ m_dynamicsWorld->addConstraint(genericConstraint,disableCollisionBetweenLinkedBodies);
genericConstraint->setUserConstraintId(gConstraintUid++);
genericConstraint->setUserConstraintType(type);
//64 bit systems can't cast pointer to int. could use size_t instead.
@@ -1194,7 +1826,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
if (coneTwistContraint)
{
//m_constraints.push_back(genericConstraint);
- m_dynamicsWorld->addConstraint(coneTwistContraint);
+ m_dynamicsWorld->addConstraint(coneTwistContraint,disableCollisionBetweenLinkedBodies);
coneTwistContraint->setUserConstraintId(gConstraintUid++);
coneTwistContraint->setUserConstraintType(type);
//64 bit systems can't cast pointer to int. could use size_t instead.
@@ -1233,7 +1865,7 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
hinge->setAngularOnly(angularOnly);
//m_constraints.push_back(hinge);
- m_dynamicsWorld->addConstraint(hinge);
+ m_dynamicsWorld->addConstraint(hinge,disableCollisionBetweenLinkedBodies);
hinge->setUserConstraintId(gConstraintUid++);
hinge->setUserConstraintType(type);
//64 bit systems can't cast pointer to int. could use size_t instead.
@@ -1275,12 +1907,19 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
PHY_IPhysicsController* CcdPhysicsEnvironment::CreateConeController(float coneradius,float coneheight)
{
CcdConstructionInfo cinfo;
+
+ // we don't need a CcdShapeConstructionInfo for this shape:
+ // it is simple enough for the standard copy constructor (see CcdPhysicsController::GetReplica)
cinfo.m_collisionShape = new btConeShape(coneradius,coneheight);
cinfo.m_MotionState = 0;
cinfo.m_physicsEnv = this;
cinfo.m_collisionFlags |= btCollisionObject::CF_NO_CONTACT_RESPONSE;
DefaultMotionState* motionState = new DefaultMotionState();
cinfo.m_MotionState = motionState;
+
+ // we will add later the possibility to select the filter from option
+ cinfo.m_collisionFilterMask = CcdConstructionInfo::AllFilter ^ CcdConstructionInfo::SensorFilter;
+ cinfo.m_collisionFilterGroup = CcdConstructionInfo::SensorFilter;
motionState->m_worldTransform.setIdentity();
// motionState->m_worldTransform.setOrigin(btVector3(position[0],position[1],position[2]));
diff --git a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
index 66a6ed59c17..74384dd8cf2 100644
--- a/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.h
@@ -18,6 +18,7 @@ subject to the following restrictions:
#include "PHY_IPhysicsEnvironment.h"
#include <vector>
+#include <set>
class CcdPhysicsController;
#include "LinearMath/btVector3.h"
#include "LinearMath/btTransform.h"
@@ -42,6 +43,7 @@ class btBroadphaseInterface;
class btOverlappingPairCache;
class btIDebugDraw;
class PHY_IVehicle;
+class CcdOverlapFilterCallBack;
/// CcdPhysicsEnvironment is an experimental mainloop for physics simulation using optional continuous collision detection.
/// Physics Environment takes care of stepping the simulation and is a container for physics entities.
@@ -49,12 +51,15 @@ class PHY_IVehicle;
/// A derived class may be able to 'construct' entities by loading and/or converting
class CcdPhysicsEnvironment : public PHY_IPhysicsEnvironment
{
+ friend class CcdOverlapFilterCallBack;
btVector3 m_gravity;
-
-
protected:
btIDebugDraw* m_debugDrawer;
+
+ class btDefaultCollisionConfiguration* m_collisionConfiguration;
+ class btBroadphaseInterface* m_broadphase;
+
//solver iterations
int m_numIterations;
@@ -69,6 +74,7 @@ protected:
btContactSolverInfo m_solverInfo;
+ void processFhSprings(double curTime,float timeStep);
public:
CcdPhysicsEnvironment(btDispatcher* dispatcher=0, btOverlappingPairCache* pairCache=0);
@@ -114,12 +120,14 @@ protected:
virtual void setDebugMode(int debugMode);
virtual void setGravity(float x,float y,float z);
+ virtual void getGravity(PHY__Vector3& grav);
+
virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
float pivotX,float pivotY,float pivotZ,
float axisX,float axisY,float axisZ,
float axis1X=0,float axis1Y=0,float axis1Z=0,
- float axis2X=0,float axis2Y=0,float axis2Z=0
+ float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
);
@@ -131,7 +139,7 @@ protected:
const btVector3& linearMinLimits,
const btVector3& linearMaxLimits,
const btVector3& angularMinLimits,
- const btVector3& angularMaxLimits
+ const btVector3& angularMaxLimits,int flags
);
virtual void setConstraintParam(int constraintId,int param,float value,float value1);
@@ -156,8 +164,7 @@ protected:
btTypedConstraint* getConstraintById(int constraintId);
- virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
- float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);
+ virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
//Methods for gamelogic collision/physics callbacks
@@ -166,7 +173,7 @@ protected:
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user);
virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl);
virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl);
-
+ //These two methods are used *solely* to create controllers for Near/Radar sensor! Don't use for anything else
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position);
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight);
@@ -183,10 +190,15 @@ protected:
void removeCcdPhysicsController(CcdPhysicsController* ctrl);
+ void updateCcdPhysicsController(CcdPhysicsController* ctrl, btScalar newMass, int newCollisionFlags, short int newCollisionGroup, short int newCollisionMask);
+
+ void disableCcdPhysicsController(CcdPhysicsController* ctrl);
+
+ void enableCcdPhysicsController(CcdPhysicsController* ctrl);
+
btBroadphaseInterface* getBroadphase();
-
-
+ btDispatcher* getDispatcher();
bool IsSatCollisionDetectionEnabled() const
@@ -200,18 +212,15 @@ protected:
}
- int GetNumControllers();
-
- CcdPhysicsController* GetPhysicsController( int index);
-
-
-
const btPersistentManifold* GetManifold(int index) const;
void SyncMotionStates(float timeStep);
-
+ class btSoftRigidDynamicsWorld* getDynamicsWorld()
+ {
+ return m_dynamicsWorld;
+ }
class btConstraintSolver* GetConstraintSolver();
@@ -220,19 +229,31 @@ protected:
- std::vector<CcdPhysicsController*> m_controllers;
+ std::set<CcdPhysicsController*> m_controllers;
- std::vector<CcdPhysicsController*> m_triggerControllers;
+ std::set<CcdPhysicsController*> m_triggerControllers;
PHY_ResponseCallback m_triggerCallbacks[PHY_NUM_RESPONSE];
void* m_triggerCallbacksUserPtrs[PHY_NUM_RESPONSE];
std::vector<WrapperVehicle*> m_wrapperVehicles;
- class btDynamicsWorld* m_dynamicsWorld;
+ //use explicit btSoftRigidDynamicsWorld/btDiscreteDynamicsWorld* so that we have access to
+ //btDiscreteDynamicsWorld::addRigidBody(body,filter,group)
+ //so that we can set the body collision filter/group at the time of creation
+ //and not afterwards (breaks the collision system for radar/near sensor)
+ //Ideally we would like to have access to this function from the btDynamicsWorld interface
+ //class btDynamicsWorld* m_dynamicsWorld;
+ class btSoftRigidDynamicsWorld* m_dynamicsWorld;
class btConstraintSolver* m_solver;
+ class btOverlappingPairCache* m_ownPairCache;
+
+ class CcdOverlapFilterCallBack* m_filterCallback;
+
+ class btDispatcher* m_ownDispatcher;
+
bool m_scalingPropagated;
diff --git a/source/gameengine/Physics/Bullet/Makefile b/source/gameengine/Physics/Bullet/Makefile
index 49259d0a67c..d5570e75833 100644
--- a/source/gameengine/Physics/Bullet/Makefile
+++ b/source/gameengine/Physics/Bullet/Makefile
@@ -37,5 +37,10 @@ CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
CPPFLAGS += -I$(NAN_BULLET2)/include
CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
+CPPFLAGS += -I$(NAN_STRING)/include
+CPPFLAGS += -I$(NAN_MOTO)/include
+CPPFLAGS += -I../../../kernel/gen_system
CPPFLAGS += -I../../Physics/common
CPPFLAGS += -I../../Physics/Dummy
+CPPFLAGS += -I../../Rasterizer
+
diff --git a/source/gameengine/Physics/Bullet/SConscript b/source/gameengine/Physics/Bullet/SConscript
index 04abca6e4a5..138ae493013 100644
--- a/source/gameengine/Physics/Bullet/SConscript
+++ b/source/gameengine/Physics/Bullet/SConscript
@@ -3,13 +3,13 @@ Import ('env')
sources = 'CcdPhysicsEnvironment.cpp CcdPhysicsController.cpp'
-incs = '. ../common'
+incs = '. ../common #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer'
incs += ' ' + env['BF_BULLET_INC']
cflags = []
if env['OURPLATFORM']=='win32-vc':
- cflags.append('/GR')
- cflags.append('/O2')
+ cflags.append('/GR')
+ cflags.append('/O2')
env.BlenderLib ( 'bf_bullet', Split(sources), Split(incs), [], libtype=['game','player'], priority=[15,80] )
diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
index f512d44c9f2..ba196b5cf55 100644
--- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.cpp
@@ -92,8 +92,7 @@ void DummyPhysicsEnvironment::setGravity(float x,float y,float z)
int DummyPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
float pivotX,float pivotY,float pivotZ,float axisX,float axisY,float axisZ,
float axis1X,float axis1Y,float axis1Z,
- float axis2X,float axis2Y,float axis2Z
-
+ float axis2X,float axis2Y,float axis2Z,int flag
)
{
@@ -109,8 +108,7 @@ void DummyPhysicsEnvironment::removeConstraint(int constraintid)
}
}
-PHY_IPhysicsController* DummyPhysicsEnvironment::rayTest(PHY_IPhysicsController* ignoreClient,float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
- float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ)
+PHY_IPhysicsController* DummyPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ)
{
//collision detection / raytesting
return NULL;
diff --git a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
index f0761618e4e..a92b1e7f4a6 100644
--- a/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Dummy/DummyPhysicsEnvironment.h
@@ -58,7 +58,7 @@ public:
float pivotX,float pivotY,float pivotZ,
float axisX,float axisY,float axisZ,
float axis1X=0,float axis1Y=0,float axis1Z=0,
- float axis2X=0,float axis2Y=0,float axis2Z=0
+ float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
);
virtual void removeConstraint(int constraintid);
@@ -69,8 +69,7 @@ public:
return 0;
}
- virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
- float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);
+ virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
//gamelogic callbacks
@@ -80,6 +79,7 @@ public:
{
}
virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl) {}
+ virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl) {}
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) {return 0;}
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight) { return 0;}
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h
index a43ddbec483..42b5ab48ab6 100644
--- a/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h
+++ b/source/gameengine/Physics/Sumo/Fuzzics/include/SM_Callback.h
@@ -4,6 +4,7 @@
class SM_Callback {
public:
virtual void do_me() = 0;
+ virtual ~SM_Callback() {}
};
#endif
diff --git a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
index b5bf67b14ea..f0791bbf89f 100644
--- a/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
+++ b/source/gameengine/Physics/Sumo/Fuzzics/src/SM_Scene.cpp
@@ -98,12 +98,17 @@ void SM_Scene::addTouchCallback(int response_class, DT_ResponseCallback callback
void SM_Scene::addSensor(SM_Object& object)
{
- object.calcXform();
- m_objectList.push_back(&object);
- DT_AddObject(m_scene, object.getObjectHandle());
- DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[SENSOR_RESPONSE]);
- DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass[SENSOR_RESPONSE]);
- DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[SENSOR_RESPONSE]);
+ T_ObjectList::iterator i =
+ std::find(m_objectList.begin(), m_objectList.end(), &object);
+ if (i == m_objectList.end())
+ {
+ object.calcXform();
+ m_objectList.push_back(&object);
+ DT_AddObject(m_scene, object.getObjectHandle());
+ DT_SetResponseClass(m_respTable, object.getObjectHandle(), m_ResponseClass[SENSOR_RESPONSE]);
+ DT_SetResponseClass(m_secondaryRespTable, object.getObjectHandle(), m_secondaryResponseClass [SENSOR_RESPONSE]);
+ DT_SetResponseClass(m_fixRespTable, object.getObjectHandle(), m_fixResponseClass[SENSOR_RESPONSE]);
+ }
}
void SM_Scene::add(SM_Object& object) {
diff --git a/source/gameengine/Physics/Sumo/SConscript b/source/gameengine/Physics/Sumo/SConscript
index b5900919321..fdf6fdafec2 100644
--- a/source/gameengine/Physics/Sumo/SConscript
+++ b/source/gameengine/Physics/Sumo/SConscript
@@ -1,22 +1,21 @@
#!/usr/bin/python
Import ('env')
-sumoenv = env.Clone()
sources = ['SumoPHYCallbackBridge.cpp',
- 'SumoPhysicsController.cpp',
- 'SumoPhysicsEnvironment.cpp',
- 'Fuzzics/src/SM_FhObject.cpp',
- 'Fuzzics/src/SM_Object.cpp',
- 'Fuzzics/src/SM_Scene.cpp',
- 'Fuzzics/src/SM_MotionState.cpp'
- ]
+ 'SumoPhysicsController.cpp',
+ 'SumoPhysicsEnvironment.cpp',
+ 'Fuzzics/src/SM_FhObject.cpp',
+ 'Fuzzics/src/SM_Object.cpp',
+ 'Fuzzics/src/SM_Scene.cpp',
+ 'Fuzzics/src/SM_MotionState.cpp'
+ ]
incs =['.',
'../common',
'Fuzzics/include',
'#/intern/moto/include'
]
-incs += [sumoenv['BF_SOLID_INC']]
+incs += [env['BF_SOLID_INC']]
cflags = []
if env['OURPLATFORM']=='win32-vc':
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsController.h b/source/gameengine/Physics/Sumo/SumoPhysicsController.h
index 95f01b45f2b..d8ee54935d7 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsController.h
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsController.h
@@ -120,6 +120,7 @@ public:
virtual void SetMargin(float margin) ;
virtual float GetMargin() const;
virtual float GetRadius() const ;
+ virtual void SetRadius(float margin) { SetMargin(margin); }
// clientinfo for raycasts for example
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
index f324b979fb9..3be5e027345 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.cpp
@@ -26,6 +26,7 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
+#include <string.h> // memset
#include "SumoPhysicsEnvironment.h"
#include "PHY_IMotionState.h"
#include "SumoPhysicsController.h"
@@ -110,8 +111,8 @@ int SumoPhysicsEnvironment::createConstraint(
float pivotX,float pivotY,float pivotZ,
float axisX,float axisY,float axisZ,
float axis1X,float axis1Y,float axis1Z,
- float axis2X,float axis2Y,float axis2Z
-
+ float axis2X,float axis2Y,float axis2Z,
+ int flag
)
{
int constraintid = 0;
@@ -125,37 +126,35 @@ void SumoPhysicsEnvironment::removeConstraint(int constraintid)
}
}
-PHY_IPhysicsController* SumoPhysicsEnvironment::rayTest(PHY_IPhysicsController* ignoreClientCtrl,
+PHY_IPhysicsController* SumoPhysicsEnvironment::rayTest(PHY_IRayCastFilterCallback &filterCallback,
float fromX,float fromY,float fromZ,
- float toX,float toY,float toZ,
- float& hitX,float& hitY,float& hitZ,
- float& normalX,float& normalY,float& normalZ)
+ float toX,float toY,float toZ)
{
- SumoPhysicsController* ignoreCtr = static_cast<SumoPhysicsController*> (ignoreClientCtrl);
+ SumoPhysicsController* ignoreCtr = static_cast<SumoPhysicsController*> (filterCallback.m_ignoreController);
//collision detection / raytesting
MT_Point3 hit, normal;
- PHY_IPhysicsController *ret = 0;
+ PHY_RayCastResult result;
SM_Object* sm_ignore = 0;
if (ignoreCtr)
sm_ignore = ignoreCtr->GetSumoObject();
+ memset(&result, 0, sizeof(result));
SM_Object* smOb = m_sumoScene->rayTest(sm_ignore,MT_Point3(fromX, fromY, fromZ),MT_Point3(toX, toY, toZ), hit, normal);
if (smOb)
{
- ret = (PHY_IPhysicsController *) smOb->getPhysicsClientObject();
+ result.m_controller = (PHY_IPhysicsController *) smOb->getPhysicsClientObject();
+ result.m_hitPoint[0] = hit[0];
+ result.m_hitPoint[1] = hit[1];
+ result.m_hitPoint[2] = hit[2];
+ result.m_hitNormal[0] = normal[0];
+ result.m_hitNormal[1] = normal[1];
+ result.m_hitNormal[2] = normal[2];
+ filterCallback.reportHit(&result);
}
- hitX = hit[0];
- hitY = hit[1];
- hitZ = hit[2];
-
- normalX = normal[0];
- normalY = normal[1];
- normalZ = normal[2];
-
- return ret;
+ return result.m_controller;
}
//gamelogic callbacks
void SumoPhysicsEnvironment::addSensor(PHY_IPhysicsController* ctrl)
@@ -203,6 +202,8 @@ void SumoPhysicsEnvironment::addTouchCallback(int response_class, PHY_ResponseCa
case PHY_STATIC_RESPONSE:
sumoRespClass = PHY_STATIC_RESPONSE;
break;
+ case PHY_BROADPH_RESPONSE:
+ return;
default:
assert(0);
return;
@@ -226,6 +227,12 @@ void SumoPhysicsEnvironment::requestCollisionCallback(PHY_IPhysicsController* ct
m_sumoScene->requestCollisionCallback(*smObject);
}
}
+
+void SumoPhysicsEnvironment::removeCollisionCallback(PHY_IPhysicsController* ctrl)
+{
+ // intentionally empty
+}
+
PHY_IPhysicsController* SumoPhysicsEnvironment::CreateSphereController(float radius,const PHY__Vector3& position)
{
DT_ShapeHandle shape = DT_NewSphere(0.0);
diff --git a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
index ce5cd70e8cc..65b07a7a0be 100644
--- a/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
+++ b/source/gameengine/Physics/Sumo/SumoPhysicsEnvironment.h
@@ -63,7 +63,7 @@ public:
float pivotX,float pivotY,float pivotZ,
float axisX,float axisY,float axisZ,
float axis1X=0,float axis1Y=0,float axis1Z=0,
- float axis2X=0,float axis2Y=0,float axis2Z=0
+ float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
);
@@ -75,8 +75,7 @@ public:
return 0;
}
- virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient,float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
- float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ);
+ virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback,float fromX,float fromY,float fromZ, float toX,float toY,float toZ);
//gamelogic callbacks
@@ -84,6 +83,7 @@ public:
virtual void removeSensor(PHY_IPhysicsController* ctrl);
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user);
virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl);
+ virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl);
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position);
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight);
diff --git a/source/gameengine/Physics/common/PHY_DynamicTypes.h b/source/gameengine/Physics/common/PHY_DynamicTypes.h
index 68b60192fbc..3b3e42c38d2 100644
--- a/source/gameengine/Physics/common/PHY_DynamicTypes.h
+++ b/source/gameengine/Physics/common/PHY_DynamicTypes.h
@@ -19,7 +19,6 @@ subject to the following restrictions:
-class PHY_ResponseTable;
class PHY_Shape;
@@ -40,10 +39,11 @@ struct PHY__Vector3
typedef enum
{
PHY_FH_RESPONSE,
- PHY_SENSOR_RESPONSE, /* Touch Sensors */
+ PHY_SENSOR_RESPONSE, /* Touch Sensors */
PHY_CAMERA_RESPONSE, /* Visibility Culling */
PHY_OBJECT_RESPONSE, /* Object Dynamic Geometry Response */
PHY_STATIC_RESPONSE, /* Static Geometry Response */
+ PHY_BROADPH_RESPONSE, /* broadphase Response */
PHY_NUM_RESPONSE
};
@@ -87,6 +87,18 @@ typedef enum PHY_ConstraintType {
} PHY_ConstraintType;
+typedef enum PHY_ShapeType {
+ PHY_SHAPE_NONE,
+ PHY_SHAPE_BOX,
+ PHY_SHAPE_SPHERE,
+ PHY_SHAPE_CYLINDER,
+ PHY_SHAPE_CONE,
+ PHY_SHAPE_MESH,
+ PHY_SHAPE_POLYTOPE,
+ PHY_SHAPE_COMPOUND
+} PHY_ShapeType;
+
+
typedef float PHY_Vector3[3];
#endif //__PHY_DYNAMIC_TYPES
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsController.h b/source/gameengine/Physics/common/PHY_IPhysicsController.h
index 2f1d0b34eb2..884e14cfb5a 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsController.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsController.h
@@ -82,7 +82,6 @@ class PHY_IPhysicsController
// dyna's that are rigidbody are free in orientation, dyna's with non-rigidbody are restricted
virtual void setRigidBody(bool rigid)=0;
-
// clientinfo for raycasts for example
virtual void* getNewClientInfo()=0;
virtual void setNewClientInfo(void* clientinfo)=0;
@@ -91,7 +90,8 @@ class PHY_IPhysicsController
virtual void calcXform() =0;
virtual void SetMargin(float margin) =0;
virtual float GetMargin() const=0;
- virtual float GetRadius() const { return 0.f;}
+ virtual float GetRadius() const=0;
+ virtual void SetRadius(float margin) = 0;
PHY__Vector3 GetWorldPosition(PHY__Vector3& localpos);
};
diff --git a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
index 7f01d16a796..0e9c571924c 100644
--- a/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
+++ b/source/gameengine/Physics/common/PHY_IPhysicsEnvironment.h
@@ -33,6 +33,50 @@
#include <vector>
#include "PHY_DynamicTypes.h"
class PHY_IVehicle;
+class RAS_MeshObject;
+class PHY_IPhysicsController;
+
+/**
+ * pass back information from rayTest
+ */
+struct PHY_RayCastResult
+{
+ PHY_IPhysicsController* m_controller;
+ PHY__Vector3 m_hitPoint;
+ PHY__Vector3 m_hitNormal;
+ const RAS_MeshObject* m_meshObject; // !=NULL for mesh object (only for Bullet controllers)
+ int m_polygon; // index of the polygon hit by the ray,
+ // only if m_meshObject != NULL
+};
+
+/**
+ * This class replaces the ignoreController parameter of rayTest function.
+ * It allows more sophisticated filtering on the physics controller before computing the ray intersection to save CPU.
+ * It is only used to its full extend by the Ccd physics environement (Bullet).
+ */
+class PHY_IRayCastFilterCallback
+{
+public:
+ PHY_IPhysicsController* m_ignoreController;
+ bool m_faceNormal;
+
+ virtual ~PHY_IRayCastFilterCallback()
+ {
+ }
+
+ virtual bool needBroadphaseRayCast(PHY_IPhysicsController* controller)
+ {
+ return true;
+ }
+
+ virtual void reportHit(PHY_RayCastResult* result) = 0;
+
+ PHY_IRayCastFilterCallback(PHY_IPhysicsController* ignoreController, bool faceNormal=false)
+ :m_ignoreController(ignoreController),
+ m_faceNormal(faceNormal)
+ {
+ }
+};
/**
* Physics Environment takes care of stepping the simulation and is a container for physics entities (rigidbodies,constraints, materials etc.)
@@ -85,7 +129,7 @@ class PHY_IPhysicsEnvironment
float pivotX,float pivotY,float pivotZ,
float axis0X,float axis0Y,float axis0Z,
float axis1X=0,float axis1Y=0,float axis1Z=0,
- float axis2X=0,float axis2Y=0,float axis2Z=0
+ float axis2X=0,float axis2Y=0,float axis2Z=0,int flag=0
)=0;
virtual void removeConstraint(int constraintid)=0;
virtual float getAppliedImpulse(int constraintid){ return 0.f;}
@@ -94,8 +138,7 @@ class PHY_IPhysicsEnvironment
//complex constraint for vehicles
virtual PHY_IVehicle* getVehicleConstraint(int constraintId) =0;
- virtual PHY_IPhysicsController* rayTest(PHY_IPhysicsController* ignoreClient, float fromX,float fromY,float fromZ, float toX,float toY,float toZ,
- float& hitX,float& hitY,float& hitZ,float& normalX,float& normalY,float& normalZ)=0;
+ virtual PHY_IPhysicsController* rayTest(PHY_IRayCastFilterCallback &filterCallback, float fromX,float fromY,float fromZ, float toX,float toY,float toZ)=0;
//Methods for gamelogic collision/physics callbacks
@@ -104,6 +147,8 @@ class PHY_IPhysicsEnvironment
virtual void removeSensor(PHY_IPhysicsController* ctrl)=0;
virtual void addTouchCallback(int response_class, PHY_ResponseCallback callback, void *user)=0;
virtual void requestCollisionCallback(PHY_IPhysicsController* ctrl)=0;
+ virtual void removeCollisionCallback(PHY_IPhysicsController* ctrl)=0;
+ //These two methods are *solely* used to create controllers for sensor! Don't use for anything else
virtual PHY_IPhysicsController* CreateSphereController(float radius,const PHY__Vector3& position) =0;
virtual PHY_IPhysicsController* CreateConeController(float coneradius,float coneheight)=0;
diff --git a/source/gameengine/PyDoc/BL_ActionActuator.py b/source/gameengine/PyDoc/BL_ActionActuator.py
index 41f41080c31..b68d3014115 100644
--- a/source/gameengine/PyDoc/BL_ActionActuator.py
+++ b/source/gameengine/PyDoc/BL_ActionActuator.py
@@ -86,6 +86,14 @@ class BL_ActionActuator(SCA_IActuator):
@param mode: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
@type mode: integer
"""
+
+ def setContinue(cont):
+ """
+ Set the actions continue option True or False. see getContinue.
+
+ @param cont: The continue option.
+ @type cont: bool
+ """
def getType():
"""
@@ -94,6 +102,13 @@ class BL_ActionActuator(SCA_IActuator):
@rtype: integer
@return: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
"""
+
+ def getContinue():
+ """
+ When True, the action will always play from where last left off, otherwise negative events to this actuator will reset it to its start frame.
+
+ @rtype: bool
+ """
def getAction():
"""
@@ -149,5 +164,14 @@ class BL_ActionActuator(SCA_IActuator):
@param mode: True for armature/world space, False for bone space
@type mode: boolean
"""
-
-
+ def setFrameProperty(prop):
+ """
+ @param prop: A string specifying the property of the object that will be updated with the action frame number.
+ @type prop: string
+ """
+ def getFrameProperty():
+ """
+ Returns the name of the property that is set to the current frame number.
+
+ @rtype: string
+ """
diff --git a/source/gameengine/PyDoc/BL_ShapeActionActuator.py b/source/gameengine/PyDoc/BL_ShapeActionActuator.py
new file mode 100644
index 00000000000..a26b276a2da
--- /dev/null
+++ b/source/gameengine/PyDoc/BL_ShapeActionActuator.py
@@ -0,0 +1,167 @@
+# $Id$
+# Documentation for BL_ShapeActionActuator
+from SCA_IActuator import *
+
+class BL_ShapeActionActuator(SCA_IActuator):
+ """
+ ShapeAction Actuators apply an shape action to an mesh object.
+ """
+ def setAction(action, reset = True):
+ """
+ Sets the current action.
+
+ @param action: The name of the action to set as the current action.
+ @type action: string
+ @param reset: Optional parameter indicating whether to reset the
+ blend timer or not. A value of 1 indicates that the
+ timer should be reset. A value of 0 will leave it
+ unchanged. If reset is not specified, the timer will
+ be reset.
+ """
+
+ def setStart(start):
+ """
+ Specifies the starting frame of the animation.
+
+ @param start: the starting frame of the animation
+ @type start: float
+ """
+
+ def setEnd(end):
+ """
+ Specifies the ending frame of the animation.
+
+ @param end: the ending frame of the animation
+ @type end: float
+ """
+ def setBlendin(blendin):
+ """
+ Specifies the number of frames of animation to generate
+ when making transitions between actions.
+
+ @param blendin: the number of frames in transition.
+ @type blendin: float
+ """
+
+ def setPriority(priority):
+ """
+ Sets the priority of this actuator.
+
+ @param priority: Specifies the new priority. Actuators will lower
+ priority numbers will override actuators with higher
+ numbers.
+ @type priority: integer
+ """
+ def setFrame(frame):
+ """
+ Sets the current frame for the animation.
+
+ @param frame: Specifies the new current frame for the animation
+ @type frame: float
+ """
+
+ def setProperty(prop):
+ """
+ Sets the property to be used in FromProp playback mode.
+
+ @param prop: the name of the property to use.
+ @type prop: string.
+ """
+
+ def setBlendtime(blendtime):
+ """
+ Sets the internal frame timer.
+
+ Allows the script to directly modify the internal timer
+ used when generating transitions between actions.
+
+ @param blendtime: The new time. This parameter must be in the range from 0.0 to 1.0.
+ @type blendtime: float
+ """
+
+ def setType(mode):
+ """
+ Sets the operation mode of the actuator
+
+ @param mode: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
+ @type mode: integer
+ """
+
+ def setContinue(cont):
+ """
+ Set the actions continue option True or False. see getContinue.
+
+ @param cont: The continue option.
+ @type cont: bool
+ """
+
+ def getType():
+ """
+ Returns the operation mode of the actuator
+
+ @rtype: integer
+ @return: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
+ """
+
+ def getContinue():
+ """
+ When True, the action will always play from where last left off, otherwise negative events to this actuator will reset it to its start frame.
+
+ @rtype: bool
+ """
+
+ def getAction():
+ """
+ getAction() returns the name of the action associated with this actuator.
+
+ @rtype: string
+ """
+
+ def getStart():
+ """
+ Returns the starting frame of the action.
+
+ @rtype: float
+ """
+ def getEnd():
+ """
+ Returns the last frame of the action.
+
+ @rtype: float
+ """
+ def getBlendin():
+ """
+ Returns the number of interpolation animation frames to be generated when this actuator is triggered.
+
+ @rtype: float
+ """
+ def getPriority():
+ """
+ Returns the priority for this actuator. Actuators with lower Priority numbers will
+ override actuators with higher numbers.
+
+ @rtype: integer
+ """
+ def getFrame():
+ """
+ Returns the current frame number.
+
+ @rtype: float
+ """
+ def getProperty():
+ """
+ Returns the name of the property to be used in FromProp mode.
+
+ @rtype: string
+ """
+ def setFrameProperty(prop):
+ """
+ @param prop: A string specifying the property of the object that will be updated with the action frame number.
+ @type prop: string
+ """
+ def getFrameProperty():
+ """
+ Returns the name of the property that is set to the current frame number.
+
+ @rtype: string
+ """
diff --git a/source/gameengine/PyDoc/GameKeys.py b/source/gameengine/PyDoc/GameKeys.py
index 268fb9cc172..1a0a737718e 100644
--- a/source/gameengine/PyDoc/GameKeys.py
+++ b/source/gameengine/PyDoc/GameKeys.py
@@ -164,3 +164,12 @@ Example::
# Activate Right!
"""
+
+def EventToString(event):
+ """
+ Return the string name of a key event. Will raise a ValueError error if its invalid.
+
+ @type event: int
+ @param event: key event from GameKeys or the keyboard sensor.
+ @rtype: string
+ """
diff --git a/source/gameengine/PyDoc/GameLogic.py b/source/gameengine/PyDoc/GameLogic.py
index fcfd8bfc4eb..9dab7db6081 100644
--- a/source/gameengine/PyDoc/GameLogic.py
+++ b/source/gameengine/PyDoc/GameLogic.py
@@ -13,11 +13,10 @@ Documentation for the GameLogic Module.
See L{WhatsNew} for updates, changes and new functionality in the Game Engine Python API.
Examples::
- # To get a controller:
- import GameLogic
- co = GameLogic.getCurrentController()
+ # To get the controller thats running this python script:
+ co = GameLogic.getCurrentController() # GameLogic is automatically imported
- # To get the game object associated with this controller:
+ # To get the game object this controller is on:
obj = co.getOwner()
L{KX_GameObject} and L{KX_Camera} or L{KX_Light} methods are
available depending on the type of object::
@@ -32,16 +31,18 @@ Documentation for the GameLogic Module.
sensors = co.getSensors()
See the sensor's reference for available methods:
- - L{KX_NetworkMessageSensor}
- - L{KX_RaySensor}
- - L{KX_MouseFocusSensor}
- - L{KX_NearSensor}
- - L{KX_RadarSensor}
- - L{KX_TouchSensor}
- - L{SCA_KeyboardSensor}
- - L{SCA_MouseSensor}
- - L{SCA_PropertySensor}
- - L{SCA_RandomSensor}
+ - L{DelaySensor<SCA_DelaySensor.SCA_DelaySensor>}
+ - L{JoystickSensor<SCA_JoystickSensor.SCA_JoystickSensor>}
+ - L{KeyboardSensor<SCA_KeyboardSensor.SCA_KeyboardSensor>}
+ - L{MouseFocusSensor<KX_MouseFocusSensor.KX_MouseFocusSensor>}
+ - L{MouseSensor<SCA_MouseSensor.SCA_MouseSensor>}
+ - L{NearSensor<KX_NearSensor.KX_NearSensor>}
+ - L{NetworkMessageSensor<KX_NetworkMessageSensor.KX_NetworkMessageSensor>}
+ - L{PropertySensor<SCA_PropertySensor.SCA_PropertySensor>}
+ - L{RadarSensor<KX_RadarSensor.KX_RadarSensor>}
+ - L{RandomSensor<SCA_RandomSensor.SCA_RandomSensor>}
+ - L{RaySensor<KX_RaySensor.KX_RaySensor>}
+ - L{TouchSensor<KX_TouchSensor.KX_TouchSensor>}
You can also access actuators linked to the controller::
# To get an actuator attached to the controller:
@@ -54,23 +55,23 @@ Documentation for the GameLogic Module.
GameLogic.addActiveActuator(actuator, True)
See the actuator's reference for available methods:
- - L{BL_ActionActuator}
- - L{KX_CameraActuator}
- - L{KX_CDActuator}
- - L{KX_ConstraintActuator}
- - L{KX_GameActuator}
- - L{KX_IpoActuator}
- - L{KX_NetworkMessageActuator}
- - L{KX_ObjectActuator}
- - L{KX_SCA_AddObjectActuator}
- - L{KX_SCA_EndObjectActuator}
- - L{KX_SCA_ReplaceMeshActuator}
- - L{KX_SceneActuator}
- - L{KX_SoundActuator}
- - L{KX_TrackToActuator}
- - L{KX_VisibilityActuator}
- - L{SCA_PropertyActuator}
- - L{SCA_RandomActuator}
+ - L{ActionActuator<BL_ActionActuator.BL_ActionActuator>}
+ - L{AddObjectActuator<KX_SCA_AddObjectActuator.KX_SCA_AddObjectActuator>}
+ - L{CameraActuator<KX_CameraActuator.KX_CameraActuator>}
+ - L{CDActuator<KX_CDActuator.KX_CDActuator>}
+ - L{ConstraintActuator<KX_ConstraintActuator.KX_ConstraintActuator>}
+ - L{EndObjectActuator<KX_SCA_EndObjectActuator.KX_SCA_EndObjectActuator>}
+ - L{GameActuator<KX_GameActuator.KX_GameActuator>}
+ - L{IpoActuator<KX_IpoActuator.KX_IpoActuator>}
+ - L{NetworkMessageActuator<KX_NetworkMessageActuator.KX_NetworkMessageActuator>}
+ - L{ObjectActuator<KX_ObjectActuator.KX_ObjectActuator>}
+ - L{PropertyActuator<SCA_PropertyActuator.SCA_PropertyActuator>}
+ - L{RandomActuator<SCA_RandomActuator.SCA_RandomActuator>}
+ - L{ReplaceMeshActuator<KX_SCA_ReplaceMeshActuator.KX_SCA_ReplaceMeshActuator>}
+ - L{SceneActuator<KX_SceneActuator.KX_SceneActuator>}
+ - L{SoundActuator<KX_SoundActuator.KX_SoundActuator>}
+ - L{TrackToActuator<KX_TrackToActuator.KX_TrackToActuator>}
+ - L{VisibilityActuator<KX_VisibilityActuator.KX_VisibilityActuator>}
Most logic brick's methods are accessors for the properties available in the logic buttons.
Consult the logic bricks documentation for more information on how each logic brick works.
@@ -220,4 +221,36 @@ def setPhysicsTicRate(ticrate):
@param ticrate: The new update frequency (in Hz).
@type ticrate: float
"""
+def getAverageFrameRate():
+ """
+ Gets the estimated average framerate
+
+ @return: The estimed average framerate in frames per second
+ @rtype: float
+ """
+
+def expandPath(path):
+ """
+ Converts a blender internal path into a proper file system path.
+ Use / as directory separator in path
+ You can use '//' at the start of the string to define a relative path;
+ Blender replaces that string by the directory of the startup .blend or runtime file
+ to make a full path name (doesn't change during the game, even if you load other .blend).
+ The function also converts the directory separator to the local file system format.
+
+ @param path: The path string to be converted/expanded.
+ @type path: string
+ @return: The converted string
+ @rtype: string
+ """
+
+def getBlendFileList(path = "//"):
+ """
+ Returns a list of blend files in the same directory as the open blend file, or from using the option argument.
+
+ @param path: Optional directory argument, will be expanded (like expandPath) into the full path.
+ @type path: string
+ @return: A list of filenames, with no directory prefix
+ @rtype: list
+ """
diff --git a/source/gameengine/PyDoc/KX_ActuatorSensor.py b/source/gameengine/PyDoc/KX_ActuatorSensor.py
new file mode 100644
index 00000000000..cdfbf27576e
--- /dev/null
+++ b/source/gameengine/PyDoc/KX_ActuatorSensor.py
@@ -0,0 +1,25 @@
+# $Id$
+# Documentation for KX_ActuatorSensor
+from SCA_IActuator import *
+from SCA_ISensor import *
+
+class KX_ActuatorSensor(SCA_ISensor):
+ """
+ Actuator sensor detect change in actuator state of the parent object.
+ It generates a positive pulse if the corresponding actuator is activated
+ and a negative pulse if the actuator is deactivated.
+ """
+ def getActuator():
+ """
+ Return the Actuator with which the sensor operates.
+
+ @rtype: string
+ """
+ def setActuator(name):
+ """
+ Sets the Actuator with which to operate. If there is no Actuator
+ of this name, the function has no effect.
+
+ @param name: actuator name
+ @type name: string
+ """
diff --git a/source/gameengine/PyDoc/KX_CameraActuator.py b/source/gameengine/PyDoc/KX_CameraActuator.py
index 032fc7338ac..9a9abaf3d57 100644
--- a/source/gameengine/PyDoc/KX_CameraActuator.py
+++ b/source/gameengine/PyDoc/KX_CameraActuator.py
@@ -8,11 +8,13 @@ class KX_CameraActuator(SCA_IActuator):
@author: snail
"""
- def getObject():
+ def getObject(name_only = 1):
"""
Returns the name of the object this actuator tracks.
- rtype: string
+ @type name_only: bool
+ @param name_only: optional argument, when 0 return a KX_GameObject
+ @rtype: string, KX_GameObject or None if no object is set
"""
def setObject(target):
@@ -20,7 +22,7 @@ class KX_CameraActuator(SCA_IActuator):
Sets the object this actuator tracks.
@param target: the object to track.
- @type target: string or L{KX_GameObject}
+ @type target: L{KX_GameObject}, string or None
"""
def getMin():
diff --git a/source/gameengine/PyDoc/KX_ConstraintActuator.py b/source/gameengine/PyDoc/KX_ConstraintActuator.py
index 9630690e572..7c7ad5aa0fa 100644
--- a/source/gameengine/PyDoc/KX_ConstraintActuator.py
+++ b/source/gameengine/PyDoc/KX_ConstraintActuator.py
@@ -4,7 +4,7 @@ from SCA_IActuator import *
class KX_ConstraintActuator(SCA_IActuator):
"""
- A constraint actuator limits the position or orientation of an object.
+ A constraint actuator limits the position, rotation, distance or orientation of an object.
"""
def setDamp(time):
"""
@@ -24,7 +24,7 @@ class KX_ConstraintActuator(SCA_IActuator):
"""
Sets the lower bound of the constraint.
- For rotational constraints, lower is specified in degrees.
+ For rotational and orientation constraints, lower is specified in degrees.
@type lower: float
"""
@@ -32,7 +32,7 @@ class KX_ConstraintActuator(SCA_IActuator):
"""
Gets the lower bound of the constraint.
- For rotational constraints, the lower bound is returned in radians.
+ For rotational and orientation constraints, the lower bound is returned in radians.
@rtype: float
"""
@@ -40,7 +40,7 @@ class KX_ConstraintActuator(SCA_IActuator):
"""
Sets the upper bound of the constraint.
- For rotational constraints, upper is specified in degrees.
+ For rotational and orientation constraints, upper is specified in degrees.
@type upper: float
"""
@@ -48,7 +48,7 @@ class KX_ConstraintActuator(SCA_IActuator):
"""
Gets the upper bound of the constraint.
- For rotational constraints, the upper bound is returned in radians.
+ For rotational and orientation constraints, the upper bound is returned in radians.
@rtype: float
"""
@@ -58,8 +58,11 @@ class KX_ConstraintActuator(SCA_IActuator):
See module L{GameLogic} for valid constraint types.
- @param limit: Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ,
- Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY or KX_CONSTRAINTACT_ROTZ
+ @param limit:
+ Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ
+ Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY or KX_CONSTRAINTACT_ROTZ
+ Distance contraints: KX_ACT_CONSTRAINT_DIRPX, KX_ACT_CONSTRAINT_DIRPY, KX_ACT_CONSTRAINT_DIRPZ, KX_ACT_CONSTRAINT_DIRNX, KX_ACT_CONSTRAINT_DIRNY, KX_ACT_CONSTRAINT_DIRNZ
+ Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ
"""
def getLimit():
"""
@@ -67,6 +70,111 @@ class KX_ConstraintActuator(SCA_IActuator):
See module L{GameLogic} for valid constraints.
- @return: Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ,
- Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY or KX_CONSTRAINTACT_ROTZ
+ @return:
+ Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ,
+ Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY, KX_CONSTRAINTACT_ROTZ,
+ Distance contraints: KX_ACT_CONSTRAINT_DIRPX, KX_ACT_CONSTRAINT_DIRPY, KX_ACT_CONSTRAINT_DIRPZ, KX_ACT_CONSTRAINT_DIRNX, KX_ACT_CONSTRAINT_DIRNY, KX_ACT_CONSTRAINT_DIRNZ,
+ Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ
"""
+ def setRotDamp(duration):
+ """
+ Sets the time constant of the orientation constraint.
+
+ @param duration: If the duration is negative, it is set to 0.
+ @type duration: integer
+ """
+ def getRotDamp():
+ """
+ Returns the damping time for application of the constraint.
+
+ @rtype: integer
+ """
+ def setDirection(vector):
+ """
+ Sets the reference direction in world coordinate for the orientation constraint
+
+ @type vector: 3-tuple
+ """
+ def getDirection():
+ """
+ Returns the reference direction of the orientation constraint in world coordinate.
+
+ @rtype: 3-tuple
+ """
+ def setOption(option):
+ """
+ Sets several options of the distance constraint.
+
+ @type option: integer
+ @param option: Binary combination of the following values:
+ 64 : Activate alignment to surface
+ 128 : Detect material rather than property
+ 256 : No deactivation if ray does not hit target
+ 512 : Activate distance control
+ """
+ def getOption():
+ """
+ Returns the option parameter.
+
+ @rtype: integer
+ """
+ def setTime(duration):
+ """
+ Sets the activation time of the actuator.
+
+ @type duration: integer
+ @param duration: The actuator disables itself after this many frame.
+ If set to 0 or negative, the actuator is not limited in time.
+ """
+ def getTime():
+ """
+ Returns the time parameter.
+
+ @rtype: integer
+ """
+ def setProperty(property):
+ """
+ Sets the name of the property or material for the ray detection of the distance constraint.
+
+ @type property: string
+ @param property: If empty, the ray will detect any collisioning object.
+ """
+ def getProperty():
+ """
+ Returns the property parameter.
+
+ @rtype: string
+ """
+ def setDistance(distance):
+ """
+ Sets the target distance in distance constraint.
+
+ @type distance: float
+ """
+ def getDistance():
+ """
+ Returns the distance parameter.
+
+ @rtype: float
+ """
+ def setRayLength(length):
+ """
+ Sets the maximum ray length of the distance constraint.
+
+ @type length: float
+ """
+ def getRayLength():
+ """
+ Returns the length of the ray
+
+ @rtype: float
+ """
+
+
+
+
+
+
+
+
+
diff --git a/source/gameengine/PyDoc/KX_GameObject.py b/source/gameengine/PyDoc/KX_GameObject.py
index d3428915f25..505ce253dd1 100644
--- a/source/gameengine/PyDoc/KX_GameObject.py
+++ b/source/gameengine/PyDoc/KX_GameObject.py
@@ -22,17 +22,57 @@ class KX_GameObject:
@type orientation: 3x3 Matrix [[float]]
@ivar scaling: The object's scaling factor. list [sx, sy, sz]
@type scaling: list [sx, sy, sz]
+ @ivar timeOffset: adjust the slowparent delay at runtime.
+ @type timeOffset: float
"""
-
+ def endObject(visible):
+ """
+ Delete this object, can be used inpace of the EndObject Actuator.
+ The actual removal of the object from the scene is delayed.
+ """
+ def replaceMesh(mesh_name):
+ """
+ Replace the mesh of this object with a new mesh. This works the same was as the actuator.
+ @type mesh_name: string
+ """
+ def getVisible():
+ """
+ Gets the game object's visible flag.
+
+ @rtype: boolean
+ """
def setVisible(visible):
"""
Sets the game object's visible flag.
@type visible: boolean
"""
+ def getState():
+ """
+ Gets the game object's state bitmask.
+
+ @rtype: int
+ @return: the objects state.
+ """
+ def setState(state):
+ """
+ Sets the game object's state flag.
+ The bitmasks for states from 1 to 30 can be set with (1<<0, 1<<1, 1<<2 ... 1<<29)
+
+ @type state: integer
+ """
def setPosition(pos):
"""
- Sets the game object's position.
+ Sets the game object's position.
+ Global coordinates for root object, local for child objects.
+
+
+ @type pos: [x, y, z]
+ @param pos: the new position, in local coordinates.
+ """
+ def setWorldPosition(pos):
+ """
+ Sets the game object's position in world coordinates regardless if the object is root or child.
@type pos: [x, y, z]
@param pos: the new position, in world coordinates.
@@ -50,6 +90,30 @@ class KX_GameObject:
@type orn: 3x3 rotation matrix, or Quaternion.
@param orn: a rotation matrix specifying the new rotation.
+ @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
+ """
+ def alignAxisToVect(vect, axis):
+ """
+ Aligns any of the game object's axis along the given vector.
+
+ @type vect: 3d vector.
+ @param vect: a vector to align the axis.
+ @type axis: integer.
+ @param axis:The axis you want to align
+ - 0: X axis
+ - 1: Y axis
+ - 2: Z axis (default)
+ """
+ def getAxisVect(vect):
+ """
+ Returns the axis vector rotates by the objects worldspace orientation.
+ This is the equivalent if multiplying the vector by the orientation matrix.
+
+ @type vect: 3d vector.
+ @param vect: a vector to align the axis.
+ @rtype: 3d vector.
+ @return: The vector in relation to the objects rotation.
+
"""
def getOrientation():
"""
@@ -57,19 +121,54 @@ class KX_GameObject:
@rtype: 3x3 rotation matrix
@return: The game object's rotation matrix
+ @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
"""
- def getLinearVelocity():
+ def getLinearVelocity(local = 0):
"""
Gets the game object's linear velocity.
This method returns the game object's velocity through it's centre of mass,
ie no angular velocity component.
- cf getVelocity()
-
+ @type local: boolean
+ @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
+ - True: you get the "local" velocity ie: relative to object orientation.
@rtype: list [vx, vy, vz]
@return: the object's linear velocity.
"""
+ def setLinearVelocity(velocity, local = 0):
+ """
+ Sets the game object's linear velocity.
+
+ This method sets game object's velocity through it's centre of mass,
+ ie no angular velocity component.
+
+ @type velocity: 3d vector.
+ @param velocity: linear velocity vector.
+ @type local: boolean
+ @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
+ - True: you get the "local" velocity ie: relative to object orientation.
+ """
+ def getAngularVelocity(local = 0):
+ """
+ Gets the game object's angular velocity.
+
+ @type local: boolean
+ @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
+ - True: you get the "local" velocity ie: relative to object orientation.
+ @rtype: list [vx, vy, vz]
+ @return: the object's angular velocity.
+ """
+ def setAngularVelocity(velocity, local = 0):
+ """
+ Sets the game object's angular velocity.
+
+ @type velocity: 3d vector.
+ @param velocity: angular velocity vector.
+ @type local: boolean
+ @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
+ - True: you get the "local" velocity ie: relative to object orientation.
+ """
def getVelocity(point):
"""
Gets the game object's velocity at the specified point.
@@ -117,16 +216,19 @@ class KX_GameObject:
def restoreDynamics():
"""
Resumes physics for this object.
+ @Note: The objects linear velocity will be applied from when the dynamics were suspended.
"""
def enableRigidBody():
"""
Enables rigid body physics for this object.
Rigid body physics allows the object to roll on collisions.
+ @Note: This is not working with bullet physics yet.
"""
def disableRigidBody():
"""
Disables rigid body physics for this object.
+ @Note: This is not working with bullet physics yet. The angular is removed but rigid body physics can still rotate it later.
"""
def getParent():
"""
@@ -135,6 +237,29 @@ class KX_GameObject:
@rtype: L{KX_GameObject}
@return: this object's parent object, or None if this object has no parent.
"""
+ def setParent(parent):
+ """
+ Sets this object's parent.
+
+ @type parent: L{KX_GameObject}
+ @param parent: new parent object.
+ """
+ def removeParent():
+ """
+ Removes this objects parent.
+ """
+ def getChildren():
+ """
+ Return a list of immediate children of this object.
+ @rtype: list
+ @return: a list of all this objects children.
+ """
+ def getChildrenRecursive():
+ """
+ Return a list of children of this object, including all their childrens children.
+ @rtype: list
+ @return: a list of all this objects children recursivly.
+ """
def getMesh(mesh):
"""
Gets the mesh object for this object.
@@ -148,6 +273,12 @@ class KX_GameObject:
"""
Returns the user data object associated with this game object's physics controller.
"""
+ def getPropertyNames():
+ """
+ Gets a list of all property names.
+ @rtype: list
+ @return: All property names for this object.
+ """
def getDistanceTo(other):
"""
Returns the distance to another object or point.
@@ -156,3 +287,83 @@ class KX_GameObject:
@type other: L{KX_GameObject} or list [x, y, z]
@rtype: float
"""
+ def getVectTo(other):
+ """
+ Returns the vector and the distance to another object or point.
+ The vector is normalized unless the distance is 0, in which a NULL vector is returned.
+
+ @param other: a point or another L{KX_GameObject} to get the vector and distance to.
+ @type other: L{KX_GameObject} or list [x, y, z]
+ @rtype: 3-tuple (float, 3-tuple (x,y,z), 3-tuple (x,y,z))
+ @return: (distance, globalVector(3), localVector(3))
+ """
+ def rayCastTo(other,dist,prop):
+ """
+ Look towards another point/object and find first object hit within dist that matches prop.
+
+ The ray is always casted from the center of the object, ignoring the object itself.
+ The ray is casted towards the center of another object or an explicit [x,y,z] point.
+ Use rayCast() if you need to retrieve the hit point
+
+ @param other: [x,y,z] or object towards which the ray is casted
+ @type other: L{KX_GameObject} or 3-tuple
+ @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
+ @type dist: float
+ @param prop: property name that object must have; can be omitted => detect any object
+ @type prop: string
+ @rtype: L{KX_GameObject}
+ @return: the first object hit or None if no object or object does not match prop
+ """
+ def rayCast(objto,objfrom,dist,prop,face,xray,poly):
+ """
+ Look from a point/object to another point/object and find first object hit within dist that matches prop.
+ if poly is 0, 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 L{KX_PolyProxy} as 4th element.
+
+ Ex::
+ # shoot along the axis gun-gunAim (gunAim should be collision-free)
+ ob,point,normal = gun.rayCast(gunAim,None,50)
+ if ob:
+ # hit something
+
+ Notes:
+ The ray ignores the object on which the method is called.
+ It is casted from/to object center or explicit [x,y,z] points.
+
+ The face paremeter determines the orientation of the normal::
+ 0 => 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.
+ The L{KX_PolyProxy} 4th element of the return tuple when poly=1 allows to retrieve information on the polygon hit by the ray.
+ If there is no hit or the hit object is not a static mesh, None is returned as 4th element.
+
+ The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects.
+
+ @param objto: [x,y,z] or object to which the ray is casted
+ @type objto: L{KX_GameObject} or 3-tuple
+ @param objfrom: [x,y,z] or object from which the ray is casted; None or omitted => use self object center
+ @type objfrom: L{KX_GameObject} or 3-tuple or None
+ @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to to
+ @type dist: float
+ @param prop: property name that object must have; can be omitted => detect any object
+ @type prop: string
+ @param face: normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin
+ @type face: int
+ @param xray: X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object
+ @type xray: int
+ @param poly: polygon option: 1=>return value is a 4-tuple and the 4th element is a L{KX_PolyProxy}
+ @type poly: int
+ @rtype: 3-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz))
+ or 4-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz), L{KX_PolyProxy})
+ @return: (object,hitpoint,hitnormal) or (object,hitpoint,hitnormal,polygon)
+ If no hit, returns (None,None,None) or (None,None,None,None)
+ If the object hit is not a static mesh, polygon is None
+ """
+
+
diff --git a/source/gameengine/PyDoc/KX_IpoActuator.py b/source/gameengine/PyDoc/KX_IpoActuator.py
index da8d05ddd5e..e2fe3b289e3 100644
--- a/source/gameengine/PyDoc/KX_IpoActuator.py
+++ b/source/gameengine/PyDoc/KX_IpoActuator.py
@@ -16,8 +16,8 @@ class KX_IpoActuator(SCA_IActuator):
@type startframe: integer
@param endframe: last frame to use
@type endframe: integer
- @param force: interpret this ipo as a force
- @type force: boolean (KX_TRUE, KX_FALSE)
+ @param force: special mode
+ @type force: integer (0=normal, 1=interpret location as force, 2=additive)
"""
def setProperty(property):
"""
@@ -62,6 +62,19 @@ class KX_IpoActuator(SCA_IActuator):
@rtype: boolean
"""
+ def setIpoAdd(add):
+ """
+ Set whether to interpret the ipo as additive rather than absolute.
+
+ @type add: boolean
+ @param add: KX_TRUE or KX_FALSE
+ """
+ def getIpoAdd():
+ """
+ Returns whether to interpret the ipo as additive rather than absolute.
+
+ @rtype: boolean
+ """
def setType(mode):
"""
Sets the operation mode of the actuator.
diff --git a/source/gameengine/PyDoc/KX_MeshProxy.py b/source/gameengine/PyDoc/KX_MeshProxy.py
index e43fa3598f0..03bc36b6ac1 100644
--- a/source/gameengine/PyDoc/KX_MeshProxy.py
+++ b/source/gameengine/PyDoc/KX_MeshProxy.py
@@ -95,6 +95,21 @@ class KX_MeshProxy:
@rtype: L{KX_VertexProxy}
@return: a vertex object.
"""
+ def getNumPolygons():
+ """
+ Returns the number of polygon in the mesh.
+
+ @rtype: integer
+ """
+ def getPolygon(index):
+ """
+ Gets the specified polygon from the mesh.
+
+ @type index: integer
+ @param index: polygon number
+ @rtype: L{KX_PolyProxy}
+ @return: a polygon object.
+ """
def reinstancePhysicsMesh():
"""
Updates the physics system with the changed mesh.
diff --git a/source/gameengine/PyDoc/KX_ObjectActuator.py b/source/gameengine/PyDoc/KX_ObjectActuator.py
index 532c18eea5c..b7b76473292 100644
--- a/source/gameengine/PyDoc/KX_ObjectActuator.py
+++ b/source/gameengine/PyDoc/KX_ObjectActuator.py
@@ -6,6 +6,7 @@ class KX_ObjectActuator(SCA_IActuator):
"""
The object actuator ("Motion Actuator") applies force, torque, displacement, angular displacement,
velocity, or angular velocity to an object.
+ Servo control allows to regulate force to achieve a certain speed target.
"""
def getForce():
"""
@@ -107,15 +108,15 @@ class KX_ObjectActuator(SCA_IActuator):
def getLinearVelocity():
"""
Returns the linear velocity applied by the actuator.
+ For the servo control actuator, this is the target speed.
@rtype: list [vx, vy, vz, local]
- @return: A four item list, containing the vector velocity, and whether
- the velocity is applied in local coordinates (True) or world
- coordinates (False)
+ @return: A four item list, containing the vector velocity, and whether the velocity is applied in local coordinates (True) or world coordinates (False)
"""
def setLinearVelocity(vx, vy, vz, local):
"""
Sets the linear velocity applied by the actuator.
+ For the servo control actuator, sets the target speed.
@type vx: float
@param vx: the x component of the velocity vector.
@@ -124,8 +125,8 @@ class KX_ObjectActuator(SCA_IActuator):
@type vz: float
@param vz: the z component of the velocity vector.
@type local: boolean
- @param local: - False: the velocity vector is applied in world coordinates.
- - True: the velocity vector is applied in local coordinates.
+ @param local: - False: the velocity vector is in world coordinates.
+ - True: the velocity vector is in local coordinates.
"""
def getAngularVelocity():
"""
@@ -150,5 +151,100 @@ class KX_ObjectActuator(SCA_IActuator):
@param local: - False: the velocity vector is applied in world coordinates.
- True: the velocity vector is applied in local coordinates.
"""
+ def getDamping():
+ """
+ Returns the damping parameter of the servo controller.
+
+ @rtype: integer
+ @return: the time constant of the servo controller in frame unit.
+ """
+ def setDamping(damp):
+ """
+ Sets the damping parameter of the servo controller.
+
+ @type damp: integer
+ @param damp: the damping parameter in frame unit.
+ """
+ def getForceLimitX():
+ """
+ Returns the min/max force limit along the X axis used by the servo controller.
+
+ @rtype: list [min, max, enabled]
+ @return: A three item list, containing the min and max limits of the force as float
+ and whether the limits are active(true) or inactive(true)
+ """
+ def setForceLimitX(min, max, enable):
+ """
+ Sets the min/max force limit along the X axis and activates or deactivates the limits in the servo controller.
+
+ @type min: float
+ @param min: the minimum value of the force along the X axis.
+ @type max: float
+ @param max: the maximum value of the force along the X axis.
+ @type enable: boolean
+ @param enable: - True: the force will be limited to the min/max
+ - False: the force will not be limited
+ """
+ def getForceLimitY():
+ """
+ Returns the min/max force limit along the Y axis used by the servo controller.
+
+ @rtype: list [min, max, enabled]
+ @return: A three item list, containing the min and max limits of the force as float
+ and whether the limits are active(true) or inactive(true)
+ """
+ def setForceLimitY(min, max, enable):
+ """
+ Sets the min/max force limit along the Y axis and activates or deactivates the limits in the servo controller.
+
+ @type min: float
+ @param min: the minimum value of the force along the Y axis.
+ @type max: float
+ @param max: the maximum value of the force along the Y axis.
+ @type enable: boolean
+ @param enable: - True: the force will be limited to the min/max
+ - False: the force will not be limited
+ """
+ def getForceLimitZ():
+ """
+ Returns the min/max force limit along the Z axis used by the servo controller.
+
+ @rtype: list [min, max, enabled]
+ @return: A three item list, containing the min and max limits of the force as float
+ and whether the limits are active(true) or inactive(true)
+ """
+ def setForceLimitZ(min, max, enable):
+ """
+ Sets the min/max force limit along the Z axis and activates or deactivates the limits in the servo controller.
+
+ @type min: float
+ @param min: the minimum value of the force along the Z axis.
+ @type max: float
+ @param max: the maximum value of the force along the Z axis.
+ @type enable: boolean
+ @param enable: - True: the force will be limited to the min/max
+ - False: the force will not be limited
+ """
+ def getPID():
+ """
+ Returns the PID coefficient of the servo controller.
+
+ @rtype: list [P, I, D]
+ @return: A three item list, containing the PID coefficient as floats:
+ P : proportional coefficient
+ I : Integral coefficient
+ D : Derivate coefficient
+ """
+ def setPID(P, I, D):
+ """
+ Sets the PID coefficients of the servo controller.
+
+ @type P: flat
+ @param P: proportional coefficient
+ @type I: float
+ @param I: Integral coefficient
+ @type D: float
+ @param D: Derivate coefficient
+ """
diff --git a/source/gameengine/PyDoc/KX_ParentActuator.py b/source/gameengine/PyDoc/KX_ParentActuator.py
new file mode 100644
index 00000000000..6d6e0937257
--- /dev/null
+++ b/source/gameengine/PyDoc/KX_ParentActuator.py
@@ -0,0 +1,23 @@
+# $Id: KX_ParentActuator.py 2615 2004-06-02 12:43:27Z kester $
+# Documentation for KX_ParentActuator
+from SCA_IActuator import *
+
+class KX_ParentActuator(SCA_IActuator):
+ """
+ The parent actuator can set or remove an objects parent object.
+ """
+ def setObject(object):
+ """
+ Sets the object to set as parent.
+
+ Object can be either a L{KX_GameObject} or the name of the object.
+
+ @type object: L{KX_GameObject}, string or None
+ """
+ def getObject(name_only = 1):
+ """
+ Returns the name of the object to change to.
+ @type name_only: bool
+ @param name_only: optional argument, when 0 return a KX_GameObject
+ @rtype: string, KX_GameObject or None if no object is set
+ """
diff --git a/source/gameengine/PyDoc/KX_PolyProxy.py b/source/gameengine/PyDoc/KX_PolyProxy.py
new file mode 100644
index 00000000000..bcd42c2ac2e
--- /dev/null
+++ b/source/gameengine/PyDoc/KX_PolyProxy.py
@@ -0,0 +1,100 @@
+# $Id$
+# Documentation for the polygon proxy class
+
+class KX_PolyProxy:
+ """
+ A polygon holds the index of the vertex forming the poylgon.
+
+ Note:
+ The polygon attributes are read-only, you need to retrieve the vertex proxy if you want
+ to change the vertex settings.
+
+ @ivar matname: The name of polygon material, empty if no material.
+ @type matname: string
+ @ivar material: The material of the polygon
+ @type material: L{KX_PolygonMaterial} or KX_BlenderMaterial
+ @ivar texture: The texture name of the polygon.
+ @type texture: string
+ @ivar matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
+ @type matid: integer
+ @ivar v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
+ @type v1: integer
+ @ivar v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
+ @type v2: integer
+ @ivar v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
+ @type v3: integer
+ @ivar 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
+ @type v4: integer
+ @ivar visible: visible state of the polygon: 1=visible, 0=invisible
+ @type visible: integer
+ @ivar collide: collide state of the polygon: 1=receives collision, 0=collision free.
+ @type collide: integer
+ """
+
+ def getMaterialName():
+ """
+ Returns the polygon material name with MA prefix
+
+ @rtype: string
+ @return: material name
+ """
+ def getMaterial():
+ """
+ Returns the polygon material
+
+ @rtype: L{KX_PolygonMaterial} or KX_BlenderMaterial
+ """
+ def getTextureName():
+ """
+ Returns the polygon texture name
+
+ @rtype: string
+ @return: texture name
+ """
+ def getMaterialIndex():
+ """
+ Returns the material bucket index of the polygon.
+ This index and the ones returned by getVertexIndex() are needed to retrieve the vertex proxy from L{KX_MeshProxy}.
+
+ @rtype: integer
+ @return: the material index in the mesh
+ """
+ def getNumVertex():
+ """
+ Returns the number of vertex of the polygon.
+
+ @rtype: integer
+ @return: number of vertex, 3 or 4.
+ """
+ def isVisible():
+ """
+ Returns whether the polygon is visible or not
+
+ @rtype: integer
+ @return: 0=invisible, 1=visible
+ """
+ def isCollider():
+ """
+ Returns whether the polygon is receives collision or not
+
+ @rtype: integer
+ @return: 0=collision free, 1=receives collision
+ """
+ def getVertexIndex(vertex):
+ """
+ Returns the mesh vertex index of a polygon vertex
+ This index and the one returned by getMaterialIndex() are needed to retrieve the vertex proxy from L{KX_MeshProxy}.
+
+ @type vertex: integer
+ @param vertex: index of the vertex in the polygon: 0->3
+ @rtype: integer
+ @return: mesh vertex index
+ """
+ def getMesh():
+ """
+ Returns a mesh proxy
+
+ @rtype: L{KX_MeshProxy}
+ @return: mesh proxy
+ """
diff --git a/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py b/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py
index 44f9e051c8c..c3b2e947ddb 100644
--- a/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py
+++ b/source/gameengine/PyDoc/KX_SCA_AddObjectActuator.py
@@ -13,7 +13,7 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
C{ERROR: GameObject I{OBName} has a AddObjectActuator I{ActuatorName} without object (in 'nonactive' layer)}
"""
- def setObject(obj):
+ def setObject(object):
"""
Sets the game object to add.
@@ -21,17 +21,18 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
If the object does not exist, this function is ignored.
- obj can either be a L{KX_GameObject} or the name of an object.
+ object can either be a L{KX_GameObject} or the name of an object or None.
- @type obj: L{KX_GameObject} or string
+ @type object: L{KX_GameObject}, string or None
"""
- def getObject():
+ def getObject(name_only = 0):
"""
Returns the name of the game object to be added.
Returns None if no game object has been assigned to be added.
-
- @rtype: string
+ @type name_only: bool
+ @param name_only: optional argument, when 0 return a KX_GameObject
+ @rtype: string, KX_GameObject or None if no object is set
"""
def setTime(time):
"""
@@ -65,6 +66,23 @@ class KX_SCA_AddObjectActuator(SCA_IActuator):
@rtype: list [vx, vy, vz]
"""
+ def setAngularVelocity(vx, vy, vz):
+ """
+ Sets the initial angular velocity of added objects.
+
+ @type vx: float
+ @param vx: the x component of the initial angular velocity.
+ @type vy: float
+ @param vy: the y component of the initial angular velocity.
+ @type vz: float
+ @param vz: the z component of the initial angular velocity.
+ """
+ def getAngularVelocity():
+ """
+ Returns the initial angular velocity of added objects.
+
+ @rtype: list [vx, vy, vz]
+ """
def getLastCreatedObject():
"""
Returns the last object created by this actuator.
diff --git a/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py b/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py
index eb00a91a4ce..498f6072e23 100644
--- a/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py
+++ b/source/gameengine/PyDoc/KX_SCA_ReplaceMeshActuator.py
@@ -59,8 +59,9 @@ class KX_SCA_ReplaceMeshActuator(SCA_IActuator):
def setMesh(name):
"""
Sets the name of the mesh that will replace the current one.
+ When the name is None it will unset the mesh value so no action is taken.
- @type name: string
+ @type name: string or None
"""
def getMesh():
"""
@@ -68,6 +69,6 @@ class KX_SCA_ReplaceMeshActuator(SCA_IActuator):
Returns None if no mesh has been scheduled to be added.
- @rtype: string
+ @rtype: string or None
"""
diff --git a/source/gameengine/PyDoc/KX_StateActuator.py b/source/gameengine/PyDoc/KX_StateActuator.py
new file mode 100644
index 00000000000..fb6ae5a3621
--- /dev/null
+++ b/source/gameengine/PyDoc/KX_StateActuator.py
@@ -0,0 +1,26 @@
+# $Id$
+# Documentation for KX_StateActuator
+from SCA_IActuator import *
+
+class KX_StateActuator(SCA_IActuator):
+ """
+ State actuator changes the state mask of parent object.
+ """
+ def setOperation(op):
+ """
+ Set the type of bit operation to be applied on object state mask.
+ Use setMask() to specify the bits that will be modified.
+
+ @param op: bit operation (0=Copy, 1=Add, 2=Substract, 3=Invert)
+ @type op: integer
+ """
+ def setMask(mask):
+ """
+ Set the value that defines the bits that will be modified by the operation.
+ The bits that are 1 in the value will be updated in the object state,
+ the bits that are 0 are will be left unmodified expect for the Copy operation
+ which copies the value to the object state.
+
+ @param mask: bits that will be modified
+ @type mask: integer
+ """
diff --git a/source/gameengine/PyDoc/KX_TrackToActuator.py b/source/gameengine/PyDoc/KX_TrackToActuator.py
index 39fb99ec2e2..948302991b7 100644
--- a/source/gameengine/PyDoc/KX_TrackToActuator.py
+++ b/source/gameengine/PyDoc/KX_TrackToActuator.py
@@ -18,16 +18,16 @@ class KX_TrackToActuator(SCA_IActuator):
"""
Sets the object to track.
- @type object: L{KX_GameObject} or string
+ @type object: L{KX_GameObject}, string or None
@param object: Either a reference to a game object or the name of the object to track.
"""
- def getObject():
+ def getObject(name_only):
"""
Returns the name of the object to track.
- Returns None if no object has been set to track.
-
- @rtype: string
+ @type name_only: bool
+ @param name_only: optional argument, when 0 return a KX_GameObject
+ @rtype: string, KX_GameObject or None if no object is set
"""
def setTime(time):
"""
diff --git a/source/gameengine/PyDoc/Makefile b/source/gameengine/PyDoc/Makefile
deleted file mode 100644
index 7861894ddec..00000000000
--- a/source/gameengine/PyDoc/Makefile
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-SOURCES=$(shell ls *.py)
-TARGETS:=$(SOURCES:.py=.html)
-PYDOC=/usr/lib/python2.2/pydoc.py
-
-all: $(SOURCES)
- epydoc -o BPY_GE_236 --url "http://www.blender.org" -t GameLogic.py \
- -n "Blender GameEngine" --no-private --no-frames \
- $(shell ls *.py )
-
-clean:
- rm *.html
diff --git a/source/gameengine/PyDoc/Rasterizer.py b/source/gameengine/PyDoc/Rasterizer.py
index f0e48b6ed43..6a67cdcc71b 100644
--- a/source/gameengine/PyDoc/Rasterizer.py
+++ b/source/gameengine/PyDoc/Rasterizer.py
@@ -37,7 +37,11 @@ Example Uses an L{SCA_MouseSensor}, and two L{KX_ObjectActuator}s to implement M
# Centre the mouse
Rasterizer.setMousePosition(Rasterizer.getWindowWidth()/2, Rasterizer.getWindowHeight()/2)
-
+@group Material Types: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
+@var KX_TEXFACE_MATERIAL: Materials as defined by the texture face settings.
+@var KX_BLENDER_MULTITEX_MATERIAL: Materials approximating blender materials with multitexturing.
+@var KX_BLENDER_GLSL_MATERIAL: Materials approximating blender materials with GLSL.
+
"""
def getWindowWidth():
@@ -84,7 +88,8 @@ def setMousePosition(x, y):
"""
Sets the mouse cursor position.
- @type x, y: integer
+ @type x: integer
+ @type y: integer
"""
def setBackgroundColor(rgba):
@@ -145,3 +150,47 @@ def getFocalLength():
@rtype: float
"""
+
+def setMaterialMode(mode):
+ """
+ Set the material mode to use for OpenGL rendering.
+
+ @type mode: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
+ @note: Changes will only affect newly created scenes.
+ """
+
+def getMaterialMode(mode):
+ """
+ Get the material mode to use for OpenGL rendering.
+
+ @rtype: KX_TEXFACE_MATERIAL, KX_BLENDER_MULTITEX_MATERIAL, KX_BLENDER_GLSL_MATERIAL
+ """
+
+def setGLSLMaterialSetting(setting, enable):
+ """
+ Enables or disables a GLSL material setting.
+
+ @type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
+ @type enable: boolean
+ """
+
+def getGLSLMaterialSetting(setting, enable):
+ """
+ Get the state of a GLSL material setting.
+
+ @type setting: string (lights, shaders, shadows, ramps, nodes, extra_textures)
+ @rtype: boolean
+ """
+
+def drawLine(fromVec,toVec,color):
+ """
+ Draw a line in the 3D scene.
+
+ @param fromVec: the origin of the line
+ @type fromVec: list [x, y, z]
+ @param toVec: the end of the line
+ @type toVec: list [x, y, z]
+ @param color: the color of the line
+ @type color: list [r, g, b]
+ """
+
diff --git a/source/gameengine/PyDoc/SCA_DelaySensor.py b/source/gameengine/PyDoc/SCA_DelaySensor.py
new file mode 100644
index 00000000000..19df589ea7b
--- /dev/null
+++ b/source/gameengine/PyDoc/SCA_DelaySensor.py
@@ -0,0 +1,56 @@
+# $Id$
+# Documentation for SCA_DelaySensor
+from SCA_ISensor import *
+
+class SCA_DelaySensor(SCA_ISensor):
+ """
+ The Delay sensor generates positive and negative triggers at precise time,
+ expressed in number of frames. The delay parameter defines the length
+ of the initial OFF period. A positive trigger is generated at the end of this period.
+ The duration parameter defines the length of the ON period following the OFF period.
+ There is a negative trigger at the end of the ON period. If duration is 0, the sensor
+ stays ON and there is no negative trigger.
+ The sensor runs the OFF-ON cycle once unless the repeat option is set: the
+ OFF-ON cycle repeats indefinately (or the OFF cycle if duration is 0).
+ Use SCA_ISensor::reset() at any time to restart sensor.
+ """
+ def setDelay(delay):
+ """
+ Set the initial delay before the positive trigger.
+
+ @param delay: length of the initial OFF period as number of frame, 0 for immediate trigger
+ @type delay: integer
+ """
+ def setDuration(duration):
+ """
+ Set the duration of the ON pulse after initial delay and the generation of the positive trigger.
+ If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
+
+ @param duration: length of the ON period in number of frame after the initial OFF period
+ @type duration: integer
+ """
+ def setRepeat(repeat):
+ """
+ Set if the sensor repeat mode.
+
+ @param repeat: 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
+ @type repeat: integer
+ """
+ def getDelay():
+ """
+ Return the delay parameter value.
+
+ @rtype: integer
+ """
+ def getDuration():
+ """
+ Return the duration parameter value
+
+ @rtype: integer
+ """
+ def getRepeat():
+ """
+ Return the repeat parameter value
+
+ @rtype: KX_TRUE or KX_FALSE
+ """
diff --git a/source/gameengine/PyDoc/SCA_ISensor.py b/source/gameengine/PyDoc/SCA_ISensor.py
index b96d8c8c075..14858505e24 100644
--- a/source/gameengine/PyDoc/SCA_ISensor.py
+++ b/source/gameengine/PyDoc/SCA_ISensor.py
@@ -9,7 +9,12 @@ class SCA_ISensor(SCA_ILogicBrick):
def isPositive():
"""
- True if this sensor brick has been activated.
+ True if this sensor brick is in a positive state.
+ """
+
+ def isTriggered():
+ """
+ True if this sensor brick has triggered the current controller.
"""
def getUsePosPulseMode():
@@ -59,4 +64,28 @@ class SCA_ISensor(SCA_ILogicBrick):
@type invert: boolean
@param invert: true if activates on negative events; false if activates on positive events.
"""
+ def getLevel():
+ """
+ Returns whether this sensor is a level detector or a edge detector.
+ It makes a difference only in case of logic state transition (state actuator).
+ A level detector will immediately generate a pulse, negative or positive
+ depending on the sensor condition, as soon as the state is activated.
+ A edge detector will wait for a state change before generating a pulse.
+
+ @rtype: boolean
+ @return: true if sensor is level sensitive, false if it is edge sensitive
+ """
+ def setLevel(level):
+ """
+ Set whether to detect level or edge transition when entering a state.
+
+ @param level: Detect level instead of edge? (KX_TRUE, KX_FALSE)
+ @type level: boolean
+ """
+ def reset():
+ """
+ Reset sensor internal state, effect depends on the type of sensor and settings.
+
+ The sensor is put in its initial state as if it was just activated.
+ """
diff --git a/source/gameengine/PyDoc/SCA_JoystickSensor.py b/source/gameengine/PyDoc/SCA_JoystickSensor.py
new file mode 100644
index 00000000000..d1dab9afcaf
--- /dev/null
+++ b/source/gameengine/PyDoc/SCA_JoystickSensor.py
@@ -0,0 +1,106 @@
+# $Id: SCA_RandomSensor.py 15444 2008-07-05 17:05:05Z lukep $
+# Documentation for SCA_RandomSensor
+from SCA_ISensor import *
+
+class SCA_JoystickSensor(SCA_ISensor):
+ """
+ This sensor detects player joystick events.
+ """
+
+ def getIndex():
+ """
+ Returns the joystick index to use (from 1 to 8).
+ @rtype: integer
+ """
+ def setIndex(index):
+ """
+ Sets the joystick index to use.
+ @param index: The index of this joystick sensor, Clamped between 1 and 8.
+ @type index: integer
+ @note: This is only useful when you have more then 1 joystick connected to your computer - multiplayer games.
+ """
+ def getAxis():
+ """
+ Returns the current axis this sensor reacts to. See L{getAxisValue()<SCA_JoystickSensor.getAxisValue>} for the current axis state.
+ @rtype: list
+ @return: 2 values returned are [axisIndex, axisDirection] - see L{setAxis()<SCA_JoystickSensor.setAxis>} for their purpose.
+ @note: When the "All Events" toggle is set, this option has no effect.
+ """
+ def setAxis(axisIndex, axisDirection):
+ """
+ @param axisIndex: Set the axis index to use when detecting axis movement.
+ @type axisIndex: integer from 1 to 2
+ @param axisDirection: Set the axis direction used for detecting motion. 0:right, 1:up, 2:left, 3:down.
+ @type axisDirection: integer from 0 to 3
+ @note: When the "All Events" toggle is set, this option has no effect.
+ """
+ def getAxisValue():
+ """
+ Returns the state of the joysticks axis. See differs to L{getAxis()<SCA_JoystickSensor.getAxis>} returning the current state of the joystick.
+ @rtype: list
+ @return: 4 values, each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.
+
+ The first 2 values are used by most joysticks and gamepads for directional control. 3rd and 4th values are only on some joysticks and can be used for arbitary controls.
+
+ left:[-32767, 0, ...], right:[32767, 0, ...], up:[0, -32767, ...], down:[0, 32767, ...]
+ @note: Some gamepads only set the axis on and off like a button.
+ """
+ def getThreshold():
+ """
+ Get the axis threshold. See L{setThreshold()<SCA_JoystickSensor.setThreshold>} for details.
+ @rtype: integer
+ """
+ def setThreshold(threshold):
+ """
+ Set the axis threshold.
+ @param threshold: Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
+ @type threshold: integer
+ """
+ def getButton():
+ """
+ Returns the button index the sensor reacts to. See L{getButtonValue()<SCA_JoystickSensor.getButtonValue>} for a list of pressed buttons.
+ @rtype: integer
+ @note: When the "All Events" toggle is set, this option has no effect.
+ """
+ def setButton(index):
+ """
+ Sets the button index the sensor reacts to when the "All Events" option is not set.
+ @note: When the "All Events" toggle is set, this option has no effect.
+ """
+ def getButtonValue():
+ """
+ Returns a list containing the indicies of the currently pressed buttons.
+ @rtype: list
+ """
+ def getHat():
+ """
+ Returns the current hat direction this sensor is set to.
+ [hatNumber, hatDirection].
+ @rtype: list
+ @note: When the "All Events" toggle is set, this option has no effect.
+ """
+ def setHat(index):
+ """
+ Sets the hat index the sensor reacts to when the "All Events" option is not set.
+ @type index: integer
+ """
+ def getNumAxes():
+ """
+ Returns the number of axes for the joystick at this index.
+ @rtype: integer
+ """
+ def getNumButtons():
+ """
+ Returns the number of buttons for the joystick at this index.
+ @rtype: integer
+ """
+ def getNumHats():
+ """
+ Returns the number of hats for the joystick at this index.
+ @rtype: integer
+ """
+ def isConnected():
+ """
+ Returns True if a joystick is detected at this joysticks index.
+ @rtype: bool
+ """
diff --git a/source/gameengine/PyDoc/SCA_PythonController.py b/source/gameengine/PyDoc/SCA_PythonController.py
index eb9e57c0819..6d91736d636 100644
--- a/source/gameengine/PyDoc/SCA_PythonController.py
+++ b/source/gameengine/PyDoc/SCA_PythonController.py
@@ -46,4 +46,12 @@ class SCA_PythonController(SCA_IController):
@type script: string.
"""
+ def getState():
+ """
+ Get the controllers state bitmask, this can be used with the GameObject's state to test if the the controller is active.
+ This for instance will always be true however you could compare with a previous state to see when the state was activated.
+ GameLogic.getCurrentController().getState() & GameLogic.getCurrentController().getOwner().getState()
+
+ @rtype: int
+ """
diff --git a/source/gameengine/PyDoc/SConscript b/source/gameengine/PyDoc/SConscript
new file mode 100644
index 00000000000..ac0b163d7bd
--- /dev/null
+++ b/source/gameengine/PyDoc/SConscript
@@ -0,0 +1,28 @@
+#!/usr/bin/python
+Import ('env')
+
+
+from optparse import OptionParser
+try:
+ import epydoc
+except ImportError:
+ print "No epydoc install detected, Python API Docs will not be generated "
+if epydoc:
+ from epydoc.docbuilder import build_doc_index
+ from epydoc import cli
+ names = env.Glob("source/gameengine/PyDoc/*.py")
+ docindex = build_doc_index(names)
+ optvalues = cli.OPTION_DEFAULTS
+ optvalues["verbose"] = 1
+ optvalues["target"] = env["BF_DOCDIR"]+"/BGE_API/"
+ optvalues["url"] = "http://www.blender.org"
+ optvalues["top"] = "Game Engine API"
+ optvalues["name"] = "Blender"
+ optvalues["noprivate"] = 1
+ optvalues["noframes"] = 1
+ optvalues["names"] = names
+ optparser = OptionParser()
+ optparser.set_defaults(**optvalues)
+ (options, args) = optparser.parse_args([])
+ cli.write_html(docindex, options)
+
diff --git a/source/gameengine/PyDoc/epy_docgen.sh b/source/gameengine/PyDoc/epy_docgen.sh
new file mode 100644
index 00000000000..b243101ddcb
--- /dev/null
+++ b/source/gameengine/PyDoc/epy_docgen.sh
@@ -0,0 +1,11 @@
+# epy_docgen.sh
+# generates blender python doc using epydoc
+# requires epydoc in your PATH.
+# run from the doc directory containing the .py files
+# usage: sh epy_docgen.sh
+
+# set posix locale so regex works properly for [A-Z]*.py
+LC_ALL=POSIX
+
+epydoc --debug -v -o BPY_GE --url "http://www.blender.org" --top GameLogic \
+ --name "Blender GameEngine" --no-private --no-frames *.py
diff --git a/source/gameengine/Rasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/CMakeLists.txt
index e604fe0e133..6d53ee53471 100644
--- a/source/gameengine/Rasterizer/CMakeLists.txt
+++ b/source/gameengine/Rasterizer/CMakeLists.txt
@@ -31,6 +31,9 @@ SET(INC
../../../source/kernel/gen_system
../../../intern/string
../../../intern/moto/include
+ ../../../extern/glew/include
+ ../Expressions
+ ${PYTHON_INC}
)
BLENDERLIB(bf_rasterizer "${SRC}" "${INC}")
diff --git a/source/gameengine/Rasterizer/Makefile b/source/gameengine/Rasterizer/Makefile
index 3fb8dda588c..917f70c7108 100644
--- a/source/gameengine/Rasterizer/Makefile
+++ b/source/gameengine/Rasterizer/Makefile
@@ -35,13 +35,20 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
+CPPFLAGS += -I$(NAN_GLEW)/include
CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I../../kernel/gen_system
+CPPFLAGS += -I../BlenderRoutines
+CPPFLAGS += -I../Expressions
+
+CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
+
ifeq ($(OS),darwin)
CPPFLAGS += -fpascal-strings
endif
+
###############
SOURCEDIR = source/gameengine/Rasterizer
diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
new file mode 100644
index 00000000000..d2cfa7d07f9
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.cpp
@@ -0,0 +1,500 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#define STRINGIFY(A) #A
+
+#include "RAS_OpenGLFilters/RAS_Blur2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Sharpen2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Dilation2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Erosion2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Laplacian2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Sobel2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Prewitt2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_GrayScale2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Sepia2DFilter.h"
+#include "RAS_OpenGLFilters/RAS_Invert2DFilter.h"
+
+#include "STR_String.h"
+#include "RAS_ICanvas.h"
+#include "RAS_Rect.h"
+#include "RAS_2DFilterManager.h"
+#include <iostream>
+
+#include "GL/glew.h"
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "Value.h"
+
+RAS_2DFilterManager::RAS_2DFilterManager():
+texturewidth(-1), textureheight(-1),
+canvaswidth(-1), canvasheight(-1),
+numberoffilters(0)
+{
+ isshadersupported = GLEW_ARB_shader_objects &&
+ GLEW_ARB_fragment_shader && GLEW_ARB_multitexture;
+
+ if(!isshadersupported)
+ {
+ std::cout<<"shaders not supported!" << std::endl;
+ return;
+ }
+
+ int passindex;
+ for(passindex =0; passindex<MAX_RENDER_PASS; passindex++)
+ {
+ m_filters[passindex] = 0;
+ m_enabled[passindex] = 0;
+ texflag[passindex] = 0;
+ m_gameObjects[passindex] = NULL;
+ }
+ texname[0] = texname[1] = texname[2] = -1;
+ errorprinted= false;
+}
+
+RAS_2DFilterManager::~RAS_2DFilterManager()
+{
+ FreeTextures();
+}
+
+void RAS_2DFilterManager::PrintShaderErrors(unsigned int shader, const char *task, const char *code)
+{
+ GLcharARB log[5000];
+ GLsizei length = 0;
+ const char *c, *pos, *end;
+ int line = 1;
+
+ if(errorprinted)
+ return;
+
+ errorprinted= true;
+
+ glGetInfoLogARB(shader, sizeof(log), &length, log);
+ end = code + strlen(code);
+
+ printf("2D Filter GLSL Shader: %s error:\n", task);
+
+ c = code;
+ while ((c < end) && (pos = strchr(c, '\n'))) {
+ printf("%2d ", line);
+ fwrite(c, (pos+1)-c, 1, stdout);
+ c = pos+1;
+ line++;
+ }
+ printf("%s", c);
+
+ printf("%s\n", log);
+}
+
+unsigned int RAS_2DFilterManager::CreateShaderProgram(const char* shadersource)
+{
+ GLuint program = 0;
+ GLuint fShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER);
+ GLint success;
+
+ glShaderSourceARB(fShader, 1, (const char**)&shadersource, NULL);
+
+ glCompileShaderARB(fShader);
+
+
+ glGetObjectParameterivARB(fShader, GL_COMPILE_STATUS, &success);
+ if(!success)
+ {
+ /*Shader Comile Error*/
+ PrintShaderErrors(fShader, "compile", shadersource);
+ return 0;
+ }
+
+ program = glCreateProgramObjectARB();
+ glAttachObjectARB(program, fShader);
+
+ glLinkProgramARB(program);
+ glGetObjectParameterivARB(program, GL_LINK_STATUS, &success);
+ if (!success)
+ {
+ /*Program Link Error*/
+ PrintShaderErrors(fShader, "link", shadersource);
+ return 0;
+ }
+
+ glValidateProgramARB(program);
+ glGetObjectParameterivARB(program, GL_VALIDATE_STATUS, &success);
+ if (!success)
+ {
+ /*Program Validation Error*/
+ PrintShaderErrors(fShader, "validate", shadersource);
+ return 0;
+ }
+
+ return program;
+}
+
+unsigned int RAS_2DFilterManager::CreateShaderProgram(int filtermode)
+{
+ switch(filtermode)
+ {
+ case RAS_2DFILTER_BLUR:
+ return CreateShaderProgram(BlurFragmentShader);
+ case RAS_2DFILTER_SHARPEN:
+ return CreateShaderProgram(SharpenFragmentShader);
+ case RAS_2DFILTER_DILATION:
+ return CreateShaderProgram(DilationFragmentShader);
+ case RAS_2DFILTER_EROSION:
+ return CreateShaderProgram(ErosionFragmentShader);
+ case RAS_2DFILTER_LAPLACIAN:
+ return CreateShaderProgram(LaplacionFragmentShader);
+ case RAS_2DFILTER_SOBEL:
+ return CreateShaderProgram(SobelFragmentShader);
+ case RAS_2DFILTER_PREWITT:
+ return CreateShaderProgram(PrewittFragmentShader);
+ case RAS_2DFILTER_GRAYSCALE:
+ return CreateShaderProgram(GrayScaleFragmentShader);
+ case RAS_2DFILTER_SEPIA:
+ return CreateShaderProgram(SepiaFragmentShader);
+ case RAS_2DFILTER_INVERT:
+ return CreateShaderProgram(InvertFragmentShader);
+ }
+ return 0;
+}
+
+void RAS_2DFilterManager::AnalyseShader(int passindex, vector<STR_String>& propNames)
+{
+ texflag[passindex] = 0;
+ if(glGetUniformLocationARB(m_filters[passindex], "bgl_DepthTexture") != -1)
+ {
+ if(GLEW_ARB_depth_texture)
+ texflag[passindex] |= 0x1;
+ }
+ if(glGetUniformLocationARB(m_filters[passindex], "bgl_LuminanceTexture") != -1)
+ {
+ texflag[passindex] |= 0x2;
+ }
+
+ if(m_gameObjects[passindex])
+ {
+ int objProperties = propNames.size();
+ int i;
+ for(i=0; i<objProperties; i++)
+ if(glGetUniformLocationARB(m_filters[passindex], propNames[i]) != -1)
+ m_properties[passindex].push_back(propNames[i]);
+ }
+}
+
+void RAS_2DFilterManager::StartShaderProgram(int passindex)
+{
+ GLint uniformLoc;
+ glUseProgramObjectARB(m_filters[passindex]);
+ uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTexture");
+ glActiveTextureARB(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, texname[0]);
+
+ if (uniformLoc != -1)
+ {
+ glUniform1iARB(uniformLoc, 0);
+ }
+
+ /* send depth texture to glsl program if it needs */
+ if(texflag[passindex] & 0x1){
+ uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_DepthTexture");
+ glActiveTextureARB(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, texname[1]);
+
+ if (uniformLoc != -1)
+ {
+ glUniform1iARB(uniformLoc, 1);
+ }
+ }
+
+ /* send luminance texture to glsl program if it needs */
+ if(texflag[passindex] & 0x2){
+ uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_LuminanceTexture");
+ glActiveTextureARB(GL_TEXTURE2);
+ glBindTexture(GL_TEXTURE_2D, texname[2]);
+
+ if (uniformLoc != -1)
+ {
+ glUniform1iARB(uniformLoc, 2);
+ }
+ }
+
+ uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_TextureCoordinateOffset");
+ if (uniformLoc != -1)
+ {
+ glUniform2fvARB(uniformLoc, 9, textureoffsets);
+ }
+ uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureWidth");
+ if (uniformLoc != -1)
+ {
+ glUniform1fARB(uniformLoc,texturewidth);
+ }
+ uniformLoc = glGetUniformLocationARB(m_filters[passindex], "bgl_RenderedTextureHeight");
+ if (uniformLoc != -1)
+ {
+ glUniform1fARB(uniformLoc,textureheight);
+ }
+
+ int i, objProperties = m_properties[passindex].size();
+ for(i=0; i<objProperties; i++)
+ {
+ uniformLoc = glGetUniformLocationARB(m_filters[passindex], m_properties[passindex][i]);
+ if(uniformLoc != -1)
+ {
+ float value = ((CValue*)m_gameObjects[passindex])->GetPropertyNumber(m_properties[passindex][i], 0.0);
+ glUniform1fARB(uniformLoc,value);
+ }
+ }
+}
+
+void RAS_2DFilterManager::EndShaderProgram()
+{
+ glUseProgramObjectARB(0);
+}
+
+void RAS_2DFilterManager::FreeTextures()
+{
+ if(texname[0]!=(unsigned int)-1)
+ glDeleteTextures(1, (GLuint*)&texname[0]);
+ if(texname[1]!=(unsigned int)-1)
+ glDeleteTextures(1, (GLuint*)&texname[1]);
+ if(texname[2]!=(unsigned int)-1)
+ glDeleteTextures(1, (GLuint*)&texname[2]);
+}
+
+void RAS_2DFilterManager::SetupTextures(bool depth, bool luminance)
+{
+ FreeTextures();
+
+ glGenTextures(1, (GLuint*)&texname[0]);
+ glBindTexture(GL_TEXTURE_2D, texname[0]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texturewidth, textureheight, 0, GL_RGBA,
+ GL_UNSIGNED_BYTE, 0);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+
+ if(depth){
+ glGenTextures(1, (GLuint*)&texname[1]);
+ glBindTexture(GL_TEXTURE_2D, texname[1]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32, texturewidth,textureheight,
+ 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE,NULL);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE,
+ GL_NONE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ }
+
+ if(luminance){
+ glGenTextures(1, (GLuint*)&texname[2]);
+ glBindTexture(GL_TEXTURE_2D, texname[2]);
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE16, texturewidth, textureheight,
+ 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ }
+}
+
+void RAS_2DFilterManager::UpdateOffsetMatrix(RAS_ICanvas* canvas)
+{
+ RAS_Rect canvas_rect = canvas->GetWindowArea();
+ canvaswidth = canvas->GetWidth();
+ canvasheight = canvas->GetHeight();
+ texturewidth = canvaswidth;
+ textureheight = canvasheight;
+
+ GLint i,j;
+ i = 0;
+ while ((1 << i) <= texturewidth)
+ i++;
+ texturewidth = (1 << (i));
+
+ // Now for height
+ i = 0;
+ while ((1 << i) <= textureheight)
+ i++;
+ textureheight = (1 << (i));
+
+ GLfloat xInc = 1.0f / (GLfloat)texturewidth;
+ GLfloat yInc = 1.0f / (GLfloat)textureheight;
+
+ for (i = 0; i < 3; i++)
+ {
+ for (j = 0; j < 3; j++)
+ {
+ textureoffsets[(((i*3)+j)*2)+0] = (-1.0f * xInc) + ((GLfloat)i * xInc);
+ textureoffsets[(((i*3)+j)*2)+1] = (-1.0f * yInc) + ((GLfloat)j * yInc);
+ }
+ }
+}
+
+void RAS_2DFilterManager::RenderFilters(RAS_ICanvas* canvas)
+{
+ bool need_depth=false;
+ bool need_luminance=false;
+ int num_filters = 0;
+
+ int passindex;
+
+ if(!isshadersupported)
+ return;
+
+ for(passindex =0; passindex<MAX_RENDER_PASS; passindex++)
+ {
+ if(m_filters[passindex] && m_enabled[passindex]){
+ num_filters ++;
+ if(texflag[passindex] & 0x1)
+ need_depth = true;
+ if(texflag[passindex] & 0x2)
+ need_luminance = true;
+ if(need_depth && need_luminance)
+ break;
+ }
+ }
+
+ if(num_filters <= 0)
+ return;
+
+ if(canvaswidth != canvas->GetWidth() || canvasheight != canvas->GetHeight())
+ {
+ UpdateOffsetMatrix(canvas);
+ SetupTextures(need_depth, need_luminance);
+ }
+ GLuint viewport[4]={0};
+
+ if(need_depth){
+ glActiveTextureARB(GL_TEXTURE1);
+ glBindTexture(GL_TEXTURE_2D, texname[1]);
+ glCopyTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT, viewport[0], viewport[1], texturewidth,textureheight, 0);
+ }
+
+ if(need_luminance){
+ glActiveTextureARB(GL_TEXTURE2);
+ glBindTexture(GL_TEXTURE_2D, texname[2]);
+ glCopyTexImage2D(GL_TEXTURE_2D,0,GL_LUMINANCE16, viewport[0], viewport[1] , texturewidth,textureheight, 0);
+ }
+
+ glGetIntegerv(GL_VIEWPORT,(GLint *)viewport);
+ glViewport(viewport[0],viewport[1], texturewidth, textureheight);
+
+ glDisable(GL_DEPTH_TEST);
+ glMatrixMode(GL_TEXTURE);
+ glLoadIdentity();
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+
+ for(passindex =0; passindex<MAX_RENDER_PASS; passindex++)
+ {
+ if(m_filters[passindex] && m_enabled[passindex])
+ {
+ StartShaderProgram(passindex);
+
+ glActiveTextureARB(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, texname[0]);
+ glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, viewport[0], viewport[1], texturewidth, textureheight, 0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ float canvascoordx, canvascoordy;
+
+ canvascoordx = (GLfloat) texturewidth / canvaswidth;
+ canvascoordy = (GLfloat) textureheight / canvasheight;
+
+ glBegin(GL_QUADS);
+ glColor4f(1.f, 1.f, 1.f, 1.f);
+ glTexCoord2f(1.0, 1.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, canvascoordx, canvascoordy); glVertex2f(1,1);
+ glTexCoord2f(0.0, 1.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, canvascoordy); glVertex2f(-1,1);
+ glTexCoord2f(0.0, 0.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, 0.0, 0.0); glVertex2f(-1,-1);
+ glTexCoord2f(1.0, 0.0); glMultiTexCoord2fARB(GL_TEXTURE1_ARB, canvascoordx, 0.0); glVertex2f(1,-1);
+ glEnd();
+ }
+ }
+
+ glEnable(GL_DEPTH_TEST);
+ glViewport(viewport[0],viewport[1],viewport[2],viewport[3]);
+ EndShaderProgram();
+}
+
+void RAS_2DFilterManager::EnableFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text)
+{
+ if(!isshadersupported)
+ return;
+ if(pass<0 || pass>=MAX_RENDER_PASS)
+ return;
+
+ if(mode == RAS_2DFILTER_DISABLED)
+ {
+ m_enabled[pass] = 0;
+ return;
+ }
+
+ if(mode == RAS_2DFILTER_ENABLED)
+ {
+ m_enabled[pass] = 1;
+ return;
+ }
+
+ if(mode == RAS_2DFILTER_NOFILTER)
+ {
+ if(m_filters[pass])
+ glDeleteObjectARB(m_filters[pass]);
+ m_enabled[pass] = 0;
+ m_filters[pass] = 0;
+ m_gameObjects[pass] = NULL;
+ m_properties[pass].clear();
+ texflag[pass] = 0;
+ return;
+ }
+
+ if(mode == RAS_2DFILTER_CUSTOMFILTER)
+ {
+ if(m_filters[pass])
+ glDeleteObjectARB(m_filters[pass]);
+ m_filters[pass] = CreateShaderProgram(text.Ptr());
+ m_gameObjects[pass] = gameObj;
+ AnalyseShader(pass, propNames);
+ m_enabled[pass] = 1;
+ return;
+ }
+
+ if(mode>=RAS_2DFILTER_MOTIONBLUR && mode<=RAS_2DFILTER_INVERT)
+ {
+ if(m_filters[pass])
+ glDeleteObjectARB(m_filters[pass]);
+ m_filters[pass] = CreateShaderProgram(mode);
+ m_enabled[pass] = 1;
+ }
+}
diff --git a/source/gameengine/Rasterizer/RAS_2DFilterManager.h b/source/gameengine/Rasterizer/RAS_2DFilterManager.h
new file mode 100644
index 00000000000..454643a5077
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_2DFilterManager.h
@@ -0,0 +1,98 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_I2DFILTER
+#define __RAS_I2DFILTER
+
+#define MAX_RENDER_PASS 100
+
+class RAS_2DFilterManager
+{
+private:
+ unsigned int CreateShaderProgram(const char* shadersource);
+ unsigned int CreateShaderProgram(int filtermode);
+ void AnalyseShader(int passindex, vector<STR_String>& propNames);
+ void StartShaderProgram(int passindex);
+ void EndShaderProgram();
+ void PrintShaderErrors(unsigned int shader, const char *task, const char *code);
+
+ void SetupTextures(bool depth, bool luminance);
+ void FreeTextures();
+
+ void UpdateOffsetMatrix(RAS_ICanvas* canvas);
+
+ float textureoffsets[18];
+ float view[4];
+ /* texname[0] contains render to texture, texname[1] contains depth texture, texname[2] contains luminance texture*/
+ unsigned int texname[3];
+ int texturewidth;
+ int textureheight;
+ int canvaswidth;
+ int canvasheight;
+ int numberoffilters;
+ /* bit 0: enable/disable depth texture
+ * bit 1: enable/disable luminance texture*/
+ short texflag[MAX_RENDER_PASS];
+
+ bool isshadersupported;
+ bool errorprinted;
+
+ unsigned int m_filters[MAX_RENDER_PASS];
+ short m_enabled[MAX_RENDER_PASS];
+
+ // stores object properties to send to shaders in each pass
+ vector<STR_String> m_properties[MAX_RENDER_PASS];
+ void* m_gameObjects[MAX_RENDER_PASS];
+public:
+ enum RAS_2DFILTER_MODE {
+ RAS_2DFILTER_ENABLED = -2,
+ RAS_2DFILTER_DISABLED = -1,
+ RAS_2DFILTER_NOFILTER = 0,
+ RAS_2DFILTER_MOTIONBLUR,
+ RAS_2DFILTER_BLUR,
+ RAS_2DFILTER_SHARPEN,
+ RAS_2DFILTER_DILATION,
+ RAS_2DFILTER_EROSION,
+ RAS_2DFILTER_LAPLACIAN,
+ RAS_2DFILTER_SOBEL,
+ RAS_2DFILTER_PREWITT,
+ RAS_2DFILTER_GRAYSCALE,
+ RAS_2DFILTER_SEPIA,
+ RAS_2DFILTER_INVERT,
+ RAS_2DFILTER_CUSTOMFILTER,
+ RAS_2DFILTER_NUMBER_OF_FILTERS
+ };
+
+ RAS_2DFilterManager();
+
+ ~RAS_2DFilterManager();
+
+ void RenderFilters(RAS_ICanvas* canvas);
+
+ void EnableFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFILTER_MODE mode, int pass, STR_String& text);
+};
+#endif
diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.cpp b/source/gameengine/Rasterizer/RAS_BucketManager.cpp
index 48e761cfc5a..f7938bb62e6 100644
--- a/source/gameengine/Rasterizer/RAS_BucketManager.cpp
+++ b/source/gameengine/Rasterizer/RAS_BucketManager.cpp
@@ -26,10 +26,6 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifdef WIN32
// don't show these anoying STL warnings
#pragma warning (disable:4786)
@@ -39,156 +35,236 @@
#include "RAS_MaterialBucket.h"
#include "STR_HashedString.h"
#include "RAS_MeshObject.h"
-#define KX_NUM_MATERIALBUCKETS 100
#include "RAS_IRasterizer.h"
#include "RAS_IRenderTools.h"
#include "RAS_BucketManager.h"
+#include <algorithm>
#include <set>
-RAS_BucketManager::RAS_BucketManager()
+/* sorting */
+
+struct RAS_BucketManager::sortedmeshslot
{
+public:
+ MT_Scalar m_z; /* depth */
+ RAS_MeshSlot *m_ms; /* mesh slot */
+ RAS_MaterialBucket *m_bucket; /* buck mesh slot came from */
-}
+ sortedmeshslot() {}
-RAS_BucketManager::~RAS_BucketManager()
-{
- RAS_BucketManagerClearAll();
-}
+ void set(RAS_MeshSlot *ms, RAS_MaterialBucket *bucket, const MT_Vector3& pnorm)
+ {
+ // would be good to use the actual bounding box center instead
+ MT_Point3 pos(ms->m_OpenGLMatrix[12], ms->m_OpenGLMatrix[13], ms->m_OpenGLMatrix[14]);
-/**
- * struct alphamesh holds a mesh, (m_ms) it's depth, (m_z) and the bucket it came from (m_bucket.)
- */
-struct RAS_BucketManager::alphamesh
-{
-public:
- MT_Scalar m_z;
- RAS_MaterialBucket::T_MeshSlotList::iterator m_ms;
- RAS_MaterialBucket *m_bucket;
- alphamesh(MT_Scalar z, RAS_MaterialBucket::T_MeshSlotList::iterator &ms, RAS_MaterialBucket *bucket) :
- m_z(z),
- m_ms(ms),
- m_bucket(bucket)
- {}
+ m_z = MT_dot(pnorm, pos);
+ m_ms = ms;
+ m_bucket = bucket;
+ }
};
struct RAS_BucketManager::backtofront
{
- bool operator()(const alphamesh &a, const alphamesh &b)
+ bool operator()(const sortedmeshslot &a, const sortedmeshslot &b)
{
- return a.m_z < b.m_z;
+ return (a.m_z < b.m_z) || (a.m_z == b.m_z && a.m_ms < b.m_ms);
}
};
-
-void RAS_BucketManager::RenderAlphaBuckets(
- const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools)
+struct RAS_BucketManager::fronttoback
{
- BucketList::iterator bit;
- std::multiset<alphamesh, backtofront> alphameshset;
- RAS_MaterialBucket::T_MeshSlotList::iterator mit;
-
- /* Camera's near plane equation: cam_norm.dot(point) + cam_origin */
- const MT_Vector3 cam_norm(cameratrans.getBasis()[2]);
- const MT_Scalar cam_origin = cameratrans.getOrigin()[2];
- for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit)
+ bool operator()(const sortedmeshslot &a, const sortedmeshslot &b)
{
- (*bit)->ClearScheduledPolygons();
- for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit)
- {
- if ((*mit).m_bVisible)
- {
- MT_Point3 pos((*mit).m_OpenGLMatrix[12], (*mit).m_OpenGLMatrix[13], (*mit).m_OpenGLMatrix[14]);
- alphameshset.insert(alphamesh(MT_dot(cam_norm, pos) + cam_origin, mit, *bit));
- }
- }
+ return (a.m_z > b.m_z) || (a.m_z == b.m_z && a.m_ms > b.m_ms);
}
+};
+
+/* bucket manager */
+
+RAS_BucketManager::RAS_BucketManager()
+{
+
+}
+
+RAS_BucketManager::~RAS_BucketManager()
+{
+ BucketList::iterator it;
+
+ for (it = m_SolidBuckets.begin(); it != m_SolidBuckets.end(); it++)
+ delete (*it);
+
+ for (it = m_AlphaBuckets.begin(); it != m_AlphaBuckets.end(); it++)
+ delete(*it);
- // It shouldn't be strictly necessary to disable depth writes; but
- // it is needed for compatibility.
+ m_SolidBuckets.clear();
+ m_AlphaBuckets.clear();
+}
+
+void RAS_BucketManager::OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector<sortedmeshslot>& slots, bool alpha)
+{
+ BucketList::iterator bit;
+ list<RAS_MeshSlot>::iterator mit;
+ size_t size = 0, i = 0;
+
+ /* Camera's near plane equation: pnorm.dot(point) + pval,
+ * but we leave out pval since it's constant anyway */
+ const MT_Vector3 pnorm(cameratrans.getBasis()[2]);
+
+ for (bit = buckets.begin(); bit != buckets.end(); ++bit)
+ for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit)
+ if (!mit->IsCulled())
+ size++;
+
+ slots.resize(size);
+
+ for (bit = buckets.begin(); bit != buckets.end(); ++bit)
+ for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit)
+ if (!mit->IsCulled())
+ slots[i++].set(&*mit, *bit, pnorm);
+
+ if(alpha)
+ sort(slots.begin(), slots.end(), backtofront());
+ else
+ sort(slots.begin(), slots.end(), fronttoback());
+}
+
+void RAS_BucketManager::RenderAlphaBuckets(
+ const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools)
+{
+ vector<sortedmeshslot> slots;
+ vector<sortedmeshslot>::iterator sit;
+
+ // Having depth masks disabled/enabled gives different artifacts in
+ // case no sorting is done or is done inexact. For compatibility, we
+ // disable it.
rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_DISABLED);
- int drawingmode;
- std::multiset< alphamesh, backtofront>::iterator msit = alphameshset.begin();
- for (; msit != alphameshset.end(); ++msit)
- {
- while ((*msit).m_bucket->ActivateMaterial(cameratrans, rasty, rendertools, drawingmode))
- (*msit).m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(*msit).m_ms, drawingmode);
- }
+ OrderBuckets(cameratrans, m_AlphaBuckets, slots, true);
+ for(sit=slots.begin(); sit!=slots.end(); ++sit) {
+ rendertools->SetClientObject(rasty, sit->m_ms->m_clientObj);
+
+ while(sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools))
+ sit->m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(sit->m_ms));
+ }
+
rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED);
}
-void RAS_BucketManager::Renderbuckets(
+void RAS_BucketManager::RenderSolidBuckets(
const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools)
{
- BucketList::iterator bucket;
-
- rasty->EnableTextures(false);
+ BucketList::iterator bit;
+ list<RAS_MeshSlot>::iterator mit;
+
rasty->SetDepthMask(RAS_IRasterizer::KX_DEPTHMASK_ENABLED);
-
- // beginning each frame, clear (texture/material) caching information
- rasty->ClearCachingInfo();
- RAS_MaterialBucket::StartFrame();
- for (bucket = m_MaterialBuckets.begin(); bucket != m_MaterialBuckets.end(); ++bucket)
- {
- (*bucket)->ClearScheduledPolygons();
+ for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) {
+ for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
+ if (mit->IsCulled())
+ continue;
+
+ rendertools->SetClientObject(rasty, mit->m_clientObj);
+
+ while ((*bit)->ActivateMaterial(cameratrans, rasty, rendertools))
+ (*bit)->RenderMeshSlot(cameratrans, rasty, rendertools, *mit);
+ }
}
- for (bucket = m_MaterialBuckets.begin(); bucket != m_MaterialBuckets.end(); ++bucket)
- {
- RAS_IPolyMaterial *tmp = (*bucket)->GetPolyMaterial();
- if(tmp->IsZSort() || tmp->GetFlag() &RAS_FORCEALPHA )
- rasty->SetAlphaTest(true);
- else
- rasty->SetAlphaTest(false);
+ /* this code draws meshes order front-to-back instead to reduce overdraw.
+ * it turned out slower due to much material state switching, a more clever
+ * algorithm might do better. */
+#if 0
+ vector<sortedmeshslot> slots;
+ vector<sortedmeshslot>::iterator sit;
+
+ OrderBuckets(cameratrans, m_SolidBuckets, slots, false);
+
+ for(sit=slots.begin(); sit!=slots.end(); ++sit) {
+ rendertools->SetClientObject(rasty, sit->m_ms->m_clientObj);
- (*bucket)->Render(cameratrans,rasty,rendertools);
+ while(sit->m_bucket->ActivateMaterial(cameratrans, rasty, rendertools))
+ sit->m_bucket->RenderMeshSlot(cameratrans, rasty, rendertools, *(sit->m_ms));
}
- rasty->SetAlphaTest(false);
+#endif
+}
+
+void RAS_BucketManager::Renderbuckets(
+ const MT_Transform& cameratrans, RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools)
+{
+ /* beginning each frame, clear (texture/material) caching information */
+ rasty->ClearCachingInfo();
+ RenderSolidBuckets(cameratrans, rasty, rendertools);
RenderAlphaBuckets(cameratrans, rasty, rendertools);
- RAS_MaterialBucket::EndFrame();
+
+ rendertools->SetClientObject(rasty, NULL);
}
-RAS_MaterialBucket* RAS_BucketManager::RAS_BucketManagerFindBucket(RAS_IPolyMaterial * material)
+RAS_MaterialBucket* RAS_BucketManager::FindBucket(RAS_IPolyMaterial * material, bool &bucketCreated)
{
BucketList::iterator it;
- for (it = m_MaterialBuckets.begin(); it != m_MaterialBuckets.end(); it++)
- {
+
+ bucketCreated = false;
+
+ for (it = m_SolidBuckets.begin(); it != m_SolidBuckets.end(); it++)
if (*(*it)->GetPolyMaterial() == *material)
return *it;
- }
for (it = m_AlphaBuckets.begin(); it != m_AlphaBuckets.end(); it++)
- {
if (*(*it)->GetPolyMaterial() == *material)
return *it;
- }
RAS_MaterialBucket *bucket = new RAS_MaterialBucket(material);
- if (bucket->IsTransparant())
+ bucketCreated = true;
+
+ if (bucket->IsAlpha())
m_AlphaBuckets.push_back(bucket);
else
- m_MaterialBuckets.push_back(bucket);
+ m_SolidBuckets.push_back(bucket);
return bucket;
}
-void RAS_BucketManager::RAS_BucketManagerClearAll()
+void RAS_BucketManager::OptimizeBuckets(MT_Scalar distance)
{
- BucketList::iterator it;
- for (it = m_MaterialBuckets.begin(); it != m_MaterialBuckets.end(); it++)
- {
- delete (*it);
- }
- for (it = m_AlphaBuckets.begin(); it != m_AlphaBuckets.end(); it++)
- {
- delete(*it);
+ BucketList::iterator bit;
+
+ distance = 10.0;
+
+ for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit)
+ (*bit)->Optimize(distance);
+ for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit)
+ (*bit)->Optimize(distance);
+}
+
+void RAS_BucketManager::ReleaseDisplayLists(RAS_IPolyMaterial *mat)
+{
+ BucketList::iterator bit;
+ list<RAS_MeshSlot>::iterator mit;
+
+ for (bit = m_SolidBuckets.begin(); bit != m_SolidBuckets.end(); ++bit) {
+ if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) {
+ for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
+ if(mit->m_DisplayList) {
+ mit->m_DisplayList->Release();
+ mit->m_DisplayList = NULL;
+ }
+ }
+ }
}
- m_MaterialBuckets.clear();
- m_AlphaBuckets.clear();
+ for (bit = m_AlphaBuckets.begin(); bit != m_AlphaBuckets.end(); ++bit) {
+ if (mat == NULL || (mat == (*bit)->GetPolyMaterial())) {
+ for (mit = (*bit)->msBegin(); mit != (*bit)->msEnd(); ++mit) {
+ if(mit->m_DisplayList) {
+ mit->m_DisplayList->Release();
+ mit->m_DisplayList = NULL;
+ }
+ }
+ }
+ }
}
+
diff --git a/source/gameengine/Rasterizer/RAS_BucketManager.h b/source/gameengine/Rasterizer/RAS_BucketManager.h
index d99053c1e37..74526f365a0 100644
--- a/source/gameengine/Rasterizer/RAS_BucketManager.h
+++ b/source/gameengine/Rasterizer/RAS_BucketManager.h
@@ -39,31 +39,33 @@
class RAS_BucketManager
{
- //GEN_Map<class RAS_IPolyMaterial,class RAS_MaterialBucket*> m_MaterialBuckets;
-
typedef std::vector<class RAS_MaterialBucket*> BucketList;
- BucketList m_MaterialBuckets;
+ BucketList m_SolidBuckets;
BucketList m_AlphaBuckets;
- struct alphamesh;
+ struct sortedmeshslot;
struct backtofront;
+ struct fronttoback;
public:
RAS_BucketManager();
virtual ~RAS_BucketManager();
- void RenderAlphaBuckets(const MT_Transform& cameratrans,
- RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools);
void Renderbuckets(const MT_Transform & cameratrans,
- RAS_IRasterizer* rasty,
- class RAS_IRenderTools* rendertools);
+ RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools);
- RAS_MaterialBucket* RAS_BucketManagerFindBucket(RAS_IPolyMaterial * material);
+ RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial * material, bool &bucketCreated);
+ void OptimizeBuckets(MT_Scalar distance);
+ void ReleaseDisplayLists(RAS_IPolyMaterial * material = NULL);
private:
- void RAS_BucketManagerClearAll();
+ void OrderBuckets(const MT_Transform& cameratrans, BucketList& buckets, vector<sortedmeshslot>& slots, bool alpha);
+ void RenderSolidBuckets(const MT_Transform& cameratrans,
+ RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools);
+ void RenderAlphaBuckets(const MT_Transform& cameratrans,
+ RAS_IRasterizer* rasty, RAS_IRenderTools* rendertools);
};
#endif //__RAS_BUCKETMANAGER
diff --git a/source/gameengine/Rasterizer/RAS_CameraData.h b/source/gameengine/Rasterizer/RAS_CameraData.h
index 99c0c412cf7..e3af43fb839 100644
--- a/source/gameengine/Rasterizer/RAS_CameraData.h
+++ b/source/gameengine/Rasterizer/RAS_CameraData.h
@@ -40,9 +40,11 @@ struct RAS_CameraData
int m_viewportbottom;
int m_viewportright;
int m_viewporttop;
+ float m_focallength;
- RAS_CameraData(float lens = 35., float clipstart = 0.1, float clipend = 100., bool perspective = true,
- bool viewport = false, int viewportleft = 0, int viewportbottom = 0, int viewportright = 0, int viewporttop = 0) :
+ RAS_CameraData(float lens = 35.0, float clipstart = 0.1, float clipend = 5000.0, bool perspective = true,
+ float focallength = 0.0f, bool viewport = false, int viewportleft = 0, int viewportbottom = 0,
+ int viewportright = 0, int viewporttop = 0) :
m_lens(lens),
m_clipstart(clipstart),
m_clipend(clipend),
@@ -51,7 +53,8 @@ struct RAS_CameraData
m_viewportleft(viewportleft),
m_viewportbottom(viewportbottom),
m_viewportright(viewportright),
- m_viewporttop(viewporttop)
+ m_viewporttop(viewporttop),
+ m_focallength(focallength)
{
}
};
diff --git a/source/gameengine/Rasterizer/RAS_Deformer.h b/source/gameengine/Rasterizer/RAS_Deformer.h
index bea68e203a9..3332ac4c0a7 100644
--- a/source/gameengine/Rasterizer/RAS_Deformer.h
+++ b/source/gameengine/Rasterizer/RAS_Deformer.h
@@ -43,8 +43,12 @@ public:
virtual ~RAS_Deformer(){};
virtual void Relink(GEN_Map<class GEN_HashedPtr, void*>*map)=0;
virtual bool Apply(class RAS_IPolyMaterial *polymat)=0;
- virtual void Update(void)=0;
- virtual RAS_Deformer *GetReplica()=0;
+ virtual bool Update(void)=0;
+ virtual RAS_Deformer *GetReplica(class KX_GameObject* replica)=0;
+ virtual bool SkipVertexTransform()
+ {
+ return false;
+ }
protected:
class RAS_MeshObject *m_pMesh;
};
diff --git a/source/gameengine/Rasterizer/RAS_FramingManager.h b/source/gameengine/Rasterizer/RAS_FramingManager.h
index dcb48c1c2a0..9cb59f300f7 100644
--- a/source/gameengine/Rasterizer/RAS_FramingManager.h
+++ b/source/gameengine/Rasterizer/RAS_FramingManager.h
@@ -108,6 +108,13 @@ public :
) const {
return m_frame_type;
};
+
+ void
+ SetFrameType(
+ RAS_FrameType type
+ ) {
+ m_frame_type = type;
+ };
float
BarRed(
@@ -140,14 +147,6 @@ public :
};
private :
-
- /**
- * private to force use of public constructor
- */
-
- RAS_FrameSettings(
- const RAS_FrameSettings &
- );
RAS_FrameType m_frame_type;
float m_bar_r;
diff --git a/source/gameengine/Rasterizer/RAS_ICanvas.h b/source/gameengine/Rasterizer/RAS_ICanvas.h
index d799dc9c9bb..f3f817a943d 100644
--- a/source/gameengine/Rasterizer/RAS_ICanvas.h
+++ b/source/gameengine/Rasterizer/RAS_ICanvas.h
@@ -137,6 +137,14 @@ public:
) = 0;
/**
+ * Used to get canvas area within blender.
+ */
+ virtual
+ RAS_Rect &
+ GetWindowArea(
+ ) = 0;
+
+ /**
* Set the visible vieport
*/
diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
index 61860c4c405..fb3607f89f4 100644
--- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
+++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.cpp
@@ -27,6 +27,7 @@
*/
#include "RAS_IPolygonMaterial.h"
+#include "RAS_IRasterizer.h"
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -38,25 +39,22 @@ RAS_IPolyMaterial::RAS_IPolyMaterial(const STR_String& texname,
int tilexrep,
int tileyrep,
int mode,
- bool transparant,
+ int transp,
+ bool alpha,
bool zsort,
- int lightlayer,
- bool bIsTriangle,
- void* clientobject=NULL) :
-
- m_texturename(texname),
+ int lightlayer)
+ : m_texturename(texname),
m_materialname(matname),
m_tile(tile),
m_tilexrep(tilexrep),
m_tileyrep(tileyrep),
m_drawingmode (mode),
- m_transparant(transparant),
+ m_transp(transp),
+ m_alpha(alpha),
m_zsort(zsort),
m_lightlayer(lightlayer),
- m_bIsTriangle(bIsTriangle),
m_polymatid(m_newpolymatid++),
m_flag(0),
- m_enabled(0),
m_multimode(0)
{
m_shininess = 35.0;
@@ -70,14 +68,16 @@ bool RAS_IPolyMaterial::Equals(const RAS_IPolyMaterial& lhs) const
{
if(m_flag &RAS_BLENDERMAT)
{
- return (
+ bool test = (
this->m_multimode == lhs.m_multimode &&
this->m_flag == lhs.m_flag &&
this->m_drawingmode == lhs.m_drawingmode &&
- this->m_lightlayer == lhs.m_lightlayer &&
+ this->m_transp == lhs.m_transp &&
this->m_texturename.hash() == lhs.m_texturename.hash() &&
this->m_materialname.hash() == lhs.m_materialname.hash()
);
+
+ return test;
}
else
{
@@ -85,11 +85,10 @@ bool RAS_IPolyMaterial::Equals(const RAS_IPolyMaterial& lhs) const
this->m_tile == lhs.m_tile &&
this->m_tilexrep == lhs.m_tilexrep &&
this->m_tileyrep == lhs.m_tileyrep &&
- this->m_transparant == lhs.m_transparant &&
+ this->m_transp == lhs.m_transp &&
+ this->m_alpha == lhs.m_alpha &&
this->m_zsort == lhs.m_zsort &&
this->m_drawingmode == lhs.m_drawingmode &&
- this->m_bIsTriangle == lhs.m_bIsTriangle &&
- this->m_lightlayer == lhs.m_lightlayer &&
this->m_texturename.hash() == lhs.m_texturename.hash() &&
this->m_materialname.hash() == lhs.m_materialname.hash()
);
@@ -109,9 +108,9 @@ int RAS_IPolyMaterial::GetLightLayer() const
return m_lightlayer;
}
-bool RAS_IPolyMaterial::IsTransparant() const
+bool RAS_IPolyMaterial::IsAlpha() const
{
- return m_transparant;
+ return m_alpha || m_zsort;
}
bool RAS_IPolyMaterial::IsZSort() const
@@ -119,11 +118,6 @@ bool RAS_IPolyMaterial::IsZSort() const
return m_zsort;
}
-bool RAS_IPolyMaterial::UsesTriangles() const
-{
- return m_bIsTriangle;
-}
-
unsigned int RAS_IPolyMaterial::hash() const
{
return m_texturename.hash();
@@ -139,6 +133,11 @@ const STR_String& RAS_IPolyMaterial::GetMaterialName() const
return m_materialname;
}
+dword RAS_IPolyMaterial::GetMaterialNameHash() const
+{
+ return m_materialname.hash();
+}
+
const STR_String& RAS_IPolyMaterial::GetTextureName() const
{
return m_texturename;
@@ -148,10 +147,25 @@ const unsigned int RAS_IPolyMaterial::GetFlag() const
{
return m_flag;
}
-const unsigned int RAS_IPolyMaterial::GetEnabled() const
+
+bool RAS_IPolyMaterial::UsesLighting(RAS_IRasterizer *rasty) const
{
- return m_enabled;
+ bool dolights = false;
+
+ if(m_flag & RAS_BLENDERMAT)
+ dolights = (m_flag &RAS_MULTILIGHT)!=0;
+ else if(rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID);
+ else if(rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW);
+ else
+ dolights = (m_drawingmode & 16)!=0;
+
+ return dolights;
}
+bool RAS_IPolyMaterial::UsesObjectColor() const
+{
+ return !(m_flag & RAS_BLENDERGLSL);
+}
unsigned int RAS_IPolyMaterial::m_newpolymatid = 0;
+
diff --git a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
index 3284ddb7ddd..218dd91cb30 100644
--- a/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
+++ b/source/gameengine/Rasterizer/RAS_IPolygonMaterial.h
@@ -52,7 +52,7 @@ enum MaterialProps
RAS_AUTOGEN =128,
RAS_NORMAL =256,
RAS_DEFMULTI =512,
- RAS_FORCEALPHA =1024
+ RAS_BLENDERGLSL =1024
};
/**
@@ -67,17 +67,16 @@ protected:
int m_tile;
int m_tilexrep,m_tileyrep;
int m_drawingmode; // tface->mode
- bool m_transparant;
+ int m_transp;
+ bool m_alpha;
bool m_zsort;
int m_lightlayer;
- bool m_bIsTriangle;
unsigned int m_polymatid;
static unsigned int m_newpolymatid;
// will move...
unsigned int m_flag;//MaterialProps
- unsigned int m_enabled;// enabled for this mat
int m_multimode; // sum of values
public:
@@ -103,11 +102,10 @@ public:
int tilexrep,
int tileyrep,
int mode,
- bool transparant,
+ int transp,
+ bool alpha,
bool zsort,
- int lightlayer,
- bool bIsTriangle,
- void* clientobject);
+ int lightlayer);
virtual ~RAS_IPolyMaterial() {};
/**
@@ -128,20 +126,22 @@ public:
{
return false;
}
- virtual void ActivateMeshSlot(const class KX_MeshSlot & ms, RAS_IRasterizer* rasty) const {}
+ virtual void ActivateMeshSlot(const class RAS_MeshSlot & ms, RAS_IRasterizer* rasty) const {}
virtual bool Equals(const RAS_IPolyMaterial& lhs) const;
bool Less(const RAS_IPolyMaterial& rhs) const;
int GetLightLayer() const;
- bool IsTransparant() const;
+ bool IsAlpha() const;
bool IsZSort() const;
- bool UsesTriangles() const;
unsigned int hash() const;
int GetDrawingMode() const;
const STR_String& GetMaterialName() const;
+ dword GetMaterialNameHash() const;
const STR_String& GetTextureName() const;
const unsigned int GetFlag() const;
- const unsigned int GetEnabled() const;
+
+ virtual bool UsesLighting(RAS_IRasterizer *rasty) const;
+ virtual bool UsesObjectColor() const;
/*
* PreCalculate texture gen
diff --git a/source/gameengine/Rasterizer/RAS_IRasterizer.h b/source/gameengine/Rasterizer/RAS_IRasterizer.h
index 5e8b5ad8276..411b28fa3b7 100644
--- a/source/gameengine/Rasterizer/RAS_IRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_IRasterizer.h
@@ -33,12 +33,23 @@
#pragma warning (disable:4786)
#endif
+#include "STR_HashedString.h"
+
#include "MT_CmMatrix4x4.h"
#include "MT_Matrix4x4.h"
+#include "RAS_TexVert.h"
+
+#include <vector>
+using namespace std;
+
class RAS_ICanvas;
class RAS_IPolyMaterial;
-#include "RAS_MaterialBucket.h"
+
+typedef vector<unsigned short> KX_IndexArray;
+typedef vector<RAS_TexVert> KX_VertexArray;
+typedef vector< KX_VertexArray* > vecVertexArray;
+typedef vector< KX_IndexArray* > vecIndexArrays;
/**
* 3D rendering device context interface.
@@ -62,7 +73,18 @@ public:
KX_WIREFRAME,
KX_SOLID,
KX_SHADED,
- KX_TEXTURED
+ KX_TEXTURED,
+ KX_SHADOW
+ };
+
+ /**
+ * Drawing modes
+ */
+
+ enum DrawMode {
+ KX_MODE_LINES = 1,
+ KX_MODE_TRIANGLES,
+ KX_MODE_QUADS
};
/**
@@ -111,6 +133,7 @@ public:
RAS_TEXCO_NORM, //< Normal coordinates
RAS_TEXTANGENT, //<
RAS_TEXCO_UV2, //<
+ RAS_TEXCO_VCOL, //< Vertex Color
RAS_TEXCO_DISABLE //< Disable this texture unit (cached)
};
@@ -146,6 +169,10 @@ public:
*/
virtual bool BeginFrame(int drawingmode, double time)=0;
/**
+ * ClearColorBuffer clears the color buffer.
+ */
+ virtual void ClearColorBuffer()=0;
+ /**
* ClearDepthBuffer clears the depth buffer.
*/
virtual void ClearDepthBuffer()=0;
@@ -158,7 +185,8 @@ public:
*/
virtual void EndFrame()=0;
/**
- * SetRenderArea sets the render area from the 2d canvas
+ * SetRenderArea sets the render area from the 2d canvas.
+ * Returns true if only of subset of the canvas is used.
*/
virtual void SetRenderArea()=0;
@@ -172,6 +200,7 @@ public:
* @return true if stereo mode is enabled.
*/
virtual bool Stereo()=0;
+ virtual bool InterlacedStereo()=0;
/**
* Sets which eye buffer subsequent primitives will be rendered to.
*/
@@ -194,67 +223,18 @@ public:
// Drawing Functions
/**
- * IndexPrimitives: Renders primitives.
- * @param vertexarrays is an array of vertex arrays
- * @param indexarrays is an array of index arrays
- * @param mode determines the type of primitive stored in the vertex/index arrays:
- * 0 triangles
- * 1 lines (default)
- * 2 quads
- * @param polymat (reserved)
- * @param useObjectColor will render the object using @param rgbacolor instead of
- * vertex colors.
- */
- virtual void IndexPrimitives( const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot)=0;
- /**
- * @copydoc IndexPrimitives
- * IndexPrimitivesEx will renormalize faces if @param vertexarrays[i].getFlag() & TV_CALCFACENORMAL
+ * IndexPrimitives: Renders primitives from mesh slot.
*/
- virtual void IndexPrimitives_Ex( const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor)=0;
+ virtual void IndexPrimitives(class RAS_MeshSlot& ms)=0;
+ virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms)=0;
+
/**
* IndexPrimitives_3DText will render text into the polygons.
* The text to be rendered is from @param rendertools client object's text property.
*/
- virtual void IndexPrimitives_3DText( const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
+ virtual void IndexPrimitives_3DText(class RAS_MeshSlot& ms,
class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor)=0;
-
- virtual void IndexPrimitivesMulti(
- const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot)=0;
-
- virtual void IndexPrimitivesMulti_Ex(
- const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor)=0;
-
+ class RAS_IRenderTools* rendertools)=0;
virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat)=0;
/* This one should become our final version, methinks. */
@@ -276,9 +256,6 @@ public:
virtual const MT_Point3& GetCameraPosition()=0;
/**
*/
- virtual void LoadViewMatrix()=0;
- /**
- */
virtual void SetFog(float start,
float dist,
float r,
@@ -314,9 +291,6 @@ public:
*/
virtual int GetDrawingMode()=0;
/**
- */
- virtual void EnableTextures(bool enable)=0;
- /**
* Sets face culling
*/
virtual void SetCullFace(bool enable)=0;
@@ -344,6 +318,7 @@ public:
float top,
float frustnear,
float frustfar,
+ float focallength = 0.0f,
bool perspective = true
)=0;
/**
@@ -376,10 +351,6 @@ public:
virtual void SetAmbientColor(float red, float green, float blue)=0;
virtual void SetAmbient(float factor)=0;
- /**
- * Sets alpha testing
- */
- virtual void SetAlphaTest(bool enable)=0;
/**
* Sets a polygon offset. z depth will be: z1 = mult*z0 + add
@@ -388,9 +359,14 @@ public:
virtual void DrawDebugLine(const MT_Vector3& from,const MT_Vector3& to,const MT_Vector3& color)=0;
- virtual void SetTexCoords(TexCoGen coords, int unit) = 0;
- virtual void SetAttrib(int type) = 0;
- virtual void GetViewMatrix(MT_Matrix4x4 &mat) const = 0;
+
+ virtual void SetTexCoordNum(int num) = 0;
+ virtual void SetAttribNum(int num) = 0;
+ virtual void SetTexCoord(TexCoGen coords, int unit) = 0;
+ virtual void SetAttrib(TexCoGen coords, int unit) = 0;
+
+ virtual const MT_Matrix4x4& GetViewMatrix() const = 0;
+ virtual const MT_Matrix4x4& GetViewInvMatrix() const = 0;
virtual bool QueryLists(){return false;}
virtual bool QueryArrays(){return false;}
@@ -399,8 +375,11 @@ public:
virtual void DisableMotionBlur()=0;
virtual float GetMotionBlurValue()=0;
- virtual int GetMotionBlurState()=0;
- virtual void SetMotionBlurState(int newstate)=0;
+ virtual int GetMotionBlurState()=0;
+ virtual void SetMotionBlurState(int newstate)=0;
+
+ virtual void SetBlendingMode(int blendmode)=0;
+ virtual void SetFrontFace(bool ccw)=0;
};
#endif //__RAS_IRASTERIZER
diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.cpp b/source/gameengine/Rasterizer/RAS_IRenderTools.cpp
index 2be9bb75ebf..555a3520bb4 100644
--- a/source/gameengine/Rasterizer/RAS_IRenderTools.cpp
+++ b/source/gameengine/Rasterizer/RAS_IRenderTools.cpp
@@ -28,42 +28,22 @@
#include "RAS_IRenderTools.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-void RAS_IRenderTools::SetViewMat(const MT_Transform& trans)
-{
- trans.getValue(m_viewmat);
-}
-
-
-
-void RAS_IRenderTools::SetClientObject(void* obj)
+void RAS_IRenderTools::SetClientObject(RAS_IRasterizer* rasty, void *obj)
{
if (m_clientobject != obj)
- {
m_clientobject = obj;
- m_modified = true;
- }
}
-
-
void RAS_IRenderTools::SetAuxilaryClientInfo(void* inf)
{
m_auxilaryClientInfo = inf;
}
-
-
void RAS_IRenderTools::AddLight(struct RAS_LightObject* lightobject)
{
m_lights.push_back(lightobject);
}
-
-
void RAS_IRenderTools::RemoveLight(struct RAS_LightObject* lightobject)
{
std::vector<struct RAS_LightObject*>::iterator lit =
@@ -71,5 +51,5 @@ void RAS_IRenderTools::RemoveLight(struct RAS_LightObject* lightobject)
if (!(lit==m_lights.end()))
m_lights.erase(lit);
-
}
+
diff --git a/source/gameengine/Rasterizer/RAS_IRenderTools.h b/source/gameengine/Rasterizer/RAS_IRenderTools.h
index b4c0386613f..57f331e64cb 100644
--- a/source/gameengine/Rasterizer/RAS_IRenderTools.h
+++ b/source/gameengine/Rasterizer/RAS_IRenderTools.h
@@ -31,6 +31,7 @@
#include "MT_Transform.h"
#include "RAS_IRasterizer.h"
+#include "RAS_2DFilterManager.h"
#include <vector>
#include <algorithm>
@@ -38,18 +39,17 @@
class RAS_IPolyMaterial;
struct RAS_LightObject;
+
class RAS_IRenderTools
{
protected:
- float m_viewmat[16];
void* m_clientobject;
void* m_auxilaryClientInfo;
- bool m_modified;
-
std::vector<struct RAS_LightObject*> m_lights;
-
+
+ RAS_2DFilterManager m_filtermanager;
public:
enum RAS_TEXT_RENDER_MODE {
@@ -58,11 +58,14 @@ public:
RAS_TEXT_PADDED,
RAS_TEXT_MAX
};
-
+ enum RAS_LIGHT_MODE {
+ RAS_LIGHT_NONE = -1,
+ RAS_LIGHT_OBJECT_LAYER = 0
+ };
+
RAS_IRenderTools(
) :
- m_clientobject(NULL),
- m_modified(true)
+ m_clientobject(NULL)
{
};
@@ -124,23 +127,21 @@ public:
float v1[3],
float v2[3],
float v3[3],
- float v4[3]
+ float v4[3],
+ int glattrib
)=0;
virtual
- void
- SetViewMat(
- const MT_Transform& trans
- );
-
- virtual
- int
+ void
ProcessLighting(
- int layer
+ int layer,
+ const MT_Transform& trans
)=0;
+ virtual
void
SetClientObject(
+ RAS_IRasterizer* rasty,
void* obj
);
@@ -175,25 +176,16 @@ public:
void
MotionBlur(RAS_IRasterizer* rasterizer)=0;
- virtual
- class RAS_IPolyMaterial*
- CreateBlenderPolyMaterial(
- const STR_String &texname,
- bool ba,
- const STR_String& matname,
- int tile,
- int tilexrep,
- int tileyrep,
- int mode,
- bool transparant,
- bool zsort,
- int lightlayer,
- bool bIsTriangle,
- void* clientobject,
- void* tface
- )=0;
+ virtual
+ void
+ Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text)=0;
+
+ virtual
+ void
+ Render2DFilters(RAS_ICanvas* canvas)=0;
};
#endif //__RAS_IRENDERTOOLS
+
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
index 1a736080e25..ad8d7ebd5b0 100644
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
+++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.cpp
@@ -28,10 +28,6 @@
#include "RAS_MaterialBucket.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifdef WIN32
#pragma warning (disable:4786)
#include <windows.h>
@@ -44,286 +40,561 @@
#include "RAS_MeshObject.h"
#include "RAS_Deformer.h" // __NLA
+/* mesh slot */
-
-KX_VertexIndex::KX_VertexIndex(int size)
+RAS_MeshSlot::RAS_MeshSlot()
{
- m_size = size;
+ m_clientObj = NULL;
+ m_pDeformer = NULL;
+ m_OpenGLMatrix = NULL;
+ m_mesh = NULL;
+ m_bucket = NULL;
+ m_bVisible = false;
+ m_bCulled = true;
+ m_bObjectColor = false;
+ m_RGBAcolor = MT_Vector4(0.0, 0.0, 0.0, 0.0);
+ m_DisplayList = NULL;
+ m_bDisplayList = true;
+ m_joinSlot = NULL;
}
+RAS_MeshSlot::~RAS_MeshSlot()
+{
+ vector<RAS_DisplayArray*>::iterator it;
+ Split(true);
-void KX_VertexIndex::SetIndex(short loc,unsigned int index)
-{
- m_indexarray[loc]=index;
+ while(m_joinedSlots.size())
+ m_joinedSlots.front()->Split(true);
+
+ for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
+ (*it)->m_users--;
+ if((*it)->m_users == 0)
+ delete *it;
+ }
+
+ if (m_DisplayList) {
+ m_DisplayList->Release();
+ m_DisplayList = NULL;
+ }
}
-bool KX_MeshSlot::Less(const KX_MeshSlot& lhs) const
+RAS_MeshSlot::RAS_MeshSlot(const RAS_MeshSlot& slot)
{
- bool result = ((m_mesh < lhs.m_mesh ) ||
- ((m_mesh == lhs.m_mesh)&&(m_OpenGLMatrix < lhs.m_OpenGLMatrix)));
-
- return result;
+ vector<RAS_DisplayArray*>::iterator it;
+
+ m_clientObj = NULL;
+ m_pDeformer = NULL;
+ m_OpenGLMatrix = NULL;
+ m_mesh = slot.m_mesh;
+ m_bucket = slot.m_bucket;
+ m_bVisible = slot.m_bVisible;
+ m_bCulled = slot.m_bCulled;
+ m_bObjectColor = slot.m_bObjectColor;
+ m_RGBAcolor = slot.m_RGBAcolor;
+ m_DisplayList = NULL;
+ m_bDisplayList = slot.m_bDisplayList;
+ m_joinSlot = NULL;
+ m_currentArray = slot.m_currentArray;
+ m_displayArrays = slot.m_displayArrays;
+ m_joinedSlots = slot.m_joinedSlots;
+
+ m_startarray = slot.m_startarray;
+ m_startvertex = slot.m_startvertex;
+ m_startindex = slot.m_startindex;
+ m_endarray = slot.m_endarray;
+ m_endvertex = slot.m_endvertex;
+ m_endindex = slot.m_endindex;
+
+ for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
+ // don't copy display arrays for now because it breaks python
+ // access to vertices, but we'll need a solution if we want to
+ // join display arrays for reducing draw calls.
+ //*it = new RAS_DisplayArray(**it);
+ //(*it)->m_users = 1;
+
+ (*it)->m_users++;
+ }
}
+void RAS_MeshSlot::init(RAS_MaterialBucket *bucket, int numverts)
+{
+ m_bucket = bucket;
+ SetDisplayArray(numverts);
-RAS_MaterialBucket::RAS_MaterialBucket(RAS_IPolyMaterial* mat)
- :m_bModified(true)
+ m_startarray = 0;
+ m_startvertex = 0;
+ m_startindex = 0;
+ m_endarray = 0;
+ m_endvertex = 0;
+ m_endindex = 0;
+}
+
+void RAS_MeshSlot::begin(RAS_MeshSlot::iterator& it)
{
- m_bScheduled=true;
- m_material = mat;
+ int startvertex, endvertex;
+ int startindex, endindex;
+
+ it.array = (m_displayArrays.size() > 0)? m_displayArrays[m_startarray]: NULL;
+
+ if(it.array == NULL || it.array->m_index.size() == 0 || it.array->m_vertex.size() == 0) {
+ it.array = NULL;
+ it.vertex = NULL;
+ it.index = NULL;
+ it.startvertex = 0;
+ it.endvertex = 0;
+ it.totindex = 0;
+ }
+ else {
+ startvertex = m_startvertex;
+ endvertex = (m_startarray == m_endarray)? m_endvertex: it.array->m_vertex.size();
+ startindex = m_startindex;
+ endindex = (m_startarray == m_endarray)? m_endindex: it.array->m_index.size();
+
+ it.vertex = &it.array->m_vertex[0];
+ it.index = &it.array->m_index[startindex];
+ it.startvertex = startvertex;
+ it.endvertex = endvertex;
+ it.totindex = endindex-startindex;
+ it.arraynum = m_startarray;
+ }
}
+void RAS_MeshSlot::next(RAS_MeshSlot::iterator& it)
+{
+ int startvertex, endvertex;
+ int startindex, endindex;
+
+ if(it.arraynum == (size_t)m_endarray) {
+ it.array = NULL;
+ it.vertex = NULL;
+ it.index = NULL;
+ it.startvertex = 0;
+ it.endvertex = 0;
+ it.totindex = 0;
+ }
+ else {
+ it.arraynum++;
+ it.array = m_displayArrays[it.arraynum];
+
+ startindex = 0;
+ endindex = (it.arraynum == (size_t)m_endarray)? m_endindex: it.array->m_index.size();
+ startvertex = 0;
+ endvertex = (it.arraynum == (size_t)m_endarray)? m_endvertex: it.array->m_vertex.size();
+
+ it.vertex = &it.array->m_vertex[0];
+ it.index = &it.array->m_index[startindex];
+ it.startvertex = startvertex;
+ it.endvertex = endvertex;
+ it.totindex = endindex-startindex;
+ }
+}
+bool RAS_MeshSlot::end(RAS_MeshSlot::iterator& it)
+{
+ return (it.array == NULL);
+}
-void RAS_MaterialBucket::SchedulePolygons(int drawingmode)
-{
- m_bScheduled = true;
+RAS_DisplayArray *RAS_MeshSlot::CurrentDisplayArray()
+{
+ return m_currentArray;
}
+void RAS_MeshSlot::SetDisplayArray(int numverts)
+{
+ vector<RAS_DisplayArray*>::iterator it;
+ RAS_DisplayArray *darray = NULL;
+
+ for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
+ darray = *it;
+
+ if(darray->m_type == numverts) {
+ if(darray->m_index.size()+numverts >= RAS_DisplayArray::BUCKET_MAX_INDEX)
+ darray = NULL;
+ else if(darray->m_vertex.size()+numverts >= RAS_DisplayArray::BUCKET_MAX_VERTEX)
+ darray = NULL;
+ else
+ break;
+ }
+ else
+ darray = NULL;
+ }
+
+ if(!darray) {
+ darray = new RAS_DisplayArray();
+ darray->m_users = 1;
+ if(numverts == 2) darray->m_type = RAS_DisplayArray::LINE;
+ else if(numverts == 3) darray->m_type = RAS_DisplayArray::TRIANGLE;
+ else darray->m_type = RAS_DisplayArray::QUAD;
-void RAS_MaterialBucket::ClearScheduledPolygons()
-{
- m_bScheduled = false;
+ m_displayArrays.push_back(darray);
+
+ if(numverts == 2)
+ darray->m_type = RAS_DisplayArray::LINE;
+ else if(numverts == 3)
+ darray->m_type = RAS_DisplayArray::TRIANGLE;
+ else if(numverts == 4)
+ darray->m_type = RAS_DisplayArray::QUAD;
+
+ m_endarray = m_displayArrays.size()-1;
+ m_endvertex = 0;
+ m_endindex = 0;
+ }
+
+ m_currentArray = darray;
+}
+
+void RAS_MeshSlot::AddPolygon(int numverts)
+{
+ SetDisplayArray(numverts);
}
+int RAS_MeshSlot::AddVertex(const RAS_TexVert& tv)
+{
+ RAS_DisplayArray *darray;
+ int offset;
+ darray = m_currentArray;
+ darray->m_vertex.push_back(tv);
+ offset = darray->m_vertex.size()-1;
-RAS_IPolyMaterial* RAS_MaterialBucket::GetPolyMaterial() const
-{
- return m_material;
+ if(darray == m_displayArrays[m_endarray])
+ m_endvertex++;
+
+ return offset;
}
+void RAS_MeshSlot::AddPolygonVertex(int offset)
+{
+ RAS_DisplayArray *darray;
+
+ darray = m_currentArray;
+ darray->m_index.push_back(offset);
+ if(darray == m_displayArrays[m_endarray])
+ m_endindex++;
+}
+
+bool RAS_MeshSlot::Equals(RAS_MeshSlot *target)
+{
+ if(!m_OpenGLMatrix || !target->m_OpenGLMatrix)
+ return false;
+ if(m_pDeformer || target->m_pDeformer)
+ return false;
+ if(m_bVisible != target->m_bVisible)
+ return false;
+ if(m_bObjectColor != target->m_bObjectColor)
+ return false;
+ if(m_bObjectColor && !(m_RGBAcolor == target->m_RGBAcolor))
+ return false;
-void RAS_MaterialBucket::SetMeshSlot(KX_MeshSlot& ms)
+ return true;
+}
+
+bool RAS_MeshSlot::Join(RAS_MeshSlot *target, MT_Scalar distance)
{
- m_meshSlots.insert(ms);
+ vector<RAS_DisplayArray*>::iterator it;
+ iterator mit;
+ size_t i;
+
+ // verify if we can join
+ if(m_joinSlot || m_joinedSlots.size() || target->m_joinSlot)
+ return false;
+
+ if(!Equals(target))
+ return false;
+
+ MT_Vector3 co(&m_OpenGLMatrix[12]);
+ MT_Vector3 targetco(&target->m_OpenGLMatrix[12]);
+
+ if((co - targetco).length() > distance)
+ return false;
+
+ MT_Matrix4x4 mat(m_OpenGLMatrix);
+ MT_Matrix4x4 targetmat(target->m_OpenGLMatrix);
+ targetmat.invert();
+
+ MT_Matrix4x4 transform = targetmat*mat;
+
+ // m_mesh, clientobj
+ m_joinSlot = target;
+ m_joinInvTransform = transform;
+ m_joinInvTransform.invert();
+ target->m_joinedSlots.push_back(this);
+
+ MT_Matrix4x4 ntransform = m_joinInvTransform.transposed();
+ ntransform[0][3]= ntransform[1][3]= ntransform[2][3]= 0.0f;
+
+ for(begin(mit); !end(mit); next(mit))
+ for(i=mit.startvertex; i<mit.endvertex; i++)
+ mit.vertex[i].Transform(transform, ntransform);
+
+ for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
+ target->m_displayArrays.push_back(*it);
+ target->m_endarray++;
+ target->m_endvertex = target->m_displayArrays.back()->m_vertex.size();
+ target->m_endindex = target->m_displayArrays.back()->m_index.size();
+ }
+
+ if (m_DisplayList) {
+ m_DisplayList->Release();
+ m_DisplayList = NULL;
+ }
+ if (target->m_DisplayList) {
+ target->m_DisplayList->Release();
+ target->m_DisplayList = NULL;
+ }
+
+ return true;
+#if 0
+ return false;
+#endif
}
+bool RAS_MeshSlot::Split(bool force)
+{
+ list<RAS_MeshSlot*>::iterator jit;
+ RAS_MeshSlot *target = m_joinSlot;
+ vector<RAS_DisplayArray*>::iterator it, jt;
+ iterator mit;
+ size_t i, found0 = 0, found1 = 0;
+
+ if(target && (force || !Equals(target))) {
+ m_joinSlot = NULL;
+
+ for(jit=target->m_joinedSlots.begin(); jit!=target->m_joinedSlots.end(); jit++) {
+ if(*jit == this) {
+ target->m_joinedSlots.erase(jit);
+ found0 = 1;
+ break;
+ }
+ }
+
+ if(!found0)
+ abort();
+
+ for(it=m_displayArrays.begin(); it!=m_displayArrays.end(); it++) {
+ found1 = 0;
+ for(jt=target->m_displayArrays.begin(); jt!=target->m_displayArrays.end(); jt++) {
+ if(*jt == *it) {
+ target->m_displayArrays.erase(jt);
+ target->m_endarray--;
+ found1 = 1;
+ break;
+ }
+ }
+
+ if(!found1)
+ abort();
+ }
+
+ if(target->m_displayArrays.size()) {
+ target->m_endvertex = target->m_displayArrays.back()->m_vertex.size();
+ target->m_endindex = target->m_displayArrays.back()->m_index.size();
+ }
+ else {
+ target->m_endvertex = 0;
+ target->m_endindex = 0;
+ }
+
+ MT_Matrix4x4 ntransform = m_joinInvTransform.inverse().transposed();
+ ntransform[0][3]= ntransform[1][3]= ntransform[2][3]= 0.0f;
+
+ for(begin(mit); !end(mit); next(mit))
+ for(i=mit.startvertex; i<mit.endvertex; i++)
+ mit.vertex[i].Transform(m_joinInvTransform, ntransform);
+
+ if (target->m_DisplayList) {
+ target->m_DisplayList->Release();
+ target->m_DisplayList = NULL;
+ }
+
+ return true;
+ }
+ return false;
+}
-void RAS_MaterialBucket::RemoveMeshSlot(KX_MeshSlot& ms)
+bool RAS_MeshSlot::IsCulled()
{
- T_MeshSlotList::iterator it = m_meshSlots.find(ms);
+ list<RAS_MeshSlot*>::iterator it;
- if (!(it == m_meshSlots.end()))
- m_meshSlots.erase(it);
-
+ if(m_joinSlot)
+ return true;
+ if(!m_bCulled)
+ return false;
+
+ for(it=m_joinedSlots.begin(); it!=m_joinedSlots.end(); it++)
+ if(!(*it)->m_bCulled)
+ return false;
+
+ return true;
}
+/* material bucket sorting */
+
+struct RAS_MaterialBucket::less
+{
+ bool operator()(const RAS_MaterialBucket* x, const RAS_MaterialBucket* y) const
+ {
+ return *x->GetPolyMaterial() < *y->GetPolyMaterial();
+ }
+};
+/* material bucket */
-void RAS_MaterialBucket::MarkVisibleMeshSlot(KX_MeshSlot& ms,
- bool visible,
- bool color,
- const MT_Vector4& rgbavec)
+RAS_MaterialBucket::RAS_MaterialBucket(RAS_IPolyMaterial* mat)
{
- T_MeshSlotList::iterator it = m_meshSlots.find(ms);
-
- assert (!(it == m_meshSlots.end()));
- (*it).m_bVisible = visible;
- (*it).m_bObjectColor = color;
- (*it).m_RGBAcolor= rgbavec;
+ m_material = mat;
}
-bool RAS_MaterialBucket::IsTransparant() const
-{
- return (m_material->IsTransparant());
+RAS_MaterialBucket::~RAS_MaterialBucket()
+{
+}
+
+RAS_IPolyMaterial* RAS_MaterialBucket::GetPolyMaterial() const
+{
+ return m_material;
}
+bool RAS_MaterialBucket::IsAlpha() const
+{
+ return (m_material->IsAlpha());
+}
+bool RAS_MaterialBucket::IsZSort() const
+{
+ return (m_material->IsZSort());
+}
-void RAS_MaterialBucket::StartFrame()
+RAS_MeshSlot* RAS_MaterialBucket::AddMesh(int numverts)
{
-}
+ RAS_MeshSlot *ms;
+ m_meshSlots.push_back(RAS_MeshSlot());
+
+ ms = &m_meshSlots.back();
+ ms->init(this, numverts);
+ return ms;
+}
-void RAS_MaterialBucket::EndFrame()
+RAS_MeshSlot* RAS_MaterialBucket::CopyMesh(RAS_MeshSlot *ms)
{
+ m_meshSlots.push_back(RAS_MeshSlot(*ms));
+
+ return &m_meshSlots.back();
}
-unsigned int RAS_MaterialBucket::NumMeshSlots()
+void RAS_MaterialBucket::RemoveMesh(RAS_MeshSlot* ms)
{
- return m_meshSlots.size();
+ list<RAS_MeshSlot>::iterator it;
+
+ for(it=m_meshSlots.begin(); it!=m_meshSlots.end(); it++) {
+ if(&*it == ms) {
+ m_meshSlots.erase(it);
+ return;
+ }
+ }
}
-RAS_MaterialBucket::T_MeshSlotList::iterator RAS_MaterialBucket::msBegin()
+list<RAS_MeshSlot>::iterator RAS_MaterialBucket::msBegin()
{
return m_meshSlots.begin();
}
-RAS_MaterialBucket::T_MeshSlotList::iterator RAS_MaterialBucket::msEnd()
+list<RAS_MeshSlot>::iterator RAS_MaterialBucket::msEnd()
{
return m_meshSlots.end();
}
bool RAS_MaterialBucket::ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty,
- RAS_IRenderTools *rendertools, int &drawmode)
+ RAS_IRenderTools *rendertools)
{
- rendertools->SetViewMat(cameratrans);
-
if (!rasty->SetMaterial(*m_material))
return false;
- bool dolights = false;
- const unsigned int flag = m_material->GetFlag();
-
-
- if( flag & RAS_BLENDERMAT)
- dolights = (flag &RAS_MULTILIGHT)!=0;
+ if (m_material->UsesLighting(rasty))
+ rendertools->ProcessLighting(RAS_IRenderTools::RAS_LIGHT_OBJECT_LAYER, cameratrans);
else
- dolights = (m_material->GetDrawingMode()&16)!=0;
-
- if ((rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID) || !dolights)
- {
- rendertools->ProcessLighting(-1);
- }
- else
- {
- rendertools->ProcessLighting(m_material->GetLightLayer());
- }
-
- drawmode = (rasty->GetDrawingMode() < RAS_IRasterizer::KX_SOLID ?
- 1: (m_material->UsesTriangles() ? 0 : 2));
+ rendertools->ProcessLighting(-1, cameratrans);
return true;
}
void RAS_MaterialBucket::RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty,
- RAS_IRenderTools* rendertools, const KX_MeshSlot &ms, int drawmode)
+ RAS_IRenderTools* rendertools, RAS_MeshSlot &ms)
{
- if (!ms.m_bVisible)
- return;
-
- rendertools->SetClientObject(ms.m_clientObj);
m_material->ActivateMeshSlot(ms, rasty);
- /* __NLA Do the deformation */
if (ms.m_pDeformer)
{
ms.m_pDeformer->Apply(m_material);
// KX_ReInstanceShapeFromMesh(ms.m_mesh); // Recompute the physics mesh. (Can't call KX_* from RAS_)
}
- /* End __NLA */
- if (rasty->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID)
- ms.m_mesh->SortPolygons(cameratrans*MT_Transform(ms.m_OpenGLMatrix));
+ if(IsZSort() && rasty->GetDrawingMode() >= RAS_IRasterizer::KX_SOLID)
+ ms.m_mesh->SortPolygons(ms, cameratrans*MT_Transform(ms.m_OpenGLMatrix));
rendertools->PushMatrix();
- rendertools->applyTransform(rasty,ms.m_OpenGLMatrix,m_material->GetDrawingMode());
+ if (!ms.m_pDeformer || !ms.m_pDeformer->SkipVertexTransform())
+ {
+ rendertools->applyTransform(rasty,ms.m_OpenGLMatrix,m_material->GetDrawingMode());
+ }
if(rasty->QueryLists())
- {
if(ms.m_DisplayList)
ms.m_DisplayList->SetModified(ms.m_mesh->MeshModified());
- }
- // Use the text-specific IndexPrimitives for text faces
- if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT)
- {
- rasty->IndexPrimitives_3DText(
- ms.m_mesh->GetVertexCache(m_material),
- ms.m_mesh->GetIndexCache(m_material),
- drawmode,
- m_material,
- rendertools, // needed for textprinting on polys
- ms.m_bObjectColor,
- ms.m_RGBAcolor);
-
- }
-
- // for using glMultiTexCoord
- else if(m_material->GetFlag() & RAS_MULTITEX )
- {
- rasty->IndexPrimitivesMulti(
- ms.m_mesh->GetVertexCache(m_material),
- ms.m_mesh->GetIndexCache(m_material),
- drawmode,
- m_material,
- rendertools,
- ms.m_bObjectColor,
- ms.m_RGBAcolor,
- &ms.m_DisplayList
- );
- }
-
- // for using glMultiTexCoord on deformer
- else if(m_material->GetFlag() & RAS_DEFMULTI )
- {
- rasty->IndexPrimitivesMulti_Ex(
- ms.m_mesh->GetVertexCache(m_material),
- ms.m_mesh->GetIndexCache(m_material),
- drawmode,
- m_material,
- rendertools,
- ms.m_bObjectColor,
- ms.m_RGBAcolor
- );
- }
+ // verify if we can use display list, not for deformed object, and
+ // also don't create a new display list when drawing shadow buffers,
+ // then it won't have texture coordinates for actual drawing. also
+ // for zsort we can't make a display list, since the polygon order
+ // changes all the time.
+ if(ms.m_pDeformer)
+ ms.m_bDisplayList = false;
+ else if(!ms.m_DisplayList && rasty->GetDrawingMode() == RAS_IRasterizer::KX_SHADOW)
+ ms.m_bDisplayList = false;
+ else if (IsZSort())
+ ms.m_bDisplayList = false;
+ else if(m_material->UsesObjectColor() && ms.m_bObjectColor)
+ ms.m_bDisplayList = false;
+ else
+ ms.m_bDisplayList = true;
- // Use the (slower) IndexPrimitives_Ex which can recalc face normals & such
- // for deformed objects - eventually should be extended to recalc ALL normals
- else if (ms.m_pDeformer){
- rasty->IndexPrimitives_Ex(
- ms.m_mesh->GetVertexCache(m_material),
- ms.m_mesh->GetIndexCache(m_material),
- drawmode,
- m_material,
- rendertools, // needed for textprinting on polys
- ms.m_bObjectColor,
- ms.m_RGBAcolor
- );
- }
- // Use the normal IndexPrimitives
+ // for text drawing using faces
+ if (m_material->GetDrawingMode() & RAS_IRasterizer::RAS_RENDER_3DPOLYGON_TEXT)
+ rasty->IndexPrimitives_3DText(ms, m_material, rendertools);
+ // for multitexturing
+ else if((m_material->GetFlag() & (RAS_MULTITEX|RAS_BLENDERGLSL)))
+ rasty->IndexPrimitivesMulti(ms);
+ // use normal IndexPrimitives
else
- {
- rasty->IndexPrimitives(
- ms.m_mesh->GetVertexCache(m_material),
- ms.m_mesh->GetIndexCache(m_material),
- drawmode,
- m_material,
- rendertools, // needed for textprinting on polys
- ms.m_bObjectColor,
- ms.m_RGBAcolor,
- &ms.m_DisplayList
- );
- }
+ rasty->IndexPrimitives(ms);
- if(rasty->QueryLists()) {
+ if(rasty->QueryLists())
if(ms.m_DisplayList)
ms.m_mesh->SetMeshModified(false);
- }
rendertools->PopMatrix();
}
-void RAS_MaterialBucket::Render(const MT_Transform& cameratrans,
- RAS_IRasterizer* rasty,
- RAS_IRenderTools* rendertools)
+void RAS_MaterialBucket::Optimize(MT_Scalar distance)
{
- if (m_meshSlots.begin()== m_meshSlots.end())
- return;
-
- //rendertools->SetViewMat(cameratrans);
-
- //rasty->SetMaterial(*m_material);
-
- if (m_meshSlots.size() >0)
- {
- rendertools->SetClientObject((*m_meshSlots.begin()).m_clientObj);
- }
+ /* TODO: still have to check before this works correct:
+ * - lightlayer, frontface, text, billboard
+ * - make it work with physics */
- int drawmode;
- for (T_MeshSlotList::const_iterator it = m_meshSlots.begin();
- ! (it == m_meshSlots.end()); ++it)
- {
- while (ActivateMaterial(cameratrans, rasty, rendertools, drawmode))
- RenderMeshSlot(cameratrans, rasty, rendertools, *it, drawmode);
- }
+#if 0
+ list<RAS_MeshSlot>::iterator it;
+ list<RAS_MeshSlot>::iterator jt;
+
+ // greed joining on all following buckets
+ for(it=m_meshSlots.begin(); it!=m_meshSlots.end(); it++)
+ for(jt=it, jt++; jt!=m_meshSlots.end(); jt++)
+ jt->Join(&*it, distance);
+#endif
}
-
diff --git a/source/gameengine/Rasterizer/RAS_MaterialBucket.h b/source/gameengine/Rasterizer/RAS_MaterialBucket.h
index 78424689b35..475f01d549a 100644
--- a/source/gameengine/Rasterizer/RAS_MaterialBucket.h
+++ b/source/gameengine/Rasterizer/RAS_MaterialBucket.h
@@ -35,132 +35,179 @@
#include "MT_Transform.h"
#include "RAS_IPolygonMaterial.h"
-#include "RAS_Deformer.h" // __NLA
+#include "RAS_IRasterizer.h"
+#include "RAS_Deformer.h"
+
#include <vector>
-#include <map>
#include <set>
+#include <list>
using namespace std;
-typedef vector<unsigned short> KX_IndexArray;
-typedef vector<RAS_TexVert> KX_VertexArray;
-typedef vector< KX_VertexArray* > vecVertexArray;
-typedef vector< KX_IndexArray* > vecIndexArrays;
+/* Display List Slot */
-/**
- * KX_VertexIndex
- */
-struct KX_VertexIndex {
+class KX_ListSlot
+{
+protected:
+ int m_refcount;
public:
- KX_VertexIndex(int size);
- void SetIndex(short loc,unsigned int index);
-
- // The vertex array
- short m_vtxarray;
- // An index into the vertex array for up to 4 verticies
- unsigned short m_indexarray[4];
- short m_size;
+ KX_ListSlot(){ m_refcount=1; }
+ virtual ~KX_ListSlot() {}
+ virtual int Release() {
+ if (--m_refcount > 0)
+ return m_refcount;
+ delete this;
+ return 0;
+ }
+ virtual KX_ListSlot* AddRef() {
+ m_refcount++;
+ return this;
+ }
+ virtual void SetModified(bool mod)=0;
};
-/**
- * KX_ListSlot.
- */
-class KX_ListSlot
+class RAS_DisplayArray;
+class RAS_MeshSlot;
+class RAS_MeshMaterial;
+class RAS_MaterialBucket;
+
+/* An array with data used for OpenGL drawing */
+
+class RAS_DisplayArray
{
public:
- KX_ListSlot(){}
- virtual ~KX_ListSlot(){}
+ vector<RAS_TexVert> m_vertex;
+ vector<unsigned short> m_index;
+ enum { LINE = 2, TRIANGLE = 3, QUAD = 4 } m_type;
+ //RAS_MeshSlot *m_origSlot;
+ int m_users;
- virtual void SetModified(bool mod)=0;
+ enum { BUCKET_MAX_INDEX = 65535 };
+ enum { BUCKET_MAX_VERTEX = 65535 };
};
-/**
- * KX_MeshSlot.
- */
-class KX_MeshSlot
+/* Entry of a RAS_MeshObject into RAS_MaterialBucket */
+
+class RAS_MeshSlot
{
+private:
+ // indices into display arrays
+ int m_startarray;
+ int m_endarray;
+ int m_startindex;
+ int m_endindex;
+ int m_startvertex;
+ int m_endvertex;
+ vector<RAS_DisplayArray*> m_displayArrays;
+
+ // for construction only
+ RAS_DisplayArray* m_currentArray;
+
public:
- void* m_clientObj;
- RAS_Deformer* m_pDeformer; // __NLA
- double* m_OpenGLMatrix;
- class RAS_MeshObject* m_mesh;
- mutable bool m_bVisible; // for visibility
- mutable bool m_bObjectColor;
- mutable MT_Vector4 m_RGBAcolor;
- mutable KX_ListSlot* m_DisplayList; // for lists
- KX_MeshSlot() :
- m_pDeformer(NULL),
- m_bVisible(true),
- m_DisplayList(0)
- {
- }
- ~KX_MeshSlot(){}
- bool Less(const KX_MeshSlot& lhs) const;
+ // for rendering
+ RAS_MaterialBucket* m_bucket;
+ RAS_MeshObject* m_mesh;
+ void* m_clientObj;
+ RAS_Deformer* m_pDeformer;
+ double* m_OpenGLMatrix;
+ // visibility
+ bool m_bVisible;
+ bool m_bCulled;
+ // object color
+ bool m_bObjectColor;
+ MT_Vector4 m_RGBAcolor;
+ // display lists
+ KX_ListSlot* m_DisplayList;
+ bool m_bDisplayList;
+ // joined mesh slots
+ RAS_MeshSlot* m_joinSlot;
+ MT_Matrix4x4 m_joinInvTransform;
+ list<RAS_MeshSlot*> m_joinedSlots;
+
+ RAS_MeshSlot();
+ RAS_MeshSlot(const RAS_MeshSlot& slot);
+ virtual ~RAS_MeshSlot();
+
+ void init(RAS_MaterialBucket *bucket, int numverts);
+
+ struct iterator {
+ RAS_DisplayArray *array;
+ RAS_TexVert *vertex;
+ unsigned short *index;
+ size_t startvertex;
+ size_t endvertex;
+ size_t totindex;
+ size_t arraynum;
+ };
+
+ void begin(iterator& it);
+ void next(iterator& it);
+ bool end(iterator& it);
+
+ /* used during construction */
+ void SetDisplayArray(int numverts);
+ RAS_DisplayArray *CurrentDisplayArray();
+
+ void AddPolygon(int numverts);
+ int AddVertex(const RAS_TexVert& tv);
+ void AddPolygonVertex(int offset);
+
+ /* optimization */
+ bool Split(bool force=false);
+ bool Join(RAS_MeshSlot *target, MT_Scalar distance);
+ bool Equals(RAS_MeshSlot *target);
+ bool IsCulled();
};
+/* Used by RAS_MeshObject, to point to it's slots in a bucket */
-inline bool operator <( const KX_MeshSlot& rhs,const KX_MeshSlot& lhs)
+class RAS_MeshMaterial
{
- return ( rhs.Less(lhs));
-}
+public:
+ RAS_MeshSlot *m_baseslot;
+ class RAS_MaterialBucket *m_bucket;
+
+ GEN_Map<GEN_HashedPtr,RAS_MeshSlot*> m_slots;
+};
+
+/* Contains a list of display arrays with the same material,
+ * and a mesh slot for each mesh that uses display arrays in
+ * this bucket */
-/**
- * Contains a list of meshs with the same material properties.
- */
class RAS_MaterialBucket
{
public:
- typedef std::set<KX_MeshSlot> T_MeshSlotList;
-
RAS_MaterialBucket(RAS_IPolyMaterial* mat);
- virtual ~RAS_MaterialBucket() {}
-
- void Render(const MT_Transform& cameratrans,
- class RAS_IRasterizer* rasty,
- class RAS_IRenderTools* rendertools);
-
- void SchedulePolygons(int drawingmode);
- void ClearScheduledPolygons();
+ virtual ~RAS_MaterialBucket();
+ /* Bucket Sorting */
+ struct less;
+ typedef set<RAS_MaterialBucket*, less> Set;
+
+ /* Material Properties */
RAS_IPolyMaterial* GetPolyMaterial() const;
- bool IsTransparant() const;
+ bool IsAlpha() const;
+ bool IsZSort() const;
- static void StartFrame();
- static void EndFrame();
-
- void SetMeshSlot(KX_MeshSlot& ms);
- void RemoveMeshSlot(KX_MeshSlot& ms);
- void MarkVisibleMeshSlot(KX_MeshSlot& ms,
- bool visible,
- bool color,
- const MT_Vector4& rgbavec);
-
- void RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty,
- RAS_IRenderTools* rendertools, const KX_MeshSlot &ms, int drawmode);
+ /* Rendering */
bool ActivateMaterial(const MT_Transform& cameratrans, RAS_IRasterizer* rasty,
- RAS_IRenderTools *rendertools, int &drawmode);
-
- unsigned int NumMeshSlots();
- T_MeshSlotList::iterator msBegin();
- T_MeshSlotList::iterator msEnd();
-
- struct less
- {
- bool operator()(const RAS_MaterialBucket* x, const RAS_MaterialBucket* y) const
- {
- return *x->GetPolyMaterial() < *y->GetPolyMaterial();
- }
- };
+ RAS_IRenderTools *rendertools);
+ void RenderMeshSlot(const MT_Transform& cameratrans, RAS_IRasterizer* rasty,
+ RAS_IRenderTools* rendertools, RAS_MeshSlot &ms);
- typedef set<RAS_MaterialBucket*, less> Set;
+ /* Mesh Slot Access */
+ list<RAS_MeshSlot>::iterator msBegin();
+ list<RAS_MeshSlot>::iterator msEnd();
+
+ class RAS_MeshSlot* AddMesh(int numverts);
+ class RAS_MeshSlot* CopyMesh(class RAS_MeshSlot *ms);
+ void RemoveMesh(class RAS_MeshSlot* ms);
+ void Optimize(MT_Scalar distance);
+
private:
-
- T_MeshSlotList m_meshSlots;
- bool m_bScheduled;
- bool m_bModified;
+ list<RAS_MeshSlot> m_meshSlots;
RAS_IPolyMaterial* m_material;
- double* m_pOGLMatrix;
};
-#endif //__KX_BUCKET
+#endif //__RAS_MATERIAL_BUCKET
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.cpp b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
index e441908532f..a907994bf57 100644
--- a/source/gameengine/Rasterizer/RAS_MeshObject.cpp
+++ b/source/gameengine/Rasterizer/RAS_MeshObject.cpp
@@ -26,70 +26,91 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "RAS_MeshObject.h"
#include "RAS_IRasterizer.h"
#include "MT_MinMax.h"
#include "MT_Point3.h"
+#include <algorithm>
-STR_String RAS_MeshObject::s_emptyname = "";
-
-
+/* polygon sorting */
-KX_ArrayOptimizer::~KX_ArrayOptimizer()
+struct RAS_MeshObject::polygonSlot
{
- for (vector<KX_VertexArray*>::iterator itv = m_VertexArrayCache1.begin();
- !(itv == m_VertexArrayCache1.end());++itv)
- {
- delete (*itv);
- }
+ float m_z;
+ int m_index[4];
+
+ polygonSlot() {}
- for (vector<KX_IndexArray*>::iterator iti = m_IndexArrayCache1.begin();
- !(iti == m_IndexArrayCache1.end());++iti)
+ /* pnorm is the normal from the plane equation that the distance from is
+ * used to sort again. */
+ void get(const RAS_TexVert *vertexarray, const unsigned short *indexarray,
+ int offset, int nvert, const MT_Vector3& pnorm)
{
- delete (*iti);
- }
-
- m_TriangleArrayCount.clear();
- m_VertexArrayCache1.clear();
- m_IndexArrayCache1.clear();
+ MT_Vector3 center(0, 0, 0);
+ int i;
+ for(i=0; i<nvert; i++) {
+ m_index[i] = indexarray[offset+i];
+ center += vertexarray[m_index[i]].getXYZ();
+ }
-}
+ /* note we don't divide center by the number of vertices, since all
+ * polygons have the same number of vertices, and that we leave out
+ * the 4-th component of the plane equation since it is constant. */
+ m_z = MT_dot(pnorm, center);
+ }
+ void set(unsigned short *indexarray, int offset, int nvert)
+ {
+ int i;
+ for(i=0; i<nvert; i++)
+ indexarray[offset+i] = m_index[i];
+ }
+};
+
+struct RAS_MeshObject::backtofront
+{
+ bool operator()(const polygonSlot &a, const polygonSlot &b) const
+ {
+ return a.m_z < b.m_z;
+ }
+};
-RAS_MeshObject::RAS_MeshObject(int lightlayer)
- : m_bModified(true),
- m_lightlayer(lightlayer),
- m_zsort(false),
- m_MeshMod(true),
- m_class(0)
+struct RAS_MeshObject::fronttoback
{
-}
+ bool operator()(const polygonSlot &a, const polygonSlot &b) const
+ {
+ return a.m_z > b.m_z;
+ }
+};
+/* mesh object */
-bool RAS_MeshObject::MeshModified()
+STR_String RAS_MeshObject::s_emptyname = "";
+
+RAS_MeshObject::RAS_MeshObject(Mesh* mesh, int lightlayer)
+ : m_lightlayer(lightlayer),
+ m_bModified(true),
+ m_bMeshModified(true),
+ m_mesh(mesh),
+ m_bDeformed(false)
{
- return m_MeshMod;
}
-
RAS_MeshObject::~RAS_MeshObject()
{
- for (vector<RAS_Polygon*>::iterator it=m_Polygons.begin();!(it==m_Polygons.end());it++)
- {
- delete (*it);
- }
+ vector<RAS_Polygon*>::iterator it;
- ClearArrayData();
+ for(it=m_Polygons.begin(); it!=m_Polygons.end(); it++)
+ delete (*it);
}
-
+bool RAS_MeshObject::MeshModified()
+{
+ return m_bMeshModified;
+}
unsigned int RAS_MeshObject::GetLightLayer()
{
@@ -105,18 +126,21 @@ int RAS_MeshObject::NumMaterials()
const STR_String& RAS_MeshObject::GetMaterialName(unsigned int matid)
{
- RAS_MaterialBucket* bucket = GetMaterialBucket(matid);
+ RAS_MeshMaterial* mmat = GetMeshMaterial(matid);
+
+ if(mmat)
+ return mmat->m_bucket->GetPolyMaterial()->GetMaterialName();
- return bucket?bucket->GetPolyMaterial()->GetMaterialName():s_emptyname;
+ return s_emptyname;
}
-RAS_MaterialBucket* RAS_MeshObject::GetMaterialBucket(unsigned int matid)
+RAS_MeshMaterial* RAS_MeshObject::GetMeshMaterial(unsigned int matid)
{
if (m_materials.size() > 0 && (matid < m_materials.size()))
{
- RAS_MaterialBucket::Set::const_iterator it = m_materials.begin();
+ list<RAS_MeshMaterial>::iterator it = m_materials.begin();
while (matid--) ++it;
- return *it;
+ return &*it;
}
return NULL;
@@ -131,21 +155,24 @@ int RAS_MeshObject::NumPolygons()
-RAS_Polygon* RAS_MeshObject::GetPolygon(int num)
+RAS_Polygon* RAS_MeshObject::GetPolygon(int num) const
{
return m_Polygons[num];
}
-RAS_MaterialBucket::Set::iterator RAS_MeshObject::GetFirstMaterial()
+
+ list<RAS_MeshMaterial>::iterator GetFirstMaterial();
+ list<RAS_MeshMaterial>::iterator GetLastMaterial();
+list<RAS_MeshMaterial>::iterator RAS_MeshObject::GetFirstMaterial()
{
return m_materials.begin();
}
-RAS_MaterialBucket::Set::iterator RAS_MeshObject::GetLastMaterial()
+list<RAS_MeshMaterial>::iterator RAS_MeshObject::GetLastMaterial()
{
return m_materials.end();
}
@@ -168,355 +195,238 @@ const STR_String& RAS_MeshObject::GetName()
const STR_String& RAS_MeshObject::GetTextureName(unsigned int matid)
{
- RAS_MaterialBucket* bucket = GetMaterialBucket(matid);
+ RAS_MeshMaterial* mmat = GetMeshMaterial(matid);
- return bucket?bucket->GetPolyMaterial()->GetTextureName():s_emptyname;
+ if(mmat)
+ return mmat->m_bucket->GetPolyMaterial()->GetTextureName();
+
+ return s_emptyname;
}
+RAS_MeshMaterial *RAS_MeshObject::GetMeshMaterial(RAS_IPolyMaterial *mat)
+{
+ list<RAS_MeshMaterial>::iterator mit;
+ /* find a mesh material */
+ for(mit = m_materials.begin(); mit != m_materials.end(); mit++)
+ if(mit->m_bucket->GetPolyMaterial() == mat)
+ return &*mit;
-void RAS_MeshObject::AddPolygon(RAS_Polygon* poly)
-{
- m_Polygons.push_back(poly);
+ return NULL;
}
+RAS_Polygon* RAS_MeshObject::AddPolygon(RAS_MaterialBucket *bucket, int numverts)
+{
+ RAS_MeshMaterial *mmat;
+ RAS_Polygon *poly;
+ RAS_MeshSlot *slot;
+
+ /* find a mesh material */
+ mmat = GetMeshMaterial(bucket->GetPolyMaterial());
+ /* none found, create a new one */
+ if(!mmat) {
+ RAS_MeshMaterial meshmat;
+ meshmat.m_bucket = bucket;
+ meshmat.m_baseslot = meshmat.m_bucket->AddMesh(numverts);
+ m_materials.push_back(meshmat);
+ mmat = &m_materials.back();
+ }
+
+ /* add it to the bucket, this also adds new display arrays */
+ slot = mmat->m_baseslot;
+ slot->AddPolygon(numverts);
+
+ /* create a new polygon */
+ RAS_DisplayArray *darray = slot->CurrentDisplayArray();
+ poly = new RAS_Polygon(bucket, darray, numverts);
+ m_Polygons.push_back(poly);
+
+ return poly;
+}
void RAS_MeshObject::DebugColor(unsigned int abgr)
{
-/*
- int numpolys = NumPolygons();
- for (int i=0;i<numpolys;i++)
- {
+ /*int numpolys = NumPolygons();
+
+ for (int i=0;i<numpolys;i++) {
RAS_Polygon* poly = m_polygons[i];
for (int v=0;v<poly->VertexCount();v++)
- {
- RAS_TexVert* vtx = poly->GetVertex(v);
- vtx->setDebugRGBA(abgr);
- }
+ RAS_TexVert* vtx = poly->GetVertex(v)->setDebugRGBA(abgr);
}
*/
- m_debugcolor = abgr;
+ /* m_debugcolor = abgr; */
}
-
-
-void RAS_MeshObject::SchedulePoly(const KX_VertexIndex& idx,
- int numverts,
- RAS_IPolyMaterial* mat)
+void RAS_MeshObject::SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba)
{
- //int indexpos = m_IndexArrayCount[idx.m_vtxarray];
- //m_IndexArrayCount[idx.m_vtxarray] = indexpos + 3;
-
- KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);
- ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(idx.m_indexarray[0]);
- ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(idx.m_indexarray[1]);
- ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(idx.m_indexarray[2]);
- if (!mat->UsesTriangles()) //if (!m_bUseTriangles)
- {
- //m_IndexArrayCount[idx.m_vtxarray] = indexpos+4;
- ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(idx.m_indexarray[3]);
- }
-}
-
+ RAS_MeshMaterial *mmat = GetMeshMaterial(mat);
+ RAS_MeshSlot *slot = mmat->m_baseslot;
+ RAS_MeshSlot::iterator it;
+ size_t i;
-
-void RAS_MeshObject::ScheduleWireframePoly(const KX_VertexIndex& idx,
- int numverts,
- int edgecode,
- RAS_IPolyMaterial* mat)
-{
- //int indexpos = m_IndexArrayCount[idx.m_vtxarray];
- int edgetrace = 1<<(numverts-1);
- bool drawedge = (edgecode & edgetrace)!=0;
- edgetrace = 1;
- int prevvert = idx.m_indexarray[numverts-1];
- KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);
-
- for (int v = 0; v < numverts; v++)
- {
- unsigned int curvert = idx.m_indexarray[v];
- if (drawedge)
- {
- ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(prevvert);
- ao->m_IndexArrayCache1[idx.m_vtxarray]->push_back(curvert);
- }
- prevvert = curvert;
- drawedge = (edgecode & edgetrace)!=0;
- edgetrace*=2;
- }
- //m_IndexArrayCount[idx.m_vtxarray] = indexpos;
+ for(slot->begin(it); !slot->end(it); slot->next(it))
+ for(i=it.startvertex; i<it.endvertex; i++)
+ it.vertex[i].SetRGBA(rgba);
}
-int RAS_MeshObject::FindOrAddVertex(int vtxarray,
- const MT_Point3& xyz,
- const MT_Point2& uv,
- const MT_Point2& uv2,
- const MT_Vector4& tangent,
- const unsigned int rgbacolor,
- const MT_Vector3& normal,
- RAS_IPolyMaterial* mat,
- int orgindex)
+void RAS_MeshObject::AddVertex(RAS_Polygon *poly, int i,
+ const MT_Point3& xyz,
+ const MT_Point2& uv,
+ const MT_Point2& uv2,
+ const MT_Vector4& tangent,
+ const unsigned int rgba,
+ const MT_Vector3& normal,
+ bool flat,
+ int origindex)
{
- KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
-
- int numverts = ao->m_VertexArrayCache1[vtxarray]->size();//m_VertexArrayCount[vtxarray];
- RAS_TexVert newvert(xyz,uv,uv2,tangent,rgbacolor,normal, 0);
-#define KX_FIND_SHARED_VERTICES
-#ifdef KX_FIND_SHARED_VERTICES
+ RAS_TexVert texvert(xyz, uv, uv2, tangent, rgba, normal, flat, origindex);
+ RAS_MeshMaterial *mmat;
+ RAS_DisplayArray *darray;
+ RAS_MeshSlot *slot;
+ int offset;
- for (std::vector<RAS_MatArrayIndex>::iterator it = m_xyz_index_to_vertex_index_mapping[orgindex].begin();
- it != m_xyz_index_to_vertex_index_mapping[orgindex].end();
- it++)
- {
- if ((*it).m_arrayindex1 == ao->m_index1 &&
- (*it).m_array == vtxarray &&
- *(*it).m_matid == *mat &&
- (*ao->m_VertexArrayCache1[vtxarray])[(*it).m_index].closeTo(&newvert)
- )
+ mmat = GetMeshMaterial(poly->GetMaterial()->GetPolyMaterial());
+ slot = mmat->m_baseslot;
+ darray = slot->CurrentDisplayArray();
+
+ if(!flat) {
+ /* find vertices shared between faces, with the restriction
+ * that they exist in the same display array, and have the
+ * same uv coordinate etc */
+ vector<SharedVertex>& sharedmap = m_sharedvertex_map[origindex];
+ vector<SharedVertex>::iterator it;
+
+ for(it = sharedmap.begin(); it != sharedmap.end(); it++)
{
- return (*it).m_index;
+ if(it->m_darray != darray)
+ continue;
+ if(!it->m_darray->m_vertex[it->m_offset].closeTo(&texvert))
+ continue;
+
+ /* found one, add it and we're done */
+ if(poly->IsVisible())
+ slot->AddPolygonVertex(it->m_offset);
+ poly->SetVertexOffset(i, it->m_offset);
+ return;
}
}
-#endif // KX_FIND_SHARED_VERTICES
-
- // no vertex found, add one
- ao->m_VertexArrayCache1[vtxarray]->push_back(newvert);
- // printf("(%f,%f,%f) ",xyz[0],xyz[1],xyz[2]);
- RAS_MatArrayIndex idx;
- idx.m_arrayindex1 = ao->m_index1;
- idx.m_array = vtxarray;
- idx.m_index = numverts;
- idx.m_matid = mat;
- m_xyz_index_to_vertex_index_mapping[orgindex].push_back(idx);
-
- return numverts;
-}
-
-
-
-const vecVertexArray& RAS_MeshObject::GetVertexCache (RAS_IPolyMaterial* mat)
-{
- KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
- return ao->m_VertexArrayCache1;
+ /* no shared vertex found, add a new one */
+ offset = slot->AddVertex(texvert);
+ if(poly->IsVisible())
+ slot->AddPolygonVertex(offset);
+ poly->SetVertexOffset(i, offset);
+
+ if(!flat) {
+ SharedVertex shared;
+ shared.m_darray = darray;
+ shared.m_offset = offset;
+ m_sharedvertex_map[origindex].push_back(shared);
+ }
}
-
-
-int RAS_MeshObject::GetVertexArrayLength(RAS_IPolyMaterial* mat)
+int RAS_MeshObject::NumVertices(RAS_IPolyMaterial* mat)
{
- int len = 0;
+ RAS_MeshMaterial *mmat;
+ RAS_MeshSlot *slot;
+ RAS_MeshSlot::iterator it;
+ size_t len = 0;
- const vecVertexArray & vertexvec = GetVertexCache(mat);
- vector<KX_VertexArray*>::const_iterator it = vertexvec.begin();
+ mmat = GetMeshMaterial(mat);
+ slot = mmat->m_baseslot;
+ for(slot->begin(it); !slot->end(it); slot->next(it))
+ len += it.endvertex - it.startvertex;
- for (; it != vertexvec.end(); ++it)
- {
- len += (*it)->size();
- }
-
return len;
}
-
RAS_TexVert* RAS_MeshObject::GetVertex(unsigned int matid,
unsigned int index)
{
- RAS_TexVert* vertex = NULL;
-
- RAS_MaterialBucket* bucket = GetMaterialBucket(matid);
- if (bucket)
- {
- RAS_IPolyMaterial* mat = bucket->GetPolyMaterial();
- if (mat)
- {
- const vecVertexArray & vertexvec = GetVertexCache(mat);
- vector<KX_VertexArray*>::const_iterator it = vertexvec.begin();
-
- for (unsigned int len = 0; it != vertexvec.end(); ++it)
- {
- if (index < len + (*it)->size())
- {
- vertex = &(*(*it))[index-len];
- break;
- }
- else
- {
- len += (*it)->size();
- }
- }
- }
- }
-
- return vertex;
-}
-
-
+ RAS_MeshMaterial *mmat;
+ RAS_MeshSlot *slot;
+ RAS_MeshSlot::iterator it;
+ size_t len;
-const vecIndexArrays& RAS_MeshObject::GetIndexCache (RAS_IPolyMaterial* mat)
-{
- KX_ArrayOptimizer* ao = GetArrayOptimizer(mat);//*(m_matVertexArrays[*mat]);
-
- return ao->m_IndexArrayCache1;
-}
+ mmat = GetMeshMaterial(matid);
-
-
-KX_ArrayOptimizer* RAS_MeshObject::GetArrayOptimizer(RAS_IPolyMaterial* polymat)
-{
- KX_ArrayOptimizer** aop = (m_matVertexArrayS[*polymat]);
-
- if (aop)
- return *aop;
+ if(!mmat)
+ return NULL;
- int numelements = m_matVertexArrayS.size();
- m_sortedMaterials.push_back(polymat);
-
- KX_ArrayOptimizer* ao = new KX_ArrayOptimizer(numelements);
- m_matVertexArrayS.insert(*polymat,ao);
+ slot = mmat->m_baseslot;
+ len = 0;
+ for(slot->begin(it); !slot->end(it); slot->next(it)) {
+ if(index >= len + it.endvertex - it.startvertex)
+ len += it.endvertex - it.startvertex;
+ else
+ return &it.vertex[index - len];
+ }
- return ao;
+ return NULL;
}
-
-
-void RAS_MeshObject::Bucketize(double* oglmatrix,
- void* clientobj,
- bool useObjectColor,
- const MT_Vector4& rgbavec)
+void RAS_MeshObject::AddMeshUser(void *clientobj)
{
- KX_MeshSlot ms;
- ms.m_clientObj = clientobj;
- ms.m_mesh = this;
- ms.m_OpenGLMatrix = oglmatrix;
- ms.m_bObjectColor = useObjectColor;
- ms.m_RGBAcolor = rgbavec;
-
- for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it)
- {
- RAS_MaterialBucket* bucket = *it;
- bucket->SchedulePolygons(0);
-// KX_ArrayOptimizer* oa = GetArrayOptimizer(bucket->GetPolyMaterial());
- bucket->SetMeshSlot(ms);
- }
+ list<RAS_MeshMaterial>::iterator it;
-}
-
-
-
-void RAS_MeshObject::MarkVisible(double* oglmatrix,
- void* clientobj,
- bool visible,
- bool useObjectColor,
- const MT_Vector4& rgbavec)
-{
- KX_MeshSlot ms;
- ms.m_clientObj = clientobj;
- ms.m_mesh = this;
- ms.m_OpenGLMatrix = oglmatrix;
- ms.m_RGBAcolor = rgbavec;
- ms.m_bObjectColor= useObjectColor;
-
- for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it)
- {
- RAS_MaterialBucket* bucket = *it;
- bucket->SchedulePolygons(0);
-// KX_ArrayOptimizer* oa = GetArrayOptimizer(bucket->GetPolyMaterial());
- bucket->MarkVisibleMeshSlot(ms,visible,useObjectColor,rgbavec);
+ for(it = m_materials.begin();it!=m_materials.end();++it) {
+ /* always copy from the base slot, which is never removed
+ * since new objects can be created with the same mesh data */
+ RAS_MeshSlot *ms = it->m_bucket->CopyMesh(it->m_baseslot);
+ ms->m_clientObj = clientobj;
+ it->m_slots.insert(clientobj, ms);
}
}
-
-void RAS_MeshObject::RemoveFromBuckets(double* oglmatrix,
- void* clientobj)
+void RAS_MeshObject::UpdateBuckets(void* clientobj,
+ double* oglmatrix,
+ bool useObjectColor,
+ const MT_Vector4& rgbavec,
+ bool visible,
+ bool culled)
{
- KX_MeshSlot ms;
- ms.m_clientObj = clientobj;
- ms.m_mesh = this;
- ms.m_OpenGLMatrix = oglmatrix;
-
- for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it)
- {
- RAS_MaterialBucket* bucket = *it;
-// RAS_IPolyMaterial* polymat = bucket->GetPolyMaterial();
- bucket->SchedulePolygons(0);
- //KX_ArrayOptimizer* oa = GetArrayOptimizer(polymat);
- bucket->RemoveMeshSlot(ms);
- }
-
-}
+ list<RAS_MeshMaterial>::iterator it;
+ for(it = m_materials.begin();it!=m_materials.end();++it) {
+ RAS_MeshSlot **msp = it->m_slots[clientobj];
+ if(!msp)
+ continue;
-/*
- * RAS_MeshObject::GetVertex returns the vertex located somewhere in the vertexpool
- * it is the clients responsibility to make sure the array and index are valid
- */
-RAS_TexVert* RAS_MeshObject::GetVertex(short array,
- unsigned int index,
- RAS_IPolyMaterial* polymat)
-{
- KX_ArrayOptimizer* ao = GetArrayOptimizer(polymat);//*(m_matVertexArrays[*polymat]);
- return &((*(ao->m_VertexArrayCache1)[array])[index]);
-}
+ RAS_MeshSlot *ms = *msp;
+ ms->m_mesh = this;
+ ms->m_OpenGLMatrix = oglmatrix;
+ ms->m_bObjectColor = useObjectColor;
+ ms->m_RGBAcolor = rgbavec;
+ ms->m_bVisible = visible;
+ ms->m_bCulled = culled || !visible;
-
-void RAS_MeshObject::ClearArrayData()
-{
- for (int i=0;i<m_matVertexArrayS.size();i++)
- {
- KX_ArrayOptimizer** ao = m_matVertexArrayS.at(i);
- if (ao)
- delete *ao;
+ /* split if necessary */
+ ms->Split();
}
}
-
-
-/**
- * RAS_MeshObject::CreateNewVertices creates vertices within sorted pools of vertices that share same material
-*/
-int RAS_MeshObject::FindVertexArray(int numverts,
- RAS_IPolyMaterial* polymat)
+void RAS_MeshObject::RemoveFromBuckets(void *clientobj)
{
-// bool found=false;
- int array=-1;
+ list<RAS_MeshMaterial>::iterator it;
- KX_ArrayOptimizer* ao = GetArrayOptimizer(polymat);
+ for(it = m_materials.begin();it!=m_materials.end();++it) {
+ RAS_MeshSlot **msp = it->m_slots[clientobj];
- for (unsigned int i=0;i<ao->m_VertexArrayCache1.size();i++)
- {
- if ( (ao->m_TriangleArrayCount[i] + (numverts-2)) < BUCKET_MAX_TRIANGLES)
- {
- if((ao->m_VertexArrayCache1[i]->size()+numverts < BUCKET_MAX_INDICES))
- {
- array = i;
- ao->m_TriangleArrayCount[array]+=numverts-2;
- break;
- }
- }
- }
+ if(!msp)
+ continue;
- if (array == -1)
- {
- array = ao->m_VertexArrayCache1.size();
- vector<RAS_TexVert>* va = new vector<RAS_TexVert>;
- ao->m_VertexArrayCache1.push_back(va);
- KX_IndexArray *ia = new KX_IndexArray();
- ao->m_IndexArrayCache1.push_back(ia);
- ao->m_TriangleArrayCount.push_back(numverts-2);
- }
+ RAS_MeshSlot *ms = *msp;
- return array;
+ it->m_bucket->RemoveMesh(ms);
+ it->m_slots.remove(clientobj);
+ }
}
-
-
-
//void RAS_MeshObject::Transform(const MT_Transform& trans)
//{
//m_trans.translate(MT_Vector3(0,0,1));//.operator *=(trans);
@@ -538,159 +448,62 @@ void RAS_MeshObject::RelativeTransform(const MT_Vector3& vec)
}
*/
-
-
-void RAS_MeshObject::UpdateMaterialList()
-{
- m_materials.clear();
- unsigned int numpolys = m_Polygons.size();
- // for all polygons, find out which material they use, and add it to the set of materials
- for (unsigned int i=0;i<numpolys;i++)
- {
- m_materials.insert(m_Polygons[i]->GetMaterial());
+void RAS_MeshObject::SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transform)
+{
+ // Limitations: sorting is quite simple, and handles many
+ // cases wrong, partially due to polygons being sorted per
+ // bucket.
+ //
+ // a) mixed triangles/quads are sorted wrong
+ // b) mixed materials are sorted wrong
+ // c) more than 65k faces are sorted wrong
+ // d) intersecting objects are sorted wrong
+ // e) intersecting polygons are sorted wrong
+ //
+ // a) can be solved by making all faces either triangles or quads
+ // if they need to be z-sorted. c) could be solved by allowing
+ // larger buckets, b) and d) cannot be solved easily if we want
+ // to avoid excessive state changes while drawing. e) would
+ // require splitting polygons.
+
+ RAS_MeshSlot::iterator it;
+ size_t j;
+
+ for(ms.begin(it); !ms.end(it); ms.next(it)) {
+ unsigned int nvert = (int)it.array->m_type;
+ unsigned int totpoly = it.totindex/nvert;
+
+ if(totpoly <= 1)
+ continue;
+ if(it.array->m_type == RAS_DisplayArray::LINE)
+ continue;
+
+ // Extract camera Z plane...
+ const MT_Vector3 pnorm(transform.getBasis()[2]);
+ // unneeded: const MT_Scalar pval = transform.getOrigin()[2];
+
+ vector<polygonSlot> slots(totpoly);
+
+ /* get indices and z into temporary array */
+ for(j=0; j<totpoly; j++)
+ slots[j].get(it.vertex, it.index, j*nvert, nvert, pnorm);
+
+ /* sort (stable_sort might be better, if flickering happens?) */
+ std::sort(slots.begin(), slots.end(), backtofront());
+
+ /* get indices from temporary array again */
+ for(j=0; j<totpoly; j++)
+ slots[j].set(it.index, j*nvert, nvert);
}
}
-struct RAS_MeshObject::polygonSlot
-{
- float m_z;
- RAS_Polygon *m_poly;
-
- polygonSlot(float z, RAS_Polygon* poly) :
- m_z(z),
- m_poly(poly)
- {}
- /**
- * pnorm and pval form the plane equation that the distance from is used to
- * sort against.
- */
- polygonSlot(const MT_Vector3 &pnorm, const MT_Scalar &pval, RAS_MeshObject *mesh, RAS_Polygon* poly) :
- m_poly(poly)
- {
- const KX_VertexIndex &base = m_poly->GetIndexBase();
- RAS_TexVert *vert = mesh->GetVertex(base.m_vtxarray, base.m_indexarray[0], poly->GetMaterial()->GetPolyMaterial());
- m_z = MT_dot(pnorm, vert->getLocalXYZ()) + pval;
-
- for(int i = 1; i < m_poly->VertexCount(); i++)
- {
- vert = mesh->GetVertex(base.m_vtxarray, base.m_indexarray[i], poly->GetMaterial()->GetPolyMaterial());
- float z = MT_dot(pnorm, vert->getLocalXYZ()) + pval;
- m_z += z;
- }
- m_z /= m_poly->VertexCount();
- }
-};
-
-struct RAS_MeshObject::backtofront
-{
- bool operator()(const polygonSlot &a, const polygonSlot &b) const
- {
- return a.m_z < b.m_z;
- }
-};
-struct RAS_MeshObject::fronttoback
+void RAS_MeshObject::SchedulePolygons(int drawingmode)
{
- bool operator()(const polygonSlot &a, const polygonSlot &b) const
- {
- return a.m_z > b.m_z;
- }
-};
-
-
-void RAS_MeshObject::SortPolygons(const MT_Transform &transform)
-{
- if (!m_zsort)
- return;
-
- // Extract camera Z plane...
- const MT_Vector3 pnorm(transform.getBasis()[2]);
- const MT_Scalar pval = transform.getOrigin()[2];
-
- unsigned int numpolys = m_Polygons.size();
- std::multiset<polygonSlot, backtofront> alphapolyset;
- std::multiset<polygonSlot, fronttoback> solidpolyset;
-
- for (unsigned int p = 0; p < numpolys; p++)
- {
- RAS_Polygon* poly = m_Polygons[p];
- if (poly->IsVisible())
- {
- if (poly->GetMaterial()->GetPolyMaterial()->IsTransparant())
- {
- alphapolyset.insert(polygonSlot(pnorm, pval, this, poly));
- } else {
- solidpolyset.insert(polygonSlot(pnorm, pval, this, poly));
- }
- }
- }
-
- // Clear current array data.
- for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it)
- {
- vector<KX_IndexArray*> *indexcache = &GetArrayOptimizer((*it)->GetPolyMaterial())->m_IndexArrayCache1;
- for (vector<KX_IndexArray*>::iterator iit = indexcache->begin(); iit != indexcache->end(); ++iit)
- (*iit)->clear();
- }
-
- std::multiset<polygonSlot, fronttoback>::iterator sit = solidpolyset.begin();
- for (; sit != solidpolyset.end(); ++sit)
- SchedulePoly((*sit).m_poly->GetVertexIndexBase(), (*sit).m_poly->VertexCount(), (*sit).m_poly->GetMaterial()->GetPolyMaterial());
-
- std::multiset<polygonSlot, backtofront>::iterator ait = alphapolyset.begin();
- for (; ait != alphapolyset.end(); ++ait)
- SchedulePoly((*ait).m_poly->GetVertexIndexBase(), (*ait).m_poly->VertexCount(), (*ait).m_poly->GetMaterial()->GetPolyMaterial());
-}
-
-
-void RAS_MeshObject::SchedulePolygons(const MT_Transform &transform, int drawingmode)
-{
-// int nummaterials = m_materials.size();
- int i;
-
if (m_bModified)
{
- for (RAS_MaterialBucket::Set::iterator it = m_materials.begin();it!=m_materials.end();++it)
- {
- RAS_MaterialBucket* bucket = *it;
-
- bucket->SchedulePolygons(drawingmode);
- if (bucket->GetPolyMaterial()->IsZSort())
- m_zsort = true;
- }
-
- int numpolys = m_Polygons.size();
-
- if ((drawingmode > RAS_IRasterizer::KX_BOUNDINGBOX) &&
- (drawingmode < RAS_IRasterizer::KX_SOLID))
- {
- for (i=0;i<numpolys;i++)
- {
- RAS_Polygon* poly = m_Polygons[i];
- if (poly->IsVisible())
- ScheduleWireframePoly(poly->GetVertexIndexBase(),poly->VertexCount(),poly->GetEdgeCode()
- ,poly->GetMaterial()->GetPolyMaterial());
-
- }
- m_zsort = false;
- }
- else
- {
- if (!m_zsort)
- {
- for (i=0;i<numpolys;i++)
- {
- RAS_Polygon* poly = m_Polygons[i];
- if (poly->IsVisible())
- {
- SchedulePoly(poly->GetVertexIndexBase(),poly->VertexCount(),poly->GetMaterial()->GetPolyMaterial());
- }
- }
- }
- }
-
m_bModified = false;
-
- m_MeshMod = true;
+ m_bMeshModified = true;
}
}
+
diff --git a/source/gameengine/Rasterizer/RAS_MeshObject.h b/source/gameengine/Rasterizer/RAS_MeshObject.h
index 89c472cd0d4..0d35a2f402b 100644
--- a/source/gameengine/Rasterizer/RAS_MeshObject.h
+++ b/source/gameengine/Rasterizer/RAS_MeshObject.h
@@ -36,6 +36,7 @@
#include <vector>
#include <set>
+#include <list>
#include "RAS_Polygon.h"
#include "RAS_MaterialBucket.h"
@@ -43,221 +44,116 @@
#include "GEN_HashedPtr.h"
-/**
- * This class holds an array of vertices and indicies.
- */
-class KX_ArrayOptimizer
-{
-public:
- KX_ArrayOptimizer(int index)
- : m_index1(index)
- {};
- virtual ~KX_ArrayOptimizer();
-
- vector<KX_VertexArray*> m_VertexArrayCache1;
- vector<int> m_TriangleArrayCount;
- vector<KX_IndexArray*> m_IndexArrayCache1;
-
- /**
- order in which they are stored into the mesh
- */
- int m_index1;
-};
-
-/**
- * This struct holds a triangle.
- */
-struct RAS_TriangleIndex
-{
-public:
- int m_index[3];
- int m_array;
- RAS_IPolyMaterial* m_matid;
- bool m_collider;
-};
-
-/**
- * This class looks horribly broken. Only m_matid is used, and
- * m_matid is a (int) RAS_IPolyMaterial*.
- * --> m_matid == lhs.m_matid should be *m_matid == *lhs.m_matid
- */
-class RAS_MatArrayIndex
-{
-public:
-
- int m_arrayindex1;
- RAS_IPolyMaterial* m_matid;
- int m_array;
- int m_index;
+struct Mesh;
-/*
- inline bool Less(const RAS_MatArrayIndex& lhs) const {
- bool result =
- ( (m_matid < lhs.m_matid) ||
- ((m_matid == lhs.m_matid)&&(m_array < lhs.m_array)) ||
- ((m_matid == lhs.m_matid) && (m_array == lhs.m_array) &&
- (m_index < lhs.m_index))
-
- );
- return result;
-
- }
-*/
-
-};
-/*
-inline bool operator <( const RAS_MatArrayIndex& rhs,const RAS_MatArrayIndex& lhs)
-{
- return ( rhs.Less(lhs));
-}*/
+/* RAS_MeshObject is a mesh used for rendering. It stores polygons,
+ * but the actual vertices and index arrays are stored in material
+ * buckets, referenced by the list of RAS_MeshMaterials. */
-/**
- * RAS_MeshObject stores mesh data for the renderer.
- */
class RAS_MeshObject
{
-
- // GEN_Map<class RAS_IPolyMaterial,KX_ArrayOptimizer*> m_matVertexArrayS;
- //vector<class RAS_IPolyMaterial*,KX_ArrayOptimizer> m_vertexArrays;
- virtual KX_ArrayOptimizer* GetArrayOptimizer(RAS_IPolyMaterial* polymat);
- //vector<RAS_Polygon*> m_polygons;
-
+private:
unsigned int m_debugcolor;
- bool m_bModified;
int m_lightlayer;
-
- vector<class RAS_Polygon*> m_Polygons;
+
+ bool m_bModified;
+ bool m_bMeshModified;
+
STR_String m_name;
static STR_String s_emptyname;
- bool m_zsort;
- bool m_MeshMod;
+ vector<class RAS_Polygon*> m_Polygons;
+
+ /* polygon sorting */
struct polygonSlot;
struct backtofront;
struct fronttoback;
-
protected:
- enum { BUCKET_MAX_INDICES = 65535 };//2048};//8192};
- enum { BUCKET_MAX_TRIANGLES = 65535 };
-
- GEN_Map<class RAS_IPolyMaterial,KX_ArrayOptimizer*> m_matVertexArrayS;
-
- RAS_MaterialBucket::Set m_materials;
+ list<RAS_MeshMaterial> m_materials;
+ Mesh* m_mesh;
+ bool m_bDeformed;
+
public:
// for now, meshes need to be in a certain layer (to avoid sorting on lights in realtime)
- RAS_MeshObject(int lightlayer);
+ RAS_MeshObject(Mesh* mesh, int lightlayer);
virtual ~RAS_MeshObject();
- vector<RAS_IPolyMaterial*> m_sortedMaterials;
- vector<vector<RAS_MatArrayIndex> > m_xyz_index_to_vertex_index_mapping;
- vector<RAS_TriangleIndex > m_triangle_indices;
-
- int m_class;
- unsigned int GetLightLayer();
+ bool IsDeformed() { return m_bDeformed; }
+
+ /* materials */
int NumMaterials();
const STR_String& GetMaterialName(unsigned int matid);
- RAS_MaterialBucket* GetMaterialBucket(unsigned int matid);
const STR_String& GetTextureName(unsigned int matid);
- virtual void AddPolygon(RAS_Polygon* poly);
- void UpdateMaterialList();
-
- int NumPolygons();
- RAS_Polygon* GetPolygon(int num);
-
- virtual void Bucketize(
- double* oglmatrix,
- void* clientobj,
- bool useObjectColor,
- const MT_Vector4& rgbavec
- );
- void RemoveFromBuckets(
- double* oglmatrix,
- void* clientobj
- );
+ RAS_MeshMaterial* GetMeshMaterial(unsigned int matid);
+ RAS_MeshMaterial* GetMeshMaterial(RAS_IPolyMaterial *mat);
- void MarkVisible(
- double* oglmatrix,
- void* clientobj,
- bool visible,
- bool useObjectColor,
- const MT_Vector4& rgbavec
- );
+ list<RAS_MeshMaterial>::iterator GetFirstMaterial();
+ list<RAS_MeshMaterial>::iterator GetLastMaterial();
- void DebugColor(unsigned int abgr);
-
- /**
- * Sorts the polygons by their transformed z values.
- */
- void SortPolygons(const MT_Transform &transform);
+ unsigned int GetLightLayer();
- void SchedulePolygons(
- const MT_Transform &transform,
- int drawingmode
- );
+ /* name */
+ void SetName(STR_String name);
+ const STR_String& GetName();
- void ClearArrayData();
-
- RAS_MaterialBucket::Set::iterator GetFirstMaterial();
- RAS_MaterialBucket::Set::iterator GetLastMaterial();
-
- virtual RAS_TexVert* GetVertex(
- short array,
- unsigned int index,
- RAS_IPolyMaterial* polymat
- );
-
- virtual int FindVertexArray(
- int numverts,
- RAS_IPolyMaterial* polymat
- );
-
- void SchedulePoly(
- const KX_VertexIndex& idx,
- int numverts,
- RAS_IPolyMaterial* mat
- );
+ /* modification state */
+ bool MeshModified();
+ void SetMeshModified(bool v){m_bMeshModified = v;}
- void ScheduleWireframePoly(
- const KX_VertexIndex& idx,
- int numverts,
- int edgecode,
- RAS_IPolyMaterial* mat
- );
-
- // find (and share) or add vertices
- // for some speedup, only the last 20 added vertices are searched for equality
+ /* original blender mesh */
+ Mesh* GetMesh() { return m_mesh; }
+
+ /* mesh construction */
- virtual int FindOrAddVertex(
- int vtxarray,
+ virtual RAS_Polygon* AddPolygon(RAS_MaterialBucket *bucket, int numverts);
+ virtual void AddVertex(RAS_Polygon *poly, int i,
const MT_Point3& xyz,
const MT_Point2& uv,
const MT_Point2& uv2,
const MT_Vector4& tangent,
const unsigned int rgbacolor,
const MT_Vector3& normal,
- RAS_IPolyMaterial* mat,
- int orgindex
- );
-
- const vecVertexArray& GetVertexCache (RAS_IPolyMaterial* mat);
+ bool flat,
+ int origindex);
+
+ void SchedulePolygons(int drawingmode);
+
+ /* vertex and polygon acces */
+ int NumVertices(RAS_IPolyMaterial* mat);
+ RAS_TexVert* GetVertex(unsigned int matid, unsigned int index);
+
+ int NumPolygons();
+ RAS_Polygon* GetPolygon(int num) const;
- int GetVertexArrayLength(RAS_IPolyMaterial* mat);
+ /* buckets */
+ virtual void AddMeshUser(void *clientobj);
+ virtual void UpdateBuckets(
+ void* clientobj,
+ double* oglmatrix,
+ bool useObjectColor,
+ const MT_Vector4& rgbavec,
+ bool visible,
+ bool culled);
- RAS_TexVert* GetVertex(
- unsigned int matid,
- unsigned int index
- );
+ void RemoveFromBuckets(void *clientobj);
- const vecIndexArrays& GetIndexCache (RAS_IPolyMaterial* mat);
- void SetName(STR_String name);
- const STR_String& GetName();
+ /* colors */
+ void DebugColor(unsigned int abgr);
+ void SetVertexColor(RAS_IPolyMaterial* mat,MT_Vector4 rgba);
+
+ /* polygon sorting by Z for alpha */
+ void SortPolygons(RAS_MeshSlot& ms, const MT_Transform &transform);
- bool MeshModified();
- void SetMeshModified(bool v){m_MeshMod = v;}
+ /* for construction to find shared vertices */
+ struct SharedVertex {
+ RAS_DisplayArray *m_darray;
+ int m_offset;
+ };
+ vector<vector<SharedVertex> > m_sharedvertex_map;
};
#endif //__RAS_MESHOBJECT
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h
new file mode 100644
index 00000000000..81821639489
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Blur2DFilter.h
@@ -0,0 +1,51 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_BLUR2DFILTER
+#define __RAS_BLUR2DFILTER
+
+const char * BlurFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ }
+
+ gl_FragColor = (sample[0] + (2.0*sample[1]) + sample[2] +
+ (2.0*sample[3]) + sample[4] + (2.0*sample[5]) +
+ sample[6] + (2.0*sample[7]) + sample[8]) / 13.0;
+}
+);
+#endif
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h
new file mode 100644
index 00000000000..2ee75396f42
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Dilation2DFilter.h
@@ -0,0 +1,51 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_DILATION2DFILTER
+#define __RAS_DILATION2DFILTER
+
+const char * DilationFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+ vec4 maxValue = vec4(0.0);
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ maxValue = max(sample[i], maxValue);
+ }
+
+ gl_FragColor = maxValue;
+}
+);
+#endif
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h
new file mode 100644
index 00000000000..d3ce829bab0
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Erosion2DFilter.h
@@ -0,0 +1,50 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_EROSION2DFILTER
+#define __RAS_EROSION2DFILTER
+
+const char * ErosionFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+ vec4 minValue = vec4(1.0);
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ minValue = min(sample[i], minValue);
+ }
+
+ gl_FragColor = minValue;
+}
+);
+#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h
new file mode 100644
index 00000000000..ae51308e9a4
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_GrayScale2DFilter.h
@@ -0,0 +1,41 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_GRAYSCALE2DFILTER
+#define __RAS_GRAYSCALE2DFILTER
+
+const char * GrayScaleFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+
+void main(void)
+{
+ vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
+ float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114));
+ gl_FragColor = vec4(gray, gray, gray, texcolor.a);
+}
+);
+#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h
new file mode 100644
index 00000000000..f723f619f68
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Invert2DFilter.h
@@ -0,0 +1,41 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_INVERT2DFILTER
+#define __RAS_INVERT2DFILTER
+
+const char * InvertFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+
+void main(void)
+{
+ vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
+ gl_FragColor.rgb = 1.0 - texcolor.rgb;
+ gl_FragColor.a = texcolor.a;
+}
+);
+#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h
new file mode 100644
index 00000000000..bfbb40b2fc9
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Laplacian2DFilter.h
@@ -0,0 +1,53 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_LAPLACION2DFILTER
+#define __RAS_LAPLACION2DFILTER
+
+const char * LaplacionFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ }
+
+ gl_FragColor = (sample[4] * 8.0) -
+ (sample[0] + sample[1] + sample[2] +
+ sample[3] + sample[5] +
+ sample[6] + sample[7] + sample[8]);
+ gl_FragColor = vec4(gl_FragColor.rgb, 1.0);
+}
+);
+#endif
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h
new file mode 100644
index 00000000000..0cbf8a7a802
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Prewitt2DFilter.h
@@ -0,0 +1,58 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_PREWITT2DFILTER
+#define __RAS_PREWITT2DFILTER
+
+const char * PrewittFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ }
+
+ vec4 horizEdge = sample[2] + sample[5] + sample[8] -
+ (sample[0] + sample[3] + sample[6]);
+
+ vec4 vertEdge = sample[0] + sample[1] + sample[2] -
+ (sample[6] + sample[7] + sample[8]);
+
+ gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) +
+ (vertEdge.rgb * vertEdge.rgb));
+ gl_FragColor.a = 1.0;
+}
+
+);
+#endif
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h
new file mode 100644
index 00000000000..ca431af4cd7
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sepia2DFilter.h
@@ -0,0 +1,41 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_SEPIA2DFILTER
+#define __RAS_SEPIA2DFILTER
+
+const char * SepiaFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+
+void main(void)
+{
+ vec4 texcolor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st);
+ float gray = dot(texcolor.rgb, vec3(0.299, 0.587, 0.114));
+ gl_FragColor = vec4(gray * vec3(1.2, 1.0, 0.8), texcolor.a);
+}
+);
+#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h
new file mode 100644
index 00000000000..5a9661e2617
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sharpen2DFilter.h
@@ -0,0 +1,52 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_SHARPEN2DFILTER
+#define __RAS_SHARPEN2DFILTER
+
+const char * SharpenFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ }
+
+ gl_FragColor = (sample[4] * 9.0) -
+ (sample[0] + sample[1] + sample[2] +
+ sample[3] + sample[5] +
+ sample[6] + sample[7] + sample[8]);
+}
+);
+#endif
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h
new file mode 100644
index 00000000000..142e4f0e3d4
--- /dev/null
+++ b/source/gameengine/Rasterizer/RAS_OpenGLFilters/RAS_Sobel2DFilter.h
@@ -0,0 +1,57 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ * of the License, or (at your option) any later version.
+ *
+ * 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,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * 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.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef __RAS_SOBEL2DFILTER
+#define __RAS_SOBEL2DFILTER
+
+const char * SobelFragmentShader=STRINGIFY(
+uniform sampler2D bgl_RenderedTexture;
+uniform vec2 bgl_TextureCoordinateOffset[9];
+
+void main(void)
+{
+ vec4 sample[9];
+
+ for (int i = 0; i < 9; i++)
+ {
+ sample[i] = texture2D(bgl_RenderedTexture,
+ gl_TexCoord[0].st + bgl_TextureCoordinateOffset[i]);
+ }
+
+ vec4 horizEdge = sample[2] + (2.0*sample[5]) + sample[8] -
+ (sample[0] + (2.0*sample[3]) + sample[6]);
+
+ vec4 vertEdge = sample[0] + (2.0*sample[1]) + sample[2] -
+ (sample[6] + (2.0*sample[7]) + sample[8]);
+
+ gl_FragColor.rgb = sqrt((horizEdge.rgb * horizEdge.rgb) +
+ (vertEdge.rgb * vertEdge.rgb));
+ gl_FragColor.a = 1.0;
+}
+);
+#endif
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/ARB_multitexture.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/ARB_multitexture.h
deleted file mode 100644
index a2f27ce3361..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/ARB_multitexture.h
+++ /dev/null
@@ -1,150 +0,0 @@
-#ifndef __ARB_MULTITEXTURE_H__
-#define __ARB_MULTITEXTURE_H__
-
-/*
-*/
-
-/* ----------------------------------------------------------------------------
- GL_ARB_multitexture
----------------------------------------------------------------------------- */
-#ifdef GL_ARB_multitexture
- #define GL_TEXTURE0_ARB 0x84C0
- #define GL_TEXTURE1_ARB 0x84C1
- #define GL_TEXTURE2_ARB 0x84C2
- #define GL_TEXTURE3_ARB 0x84C3
- #define GL_TEXTURE4_ARB 0x84C4
- #define GL_TEXTURE5_ARB 0x84C5
- #define GL_TEXTURE6_ARB 0x84C6
- #define GL_TEXTURE7_ARB 0x84C7
- #define GL_TEXTURE8_ARB 0x84C8
- #define GL_TEXTURE9_ARB 0x84C9
- #define GL_TEXTURE10_ARB 0x84CA
- #define GL_ACTIVE_TEXTURE_ARB 0x84E0
- #define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
- #define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
-#endif
-
-
-/* ----------------------------------------------------------------------------
- GL_ARB_texture_env_combine
----------------------------------------------------------------------------- */
-#ifdef GL_ARB_texture_env_combine
- #define GL_COMBINE_ARB 0x8570
- #define GL_COMBINE_RGB_ARB 0x8571
- #define GL_COMBINE_ALPHA_ARB 0x8572
- #define GL_SOURCE0_RGB_ARB 0x8580
- #define GL_SOURCE1_RGB_ARB 0x8581
- #define GL_SOURCE2_RGB_ARB 0x8582
- #define GL_SOURCE0_ALPHA_ARB 0x8588
- #define GL_SOURCE1_ALPHA_ARB 0x8589
- #define GL_SOURCE2_ALPHA_ARB 0x858A
- #define GL_OPERAND0_RGB_ARB 0x8590
- #define GL_OPERAND1_RGB_ARB 0x8591
- #define GL_OPERAND2_RGB_ARB 0x8592
- #define GL_OPERAND0_ALPHA_ARB 0x8598
- #define GL_OPERAND1_ALPHA_ARB 0x8599
- #define GL_OPERAND2_ALPHA_ARB 0x859A
- #define GL_RGB_SCALE_ARB 0x8573
- #define GL_ADD_SIGNED_ARB 0x8574
- #define GL_INTERPOLATE_ARB 0x8575
- #define GL_SUBTRACT_ARB 0x84E7
- #define GL_CONSTANT_ARB 0x8576
- #define GL_PRIMARY_COLOR_ARB 0x8577
- #define GL_PREVIOUS_ARB 0x8578
-#endif
-
-/* ----------------------------------------------------------------------------
- GL_ARB_texture_cube_map
----------------------------------------------------------------------------- */
-#ifdef GL_ARB_texture_cube_map
- #define GL_NORMAL_MAP_ARB 0x8511
- #define GL_REFLECTION_MAP_ARB 0x8512
- #define GL_TEXTURE_CUBE_MAP_ARB 0x8513
- #define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514
- #define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515
- #define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516
- #define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517
- #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518
- #define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519
- #define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A
- #define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B
- #define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C
-#endif
-
-/* ----------------------------------------------------------------------------
- GL_ARB_shader_objects
----------------------------------------------------------------------------- */
-#ifdef GL_ARB_shader_objects
- #define GL_PROGRAM_OBJECT_ARB 0x8B40
- #define GL_SHADER_OBJECT_ARB 0x8B48
- #define GL_OBJECT_TYPE_ARB 0x8B4E
- #define GL_OBJECT_SUBTYPE_ARB 0x8B4F
- #define GL_FLOAT_VEC2_ARB 0x8B50
- #define GL_FLOAT_VEC3_ARB 0x8B51
- #define GL_FLOAT_VEC4_ARB 0x8B52
- #define GL_INT_VEC2_ARB 0x8B53
- #define GL_INT_VEC3_ARB 0x8B54
- #define GL_INT_VEC4_ARB 0x8B55
- #define GL_BOOL_ARB 0x8B56
- #define GL_BOOL_VEC2_ARB 0x8B57
- #define GL_BOOL_VEC3_ARB 0x8B58
- #define GL_BOOL_VEC4_ARB 0x8B59
- #define GL_FLOAT_MAT2_ARB 0x8B5A
- #define GL_FLOAT_MAT3_ARB 0x8B5B
- #define GL_FLOAT_MAT4_ARB 0x8B5C
- #define GL_SAMPLER_1D_ARB 0x8B5D
- #define GL_SAMPLER_2D_ARB 0x8B5E
- #define GL_SAMPLER_3D_ARB 0x8B5F
- #define GL_SAMPLER_CUBE_ARB 0x8B60
- #define GL_SAMPLER_1D_SHADOW_ARB 0x8B61
- #define GL_SAMPLER_2D_SHADOW_ARB 0x8B62
- #define GL_SAMPLER_2D_RECT_ARB 0x8B63
- #define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64
- #define GL_OBJECT_DELETE_STATUS_ARB 0x8B80
- #define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81
- #define GL_OBJECT_LINK_STATUS_ARB 0x8B82
- #define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83
- #define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84
- #define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85
- #define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86
- #define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87
- #define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88
-#endif
-
-/* ----------------------------------------------------------------------------
- GL_ARB_vertex_shader
----------------------------------------------------------------------------- */
-#ifdef GL_ARB_vertex_shader
- #define GL_VERTEX_SHADER_ARB 0x8B31
- #define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A
- #define GL_MAX_VARYING_FLOATS_ARB 0x8B4B
- #define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C
- #define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D
- #define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89
- #define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A
-#endif
-
-
-/* ----------------------------------------------------------------------------
- GL_ARB_fragment_shader
----------------------------------------------------------------------------- */
-#ifdef GL_ARB_fragment_shader
- #define GL_FRAGMENT_SHADER_ARB 0x8B30
- #define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49
- #define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B
-#endif
-
-
-/* ----------------------------------------------------------------------------
- GL_ARB_depth_texture
----------------------------------------------------------------------------- */
-#ifndef GL_ARB_depth_texture
- #define GL_DEPTH_COMPONENT16_ARB 0x81A5
- #define GL_DEPTH_COMPONENT24_ARB 0x81A6
- #define GL_DEPTH_COMPONENT32_ARB 0x81A7
- #define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A
- #define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
-#endif
-
-
-#endif//__ARB_MULTITEXTURE_H__
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
index 5153834899b..e4403ace69f 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/CMakeLists.txt
@@ -31,6 +31,8 @@ SET(INC
../../../../intern/string
../../../../intern/moto/include
../../../../source/gameengine/Rasterizer
+ ../../../../extern/glew/include
+ ../../../../source/blender/gpu
)
BLENDERLIB(bf_oglrasterizer "${SRC}" "${INC}")
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/EXT_separate_specular_color.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/EXT_separate_specular_color.h
deleted file mode 100644
index 5a9d8f32a87..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/EXT_separate_specular_color.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef GL_EXT_separate_specular_color
-#define GL_EXT_separate_specular_color 1
-#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8
-#define GL_SINGLE_COLOR_EXT 0x81F9
-#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA
-#endif
-
-#ifndef GL_VERSION_1_2
-#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
-#define GL_SINGLE_COLOR 0x81F9
-#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile
index c0d12435b14..aee485a22be 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/Makefile
@@ -36,11 +36,16 @@ include nan_compile.mk
CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
+CPPFLAGS += -I$(NAN_GLEW)/include
CPPFLAGS += -I$(OPENGL_HEADERS)
CPPFLAGS += -I$(NAN_STRING)/include
CPPFLAGS += -I$(NAN_MOTO)/include
CPPFLAGS += -I../../../kernel/gen_system
+CPPFLAGS += -I../../../blender/gpu
+CPPFLAGS += -I../../BlenderRoutines
CPPFLAGS += -I..
+
ifeq ($(OS),darwin)
CPPFLAGS += -fpascal-strings
endif
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp
index c2b6e03fa02..d241bd1ee31 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.cpp
@@ -25,664 +25,43 @@
*
* ***** END GPL LICENSE BLOCK *****
*/
-/*
- The extension manager's job is to link at runtime OpenGL extension
- functions.
- Since the various platform have different methods of finding a fn
- pointer, this file attempts to encapsulate all that, so it gets a
- little messy. Hopefully we can
-*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef WIN32
-# include <windows.h>
-
-# include <GL/gl.h>
-
-#elif defined(__APPLE__)
-# include <Carbon/Carbon.h>
-# define GL_GLEXT_LEGACY 1
-# include <OpenGL/gl.h>
-
-#else /* UNIX */
-# include <GL/gl.h>
-# include <GL/glx.h>
-
-# include <dlfcn.h>
-#endif
-
-#include <vector>
#include <iostream>
-#include <algorithm>
-#include <bitset>
-
-#include "STR_String.h"
#include "RAS_GLExtensionManager.h"
-/* -----------------------------------------------------------------------------
-
- Platform specific functions section.
-
- Required Functions:
- static void bglInitEntryPoints (void) -- Loads the GL library
- static void bglDeallocEntryPoints (void) -- Frees the GL library
- static void *bglGetProcAddress(const GLubyte* entry) -- Finds the address of
- the GL function entry
-
-*/
-#if defined(BGL_NO_EXTENSIONS)
-static void bglInitEntryPoints (void) {}
-static void bglDeallocEntryPoints (void) {}
-
-static void *bglGetProcAddress(const GLubyte* entry)
-{
- /* No Extensions! */
- return NULL;
-}
-#elif defined(__APPLE__)
-/* http://developer.apple.com/qa/qa2001/qa1188.html */
-CFBundleRef gBundleRefOpenGL = NULL;
-
-// -------------------------
-
-static OSStatus bglInitEntryPoints (void)
-{
- OSStatus err = noErr;
- const Str255 frameworkName = "\pOpenGL.framework";
- FSRefParam fileRefParam;
- FSRef fileRef;
- CFURLRef bundleURLOpenGL;
-
- memset(&fileRefParam, 0, sizeof(fileRefParam));
- memset(&fileRef, 0, sizeof(fileRef));
-
- fileRefParam.ioNamePtr = frameworkName;
- fileRefParam.newRef = &fileRef;
-
- // Frameworks directory/folder
- err = FindFolder (kSystemDomain, kFrameworksFolderType, false,
- &fileRefParam.ioVRefNum, (SInt32*)&fileRefParam.ioDirID);
- if (noErr != err) {
- DebugStr ((unsigned char *)"\pCould not find frameworks folder");
- return err;
- }
- err = PBMakeFSRefSync (&fileRefParam); // make FSRef for folder
- if (noErr != err) {
- DebugStr ((unsigned char *)"\pCould make FSref to frameworks folder");
- return err;
- }
- // create URL to folder
- bundleURLOpenGL = CFURLCreateFromFSRef (kCFAllocatorDefault,
- &fileRef);
- if (!bundleURLOpenGL) {
- DebugStr ((unsigned char *)"\pCould create OpenGL Framework bundle URL");
- return paramErr;
- }
- // create ref to GL's bundle
- gBundleRefOpenGL = CFBundleCreate (kCFAllocatorDefault,
- bundleURLOpenGL);
- if (!gBundleRefOpenGL) {
- DebugStr ((unsigned char *)"\pCould not create OpenGL Framework bundle");
- return paramErr;
- }
- CFRelease (bundleURLOpenGL); // release created bundle
- // if the code was successfully loaded, look for our function.
- if (!CFBundleLoadExecutable (gBundleRefOpenGL)) {
- DebugStr ((unsigned char *)"\pCould not load MachO executable");
- return paramErr;
- }
- return err;
-}
-
-// -------------------------
-
-static void bglDeallocEntryPoints (void)
-{
- if (gBundleRefOpenGL != NULL) {
- // unload the bundle's code.
- CFBundleUnloadExecutable (gBundleRefOpenGL);
- CFRelease (gBundleRefOpenGL);
- gBundleRefOpenGL = NULL;
- }
-}
-
-// -------------------------
-
-/*unused*/
-static void * bglGetProcAddress (const GLubyte * pszProc)
-{
- if (!gBundleRefOpenGL)
- return NULL;
-
- return CFBundleGetFunctionPointerForName (gBundleRefOpenGL,
- CFStringCreateWithCStringNoCopy (NULL,
- (const char *) pszProc, CFStringGetSystemEncoding (), NULL));
-}
-#elif defined(GLX_ARB_get_proc_address)
-/* Not all glx.h define PFNGLXGETPROCADDRESSARBPROC !
- We define our own if needed. */
-#ifdef HAVE_PFNGLXGETPROCADDRESSARBPROC
-#define PFNBGLXGETPROCADDRESSARBPROC PFNGLXGETPROCADDRESSARBPROC
-#else
-typedef void (*(*PFNBGLXGETPROCADDRESSARBPROC)(const GLubyte *procname))();
-#endif
-
-void *_getProcAddress(const GLubyte *procName) { return NULL; }
-PFNBGLXGETPROCADDRESSARBPROC bglGetProcAddress;
-
-
-//weird bug related to combination of pthreads,libGL and dlopen
-//cannot call dlclose in such environment, causes crashes
-//so try to keep a global handle to libGL
-void* libGL = 0;
-
-static void bglInitEntryPoints (void)
-{
- Display *dpy = glXGetCurrentDisplay();
- std::vector<STR_String> Xextensions = STR_String(glXQueryExtensionsString(dpy, DefaultScreen(dpy))).Explode(' ');
- if (std::find(Xextensions.begin(), Xextensions.end(), "GLX_ARB_get_proc_address") != Xextensions.end())
- {
- if (!libGL)
- {
- libGL = dlopen("libGL.so", RTLD_LAZY|RTLD_GLOBAL);
- if (libGL)
- bglGetProcAddress = (PFNBGLXGETPROCADDRESSARBPROC) (dlsym(libGL, "glXGetProcAddressARB"));
- else
- std::cout << "Error: " << dlerror() << std::endl;
-
- // dlclose(libGL);
- if (!bglGetProcAddress)
- bglGetProcAddress = (PFNBGLXGETPROCADDRESSARBPROC) _getProcAddress;
-
- // --
- if(!bglGetProcAddress)
- std::cout << "Error: unable to find _getProcAddress in libGL" << std::endl;
- }
- }
-}
-
-static void bglDeallocEntryPoints (void) {}
-
-#elif defined(WIN32)
-static void bglInitEntryPoints (void) {}
-static void bglDeallocEntryPoints (void) {}
-
-#define bglGetProcAddress(entry) wglGetProcAddress((LPCSTR) entry)
-
-#else /* Unknown Platform - disable extensions */
-static void bglInitEntryPoints (void) {}
-static void bglDeallocEntryPoints (void) {}
-
-static void *bglGetProcAddress(const GLubyte* entry)
-{
- /* No Extensions! */
- return NULL;
-}
-
-#endif /* End Platform Specific */
-
-/* -----------------------------------------------------------------------------
-
- GL Extension Manager.
-*/
- /* Bit array of available extensions */
-static std::bitset<bgl::NUM_EXTENSIONS> enabled_extensions;
-static std::vector<STR_String> extensions;
-static int m_debug;
-
-static void LinkExtensions();
-
-static void EnableExtension(bgl::ExtensionName name)
-{
- unsigned int num = (unsigned int) name;
- if (num < bgl::NUM_EXTENSIONS)
- enabled_extensions.set(num);
-}
-
-
-static bool QueryExtension(STR_String extension_name)
-{
- return std::find(extensions.begin(), extensions.end(), extension_name) != extensions.end();
-}
-
namespace bgl
{
-
-void InitExtensions(int debug)
-{
- m_debug = debug;
- bglInitEntryPoints (); //init bundle
- EnableExtension(_BGL_TEST);
- LinkExtensions();
- bglDeallocEntryPoints();
-}
-
-bool QueryExtension(ExtensionName name)
-{
- unsigned int num = (unsigned int) name;
- if (num < NUM_EXTENSIONS)
- return enabled_extensions[num];
-
- return false;
-}
-
-bool QueryVersion(int major, int minor)
-{
- static int gl_major = 0;
- static int gl_minor = 0;
-
- if (gl_major == 0)
+ void InitExtensions(bool debug)
{
- const char *gl_version_str = (const char *) glGetString(GL_VERSION);
- if (!gl_version_str)
- return false;
- STR_String gl_version = STR_String(gl_version_str);
- int i = gl_version.Find('.');
- gl_major = gl_version.Left(i).ToInt();
- gl_minor = gl_version.Mid(i+1, gl_version.FindOneOf(". ", i+1) - i - 1).ToInt();
-
- static bool doQueryVersion = m_debug;
- if (doQueryVersion)
- {
- doQueryVersion = false;
- std::cout << "GL_VERSION: " << gl_major << "." << gl_minor << " (" << gl_version << ")" << std::endl;
- }
- }
-
- if (gl_major > major)
- return true;
-
- if (gl_major == major && gl_minor >= minor)
- return true;
+ static bool firsttime = true;
- return false;
-}
-
-
-/*******************************************************************************
-1. Extension function entry points go here
-
-Need to #ifdef (compile time test for extension)
-Add null functions if appropriate
-
-Some extensions have been incorporated into the core GL, eg Multitexture was
-added in GL v1.1. If Blender calls one of these functions before they are
-linked, it will crash. Even worse, if Blender *indirectly* calls one of these
-functions, (ie the GL implementation calls them itself) Blender will crash.
-
-We fix this by adding them to the bgl namespace - the functions are now
-private to the gameengine. Code can transparently use extensions by adding:
-
-using namespace bgl;
-
-to their source. Cunning like a weasel.
-
- ******************************************************************************/
-
-#if defined(PFNGLPNTRIANGLESIATIPROC)
-PFNGLPNTRIANGLESIATIPROC glPNTrianglesiATI;
-PFNGLPNTRIANGLESFATIPROC glPNTrianglesfATI;
-#endif
-
-BL_EXTInfo RAS_EXT_support;
-
-
-#ifdef GL_ARB_multitexture
-int max_texture_units = 2;
- PFNGLACTIVETEXTUREARBPROC blActiveTextureARB;
- PFNGLCLIENTACTIVETEXTUREARBPROC blClientActiveTextureARB;
- PFNGLMULTITEXCOORD1DARBPROC blMultiTexCoord1dARB;
- PFNGLMULTITEXCOORD1DVARBPROC blMultiTexCoord1dvARB;
- PFNGLMULTITEXCOORD1FARBPROC blMultiTexCoord1fARB;
- PFNGLMULTITEXCOORD1FVARBPROC blMultiTexCoord1fvARB;
- PFNGLMULTITEXCOORD1IARBPROC blMultiTexCoord1iARB;
- PFNGLMULTITEXCOORD1IVARBPROC blMultiTexCoord1ivARB;
- PFNGLMULTITEXCOORD1SARBPROC blMultiTexCoord1sARB;
- PFNGLMULTITEXCOORD1SVARBPROC blMultiTexCoord1svARB;
- PFNGLMULTITEXCOORD2DARBPROC blMultiTexCoord2dARB;
- PFNGLMULTITEXCOORD2DVARBPROC blMultiTexCoord2dvARB;
- PFNGLMULTITEXCOORD2FARBPROC blMultiTexCoord2fARB;
- PFNGLMULTITEXCOORD2FVARBPROC blMultiTexCoord2fvARB;
- PFNGLMULTITEXCOORD2IARBPROC blMultiTexCoord2iARB;
- PFNGLMULTITEXCOORD2IVARBPROC blMultiTexCoord2ivARB;
- PFNGLMULTITEXCOORD2SARBPROC blMultiTexCoord2sARB;
- PFNGLMULTITEXCOORD2SVARBPROC blMultiTexCoord2svARB;
- PFNGLMULTITEXCOORD3DARBPROC blMultiTexCoord3dARB;
- PFNGLMULTITEXCOORD3DVARBPROC blMultiTexCoord3dvARB;
- PFNGLMULTITEXCOORD3FARBPROC blMultiTexCoord3fARB;
- PFNGLMULTITEXCOORD3FVARBPROC blMultiTexCoord3fvARB;
- PFNGLMULTITEXCOORD3IARBPROC blMultiTexCoord3iARB;
- PFNGLMULTITEXCOORD3IVARBPROC blMultiTexCoord3ivARB;
- PFNGLMULTITEXCOORD3SARBPROC blMultiTexCoord3sARB;
- PFNGLMULTITEXCOORD3SVARBPROC blMultiTexCoord3svARB;
- PFNGLMULTITEXCOORD4DARBPROC blMultiTexCoord4dARB;
- PFNGLMULTITEXCOORD4DVARBPROC blMultiTexCoord4dvARB;
- PFNGLMULTITEXCOORD4FARBPROC blMultiTexCoord4fARB;
- PFNGLMULTITEXCOORD4FVARBPROC blMultiTexCoord4fvARB;
- PFNGLMULTITEXCOORD4IARBPROC blMultiTexCoord4iARB;
- PFNGLMULTITEXCOORD4IVARBPROC blMultiTexCoord4ivARB;
- PFNGLMULTITEXCOORD4SARBPROC blMultiTexCoord4sARB;
- PFNGLMULTITEXCOORD4SVARBPROC blMultiTexCoord4svARB;
-#endif
-
-#ifdef GL_ARB_shader_objects
- PFNGLDELETEOBJECTARBPROC blDeleteObjectARB;
- PFNGLGETHANDLEARBPROC blGetHandleARB;
- PFNGLDETACHOBJECTARBPROC blDetachObjectARB;
- PFNGLCREATESHADEROBJECTARBPROC blCreateShaderObjectARB;
- PFNGLSHADERSOURCEARBPROC blShaderSourceARB;
- PFNGLCOMPILESHADERARBPROC blCompileShaderARB;
- PFNGLCREATEPROGRAMOBJECTARBPROC blCreateProgramObjectARB;
- PFNGLATTACHOBJECTARBPROC blAttachObjectARB;
- PFNGLLINKPROGRAMARBPROC blLinkProgramARB;
- PFNGLUSEPROGRAMOBJECTARBPROC blUseProgramObjectARB;
- PFNGLVALIDATEPROGRAMARBPROC blValidateProgramARB;
- PFNGLUNIFORM1FARBPROC blUniform1fARB;
- PFNGLUNIFORM2FARBPROC blUniform2fARB;
- PFNGLUNIFORM3FARBPROC blUniform3fARB;
- PFNGLUNIFORM4FARBPROC blUniform4fARB;
- PFNGLUNIFORM1IARBPROC blUniform1iARB;
- PFNGLUNIFORM2IARBPROC blUniform2iARB;
- PFNGLUNIFORM3IARBPROC blUniform3iARB;
- PFNGLUNIFORM4IARBPROC blUniform4iARB;
- PFNGLUNIFORM1FVARBPROC blUniform1fvARB;
- PFNGLUNIFORM2FVARBPROC blUniform2fvARB;
- PFNGLUNIFORM3FVARBPROC blUniform3fvARB;
- PFNGLUNIFORM4FVARBPROC blUniform4fvARB;
- PFNGLUNIFORM1IVARBPROC blUniform1ivARB;
- PFNGLUNIFORM2IVARBPROC blUniform2ivARB;
- PFNGLUNIFORM3IVARBPROC blUniform3ivARB;
- PFNGLUNIFORM4IVARBPROC blUniform4ivARB;
- PFNGLUNIFORMMATRIX2FVARBPROC blUniformMatrix2fvARB;
- PFNGLUNIFORMMATRIX3FVARBPROC blUniformMatrix3fvARB;
- PFNGLUNIFORMMATRIX4FVARBPROC blUniformMatrix4fvARB;
- PFNGLGETOBJECTPARAMETERFVARBPROC blGetObjectParameterfvARB;
- PFNGLGETOBJECTPARAMETERIVARBPROC blGetObjectParameterivARB;
- PFNGLGETINFOLOGARBPROC blGetInfoLogARB;
- PFNGLGETATTACHEDOBJECTSARBPROC blGetAttachedObjectsARB;
- PFNGLGETUNIFORMLOCATIONARBPROC blGetUniformLocationARB;
- PFNGLGETACTIVEUNIFORMARBPROC blGetActiveUniformARB;
- PFNGLGETUNIFORMFVARBPROC blGetUniformfvARB;
- PFNGLGETUNIFORMIVARBPROC blGetUniformivARB;
- PFNGLGETSHADERSOURCEARBPROC blGetShaderSourceARB;
-#endif
-
-#ifdef GL_ARB_vertex_shader
-PFNGLBINDATTRIBLOCATIONARBPROC blBindAttribLocationARB;
-PFNGLGETACTIVEATTRIBARBPROC blGetActiveAttribARB;
-PFNGLGETATTRIBLOCATIONARBPROC blGetAttribLocationARB;
-#endif
-
-#ifdef GL_ARB_vertex_program
- PFNGLVERTEXATTRIB1FARBPROC blVertexAttrib1fARB;
- PFNGLVERTEXATTRIB1FVARBPROC blVertexAttrib1fvARB;
- PFNGLVERTEXATTRIB2FARBPROC blVertexAttrib2fARB;
- PFNGLVERTEXATTRIB2FVARBPROC blVertexAttrib2fvARB;
- PFNGLVERTEXATTRIB3FARBPROC blVertexAttrib3fARB;
- PFNGLVERTEXATTRIB3FVARBPROC blVertexAttrib3fvARB;
- PFNGLVERTEXATTRIB4FARBPROC blVertexAttrib4fARB;
- PFNGLVERTEXATTRIB4FVARBPROC blVertexAttrib4fvARB;
- PFNGLGETPROGRAMSTRINGARBPROC blGetProgramStringARB;
- PFNGLGETVERTEXATTRIBDVARBPROC blGetVertexAttribdvARB;
- PFNGLGETVERTEXATTRIBFVARBPROC blGetVertexAttribfvARB;
- PFNGLGETVERTEXATTRIBIVARBPROC blGetVertexAttribivARB;
-#endif
-
- /*
-#ifdef GL_EXT_compiled_vertex_array
- PFNGLLOCKARRAYSEXTPROC blLockArraysEXT;
- PFNGLUNLOCKARRAYSEXTPROC blUnlockArraysEXT;
-#endif
-*/
-
-} // namespace bgl
-
-using namespace bgl;
-/*******************************************************************************
-2. Query extension functions here
-
-Need to #ifdef (compile time test for extension)
-Use QueryExtension("GL_EXT_name") to test at runtime.
-Use bglGetProcAddress to find entry point
-Use EnableExtension(_GL_EXT_...) to allow Blender to use the extension.
-
- ******************************************************************************/
-static void LinkExtensions()
-{
- static bool doDebugMessages = m_debug;
- extensions = STR_String((const char *) glGetString(GL_EXTENSIONS)).Explode(' ');
- RAS_EXT_support = BL_EXTInfo();
-
-#if defined(PFNGLPNTRIANGLESIATIPROC)
- if (QueryExtension("GL_ATI_pn_triangles"))
- {
- glPNTrianglesiATI = reinterpret_cast<PFNGLPNTRIANGLESIATIPROC>(bglGetProcAddress((const GLubyte *) "glPNTrianglesiATI"));
- glPNTrianglesfATI = reinterpret_cast<PFNGLPNTRIANGLESFATIPROC>(bglGetProcAddress((const GLubyte *) "glPNTrianglesfATI"));
- if (glPNTrianglesiATI && glPNTrianglesfATI) {
- EnableExtension(_GL_ATI_pn_triangles);
- if (doDebugMessages)
- std::cout << "Enabled GL_ATI_pn_triangles" << std::endl;
- } else {
- std::cout << "ERROR: GL_ATI_pn_triangles implementation is broken!" << std::endl;
- }
- }
-#endif
-
-#ifdef GL_ARB_texture_env_combine
- if (QueryExtension("GL_ARB_texture_env_combine"))
- {
- EnableExtension(_GL_ARB_texture_env_combine);
- RAS_EXT_support._ARB_texture_env_combine = 1;
- if (doDebugMessages)
- {
- std::cout << "Detected GL_ARB_texture_env_combine" << std::endl;
- }
- }
-#endif
-
-#ifdef GL_ARB_texture_cube_map
- if (QueryExtension("GL_ARB_texture_cube_map"))
- {
- EnableExtension(_GL_ARB_texture_cube_map);
- RAS_EXT_support._ARB_texture_cube_map = 1;
- if (doDebugMessages)
- std::cout << "Detected GL_ARB_texture_cube_map" << std::endl;
- }
-#endif
-
-#ifdef GL_ARB_multitexture
- if (QueryExtension("GL_ARB_multitexture"))
- {
- bgl::blActiveTextureARB = reinterpret_cast<PFNGLACTIVETEXTUREARBPROC>(bglGetProcAddress((const GLubyte *) "glActiveTextureARB"));
- bgl::blClientActiveTextureARB = reinterpret_cast<PFNGLCLIENTACTIVETEXTUREARBPROC>(bglGetProcAddress((const GLubyte *) "glClientActiveTextureARB"));
- bgl::blMultiTexCoord1dARB = reinterpret_cast<PFNGLMULTITEXCOORD1DARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1dARB"));
- bgl::blMultiTexCoord1dvARB = reinterpret_cast<PFNGLMULTITEXCOORD1DVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1dvARB"));
- bgl::blMultiTexCoord1fARB = reinterpret_cast<PFNGLMULTITEXCOORD1FARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1fARB"));
- bgl::blMultiTexCoord1fvARB = reinterpret_cast<PFNGLMULTITEXCOORD1FVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1fvARB"));
- bgl::blMultiTexCoord1iARB = reinterpret_cast<PFNGLMULTITEXCOORD1IARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1iARB"));
- bgl::blMultiTexCoord1ivARB = reinterpret_cast<PFNGLMULTITEXCOORD1IVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1ivARB"));
- bgl::blMultiTexCoord1sARB = reinterpret_cast<PFNGLMULTITEXCOORD1SARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1sARB"));
- bgl::blMultiTexCoord1svARB = reinterpret_cast<PFNGLMULTITEXCOORD1SVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord1svARB"));
- bgl::blMultiTexCoord2dARB = reinterpret_cast<PFNGLMULTITEXCOORD2DARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2dARB"));
- bgl::blMultiTexCoord2dvARB = reinterpret_cast<PFNGLMULTITEXCOORD2DVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2dvARB"));
- bgl::blMultiTexCoord2fARB = reinterpret_cast<PFNGLMULTITEXCOORD2FARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2fARB"));
- bgl::blMultiTexCoord2fvARB = reinterpret_cast<PFNGLMULTITEXCOORD2FVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2fvARB"));
- bgl::blMultiTexCoord2iARB = reinterpret_cast<PFNGLMULTITEXCOORD2IARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2iARB"));
- bgl::blMultiTexCoord2ivARB = reinterpret_cast<PFNGLMULTITEXCOORD2IVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2ivARB"));
- bgl::blMultiTexCoord2sARB = reinterpret_cast<PFNGLMULTITEXCOORD2SARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2sARB"));
- bgl::blMultiTexCoord2svARB = reinterpret_cast<PFNGLMULTITEXCOORD2SVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord2svARB"));
- bgl::blMultiTexCoord3dARB = reinterpret_cast<PFNGLMULTITEXCOORD3DARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3dARB"));
- bgl::blMultiTexCoord3dvARB = reinterpret_cast<PFNGLMULTITEXCOORD3DVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3dvARB"));
- bgl::blMultiTexCoord3fARB = reinterpret_cast<PFNGLMULTITEXCOORD3FARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3fARB"));
- bgl::blMultiTexCoord3fvARB = reinterpret_cast<PFNGLMULTITEXCOORD3FVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3fvARB"));
- bgl::blMultiTexCoord3iARB = reinterpret_cast<PFNGLMULTITEXCOORD3IARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3iARB"));
- bgl::blMultiTexCoord3ivARB = reinterpret_cast<PFNGLMULTITEXCOORD3IVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3ivARB"));
- bgl::blMultiTexCoord3sARB = reinterpret_cast<PFNGLMULTITEXCOORD3SARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3sARB"));
- bgl::blMultiTexCoord3svARB = reinterpret_cast<PFNGLMULTITEXCOORD3SVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord3svARB"));
- bgl::blMultiTexCoord4dARB = reinterpret_cast<PFNGLMULTITEXCOORD4DARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4dARB"));
- bgl::blMultiTexCoord4dvARB = reinterpret_cast<PFNGLMULTITEXCOORD4DVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4dvARB"));
- bgl::blMultiTexCoord4fARB = reinterpret_cast<PFNGLMULTITEXCOORD4FARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4fARB"));
- bgl::blMultiTexCoord4fvARB = reinterpret_cast<PFNGLMULTITEXCOORD4FVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4fvARB"));
- bgl::blMultiTexCoord4iARB = reinterpret_cast<PFNGLMULTITEXCOORD4IARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4iARB"));
- bgl::blMultiTexCoord4ivARB = reinterpret_cast<PFNGLMULTITEXCOORD4IVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4ivARB"));
- bgl::blMultiTexCoord4sARB = reinterpret_cast<PFNGLMULTITEXCOORD4SARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4sARB"));
- bgl::blMultiTexCoord4svARB = reinterpret_cast<PFNGLMULTITEXCOORD4SVARBPROC>(bglGetProcAddress((const GLubyte *) "glMultiTexCoord4svARB"));
- if (bgl::blActiveTextureARB && bgl::blClientActiveTextureARB && bgl::blMultiTexCoord1dARB && bgl::blMultiTexCoord1dvARB && bgl::blMultiTexCoord1fARB && bgl::blMultiTexCoord1fvARB && bgl::blMultiTexCoord1iARB && bgl::blMultiTexCoord1ivARB && bgl::blMultiTexCoord1sARB && bgl::blMultiTexCoord1svARB && bgl::blMultiTexCoord2dARB && bgl::blMultiTexCoord2dvARB && bgl::blMultiTexCoord2fARB && bgl::blMultiTexCoord2fvARB && bgl::blMultiTexCoord2iARB && bgl::blMultiTexCoord2ivARB && bgl::blMultiTexCoord2sARB && bgl::blMultiTexCoord2svARB && bgl::blMultiTexCoord3dARB && bgl::blMultiTexCoord3dvARB && bgl::blMultiTexCoord3fARB && bgl::blMultiTexCoord3fvARB && bgl::blMultiTexCoord3iARB && bgl::blMultiTexCoord3ivARB && bgl::blMultiTexCoord3sARB && bgl::blMultiTexCoord3svARB && bgl::blMultiTexCoord4dARB && bgl::blMultiTexCoord4dvARB && bgl::blMultiTexCoord4fARB && bgl::blMultiTexCoord4fvARB && bgl::blMultiTexCoord4iARB && bgl::blMultiTexCoord4ivARB && bgl::blMultiTexCoord4sARB && bgl::blMultiTexCoord4svARB) {
- EnableExtension(_GL_ARB_multitexture);
- RAS_EXT_support._ARB_multitexture = 1;
- if (doDebugMessages)
- std::cout << "Enabled GL_ARB_multitexture" << std::endl;
- } else {
- std::cout << "ERROR: GL_ARB_multitexture implementation is broken!" << std::endl;
- }
- }
-#endif
-
-#if GL_ARB_shader_objects
- if (QueryExtension("GL_ARB_shader_objects"))
- {
- bgl::blDeleteObjectARB = reinterpret_cast<PFNGLDELETEOBJECTARBPROC>(bglGetProcAddress((const GLubyte *) "glDeleteObjectARB"));
- bgl::blGetHandleARB = reinterpret_cast<PFNGLGETHANDLEARBPROC>(bglGetProcAddress((const GLubyte *) "glGetHandleARB"));
- bgl::blDetachObjectARB = reinterpret_cast<PFNGLDETACHOBJECTARBPROC>(bglGetProcAddress((const GLubyte *) "glDetachObjectARB"));
- bgl::blCreateShaderObjectARB = reinterpret_cast<PFNGLCREATESHADEROBJECTARBPROC>(bglGetProcAddress((const GLubyte *) "glCreateShaderObjectARB"));
- bgl::blShaderSourceARB = reinterpret_cast<PFNGLSHADERSOURCEARBPROC>(bglGetProcAddress((const GLubyte *) "glShaderSourceARB"));
- bgl::blCompileShaderARB = reinterpret_cast<PFNGLCOMPILESHADERARBPROC>(bglGetProcAddress((const GLubyte *) "glCompileShaderARB"));
- bgl::blCreateProgramObjectARB = reinterpret_cast<PFNGLCREATEPROGRAMOBJECTARBPROC>(bglGetProcAddress((const GLubyte *) "glCreateProgramObjectARB"));
- bgl::blAttachObjectARB = reinterpret_cast<PFNGLATTACHOBJECTARBPROC>(bglGetProcAddress((const GLubyte *) "glAttachObjectARB"));
- bgl::blLinkProgramARB = reinterpret_cast<PFNGLLINKPROGRAMARBPROC>(bglGetProcAddress((const GLubyte *) "glLinkProgramARB"));
- bgl::blUseProgramObjectARB = reinterpret_cast<PFNGLUSEPROGRAMOBJECTARBPROC>(bglGetProcAddress((const GLubyte *) "glUseProgramObjectARB"));
- bgl::blValidateProgramARB = reinterpret_cast<PFNGLVALIDATEPROGRAMARBPROC>(bglGetProcAddress((const GLubyte *) "glValidateProgramARB"));
- bgl::blUniform1fARB = reinterpret_cast<PFNGLUNIFORM1FARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform1fARB"));
- bgl::blUniform2fARB = reinterpret_cast<PFNGLUNIFORM2FARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform2fARB"));
- bgl::blUniform3fARB = reinterpret_cast<PFNGLUNIFORM3FARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform3fARB"));
- bgl::blUniform4fARB = reinterpret_cast<PFNGLUNIFORM4FARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform4fARB"));
- bgl::blUniform1iARB = reinterpret_cast<PFNGLUNIFORM1IARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform1iARB"));
- bgl::blUniform2iARB = reinterpret_cast<PFNGLUNIFORM2IARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform2iARB"));
- bgl::blUniform3iARB = reinterpret_cast<PFNGLUNIFORM3IARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform3iARB"));
- bgl::blUniform4iARB = reinterpret_cast<PFNGLUNIFORM4IARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform4iARB"));
- bgl::blUniform1fvARB = reinterpret_cast<PFNGLUNIFORM1FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform1fvARB"));
- bgl::blUniform2fvARB = reinterpret_cast<PFNGLUNIFORM2FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform2fvARB"));
- bgl::blUniform3fvARB = reinterpret_cast<PFNGLUNIFORM3FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform3fvARB"));
- bgl::blUniform4fvARB = reinterpret_cast<PFNGLUNIFORM4FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform4fvARB"));
- bgl::blUniform1ivARB = reinterpret_cast<PFNGLUNIFORM1IVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform1ivARB"));
- bgl::blUniform2ivARB = reinterpret_cast<PFNGLUNIFORM2IVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform2ivARB"));
- bgl::blUniform3ivARB = reinterpret_cast<PFNGLUNIFORM3IVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform3ivARB"));
- bgl::blUniform4ivARB = reinterpret_cast<PFNGLUNIFORM4IVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniform4ivARB"));
- bgl::blUniformMatrix2fvARB = reinterpret_cast<PFNGLUNIFORMMATRIX2FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniformMatrix2fvARB"));
- bgl::blUniformMatrix3fvARB = reinterpret_cast<PFNGLUNIFORMMATRIX3FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniformMatrix3fvARB"));
- bgl::blUniformMatrix4fvARB = reinterpret_cast<PFNGLUNIFORMMATRIX4FVARBPROC>(bglGetProcAddress((const GLubyte *) "glUniformMatrix4fvARB"));
- bgl::blGetObjectParameterfvARB = reinterpret_cast<PFNGLGETOBJECTPARAMETERFVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetObjectParameterfvARB"));
- bgl::blGetObjectParameterivARB = reinterpret_cast<PFNGLGETOBJECTPARAMETERIVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetObjectParameterivARB"));
- bgl::blGetInfoLogARB = reinterpret_cast<PFNGLGETINFOLOGARBPROC>(bglGetProcAddress((const GLubyte *) "glGetInfoLogARB"));
- bgl::blGetAttachedObjectsARB = reinterpret_cast<PFNGLGETATTACHEDOBJECTSARBPROC>(bglGetProcAddress((const GLubyte *) "glGetAttachedObjectsARB"));
- bgl::blGetUniformLocationARB = reinterpret_cast<PFNGLGETUNIFORMLOCATIONARBPROC>(bglGetProcAddress((const GLubyte *) "glGetUniformLocationARB"));
- bgl::blGetActiveUniformARB = reinterpret_cast<PFNGLGETACTIVEUNIFORMARBPROC>(bglGetProcAddress((const GLubyte *) "glGetActiveUniformARB"));
- bgl::blGetUniformfvARB = reinterpret_cast<PFNGLGETUNIFORMFVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetUniformfvARB"));
- bgl::blGetUniformivARB = reinterpret_cast<PFNGLGETUNIFORMIVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetUniformivARB"));
- bgl::blGetShaderSourceARB = reinterpret_cast<PFNGLGETSHADERSOURCEARBPROC>(bglGetProcAddress((const GLubyte *) "glGetShaderSourceARB"));
- if (bgl::blDeleteObjectARB && bgl::blGetHandleARB && bgl::blDetachObjectARB && bgl::blCreateShaderObjectARB && bgl::blShaderSourceARB && bgl::blCompileShaderARB && bgl::blCreateProgramObjectARB && bgl::blAttachObjectARB && bgl::blLinkProgramARB && bgl::blUseProgramObjectARB && bgl::blValidateProgramARB && bgl::blUniform1fARB && bgl::blUniform2fARB && bgl::blUniform3fARB && bgl::blUniform4fARB && bgl::blUniform1iARB && bgl::blUniform2iARB && bgl::blUniform3iARB && bgl::blUniform4iARB && bgl::blUniform1fvARB && bgl::blUniform2fvARB && bgl::blUniform3fvARB && bgl::blUniform4fvARB && bgl::blUniform1ivARB && bgl::blUniform2ivARB && bgl::blUniform3ivARB && bgl::blUniform4ivARB && bgl::blUniformMatrix2fvARB && bgl::blUniformMatrix3fvARB && bgl::blUniformMatrix4fvARB && bgl::blGetObjectParameterfvARB && bgl::blGetObjectParameterivARB && bgl::blGetInfoLogARB && bgl::blGetAttachedObjectsARB && bgl::blGetUniformLocationARB && bgl::blGetActiveUniformARB && bgl::blGetUniformfvARB && bgl::blGetUniformivARB && bgl::blGetShaderSourceARB) {
- EnableExtension(_GL_ARB_shader_objects);
- RAS_EXT_support._ARB_shader_objects =1;
- if (doDebugMessages)
- std::cout << "Enabled GL_ARB_shader_objects" << std::endl;
- } else {
- std::cout << "ERROR: GL_ARB_shader_objects implementation is broken!" << std::endl;
- }
- }
-#endif
-
-#if GL_ARB_vertex_shader
- if (QueryExtension("GL_ARB_vertex_shader"))
- {
- bgl::blBindAttribLocationARB = reinterpret_cast<PFNGLBINDATTRIBLOCATIONARBPROC>(bglGetProcAddress((const GLubyte *) "glBindAttribLocationARB"));
- bgl::blGetActiveAttribARB = reinterpret_cast<PFNGLGETACTIVEATTRIBARBPROC>(bglGetProcAddress((const GLubyte *) "glGetActiveAttribARB"));
- bgl::blGetAttribLocationARB = reinterpret_cast<PFNGLGETATTRIBLOCATIONARBPROC>(bglGetProcAddress((const GLubyte *) "glGetAttribLocationARB"));
- if (bgl::blBindAttribLocationARB && bgl::blGetActiveAttribARB && bgl::blGetAttribLocationARB) {
- EnableExtension(_GL_ARB_vertex_shader);
- RAS_EXT_support._ARB_vertex_shader = 1;
- if (doDebugMessages)
- std::cout << "Enabled GL_ARB_vertex_shader" << std::endl;
- } else {
- std::cout << "ERROR: GL_ARB_vertex_shader implementation is broken!" << std::endl;
- }
- }
-#endif
-
-#ifdef GL_ARB_fragment_shader
- if (QueryExtension("GL_ARB_fragment_shader"))
- {
- EnableExtension(_GL_ARB_fragment_shader);
- RAS_EXT_support._ARB_fragment_shader = 1;
- if (doDebugMessages)
- std::cout << "Detected GL_ARB_fragment_shader" << std::endl;
- }
-#endif
-
-#if defined(GL_ARB_vertex_program)
- if (QueryExtension("GL_ARB_vertex_program"))
- {
- bgl::blVertexAttrib1fARB = reinterpret_cast<PFNGLVERTEXATTRIB1FARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib1fARB"));
- bgl::blVertexAttrib1fvARB = reinterpret_cast<PFNGLVERTEXATTRIB1FVARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib1fvARB"));
- bgl::blVertexAttrib2fARB = reinterpret_cast<PFNGLVERTEXATTRIB2FARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib2fARB"));
- bgl::blVertexAttrib2fvARB = reinterpret_cast<PFNGLVERTEXATTRIB2FVARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib2fvARB"));
- bgl::blVertexAttrib3fARB = reinterpret_cast<PFNGLVERTEXATTRIB3FARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib3fARB"));
- bgl::blVertexAttrib3fvARB = reinterpret_cast<PFNGLVERTEXATTRIB3FVARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib3fvARB"));
- bgl::blVertexAttrib4fARB = reinterpret_cast<PFNGLVERTEXATTRIB4FARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib4fARB"));
- bgl::blVertexAttrib4fvARB = reinterpret_cast<PFNGLVERTEXATTRIB4FVARBPROC>(bglGetProcAddress((const GLubyte *) "glVertexAttrib4fvARB"));
- bgl::blGetVertexAttribdvARB = reinterpret_cast<PFNGLGETVERTEXATTRIBDVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetVertexAttribdvARB"));
- bgl::blGetVertexAttribfvARB = reinterpret_cast<PFNGLGETVERTEXATTRIBFVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetVertexAttribfvARB"));
- bgl::blGetVertexAttribivARB = reinterpret_cast<PFNGLGETVERTEXATTRIBIVARBPROC>(bglGetProcAddress((const GLubyte *) "glGetVertexAttribivARB"));
- if (bgl::blVertexAttrib1fARB && bgl::blVertexAttrib1fvARB && bgl::blVertexAttrib2fARB && bgl::blVertexAttrib2fvARB && bgl::blVertexAttrib3fARB && bgl::blVertexAttrib3fvARB && bgl::blGetVertexAttribdvARB) {
- EnableExtension(_GL_ARB_vertex_program);
- RAS_EXT_support._ARB_vertex_program = 1;
- if (doDebugMessages)
- std::cout << "Enabled GL_ARB_vertex_program" << std::endl;
- } else {
- std::cout << "ERROR: GL_ARB_vertex_program implementation is broken!" << std::endl;
- }
- }
-#endif
-
-
-#ifdef GL_ARB_depth_texture
- if (QueryExtension("GL_ARB_depth_texture"))
- {
- EnableExtension(_GL_ARB_depth_texture);
- RAS_EXT_support._ARB_depth_texture = 1;
- if (doDebugMessages)
- {
- std::cout << "Detected GL_ARB_depth_texture" << std::endl;
- }
- }
-#endif
-/*
-#ifdef GL_EXT_compiled_vertex_array
- if (QueryExtension("GL_EXT_compiled_vertex_array"))
- {
- blLockArraysEXT = reinterpret_cast<PFNGLLOCKARRAYSEXTPROC>(bglGetProcAddress((const GLubyte *) "glLockArraysEXT"));
- blUnlockArraysEXT = reinterpret_cast<PFNGLUNLOCKARRAYSEXTPROC>(bglGetProcAddress((const GLubyte *) "glUnlockArraysEXT"));
- if (blLockArraysEXT && blUnlockArraysEXT) {
- EnableExtension(_GL_EXT_compiled_vertex_array);
- RAS_EXT_support._EXT_compiled_vertex_array = 1;
- if (doDebugMessages)
- std::cout << "Enabled GL_EXT_compiled_vertex_array" << std::endl;
- } else {
- std::cout << "ERROR: GL_EXT_compiled_vertex_array implementation is broken!" << std::endl;
- }
- }
-#endif
-*/
- if (QueryExtension("GL_EXT_separate_specular_color"))
- {
- EnableExtension(_GL_EXT_separate_specular_color);
- if (doDebugMessages)
+ if(firsttime) {
+ firsttime = false;
+
+ if(debug) {
+ if(GLEW_ATI_pn_triangles)
+ std::cout << "Enabled GL_ATI_pn_triangles" << std::endl;
+ if(GLEW_ARB_texture_env_combine)
+ std::cout << "Detected GL_ARB_texture_env_combine" << std::endl;
+ if(GLEW_ARB_texture_cube_map)
+ std::cout << "Detected GL_ARB_texture_cube_map" << std::endl;
+ if(GLEW_ARB_multitexture)
+ std::cout << "Detected GL_ARB_multitexture" << std::endl;
+ if(GLEW_ARB_shader_objects)
+ std::cout << "Detected GL_ARB_shader_objects" << std::endl;
+ if(GLEW_ARB_vertex_shader)
+ std::cout << "Detected GL_ARB_vertex_shader" << std::endl;
+ if(GLEW_ARB_fragment_shader)
+ std::cout << "Detected GL_ARB_fragment_shader" << std::endl;
+ if(GLEW_ARB_vertex_program)
+ std::cout << "Detected GL_ARB_vertex_program" << std::endl;
+ if(GLEW_ARB_depth_texture)
+ std::cout << "Detected GL_ARB_depth_texture" << std::endl;
+ if(GLEW_EXT_separate_specular_color)
std::cout << "Detected GL_EXT_separate_specular_color" << std::endl;
+ }
+ }
}
-
- doDebugMessages = false;
-}
+} // namespace bgl
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h
index a09294f723d..2265becbdad 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_GLExtensionManager.h
@@ -29,506 +29,14 @@
#ifndef __RAS_GLEXTENSIONMANAGER_H__
#define __RAS_GLEXTENSIONMANAGER_H__
+#include "GL/glew.h"
-#ifdef WIN32
-# include <windows.h>
-# include <GL/gl.h>
+/* Note: this used to have a lot more code, but now extension handling
+ * is done by GLEW, so it does mostly debug stuff */
-#elif defined(__APPLE__)
-# define __glext_h_
-# define GL_GLEXT_LEGACY 1
-# include <OpenGL/gl.h>
-# include <OpenGL/glu.h>
-# undef __glext_h_
-
-#else /* UNIX */
-# define __glext_h_
-# include <GL/gl.h>
-# include <GL/glx.h>
-# undef GL_ARB_multitexture // (ubuntu)
-# undef __glext_h_
-#endif
-
-#ifdef __sgi
-# undef GL_ARB_vertex_program
-#endif
-
-#include "glext.h"
-
-#include "EXT_separate_specular_color.h"
-#include "ARB_multitexture.h"
namespace bgl
{
- /**
- * This is a list of all registered OpenGL extensions.
- * It is available from:
- * http://oss.sgi.com/projects/ogl-sample/registry/
- */
- typedef enum {
- /* ARB Extensions */
- _GL_ARB_imaging,
- _GL_ARB_multitexture ,
- _GLX_ARB_get_proc_address ,
- _GL_ARB_transpose_matrix ,
- _WGL_ARB_buffer_region ,
- _GL_ARB_multisample ,
- _GL_ARB_texture_env_add ,
- _GL_ARB_texture_cube_map ,
- _WGL_ARB_extensions_string ,
- _WGL_ARB_pixel_format ,
- _WGL_ARB_make_current_read ,
- _WGL_ARB_pbuffer ,
- _GL_ARB_texture_compression ,
- _GL_ARB_texture_border_clamp ,
- _GL_ARB_point_parameters ,
- _GL_ARB_vertex_blend ,
- _GL_ARB_matrix_palette ,
- _GL_ARB_texture_env_combine ,
- _GL_ARB_texture_env_crossbar ,
- _GL_ARB_texture_env_dot3 ,
- _WGL_ARB_render_texture ,
- _GL_ARB_texture_mirrored_repeat ,
- _GL_ARB_depth_texture ,
- _GL_ARB_shadow ,
- _GL_ARB_shadow_ambient ,
- _GL_ARB_window_pos ,
- _GL_ARB_vertex_program ,
- _GL_ARB_fragment_program ,
- _GL_ARB_vertex_buffer_object ,
- _GL_ARB_occlusion_query ,
- _GL_ARB_shader_objects ,
- _GL_ARB_vertex_shader ,
- _GL_ARB_fragment_shader ,
- _GL_ARB_shading_language_100 ,
- _GL_ARB_texture_non_power_of_two ,
- _GL_ARB_point_sprite ,
- _GL_ARB_fragment_program_shadow ,
-
- /* Non ARB Extensions */
- _GL_EXT_abgr ,
- _GL_EXT_blend_color ,
- _GL_EXT_polygon_offset ,
- _GL_EXT_texture ,
- _GL_EXT_texture3D ,
- _GL_SGIS_texture_filter4 ,
- _GL_EXT_subtexture ,
- _GL_EXT_copy_texture ,
- _GL_EXT_histogram ,
- _GL_EXT_convolution ,
- _GL_SGI_color_matrix ,
- _GL_SGI_color_table ,
- _GL_SGIS_pixel_texture ,
- _GL_SGIS_texture4D ,
- _GL_SGI_texture_color_table ,
- _GL_EXT_cmyka ,
- _GL_EXT_texture_object ,
- _GL_SGIS_detail_texture ,
- _GL_SGIS_sharpen_texture ,
- _GL_EXT_packed_pixels ,
- _GL_SGIS_texture_lod ,
- _GL_SGIS_multisample ,
- _GL_EXT_rescale_normal ,
- _GLX_EXT_visual_info ,
- _GL_EXT_vertex_array ,
- _GL_EXT_misc_attribute ,
- _GL_SGIS_generate_mipmap ,
- _GL_SGIX_clipmap ,
- _GL_SGIX_shadow ,
- _GL_SGIS_texture_edge_clamp ,
- _GL_SGIS_texture_border_clamp ,
- _GL_EXT_blend_minmax ,
- _GL_EXT_blend_subtract ,
- _GL_EXT_blend_logic_op ,
- _GLX_SGI_swap_control ,
- _GLX_SGI_video_sync ,
- _GLX_SGI_make_current_read ,
- _GLX_SGIX_video_source ,
- _GLX_EXT_visual_rating ,
- _GL_SGIX_interlace ,
- _GLX_EXT_import_context ,
- _GLX_SGIX_fbconfig ,
- _GLX_SGIX_pbuffer ,
- _GL_SGIS_texture_select ,
- _GL_SGIX_sprite ,
- _GL_SGIX_texture_multi_buffer ,
- _GL_EXT_point_parameters ,
- _GL_SGIX_instruments ,
- _GL_SGIX_texture_scale_bias ,
- _GL_SGIX_framezoom ,
- _GL_SGIX_tag_sample_buffer ,
- _GL_SGIX_reference_plane ,
- _GL_SGIX_flush_raster ,
- _GLX_SGI_cushion ,
- _GL_SGIX_depth_texture ,
- _GL_SGIS_fog_function ,
- _GL_SGIX_fog_offset ,
- _GL_HP_image_transform ,
- _GL_HP_convolution_border_modes ,
- _GL_SGIX_texture_add_env ,
- _GL_EXT_color_subtable ,
- _GLU_EXT_object_space_tess ,
- _GL_PGI_vertex_hints ,
- _GL_PGI_misc_hints ,
- _GL_EXT_paletted_texture ,
- _GL_EXT_clip_volume_hint ,
- _GL_SGIX_list_priority ,
- _GL_SGIX_ir_instrument1 ,
- _GLX_SGIX_video_resize ,
- _GL_SGIX_texture_lod_bias ,
- _GLU_SGI_filter4_parameters ,
- _GLX_SGIX_dm_buffer ,
- _GL_SGIX_shadow_ambient ,
- _GLX_SGIX_swap_group ,
- _GLX_SGIX_swap_barrier ,
- _GL_EXT_index_texture ,
- _GL_EXT_index_material ,
- _GL_EXT_index_func ,
- _GL_EXT_index_array_formats ,
- _GL_EXT_compiled_vertex_array ,
- _GL_EXT_cull_vertex ,
- _GLU_EXT_nurbs_tessellator ,
- _GL_SGIX_ycrcb ,
- _GL_EXT_fragment_lighting ,
- _GL_IBM_rasterpos_clip ,
- _GL_HP_texture_lighting ,
- _GL_EXT_draw_range_elements ,
- _GL_WIN_phong_shading ,
- _GL_WIN_specular_fog ,
- _GLX_SGIS_color_range ,
- _GL_EXT_light_texture ,
- _GL_SGIX_blend_alpha_minmax ,
- _GL_EXT_scene_marker ,
- _GL_SGIX_pixel_texture_bits ,
- _GL_EXT_bgra ,
- _GL_SGIX_async ,
- _GL_SGIX_async_pixel ,
- _GL_SGIX_async_histogram ,
- _GL_INTEL_texture_scissor ,
- _GL_INTEL_parallel_arrays ,
- _GL_HP_occlusion_test ,
- _GL_EXT_pixel_transform ,
- _GL_EXT_pixel_transform_color_table ,
- _GL_EXT_shared_texture_palette ,
- _GLX_SGIS_blended_overlay ,
- _GL_EXT_separate_specular_color ,
- _GL_EXT_secondary_color ,
- _GL_EXT_texture_env ,
- _GL_EXT_texture_perturb_normal ,
- _GL_EXT_multi_draw_arrays ,
- _GL_EXT_fog_coord ,
- _GL_REND_screen_coordinates ,
- _GL_EXT_coordinate_frame ,
- _GL_EXT_texture_env_combine ,
- _GL_APPLE_specular_vector ,
- _GL_SGIX_pixel_texture ,
- _GL_APPLE_transform_hint ,
- _GL_SUNX_constant_data ,
- _GL_SUN_global_alpha ,
- _GL_SUN_triangle_list ,
- _GL_SUN_vertex ,
- _WGL_EXT_display_color_table ,
- _WGL_EXT_extensions_string ,
- _WGL_EXT_make_current_read ,
- _WGL_EXT_pixel_format ,
- _WGL_EXT_pbuffer ,
- _WGL_EXT_swap_control ,
- _GL_EXT_blend_func_separate ,
- _GL_INGR_color_clamp ,
- _GL_INGR_interlace_read ,
- _GL_EXT_stencil_wrap ,
- _WGL_EXT_depth_float ,
- _GL_EXT_422_pixels ,
- _GL_NV_texgen_reflection ,
- _GL_SGIX_texture_range ,
- _GL_SUN_convolution_border_modes ,
- _GLX_SUN_get_transparent_index ,
- _GL_EXT_texture_env_add ,
- _GL_EXT_texture_lod_bias ,
- _GL_EXT_texture_filter_anisotropic ,
- _GL_EXT_vertex_weighting ,
- _GL_NV_light_max_exponent ,
- _GL_NV_vertex_array_range ,
- _GL_NV_register_combiners ,
- _GL_NV_fog_distance ,
- _GL_NV_texgen_emboss ,
- _GL_NV_blend_square ,
- _GL_NV_texture_env_combine4 ,
- _GL_MESA_resize_buffers ,
- _GL_MESA_window_pos ,
- _GL_EXT_texture_compression_s3tc ,
- _GL_IBM_cull_vertex ,
- _GL_IBM_multimode_draw_arrays ,
- _GL_IBM_vertex_array_lists ,
- _GL_3DFX_texture_compression_FXT1 ,
- _GL_3DFX_multisample ,
- _GL_3DFX_tbuffer ,
- _WGL_EXT_multisample ,
- _GL_SGIX_vertex_preclip ,
- _GL_SGIX_resample ,
- _GL_SGIS_texture_color_mask ,
- _GLX_MESA_copy_sub_buffer ,
- _GLX_MESA_pixmap_colormap ,
- _GLX_MESA_release_buffers ,
- _GLX_MESA_set_3dfx_mode ,
- _GL_EXT_texture_env_dot3 ,
- _GL_ATI_texture_mirror_once ,
- _GL_NV_fence ,
- _GL_IBM_static_data ,
- _GL_IBM_texture_mirrored_repeat ,
- _GL_NV_evaluators ,
- _GL_NV_packed_depth_stencil ,
- _GL_NV_register_combiners2 ,
- _GL_NV_texture_compression_vtc ,
- _GL_NV_texture_rectangle ,
- _GL_NV_texture_shader ,
- _GL_NV_texture_shader2 ,
- _GL_NV_vertex_array_range2 ,
- _GL_NV_vertex_program ,
- _GLX_SGIX_visual_select_group ,
- _GL_SGIX_texture_coordinate_clamp ,
- _GLX_OML_swap_method ,
- _GLX_OML_sync_control ,
- _GL_OML_interlace ,
- _GL_OML_subsample ,
- _GL_OML_resample ,
- _WGL_OML_sync_control ,
- _GL_NV_copy_depth_to_color ,
- _GL_ATI_envmap_bumpmap ,
- _GL_ATI_fragment_shader ,
- _GL_ATI_pn_triangles ,
- _GL_ATI_vertex_array_object ,
- _GL_EXT_vertex_shader ,
- _GL_ATI_vertex_streams ,
- _WGL_I3D_digital_video_control ,
- _WGL_I3D_gamma ,
- _WGL_I3D_genlock ,
- _WGL_I3D_image_buffer ,
- _WGL_I3D_swap_frame_lock ,
- _WGL_I3D_swap_frame_usage ,
- _GL_ATI_element_array ,
- _GL_SUN_mesh_array ,
- _GL_SUN_slice_accum ,
- _GL_NV_multisample_filter_hint ,
- _GL_NV_depth_clamp ,
- _GL_NV_occlusion_query ,
- _GL_NV_point_sprite ,
- _WGL_NV_render_depth_texture ,
- _WGL_NV_render_texture_rectangle ,
- _GL_NV_texture_shader3 ,
- _GL_NV_vertex_program1_1 ,
- _GL_EXT_shadow_funcs ,
- _GL_EXT_stencil_two_side ,
- _GL_ATI_text_fragment_shader ,
- _GL_APPLE_client_storage ,
- _GL_APPLE_element_array ,
- _GL_APPLE_fence ,
- _GL_APPLE_vertex_array_object ,
- _GL_APPLE_vertex_array_range ,
- _GL_APPLE_ycbcr_422 ,
- _GL_S3_s3tc ,
- _GL_ATI_draw_buffers ,
- _WGL_ATI_pixel_format_float ,
- _GL_ATI_texture_env_combine3 ,
- _GL_ATI_texture_float ,
- _GL_NV_float_buffer ,
- _GL_NV_fragment_program ,
- _GL_NV_half_float ,
- _GL_NV_pixel_data_range ,
- _GL_NV_primitive_restart ,
- _GL_NV_texture_expand_normal ,
- _GL_NV_vertex_program2 ,
- _GL_ATI_map_object_buffer ,
- _GL_ATI_separate_stencil ,
- _GL_ATI_vertex_attrib_array_object ,
- _GL_OES_byte_coordinates ,
- _GL_OES_fixed_point ,
- _GL_OES_single_precision ,
- _GL_OES_compressed_paletted_texture ,
- _GL_OES_read_format ,
- _GL_OES_query_matrix ,
- _GL_EXT_depth_bounds_test ,
- _GL_EXT_texture_mirror_clamp ,
- _GL_EXT_blend_equation_separate ,
- _GL_MESA_pack_invert ,
- _GL_MESA_ycbcr_texture,
-
- /* Finished */
- _BGL_TEST,
- NUM_EXTENSIONS
- } ExtensionName;
-
- /**
- * Checks at runtime whether OpenGL supports the named extension.
- * Returns true if OpenGL supports the given extension.
- *
- * @param name The extension name to check.
- */
- bool QueryExtension(ExtensionName name);
- /**
- * Checks the OpenGL version.
- * Returns true if OpenGL is at least the given version.
- *
- * @param major The major version required
- * @param minor The minor version required
- */
- bool QueryVersion(int major, int minor);
- /**
- * This will dynamically link all runtime supported extensions into
- * the binary.
- *
- * @param debug Enable debug printing. This will print debugging info
- * when extensions are loaded.
- */
- void InitExtensions(int debug);
-
-#if defined(PFNGLPNTRIANGLESIATIPROC)
-extern PFNGLPNTRIANGLESIATIPROC blPNTrianglesiATI;
-extern PFNGLPNTRIANGLESFATIPROC blPNTrianglesfATI;
-#endif
-
-
-// quick runtime checks
-typedef struct BL_EXTInfo
-{
- BL_EXTInfo():
- _ARB_multitexture(0),
- _ARB_texture_env_combine(0),
- _EXT_blend_color(0),
- _ARB_texture_cube_map(0),
- _ARB_shader_objects(0),
- _ARB_vertex_shader(0),
- _ARB_fragment_shader(0),
- _EXT_texture3D(0),
- _ARB_vertex_program(0),
- _ARB_depth_texture(0),
- _EXT_compiled_vertex_array(0)
- {
- //
- }
- bool _ARB_multitexture;
- bool _ARB_texture_env_combine;
- bool _EXT_blend_color;
- bool _ARB_texture_cube_map;
- bool _ARB_shader_objects;
- bool _ARB_vertex_shader;
- bool _ARB_fragment_shader;
- bool _EXT_texture3D;
- bool _ARB_vertex_program;
- bool _ARB_depth_texture;
- bool _EXT_compiled_vertex_array;
-}BL_EXTInfo;
-
-extern BL_EXTInfo RAS_EXT_support;
-
-#ifdef GL_ARB_multitexture // defined in glext.h now...
-extern int max_texture_units;
-extern PFNGLACTIVETEXTUREARBPROC blActiveTextureARB;
-extern PFNGLCLIENTACTIVETEXTUREARBPROC blClientActiveTextureARB;
-extern PFNGLMULTITEXCOORD1DARBPROC blMultiTexCoord1dARB;
-extern PFNGLMULTITEXCOORD1DVARBPROC blMultiTexCoord1dvARB;
-extern PFNGLMULTITEXCOORD1FARBPROC blMultiTexCoord1fARB;
-extern PFNGLMULTITEXCOORD1FVARBPROC blMultiTexCoord1fvARB;
-extern PFNGLMULTITEXCOORD1IARBPROC blMultiTexCoord1iARB;
-extern PFNGLMULTITEXCOORD1IVARBPROC blMultiTexCoord1ivARB;
-extern PFNGLMULTITEXCOORD1SARBPROC blMultiTexCoord1sARB;
-extern PFNGLMULTITEXCOORD1SVARBPROC blMultiTexCoord1svARB;
-extern PFNGLMULTITEXCOORD2DARBPROC blMultiTexCoord2dARB;
-extern PFNGLMULTITEXCOORD2DVARBPROC blMultiTexCoord2dvARB;
-extern PFNGLMULTITEXCOORD2FARBPROC blMultiTexCoord2fARB;
-extern PFNGLMULTITEXCOORD2FVARBPROC blMultiTexCoord2fvARB;
-extern PFNGLMULTITEXCOORD2IARBPROC blMultiTexCoord2iARB;
-extern PFNGLMULTITEXCOORD2IVARBPROC blMultiTexCoord2ivARB;
-extern PFNGLMULTITEXCOORD2SARBPROC blMultiTexCoord2sARB;
-extern PFNGLMULTITEXCOORD2SVARBPROC blMultiTexCoord2svARB;
-extern PFNGLMULTITEXCOORD3DARBPROC blMultiTexCoord3dARB;
-extern PFNGLMULTITEXCOORD3DVARBPROC blMultiTexCoord3dvARB;
-extern PFNGLMULTITEXCOORD3FARBPROC blMultiTexCoord3fARB;
-extern PFNGLMULTITEXCOORD3FVARBPROC blMultiTexCoord3fvARB;
-extern PFNGLMULTITEXCOORD3IARBPROC blMultiTexCoord3iARB;
-extern PFNGLMULTITEXCOORD3IVARBPROC blMultiTexCoord3ivARB;
-extern PFNGLMULTITEXCOORD3SARBPROC blMultiTexCoord3sARB;
-extern PFNGLMULTITEXCOORD3SVARBPROC blMultiTexCoord3svARB;
-extern PFNGLMULTITEXCOORD4DARBPROC blMultiTexCoord4dARB;
-extern PFNGLMULTITEXCOORD4DVARBPROC blMultiTexCoord4dvARB;
-extern PFNGLMULTITEXCOORD4FARBPROC blMultiTexCoord4fARB;
-extern PFNGLMULTITEXCOORD4FVARBPROC blMultiTexCoord4fvARB;
-extern PFNGLMULTITEXCOORD4IARBPROC blMultiTexCoord4iARB;
-extern PFNGLMULTITEXCOORD4IVARBPROC blMultiTexCoord4ivARB;
-extern PFNGLMULTITEXCOORD4SARBPROC blMultiTexCoord4sARB;
-extern PFNGLMULTITEXCOORD4SVARBPROC blMultiTexCoord4svARB;
-#endif
-
-
-#ifdef GL_ARB_shader_objects
-extern PFNGLDELETEOBJECTARBPROC blDeleteObjectARB;
-extern PFNGLGETHANDLEARBPROC blGetHandleARB;
-extern PFNGLDETACHOBJECTARBPROC blDetachObjectARB;
-extern PFNGLCREATESHADEROBJECTARBPROC blCreateShaderObjectARB;
-extern PFNGLSHADERSOURCEARBPROC blShaderSourceARB;
-extern PFNGLCOMPILESHADERARBPROC blCompileShaderARB;
-extern PFNGLCREATEPROGRAMOBJECTARBPROC blCreateProgramObjectARB;
-extern PFNGLATTACHOBJECTARBPROC blAttachObjectARB;
-extern PFNGLLINKPROGRAMARBPROC blLinkProgramARB;
-extern PFNGLUSEPROGRAMOBJECTARBPROC blUseProgramObjectARB;
-extern PFNGLVALIDATEPROGRAMARBPROC blValidateProgramARB;
-extern PFNGLUNIFORM1FARBPROC blUniform1fARB;
-extern PFNGLUNIFORM2FARBPROC blUniform2fARB;
-extern PFNGLUNIFORM3FARBPROC blUniform3fARB;
-extern PFNGLUNIFORM4FARBPROC blUniform4fARB;
-extern PFNGLUNIFORM1IARBPROC blUniform1iARB;
-extern PFNGLUNIFORM2IARBPROC blUniform2iARB;
-extern PFNGLUNIFORM3IARBPROC blUniform3iARB;
-extern PFNGLUNIFORM4IARBPROC blUniform4iARB;
-extern PFNGLUNIFORM1FVARBPROC blUniform1fvARB;
-extern PFNGLUNIFORM2FVARBPROC blUniform2fvARB;
-extern PFNGLUNIFORM3FVARBPROC blUniform3fvARB;
-extern PFNGLUNIFORM4FVARBPROC blUniform4fvARB;
-extern PFNGLUNIFORM1IVARBPROC blUniform1ivARB;
-extern PFNGLUNIFORM2IVARBPROC blUniform2ivARB;
-extern PFNGLUNIFORM3IVARBPROC blUniform3ivARB;
-extern PFNGLUNIFORM4IVARBPROC blUniform4ivARB;
-extern PFNGLUNIFORMMATRIX2FVARBPROC blUniformMatrix2fvARB;
-extern PFNGLUNIFORMMATRIX3FVARBPROC blUniformMatrix3fvARB;
-extern PFNGLUNIFORMMATRIX4FVARBPROC blUniformMatrix4fvARB;
-extern PFNGLGETOBJECTPARAMETERFVARBPROC blGetObjectParameterfvARB;
-extern PFNGLGETOBJECTPARAMETERIVARBPROC blGetObjectParameterivARB;
-extern PFNGLGETINFOLOGARBPROC blGetInfoLogARB;
-extern PFNGLGETATTACHEDOBJECTSARBPROC blGetAttachedObjectsARB;
-extern PFNGLGETUNIFORMLOCATIONARBPROC blGetUniformLocationARB;
-extern PFNGLGETACTIVEUNIFORMARBPROC blGetActiveUniformARB;
-extern PFNGLGETUNIFORMFVARBPROC blGetUniformfvARB;
-extern PFNGLGETUNIFORMIVARBPROC blGetUniformivARB;
-extern PFNGLGETSHADERSOURCEARBPROC blGetShaderSourceARB;
-#endif
-
-#ifdef GL_ARB_vertex_shader
-extern PFNGLBINDATTRIBLOCATIONARBPROC blBindAttribLocationARB;
-extern PFNGLGETACTIVEATTRIBARBPROC blGetActiveAttribARB;
-extern PFNGLGETATTRIBLOCATIONARBPROC blGetAttribLocationARB;
-#endif
-
-#ifdef GL_ARB_vertex_program
-extern PFNGLVERTEXATTRIB1FARBPROC blVertexAttrib1fARB;
-extern PFNGLVERTEXATTRIB1FVARBPROC blVertexAttrib1fvARB;
-extern PFNGLVERTEXATTRIB2FARBPROC blVertexAttrib2fARB;
-extern PFNGLVERTEXATTRIB2FVARBPROC blVertexAttrib2fvARB;
-extern PFNGLVERTEXATTRIB3FARBPROC blVertexAttrib3fARB;
-extern PFNGLVERTEXATTRIB3FVARBPROC blVertexAttrib3fvARB;
-extern PFNGLVERTEXATTRIB4FARBPROC blVertexAttrib4fARB;
-extern PFNGLVERTEXATTRIB4FVARBPROC blVertexAttrib4fvARB;
-extern PFNGLGETPROGRAMSTRINGARBPROC blGetProgramStringARB;
-extern PFNGLGETVERTEXATTRIBDVARBPROC blGetVertexAttribdvARB;
-extern PFNGLGETVERTEXATTRIBFVARBPROC blGetVertexAttribfvARB;
-extern PFNGLGETVERTEXATTRIBIVARBPROC blGetVertexAttribivARB;
-#endif
-
-/*
-#ifdef GL_EXT_compiled_vertex_array
-extern PFNGLLOCKARRAYSEXTPROC blLockArraysEXT;
-extern PFNGLUNLOCKARRAYSEXTPROC blUnlockArraysEXT;
-#endif
-*/
+ void InitExtensions(bool debug);
} /* namespace bgl */
-
#endif /* __RAS_GLEXTENSIONMANAGER_H__ */
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
index ed4cfb2ae42..2c4b55ff964 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.cpp
@@ -6,15 +6,11 @@
#ifdef WIN32
#include <windows.h>
#endif // WIN32
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#else
-#include <GL/gl.h>
-#endif
+#include "GL/glew.h"
+
+#include "RAS_MaterialBucket.h"
#include "RAS_TexVert.h"
-#include "RAS_GLExtensionManager.h"
#include "MT_assert.h"
//#ifndef NDEBUG
@@ -25,11 +21,21 @@
#define spit(x)
//#endif
-RAS_ListSlot::RAS_ListSlot()
+RAS_ListSlot::RAS_ListSlot(RAS_ListRasterizer* rasty)
: KX_ListSlot(),
+ m_list(0),
m_flag(LIST_MODIFY|LIST_CREATE),
- m_list(0)
+ m_rasty(rasty)
+{
+}
+
+int RAS_ListSlot::Release()
{
+ if (--m_refcount > 0)
+ return m_refcount;
+ m_rasty->RemoveListSlot(this);
+ delete this;
+ return 0;
}
RAS_ListSlot::~RAS_ListSlot()
@@ -96,8 +102,9 @@ bool RAS_ListSlot::End()
-RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas)
-: RAS_OpenGLRasterizer(canvas)
+RAS_ListRasterizer::RAS_ListRasterizer(RAS_ICanvas* canvas, bool useVertexArrays, bool lock)
+: RAS_VAOpenGLRasterizer(canvas, lock),
+ mUseVertexArrays(useVertexArrays)
{
// --
}
@@ -107,22 +114,34 @@ RAS_ListRasterizer::~RAS_ListRasterizer()
ReleaseAlloc();
}
-RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(const vecVertexArray& vertexarrays, KX_ListSlot** slot)
+void RAS_ListRasterizer::RemoveListSlot(RAS_ListSlot* list)
+{
+ RAS_Lists::iterator it = mLists.begin();
+ while(it != mLists.end()) {
+ if (it->second == list) {
+ mLists.erase(it);
+ break;
+ }
+ it++;
+ }
+}
+
+RAS_ListSlot* RAS_ListRasterizer::FindOrAdd(RAS_MeshSlot& ms)
{
/*
Keep a copy of constant lists submitted for rendering,
this guards against (replicated)new...delete every frame,
and we can reuse lists!
- :: sorted by vertex array
+ :: sorted by mesh slot
*/
- RAS_ListSlot* localSlot = (RAS_ListSlot*)*slot;
+ RAS_ListSlot* localSlot = (RAS_ListSlot*)ms.m_DisplayList;
if(!localSlot) {
- RAS_Lists::iterator it = mLists.find(vertexarrays);
+ RAS_Lists::iterator it = mLists.find(&ms);
if(it == mLists.end()) {
- localSlot = new RAS_ListSlot();
- mLists.insert(std::pair<vecVertexArray, RAS_ListSlot*>(vertexarrays, localSlot));
+ localSlot = new RAS_ListSlot(this);
+ mLists.insert(std::pair<RAS_MeshSlot*, RAS_ListSlot*>(&ms, localSlot));
} else {
- localSlot = it->second;
+ localSlot = static_cast<RAS_ListSlot*>(it->second->AddRef());
}
}
MT_assert(localSlot);
@@ -139,71 +158,87 @@ void RAS_ListRasterizer::ReleaseAlloc()
mLists.clear();
}
-
-void RAS_ListRasterizer::IndexPrimitives(
- const vecVertexArray & vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot)
+void RAS_ListRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
{
RAS_ListSlot* localSlot =0;
- // useObjectColor(are we updating every frame?)
- if(!useObjectColor) {
- localSlot = FindOrAdd(vertexarrays, slot);
+ if(ms.m_bDisplayList) {
+ localSlot = FindOrAdd(ms);
localSlot->DrawList();
- if(localSlot->End())
+ if(localSlot->End()) {
+ // save slot here too, needed for replicas and object using same mesh
+ // => they have the same vertexarray but different mesh slot
+ ms.m_DisplayList = localSlot;
return;
+ }
}
+
+ if (mUseVertexArrays)
+ RAS_VAOpenGLRasterizer::IndexPrimitives(ms);
+ else
+ RAS_OpenGLRasterizer::IndexPrimitives(ms);
- RAS_OpenGLRasterizer::IndexPrimitives(
- vertexarrays, indexarrays,
- mode, polymat,
- rendertools, useObjectColor,
- rgbacolor,slot
- );
-
- if(!useObjectColor) {
+ if(ms.m_bDisplayList) {
localSlot->EndList();
- *slot = localSlot;
+ ms.m_DisplayList = localSlot;
}
}
-void RAS_ListRasterizer::IndexPrimitivesMulti(
- const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot)
+void RAS_ListRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
{
RAS_ListSlot* localSlot =0;
- // useObjectColor(are we updating every frame?)
- if(!useObjectColor) {
- localSlot = FindOrAdd(vertexarrays, slot);
+ if(ms.m_bDisplayList) {
+ localSlot = FindOrAdd(ms);
localSlot->DrawList();
- if(localSlot->End())
+ if(localSlot->End()) {
+ // save slot here too, needed for replicas and object using same mesh
+ // => they have the same vertexarray but different mesh slot
+ ms.m_DisplayList = localSlot;
return;
+ }
}
- RAS_OpenGLRasterizer::IndexPrimitivesMulti(
- vertexarrays, indexarrays,
- mode, polymat,
- rendertools, useObjectColor,
- rgbacolor,slot
- );
- if(!useObjectColor) {
+ // workaround: note how we do not use vertex arrays for making display
+ // lists, since glVertexAttribPointerARB doesn't seem to work correct
+ // in display lists on ATI? either a bug in the driver or in Blender ..
+ if (mUseVertexArrays && !localSlot)
+ RAS_VAOpenGLRasterizer::IndexPrimitivesMulti(ms);
+ else
+ RAS_OpenGLRasterizer::IndexPrimitivesMulti(ms);
+
+ if(ms.m_bDisplayList) {
localSlot->EndList();
- *slot = localSlot;
+ ms.m_DisplayList = localSlot;
+ }
+}
+
+bool RAS_ListRasterizer::Init(void)
+{
+ if (mUseVertexArrays) {
+ return RAS_VAOpenGLRasterizer::Init();
+ } else {
+ return RAS_OpenGLRasterizer::Init();
+ }
+}
+
+void RAS_ListRasterizer::SetDrawingMode(int drawingmode)
+{
+ if (mUseVertexArrays) {
+ RAS_VAOpenGLRasterizer::SetDrawingMode(drawingmode);
+ } else {
+ RAS_OpenGLRasterizer::SetDrawingMode(drawingmode);
+ }
+}
+
+void RAS_ListRasterizer::Exit()
+{
+ if (mUseVertexArrays) {
+ RAS_VAOpenGLRasterizer::Exit();
+ } else {
+ RAS_OpenGLRasterizer::Exit();
}
}
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
index 82840cd1399..96d6d2a995d 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_ListRasterizer.h
@@ -2,17 +2,21 @@
#define __RAS_LISTRASTERIZER_H__
#include "RAS_MaterialBucket.h"
-#include "RAS_OpenGLRasterizer.h"
+#include "RAS_VAOpenGLRasterizer.h"
#include <vector>
+#include <map>
+class RAS_ListRasterizer;
class RAS_ListSlot : public KX_ListSlot
{
unsigned int m_list;
unsigned int m_flag;
+ RAS_ListRasterizer* m_rasty;
public:
- RAS_ListSlot();
+ RAS_ListSlot(RAS_ListRasterizer* rasty);
virtual ~RAS_ListSlot();
virtual void SetModified(bool mod);
+ virtual int Release();
void RemoveList();
void DrawList();
@@ -31,40 +35,28 @@ enum RAS_ListSlotFlags {
LIST_REGEN =64
};
-typedef std::map<const vecVertexArray, RAS_ListSlot*> RAS_Lists;
+typedef std::map<class RAS_MeshSlot*, RAS_ListSlot*> RAS_Lists;
-class RAS_ListRasterizer : public RAS_OpenGLRasterizer
+class RAS_ListRasterizer : public RAS_VAOpenGLRasterizer
{
+ bool mUseVertexArrays;
RAS_Lists mLists;
- RAS_ListSlot* FindOrAdd(const vecVertexArray& vertexarrays, KX_ListSlot** slot);
+ RAS_ListSlot* FindOrAdd(class RAS_MeshSlot& ms);
void ReleaseAlloc();
public:
- RAS_ListRasterizer(RAS_ICanvas* canvas);
+ void RemoveListSlot(RAS_ListSlot* list);
+ RAS_ListRasterizer(RAS_ICanvas* canvas, bool useVertexArrays=false, bool lock=false);
virtual ~RAS_ListRasterizer();
- virtual void IndexPrimitives(
- const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot
- );
+ virtual void IndexPrimitives(class RAS_MeshSlot& ms);
+ virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms);
- virtual void IndexPrimitivesMulti(
- const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot
- );
+ virtual bool Init();
+ virtual void Exit();
+
+ virtual void SetDrawingMode(int drawingmode);
virtual bool QueryLists(){return true;}
};
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
index 7988bab337f..87a0a1d8b9e 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp
@@ -27,35 +27,19 @@
*/
#include <math.h>
+#include <stdlib.h>
#include "RAS_OpenGLRasterizer.h"
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#ifdef WIN32
-#include <windows.h>
-#endif // WIN32
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#include <OpenGL/glu.h>
-#else
-#include <GL/gl.h>
-#if defined(__sun__) && !defined(__sparc__)
-#include <mesa/glu.h>
-#else
-#include <GL/glu.h>
-#endif
-#endif
+#include "GL/glew.h"
#include "RAS_Rect.h"
#include "RAS_TexVert.h"
#include "MT_CmMatrix4x4.h"
#include "RAS_IRenderTools.h" // rendering text
-#include "RAS_GLExtensionManager.h"
+#include "GPU_draw.h"
+#include "GPU_material.h"
/**
* 32x32 bit masks for vinterlace stereo mode
@@ -82,12 +66,16 @@ RAS_OpenGLRasterizer::RAS_OpenGLRasterizer(RAS_ICanvas* canvas)
m_focallength(0.0),
m_setfocallength(false),
m_noOfScanlines(32),
- m_useTang(false),
- m_materialCachingInfo(0),
m_motionblur(0),
- m_motionblurvalue(-1.0)
-{
- m_viewmatrix.Identity();
+ m_motionblurvalue(-1.0),
+ m_texco_num(0),
+ m_attrib_num(0),
+ m_last_blendmode(GPU_BLEND_SOLID),
+ m_last_frontface(true),
+ m_materialCachingInfo(0)
+{
+ m_viewmatrix.setIdentity();
+ m_viewinvmatrix.setIdentity();
for (int i = 0; i < 32; i++)
{
@@ -104,78 +92,9 @@ RAS_OpenGLRasterizer::~RAS_OpenGLRasterizer()
{
}
-
-
-static void Myinit_gl_stuff(void)
-{
- float mat_specular[] = { 0.5, 0.5, 0.5, 1.0 };
- float mat_shininess[] = { 35.0 };
-/* float one= 1.0; */
- int a, x, y;
- GLubyte pat[32*32];
- const GLubyte *patc= pat;
-
- glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, mat_specular);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
- glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess);
-
-
-#if defined(__FreeBSD) || defined(__linux__)
- glDisable(GL_DITHER); /* op sgi/sun hardware && 12 bits */
-#endif
-
- /* no local viewer, looks ugly in ortho mode */
- /* glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, &one); */
-
- glDepthFunc(GL_LEQUAL);
- /* scaling matrices */
- glEnable(GL_NORMALIZE);
-
- glShadeModel(GL_FLAT);
-
- glDisable(GL_ALPHA_TEST);
- glDisable(GL_BLEND);
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_FOG);
- glDisable(GL_LIGHTING);
- glDisable(GL_LOGIC_OP);
- glDisable(GL_STENCIL_TEST);
- glDisable(GL_TEXTURE_1D);
- glDisable(GL_TEXTURE_2D);
-
- glPixelTransferi(GL_MAP_COLOR, GL_FALSE);
- glPixelTransferi(GL_RED_SCALE, 1);
- glPixelTransferi(GL_RED_BIAS, 0);
- glPixelTransferi(GL_GREEN_SCALE, 1);
- glPixelTransferi(GL_GREEN_BIAS, 0);
- glPixelTransferi(GL_BLUE_SCALE, 1);
- glPixelTransferi(GL_BLUE_BIAS, 0);
- glPixelTransferi(GL_ALPHA_SCALE, 1);
- glPixelTransferi(GL_ALPHA_BIAS, 0);
-
- a = 0;
- for(x=0; x<32; x++)
- {
- for(y=0; y<4; y++)
- {
- if( (x) & 1) pat[a++]= 0x88;
- else pat[a++]= 0x22;
- }
- }
-
- glPolygonStipple(patc);
-
- glFrontFace(GL_CCW);
- glCullFace(GL_BACK);
- glEnable(GL_CULL_FACE);
-}
-
-
-
bool RAS_OpenGLRasterizer::Init()
{
-
- Myinit_gl_stuff();
+ GPU_state_init();
m_redback = 0.4375;
m_greenback = 0.4375;
@@ -186,6 +105,13 @@ bool RAS_OpenGLRasterizer::Init()
m_ambg = 0.0f;
m_ambb = 0.0f;
+ glDisable(GL_BLEND);
+ glDisable(GL_ALPHA_TEST);
+ m_last_blendmode = GPU_BLEND_SOLID;
+
+ glFrontFace(GL_CCW);
+ m_last_frontface = true;
+
glClearColor(m_redback,m_greenback,m_blueback,m_alphaback);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -204,18 +130,6 @@ void RAS_OpenGLRasterizer::SetAmbientColor(float red, float green, float blue)
}
-void RAS_OpenGLRasterizer::SetAlphaTest(bool enable)
-{
- if (enable)
- {
- glEnable(GL_ALPHA_TEST);
- glAlphaFunc(GL_GREATER, 0.6f);
- }
- else glDisable(GL_ALPHA_TEST);
-}
-
-
-
void RAS_OpenGLRasterizer::SetAmbient(float factor)
{
float ambient[] = { m_ambr*factor, m_ambg*factor, m_ambb*factor, 1.0f };
@@ -334,27 +248,16 @@ void RAS_OpenGLRasterizer::Exit()
glDisable(GL_POLYGON_STIPPLE);
glDisable(GL_LIGHTING);
- if (bgl::QueryExtension(bgl::_GL_EXT_separate_specular_color) || bgl::QueryVersion(1, 2))
+ if (GLEW_EXT_separate_specular_color || GLEW_VERSION_1_2)
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
EndFrame();
}
-bool RAS_OpenGLRasterizer::InterlacedStereo() const
-{
- return m_stereomode == RAS_STEREO_VINTERLACE || m_stereomode == RAS_STEREO_INTERLACED;
-}
-
bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time)
{
m_time = time;
m_drawingmode = drawingmode;
-
- if (!InterlacedStereo() || m_curreye == RAS_STEREO_LEFTEYE)
- {
- m_2DCanvas->ClearColor(m_redback,m_greenback,m_blueback,m_alphaback);
- m_2DCanvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER);
- }
// Blender camera routine destroys the settings
if (m_drawingmode < KX_SOLID)
@@ -368,6 +271,13 @@ bool RAS_OpenGLRasterizer::BeginFrame(int drawingmode, double time)
glEnable (GL_CULL_FACE);
}
+ glDisable(GL_BLEND);
+ glDisable(GL_ALPHA_TEST);
+ m_last_blendmode = GPU_BLEND_SOLID;
+
+ glFrontFace(GL_CCW);
+ m_last_frontface = true;
+
glShadeModel(GL_SMOOTH);
m_2DCanvas->BeginFrame();
@@ -381,46 +291,28 @@ void RAS_OpenGLRasterizer::SetDrawingMode(int drawingmode)
{
m_drawingmode = drawingmode;
- switch (m_drawingmode)
- {
- case KX_BOUNDINGBOX:
- {
- }
- case KX_WIREFRAME:
- {
- glDisable (GL_CULL_FACE);
- break;
- }
- case KX_TEXTURED:
- {
- }
- case KX_SHADED:
- {
- }
- case KX_SOLID:
- {
- }
- default:
- {
- }
- }
+ if(m_drawingmode == KX_WIREFRAME)
+ glDisable(GL_CULL_FACE);
}
-
-
int RAS_OpenGLRasterizer::GetDrawingMode()
{
return m_drawingmode;
}
-
void RAS_OpenGLRasterizer::SetDepthMask(DepthMask depthmask)
{
glDepthMask(depthmask == KX_DEPTHMASK_DISABLED ? GL_FALSE : GL_TRUE);
}
+void RAS_OpenGLRasterizer::ClearColorBuffer()
+{
+ m_2DCanvas->ClearColor(m_redback,m_greenback,m_blueback,m_alphaback);
+ m_2DCanvas->ClearBuffer(RAS_ICanvas::COLOR_BUFFER);
+}
+
void RAS_OpenGLRasterizer::ClearDepthBuffer()
{
@@ -531,6 +423,10 @@ bool RAS_OpenGLRasterizer::Stereo()
return true;
}
+bool RAS_OpenGLRasterizer::InterlacedStereo()
+{
+ return m_stereomode == RAS_STEREO_VINTERLACE || m_stereomode == RAS_STEREO_INTERLACED;
+}
void RAS_OpenGLRasterizer::SetEye(const StereoEye eye)
{
@@ -607,1172 +503,251 @@ void RAS_OpenGLRasterizer::SwapBuffers()
-void RAS_OpenGLRasterizer::GetViewMatrix(MT_Matrix4x4 &mat) const
+const MT_Matrix4x4& RAS_OpenGLRasterizer::GetViewMatrix() const
{
- float viewmat[16];
- glGetFloatv(GL_MODELVIEW_MATRIX, viewmat);
- mat.setValue(viewmat);
+ return m_viewmatrix;
}
+const MT_Matrix4x4& RAS_OpenGLRasterizer::GetViewInvMatrix() const
+{
+ return m_viewinvmatrix;
+}
-
-void RAS_OpenGLRasterizer::IndexPrimitives(const vecVertexArray & vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
+void RAS_OpenGLRasterizer::IndexPrimitives_3DText(RAS_MeshSlot& ms,
class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot
- )
+ class RAS_IRenderTools* rendertools)
{
- GLenum drawmode;
- switch (mode)
- {
- case 0:
- drawmode = GL_TRIANGLES;
- break;
- case 1:
- drawmode = GL_LINES;
- break;
- case 2:
- drawmode = GL_QUADS;
- break;
- default:
- drawmode = GL_LINES;
- break;
+ bool obcolor = ms.m_bObjectColor;
+ MT_Vector4& rgba = ms.m_RGBAcolor;
+ RAS_MeshSlot::iterator it;
+
+ // handle object color
+ if (obcolor) {
+ glDisableClientState(GL_COLOR_ARRAY);
+ glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
}
-
- const RAS_TexVert* vertexarray ;
- unsigned int numindices,vt;
+ else
+ glEnableClientState(GL_COLOR_ARRAY);
- for (vt=0;vt<vertexarrays.size();vt++)
- {
- vertexarray = &((*vertexarrays[vt]) [0]);
- const KX_IndexArray & indexarray = (*indexarrays[vt]);
- numindices = indexarray.size();
+ for(ms.begin(it); !ms.end(it); ms.next(it)) {
+ RAS_TexVert *vertex;
+ size_t i, j, numvert;
- if (!numindices)
- break;
-
- int vindex=0;
- switch (mode)
- {
- case 1:
- {
- glBegin(GL_LINES);
- vindex=0;
- for (unsigned int i=0;i<numindices;i+=2)
- {
- glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ());
- glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ());
- }
- glEnd();
- }
- break;
- case 2:
- {
- glBegin(GL_QUADS);
- vindex=0;
- if (useObjectColor)
- {
- for (unsigned int i=0;i<numindices;i+=4)
- {
-
- glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]);
-
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
- }
- else
- {
- for (unsigned int i=0;i<numindices;i+=4)
- {
- // This looks curiously endian unsafe to me.
- // However it depends on the way the colors are packed into
- // the m_rgba field of RAS_TexVert
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
- }
- glEnd();
- break;
- }
- case 0:
- {
- glBegin(GL_TRIANGLES);
- vindex=0;
- if (useObjectColor)
- {
- for (unsigned int i=0;i<numindices;i+=3)
- {
-
- glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]);
-
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
- }
- else
- {
- for (unsigned int i=0;i<numindices;i+=3)
- {
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
- }
- glEnd();
- break;
- }
- default:
- {
- }
-
- } // switch
- } // for each vertexarray
+ numvert = it.array->m_type;
-}
+ if(it.array->m_type == RAS_DisplayArray::LINE) {
+ // line drawing, no text
+ glBegin(GL_LINES);
-void RAS_OpenGLRasterizer::IndexPrimitives_Ex(const vecVertexArray & vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor
- )
-{
- bool recalc;
- GLenum drawmode;
- switch (mode)
- {
- case 0:
- drawmode = GL_TRIANGLES;
- break;
- case 1:
- drawmode = GL_LINES;
- break;
- case 2:
- drawmode = GL_QUADS;
- break;
- default:
- drawmode = GL_LINES;
- break;
- }
-
- const RAS_TexVert* vertexarray ;
- unsigned int numindices,vt;
-
- for (vt=0;vt<vertexarrays.size();vt++)
- {
- vertexarray = &((*vertexarrays[vt]) [0]);
- const KX_IndexArray & indexarray = (*indexarrays[vt]);
- numindices = indexarray.size();
-
- if (!numindices)
- continue;
-
- int vindex=0;
- switch (mode)
- {
- case 1:
+ for(i=0; i<it.totindex; i+=2)
{
- glBegin(GL_LINES);
- vindex=0;
- for (unsigned int i=0;i<numindices;i+=2)
- {
- glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ());
- glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ());
- }
- glEnd();
- }
- break;
- case 2:
- {
- glBegin(GL_QUADS);
- vindex=0;
- if (useObjectColor)
- {
- for (unsigned int i=0;i<numindices;i+=4)
- {
- MT_Point3 mv1, mv2, mv3, mv4, fnor;
- /* Calc a new face normal */
+ vertex = &it.vertex[it.index[i]];
+ glVertex3fv(vertex->getXYZ());
- if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL)
- recalc= true;
- else
- recalc=false;
-
- if (recalc){
- mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ());
- mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ());
- mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ());
- mv4 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ());
-
- fnor = (((mv2-mv1).cross(mv3-mv2))+((mv4-mv3).cross(mv1-mv4))).safe_normalized();
-
- glNormal3f(fnor[0], fnor[1], fnor[2]);
- }
-
- glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]);
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
- }
- else
- {
- for (unsigned int i=0;i<numindices;i+=4)
- {
- // This looks curiously endian unsafe to me.
- // However it depends on the way the colors are packed into
- // the m_rgba field of RAS_TexVert
- MT_Point3 mv1, mv2, mv3, mv4, fnor;
- /* Calc a new face normal */
-
- if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL)
- recalc= true;
- else
- recalc=false;
-
-
- if (recalc){
- mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ());
- mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ());
- mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ());
- mv4 = MT_Point3(vertexarray[(indexarray[vindex+3])].getLocalXYZ());
-
- fnor = (((mv2-mv1).cross(mv3-mv2))+((mv4-mv3).cross(mv1-mv4))).safe_normalized();
-
- glNormal3f(fnor[0], fnor[1], fnor[2]);
- }
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
- }
- glEnd();
- break;
+ vertex = &it.vertex[it.index[i+1]];
+ glVertex3fv(vertex->getXYZ());
}
- case 0:
+
+ glEnd();
+ }
+ else {
+ // triangle and quad text drawing
+ for(i=0; i<it.totindex; i+=numvert)
{
- glBegin(GL_TRIANGLES);
- vindex=0;
- if (useObjectColor)
- {
- for (unsigned int i=0;i<numindices;i+=3)
- {
- MT_Point3 mv1, mv2, mv3, fnor;
- /* Calc a new face normal */
+ float v[4][3];
+ int glattrib, unit;
- if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL)
- recalc= true;
- else
- recalc=false;
-
- if (recalc){
- mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ());
- mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ());
- mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ());
-
- fnor = ((mv2-mv1).cross(mv3-mv2)).safe_normalized();
- glNormal3f(fnor[0], fnor[1], fnor[2]);
- }
-
- glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]);
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
- }
- else
- {
- for (unsigned int i=0;i<numindices;i+=3)
- {
- MT_Point3 mv1, mv2, mv3, fnor;
- /* Calc a new face normal */
+ for(j=0; j<numvert; j++) {
+ vertex = &it.vertex[it.index[i+j]];
- if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL)
- recalc= true;
- else
- recalc=false;
-
-
- if (recalc){
- mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ());
- mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ());
- mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ());
-
- fnor = ((mv2-mv1).cross(mv3-mv2)).safe_normalized();
- glNormal3f(fnor[0], fnor[1], fnor[2]);
- }
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- glTexCoord2fv(vertexarray[(indexarray[vindex])].getUV1());
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
+ v[j][0] = vertex->getXYZ()[0];
+ v[j][1] = vertex->getXYZ()[1];
+ v[j][2] = vertex->getXYZ()[2];
}
- glEnd();
- break;
- }
- default:
- {
+
+ // find the right opengl attribute
+ glattrib = -1;
+ if(GLEW_ARB_vertex_program)
+ for(unit=0; unit<m_attrib_num; unit++)
+ if(m_attrib[unit] == RAS_TEXCO_UV1)
+ glattrib = unit;
+
+ rendertools->RenderText(polymat->GetDrawingMode(), polymat,
+ v[0], v[1], v[2], (numvert == 4)? v[3]: NULL, glattrib);
+
+ ClearCachingInfo();
}
-
- } // switch
- } // for each vertexarray
+ }
+ }
+ glDisableClientState(GL_COLOR_ARRAY);
}
+void RAS_OpenGLRasterizer::SetTexCoordNum(int num)
+{
+ m_texco_num = num;
+ if(m_texco_num > RAS_MAX_TEXCO)
+ m_texco_num = RAS_MAX_TEXCO;
+}
-
-void RAS_OpenGLRasterizer::IndexPrimitives_3DText(const vecVertexArray & vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor
- )
-{
- GLenum drawmode;
- switch (mode)
- {
- case 0:
- drawmode = GL_TRIANGLES;
- break;
- case 1:
- drawmode = GL_LINES;
- break;
- case 2:
- drawmode = GL_QUADS;
- break;
- default:
- drawmode = GL_LINES;
- break;
- }
-
- const RAS_TexVert* vertexarray ;
-
- unsigned int numindices, vt;
-
- if (useObjectColor)
- {
- glDisableClientState(GL_COLOR_ARRAY);
- glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]);
- }
- else
- {
- glEnableClientState(GL_COLOR_ARRAY);
- }
-
- for (vt=0;vt<vertexarrays.size();vt++)
- {
- vertexarray = &((*vertexarrays[vt]) [0]);
- const KX_IndexArray & indexarray = (*indexarrays[vt]);
- numindices = indexarray.size();
-
- if (!numindices)
- break;
-
- int vindex=0;
- switch (mode)
- {
- case 1:
- {
- glBegin(GL_LINES);
- vindex=0;
- for (unsigned int i=0;i<numindices;i+=2)
- {
- glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ());
- glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ());
- }
- glEnd();
- }
- break;
- case 2:
- {
- vindex=0;
- for (unsigned int i=0;i<numindices;i+=4)
- {
- float v1[3],v2[3],v3[3],v4[3];
-
- v1[0] = vertexarray[(indexarray[vindex])].getLocalXYZ()[0];
- v1[1] = vertexarray[(indexarray[vindex])].getLocalXYZ()[1];
- v1[2] = vertexarray[(indexarray[vindex])].getLocalXYZ()[2];
- vindex++;
-
- v2[0] = vertexarray[(indexarray[vindex])].getLocalXYZ()[0];
- v2[1] = vertexarray[(indexarray[vindex])].getLocalXYZ()[1];
- v2[2] = vertexarray[(indexarray[vindex])].getLocalXYZ()[2];
- vindex++;
-
- v3[0] = vertexarray[(indexarray[vindex])].getLocalXYZ()[0];
- v3[1] = vertexarray[(indexarray[vindex])].getLocalXYZ()[1];
- v3[2] = vertexarray[(indexarray[vindex])].getLocalXYZ()[2];
- vindex++;
-
- v4[0] = vertexarray[(indexarray[vindex])].getLocalXYZ()[0];
- v4[1] = vertexarray[(indexarray[vindex])].getLocalXYZ()[1];
- v4[2] = vertexarray[(indexarray[vindex])].getLocalXYZ()[2];
-
- vindex++;
-
- rendertools->RenderText(polymat->GetDrawingMode(),polymat,v1,v2,v3,v4);
- ClearCachingInfo();
- }
- break;
- }
- case 0:
- {
- glBegin(GL_TRIANGLES);
- vindex=0;
- for (unsigned int i=0;i<numindices;i+=3)
- {
- float v1[3],v2[3],v3[3];
-
- v1[0] = vertexarray[(indexarray[vindex])].getLocalXYZ()[0];
- v1[1] = vertexarray[(indexarray[vindex])].getLocalXYZ()[1];
- v1[2] = vertexarray[(indexarray[vindex])].getLocalXYZ()[2];
- vindex++;
-
- v2[0] = vertexarray[(indexarray[vindex])].getLocalXYZ()[0];
- v2[1] = vertexarray[(indexarray[vindex])].getLocalXYZ()[1];
- v2[2] = vertexarray[(indexarray[vindex])].getLocalXYZ()[2];
- vindex++;
-
- v3[0] = vertexarray[(indexarray[vindex])].getLocalXYZ()[0];
- v3[1] = vertexarray[(indexarray[vindex])].getLocalXYZ()[1];
- v3[2] = vertexarray[(indexarray[vindex])].getLocalXYZ()[2];
- vindex++;
-
- rendertools->RenderText(polymat->GetDrawingMode(),polymat,v1,v2,v3,NULL);
- ClearCachingInfo();
- }
- glEnd();
- break;
- }
- default:
- {
- }
- } //switch
- } //for each vertexarray
+void RAS_OpenGLRasterizer::SetAttribNum(int num)
+{
+ m_attrib_num = num;
+ if(m_attrib_num > RAS_MAX_ATTRIB)
+ m_attrib_num = RAS_MAX_ATTRIB;
}
-void RAS_OpenGLRasterizer::SetTexCoords(TexCoGen coords,int unit)
+void RAS_OpenGLRasterizer::SetTexCoord(TexCoGen coords, int unit)
{
// this changes from material to material
- if(unit < RAS_MAX)
+ if(unit < RAS_MAX_TEXCO)
m_texco[unit] = coords;
}
-void RAS_OpenGLRasterizer::SetAttrib(int type)
+void RAS_OpenGLRasterizer::SetAttrib(TexCoGen coords, int unit)
{
- if(type == RAS_TEXTANGENT) m_useTang=true;
+ // this changes from material to material
+ if(unit < RAS_MAX_ATTRIB)
+ m_attrib[unit] = coords;
}
-void RAS_OpenGLRasterizer::TexCoord(const RAS_TexVert &tv, int enabled)
+void RAS_OpenGLRasterizer::TexCoord(const RAS_TexVert &tv)
{
-#ifdef GL_ARB_multitexture
- if(bgl::RAS_EXT_support._ARB_multitexture)
- {
- for(int unit=0; unit<enabled; unit++)
- {
- if( tv.getFlag() & TV_2NDUV && tv.getUnit() == unit ) {
- bgl::blMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV2());
+ int unit;
+
+ if(GLEW_ARB_multitexture) {
+ for(unit=0; unit<m_texco_num; unit++) {
+ if(tv.getFlag() & RAS_TexVert::SECOND_UV && (int)tv.getUnit() == unit) {
+ glMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV2());
continue;
}
- switch(m_texco[unit])
- {
- case RAS_TEXCO_DISABLE:
- case RAS_TEXCO_OBJECT:
- case RAS_TEXCO_GEN:
- break;
+ switch(m_texco[unit]) {
case RAS_TEXCO_ORCO:
case RAS_TEXCO_GLOB:
- bgl::blMultiTexCoord3fvARB(GL_TEXTURE0_ARB+unit, tv.getLocalXYZ());
+ glMultiTexCoord3fvARB(GL_TEXTURE0_ARB+unit, tv.getXYZ());
break;
case RAS_TEXCO_UV1:
- bgl::blMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV1());
+ glMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV1());
break;
case RAS_TEXCO_NORM:
- bgl::blMultiTexCoord3fvARB(GL_TEXTURE0_ARB+unit, tv.getNormal());
+ glMultiTexCoord3fvARB(GL_TEXTURE0_ARB+unit, tv.getNormal());
break;
case RAS_TEXTANGENT:
- bgl::blMultiTexCoord4fvARB(GL_TEXTURE0_ARB+unit, tv.getTangent());
+ glMultiTexCoord4fvARB(GL_TEXTURE0_ARB+unit, tv.getTangent());
break;
case RAS_TEXCO_UV2:
- bgl::blMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV2());
+ glMultiTexCoord2fvARB(GL_TEXTURE0_ARB+unit, tv.getUV2());
+ break;
+ default:
break;
}
}
}
-#endif
-#ifdef GL_ARB_vertex_program
- if(m_useTang && bgl::RAS_EXT_support._ARB_vertex_program)
- bgl::blVertexAttrib4fvARB(1/*tangent*/, tv.getTangent());
-#endif
+ if(GLEW_ARB_vertex_program) {
+ for(unit=0; unit<m_attrib_num; unit++) {
+ switch(m_attrib[unit]) {
+ case RAS_TEXCO_ORCO:
+ case RAS_TEXCO_GLOB:
+ glVertexAttrib3fvARB(unit, tv.getXYZ());
+ break;
+ case RAS_TEXCO_UV1:
+ glVertexAttrib2fvARB(unit, tv.getUV1());
+ break;
+ case RAS_TEXCO_NORM:
+ glVertexAttrib3fvARB(unit, tv.getNormal());
+ break;
+ case RAS_TEXTANGENT:
+ glVertexAttrib4fvARB(unit, tv.getTangent());
+ break;
+ case RAS_TEXCO_UV2:
+ glVertexAttrib2fvARB(unit, tv.getUV2());
+ break;
+ case RAS_TEXCO_VCOL:
+ glVertexAttrib4ubvARB(unit, tv.getRGBA());
+ break;
+ default:
+ break;
+ }
+ }
+ }
}
-void RAS_OpenGLRasterizer::Tangent( const RAS_TexVert& v1,
- const RAS_TexVert& v2,
- const RAS_TexVert& v3,
- const MT_Vector3 &no)
+
+void RAS_OpenGLRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
{
-#ifdef GL_ARB_multitexture
- // TODO: set for deformer...
- MT_Vector3 x1(v1.getLocalXYZ()), x2(v2.getLocalXYZ()), x3(v3.getLocalXYZ());
- MT_Vector2 uv1(v1.getUV1()), uv2(v2.getUV1()), uv3(v3.getUV1());
- MT_Vector3 dx1(x2 - x1), dx2(x3 - x1);
- MT_Vector2 duv1(uv2 - uv1), duv2(uv3 - uv1);
-
- MT_Scalar r = 1.0 / (duv1.x() * duv2.y() - duv2.x() * duv1.y());
- duv1 *= r;
- duv2 *= r;
- MT_Vector3 sdir(duv2.y() * dx1 - duv1.y() * dx2);
- MT_Vector3 tdir(duv1.x() * dx2 - duv2.x() * dx1);
-
- // Gram-Schmidt orthogonalize
- MT_Vector3 t(sdir - no.cross(no.cross(sdir)));
- if (!MT_fuzzyZero(t))
- t /= t.length();
-
- float tangent[4];
- t.getValue(tangent);
- // Calculate handedness
- tangent[3] = no.dot(sdir.cross(tdir)) < 0.0 ? -1.0 : 1.0;
-#endif
+ IndexPrimitivesInternal(ms, false);
}
+void RAS_OpenGLRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
+{
+ IndexPrimitivesInternal(ms, true);
+}
-void RAS_OpenGLRasterizer::IndexPrimitivesMulti(
- const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot
- )
+void RAS_OpenGLRasterizer::IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi)
{
-#ifdef GL_ARB_multitexture
-
- GLenum drawmode;
- switch (mode)
- {
- case 0:
- drawmode = GL_TRIANGLES;
- break;
- case 1:
- drawmode = GL_LINES;
- break;
- case 2:
- drawmode = GL_QUADS;
- break;
- default:
- drawmode = GL_LINES;
- break;
- }
-
- const RAS_TexVert* vertexarray ;
- unsigned int numindices,vt;
+ bool obcolor = ms.m_bObjectColor;
+ bool wireframe = m_drawingmode <= KX_WIREFRAME;
+ MT_Vector4& rgba = ms.m_RGBAcolor;
+ RAS_MeshSlot::iterator it;
+
+ // iterate over display arrays, each containing an index + vertex array
+ for(ms.begin(it); !ms.end(it); ms.next(it)) {
+ RAS_TexVert *vertex;
+ size_t i, j, numvert;
+
+ numvert = it.array->m_type;
- for (vt=0;vt<vertexarrays.size();vt++)
- {
- vertexarray = &((*vertexarrays[vt]) [0]);
- const KX_IndexArray & indexarray = (*indexarrays[vt]);
- numindices = indexarray.size();
- const unsigned int enabled = polymat->GetEnabled();
+ if(it.array->m_type == RAS_DisplayArray::LINE) {
+ // line drawing
+ glBegin(GL_LINES);
- if (!numindices)
- break;
-
- int vindex=0;
- switch (mode)
- {
- case 1:
- {
- glBegin(GL_LINES);
- vindex=0;
- for (unsigned int i=0;i<numindices;i+=2)
- {
- glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ());
- glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ());
- }
- glEnd();
- }
- break;
- case 2:
+ for(i=0; i<it.totindex; i+=2)
{
- glBegin(GL_QUADS);
- vindex=0;
- if (useObjectColor)
- {
- for (unsigned int i=0;i<numindices;i+=4)
- {
-
- glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]);
-
- //
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- //
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- //
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- //
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
- }
- else
- {
- for (unsigned int i=0;i<numindices;i+=4)
- {
- // This looks curiously endian unsafe to me.
- // However it depends on the way the colors are packed into
- // the m_rgba field of RAS_TexVert
-
- //
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
-
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- //
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- //
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- //
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
- }
- glEnd();
- break;
+ vertex = &it.vertex[it.index[i]];
+ glVertex3fv(vertex->getXYZ());
+
+ vertex = &it.vertex[it.index[i+1]];
+ glVertex3fv(vertex->getXYZ());
}
- case 0:
- {
+
+ glEnd();
+ }
+ else {
+ // triangle and quad drawing
+ if(it.array->m_type == RAS_DisplayArray::TRIANGLE)
glBegin(GL_TRIANGLES);
- vindex=0;
- if (useObjectColor)
- {
- for (unsigned int i=0;i<numindices;i+=3)
- {
-
- glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]);
- //
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- //
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- //
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
- }
- else
- {
- for (unsigned int i=0;i<numindices;i+=3)
- {
- //
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- //
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- //
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
- }
- glEnd();
- break;
- }
- default:
+ else
+ glBegin(GL_QUADS);
+
+ for(i=0; i<it.totindex; i+=numvert)
{
- }
- } // switch
- } // for each vertexarray
-#endif// GL_ARB_multitexture
+ if(obcolor)
+ glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
-}
+ for(j=0; j<numvert; j++) {
+ vertex = &it.vertex[it.index[i+j]];
-void RAS_OpenGLRasterizer::IndexPrimitivesMulti_Ex(
- const vecVertexArray & vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor)
-{
-#ifdef GL_ARB_multitexture
- bool recalc;
- GLenum drawmode;
- switch (mode)
- {
- case 0:
- drawmode = GL_TRIANGLES;
- break;
- case 1:
- drawmode = GL_LINES;
- break;
- case 2:
- drawmode = GL_QUADS;
- break;
- default:
- drawmode = GL_LINES;
- break;
- }
-
- const RAS_TexVert* vertexarray ;
- unsigned int numindices,vt;
+ if(!wireframe) {
+ if(!obcolor)
+ glColor4ubv((const GLubyte *)(vertex->getRGBA()));
- for (vt=0;vt<vertexarrays.size();vt++)
- {
- vertexarray = &((*vertexarrays[vt]) [0]);
- const KX_IndexArray & indexarray = (*indexarrays[vt]);
- numindices = indexarray.size();
- const unsigned int enabled = polymat->GetEnabled();
-
- if (!numindices)
- continue;
-
- int vindex=0;
- switch (mode)
- {
- case 1:
- {
- glBegin(GL_LINES);
- vindex=0;
- for (unsigned int i=0;i<numindices;i+=2)
- {
- glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ());
- glVertex3fv(vertexarray[(indexarray[vindex++])].getLocalXYZ());
- }
- glEnd();
- }
- break;
- case 2:
- {
- glBegin(GL_QUADS);
- vindex=0;
- if (useObjectColor)
- {
- for (unsigned int i=0;i<numindices;i+=4)
- {
- MT_Point3 mv1, mv2, mv3, mv4, fnor;
- /* Calc a new face normal */
+ glNormal3fv(vertex->getNormal());
- if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL)
- recalc= true;
- else
- recalc=false;
-
- if (recalc){
- mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ());
- mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ());
- mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ());
- mv4 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ());
-
- fnor = (((mv2-mv1).cross(mv3-mv2))+((mv4-mv3).cross(mv1-mv4))).safe_normalized();
-
- glNormal3f(fnor[0], fnor[1], fnor[2]);
- }
-
- glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]);
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
-
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
-
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
-
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
- }
- else
- {
- for (unsigned int i=0;i<numindices;i+=4)
- {
- // This looks curiously endian unsafe to me.
- // However it depends on the way the colors are packed into
- // the m_rgba field of RAS_TexVert
- MT_Point3 mv1, mv2, mv3, mv4, fnor;
- /* Calc a new face normal */
-
- if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL)
- recalc= true;
+ if(multi)
+ TexCoord(*vertex);
else
- recalc=false;
-
-
- if (recalc){
- mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ());
- mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ());
- mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ());
- mv4 = MT_Point3(vertexarray[(indexarray[vindex+3])].getLocalXYZ());
-
- fnor = (((mv2-mv1).cross(mv3-mv2))+((mv4-mv3).cross(mv1-mv4))).safe_normalized();
-
- glNormal3f(fnor[0], fnor[1], fnor[2]);
- }
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
-
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
-
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
-
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
-
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
+ glTexCoord2fv(vertex->getUV1());
}
- }
- glEnd();
- break;
- }
- case 0:
- {
- glBegin(GL_TRIANGLES);
- vindex=0;
- if (useObjectColor)
- {
- for (unsigned int i=0;i<numindices;i+=3)
- {
- MT_Point3 mv1, mv2, mv3, fnor;
- /* Calc a new face normal */
- if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL)
- recalc= true;
- else
- recalc=false;
-
- if (recalc){
- mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ());
- mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ());
- mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ());
-
- fnor = ((mv2-mv1).cross(mv3-mv2)).safe_normalized();
- glNormal3f(fnor[0], fnor[1], fnor[2]);
- }
-
- glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]);
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
+ glVertex3fv(vertex->getXYZ());
}
- else
- {
- for (unsigned int i=0;i<numindices;i+=3)
- {
- MT_Point3 mv1, mv2, mv3, fnor;
- /* Calc a new face normal */
-
- if (vertexarray[(indexarray[vindex])].getFlag() & TV_CALCFACENORMAL)
- recalc= true;
- else
- recalc=false;
-
-
- if (recalc){
- mv1 = MT_Point3(vertexarray[(indexarray[vindex])].getLocalXYZ());
- mv2 = MT_Point3(vertexarray[(indexarray[vindex+1])].getLocalXYZ());
- mv3 = MT_Point3(vertexarray[(indexarray[vindex+2])].getLocalXYZ());
-
- fnor = ((mv2-mv1).cross(mv3-mv2)).safe_normalized();
- glNormal3f(fnor[0], fnor[1], fnor[2]);
- }
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
-
- glColor4ubv((const GLubyte *)(vertexarray[(indexarray[vindex])].getRGBA()));
- if (!recalc)
- glNormal3fv(vertexarray[(indexarray[vindex])].getNormal());
- TexCoord(vertexarray[(indexarray[vindex])],enabled );
- glVertex3fv(vertexarray[(indexarray[vindex])].getLocalXYZ());
- vindex++;
- }
- }
- glEnd();
- break;
}
- default:
- {
- }
-
- } // switch
- } // for each vertexarray
-#endif
-}
-
+ glEnd();
+ }
+ }
+}
void RAS_OpenGLRasterizer::SetProjectionMatrix(MT_CmMatrix4x4 &mat)
{
@@ -1799,6 +774,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
float top,
float frustnear,
float frustfar,
+ float focallength,
bool
){
MT_Matrix4x4 result;
@@ -1810,9 +786,10 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
float near_div_focallength;
// next 2 params should be specified on command line and in Blender publisher
if (!m_setfocallength)
- m_focallength = 1.5 * right; // derived from example
+ m_focallength = (focallength == 0.f) ? 1.5 * right // derived from example
+ : focallength;
if (!m_seteyesep)
- m_eyeseparation = 0.18 * right; // just a guess...
+ m_eyeseparation = m_focallength/30; // reasonable value...
near_div_focallength = frustnear / m_focallength;
switch(m_curreye)
@@ -1844,7 +821,7 @@ MT_Matrix4x4 RAS_OpenGLRasterizer::GetFrustumMatrix(
void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Vector3& campos,
const MT_Point3 &, const MT_Quaternion &camOrientQuat)
{
- MT_Matrix4x4 viewMat = mat;
+ m_viewmatrix = mat;
// correction for stereo
if(m_stereomode != RAS_STEREO_NOSTEREO)
@@ -1871,7 +848,7 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Vecto
MT_Transform transform;
transform.setIdentity();
transform.translate(-(eyeline * m_eyeseparation / 2.0));
- viewMat *= transform;
+ m_viewmatrix *= transform;
}
break;
case RAS_STEREO_RIGHTEYE:
@@ -1880,20 +857,21 @@ void RAS_OpenGLRasterizer::SetViewMatrix(const MT_Matrix4x4 &mat, const MT_Vecto
MT_Transform transform;
transform.setIdentity();
transform.translate(eyeline * m_eyeseparation / 2.0);
- viewMat *= transform;
+ m_viewmatrix *= transform;
}
break;
}
}
- // convert row major matrix 'viewMat' to column major for OpenGL
- MT_Scalar cammat[16];
- viewMat.getValue(cammat);
- MT_CmMatrix4x4 viewCmmat = cammat;
+ m_viewinvmatrix = m_viewmatrix;
+ m_viewinvmatrix.invert();
+
+ // note: getValue gives back column major as needed by OpenGL
+ MT_Scalar glviewmat[16];
+ m_viewmatrix.getValue(glviewmat);
glMatrixMode(GL_MODELVIEW);
- m_viewmatrix = viewCmmat;
- glLoadMatrixd(&m_viewmatrix(0,0));
+ glLoadMatrixd(glviewmat);
m_campos = campos;
}
@@ -1904,20 +882,6 @@ const MT_Point3& RAS_OpenGLRasterizer::GetCameraPosition()
}
-
-void RAS_OpenGLRasterizer::LoadViewMatrix()
-{
- glLoadMatrixd(&m_viewmatrix(0,0));
-}
-
-
-
-void RAS_OpenGLRasterizer::EnableTextures(bool enable)
-{
-}
-
-
-
void RAS_OpenGLRasterizer::SetCullFace(bool enable)
{
if (enable)
@@ -1985,7 +949,10 @@ void RAS_OpenGLRasterizer::SetPolygonOffset(float mult, float add)
void RAS_OpenGLRasterizer::EnableMotionBlur(float motionblurvalue)
{
- m_motionblur = 1;
+ /* don't just set m_motionblur to 1, but check if it is 0 so
+ * we don't reset a motion blur that is already enabled */
+ if(m_motionblur == 0)
+ m_motionblur = 1;
m_motionblurvalue = motionblurvalue;
}
@@ -1994,3 +961,47 @@ void RAS_OpenGLRasterizer::DisableMotionBlur()
m_motionblur = 0;
m_motionblurvalue = -1.0;
}
+
+void RAS_OpenGLRasterizer::SetBlendingMode(int blendmode)
+{
+ if(blendmode == m_last_blendmode)
+ return;
+
+ if(blendmode == GPU_BLEND_SOLID) {
+ glDisable(GL_BLEND);
+ glDisable(GL_ALPHA_TEST);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+ else if(blendmode == GPU_BLEND_ADD) {
+ glBlendFunc(GL_ONE, GL_ONE);
+ glEnable(GL_BLEND);
+ glDisable(GL_ALPHA_TEST);
+ }
+ else if(blendmode == GPU_BLEND_ALPHA) {
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+ glEnable(GL_ALPHA_TEST);
+ glAlphaFunc(GL_GREATER, 0.0f);
+ }
+ else if(blendmode == GPU_BLEND_CLIP) {
+ glDisable(GL_BLEND);
+ glEnable(GL_ALPHA_TEST);
+ glAlphaFunc(GL_GREATER, 0.5f);
+ }
+
+ m_last_blendmode = blendmode;
+}
+
+void RAS_OpenGLRasterizer::SetFrontFace(bool ccw)
+{
+ if(m_last_frontface == ccw)
+ return;
+
+ if(ccw)
+ glFrontFace(GL_CCW);
+ else
+ glFrontFace(GL_CW);
+
+ m_last_frontface = ccw;
+}
+
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
index c63a7b80b7c..0717cce0ce8 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.h
@@ -41,7 +41,8 @@ using namespace std;
#include "RAS_MaterialBucket.h"
#include "RAS_ICanvas.h"
-#define RAS_MAX 3// match in BL_Material
+#define RAS_MAX_TEXCO 8 // match in BL_Material
+#define RAS_MAX_ATTRIB 16 // match in BL_BlenderShader
struct OglDebugLine
{
@@ -76,7 +77,8 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer
float m_ambb;
double m_time;
- MT_CmMatrix4x4 m_viewmatrix;
+ MT_Matrix4x4 m_viewmatrix;
+ MT_Matrix4x4 m_viewinvmatrix;
MT_Point3 m_campos;
StereoMode m_stereomode;
@@ -86,7 +88,6 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer
float m_focallength;
bool m_setfocallength;
int m_noOfScanlines;
- bool InterlacedStereo() const;
//motion blur
int m_motionblur;
@@ -94,8 +95,12 @@ class RAS_OpenGLRasterizer : public RAS_IRasterizer
protected:
int m_drawingmode;
- TexCoGen m_texco[RAS_MAX];
- bool m_useTang;
+ TexCoGen m_texco[RAS_MAX_TEXCO];
+ TexCoGen m_attrib[RAS_MAX_ATTRIB];
+ int m_texco_num;
+ int m_attrib_num;
+ int m_last_blendmode;
+ bool m_last_frontface;
/** Stores the caching information for the last material activated. */
RAS_IPolyMaterial::TCachingInfo m_materialCachingInfo;
@@ -125,6 +130,7 @@ public:
virtual bool Init();
virtual void Exit();
virtual bool BeginFrame(int drawingmode, double time);
+ virtual void ClearColorBuffer();
virtual void ClearDepthBuffer();
virtual void ClearCachingInfo(void);
virtual void EndFrame();
@@ -132,6 +138,7 @@ public:
virtual void SetStereoMode(const StereoMode stereomode);
virtual bool Stereo();
+ virtual bool InterlacedStereo();
virtual void SetEye(const StereoEye eye);
virtual StereoEye GetEye();
virtual void SetEyeSeparation(const float eyeseparation);
@@ -139,59 +146,16 @@ public:
virtual void SetFocalLength(const float focallength);
virtual float GetFocalLength();
- virtual void SetAlphaTest(bool enable);
-
virtual void SwapBuffers();
- virtual void IndexPrimitives(
- const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot
- );
-
- virtual void IndexPrimitives_Ex(
- const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor
- );
+ virtual void IndexPrimitives(class RAS_MeshSlot& ms);
+ virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms);
virtual void IndexPrimitives_3DText(
- const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
+ class RAS_MeshSlot& ms,
class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor
- );
-
- virtual void IndexPrimitivesMulti(
- const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot);
-
- virtual void IndexPrimitivesMulti_Ex(
- const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor);
+ class RAS_IRenderTools* rendertools);
+ void IndexPrimitivesInternal(RAS_MeshSlot& ms, bool multi);
virtual void SetProjectionMatrix(MT_CmMatrix4x4 & mat);
virtual void SetProjectionMatrix(const MT_Matrix4x4 & mat);
@@ -203,7 +167,6 @@ public:
);
virtual const MT_Point3& GetCameraPosition();
- virtual void LoadViewMatrix();
virtual void SetFog(
float start,
@@ -235,7 +198,6 @@ public:
virtual void SetDrawingMode(int drawingmode);
virtual int GetDrawingMode();
- virtual void EnableTextures(bool enable);
virtual void SetCullFace(bool enable);
virtual void SetLines(bool enable);
@@ -246,6 +208,7 @@ public:
float top,
float frustnear,
float frustfar,
+ float focallength,
bool perspective
);
@@ -285,21 +248,21 @@ public:
std::vector <OglDebugLine> m_debugLines;
- virtual void SetTexCoords(TexCoGen coords,int enabled);
- virtual void SetAttrib(int type);
- void TexCoord(const RAS_TexVert &tv, int unit);
- virtual void GetViewMatrix(MT_Matrix4x4 &mat) const;
+ virtual void SetTexCoordNum(int num);
+ virtual void SetAttribNum(int num);
+ virtual void SetTexCoord(TexCoGen coords, int unit);
+ virtual void SetAttrib(TexCoGen coords, int unit);
+
+ void TexCoord(const RAS_TexVert &tv);
- void Tangent(const RAS_TexVert& v1,
- const RAS_TexVert& v2,
- const RAS_TexVert& v3,
- const MT_Vector3 &no);
+ const MT_Matrix4x4& GetViewMatrix() const;
+ const MT_Matrix4x4& GetViewInvMatrix() const;
virtual void EnableMotionBlur(float motionblurvalue);
virtual void DisableMotionBlur();
virtual float GetMotionBlurValue(){return m_motionblurvalue;};
- virtual int GetMotionBlurState(){return m_motionblur;};
- virtual void SetMotionBlurState(int newstate)
+ virtual int GetMotionBlurState(){return m_motionblur;};
+ virtual void SetMotionBlurState(int newstate)
{
if(newstate<0)
m_motionblur = 0;
@@ -308,6 +271,9 @@ public:
else
m_motionblur = newstate;
};
+
+ virtual void SetBlendingMode(int blendmode);
+ virtual void SetFrontFace(bool ccw);
};
#endif //__RAS_OPENGLRASTERIZER
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp
index 3e4eef5bd45..2cb3b52adfb 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.cpp
@@ -30,35 +30,24 @@
#endif
#include "RAS_VAOpenGLRasterizer.h"
+#include <stdlib.h>
-#ifdef WIN32
-#include <windows.h>
-#endif // WIN32
-#ifdef __APPLE__
-#define GL_GLEXT_LEGACY 1
-#include <OpenGL/gl.h>
-#else
-#include <GL/gl.h>
-#endif
+#include "GL/glew.h"
+#include "GPU_extensions.h"
#include "STR_String.h"
#include "RAS_TexVert.h"
#include "MT_CmMatrix4x4.h"
#include "RAS_IRenderTools.h" // rendering text
-
-#include "RAS_GLExtensionManager.h"
-
-using namespace bgl;
-
RAS_VAOpenGLRasterizer::RAS_VAOpenGLRasterizer(RAS_ICanvas* canvas, bool lock)
: RAS_OpenGLRasterizer(canvas),
- m_Lock(lock && RAS_EXT_support._EXT_compiled_vertex_array)
+ m_Lock(lock && GLEW_EXT_compiled_vertex_array),
+ m_last_texco_num(0),
+ m_last_attrib_num(0)
{
}
-
-
RAS_VAOpenGLRasterizer::~RAS_VAOpenGLRasterizer()
{
}
@@ -71,9 +60,9 @@ bool RAS_VAOpenGLRasterizer::Init(void)
if (result)
{
glEnableClientState(GL_VERTEX_ARRAY);
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
@@ -81,238 +70,175 @@ bool RAS_VAOpenGLRasterizer::Init(void)
return result;
}
-
-
void RAS_VAOpenGLRasterizer::SetDrawingMode(int drawingmode)
{
m_drawingmode = drawingmode;
- switch (m_drawingmode)
+ switch (m_drawingmode)
{
- case KX_BOUNDINGBOX:
- {
- }
- case KX_WIREFRAME:
- {
- glDisable (GL_CULL_FACE);
+ case KX_BOUNDINGBOX:
+ case KX_WIREFRAME:
+ //glDisableClientState(GL_COLOR_ARRAY);
+ //glDisable(GL_CULL_FACE);
break;
- }
- case KX_TEXTURED:
- {
- }
- case KX_SHADED:
- {
- glEnableClientState(GL_COLOR_ARRAY);
- }
- case KX_SOLID:
- {
+ case KX_SOLID:
+ //glDisableClientState(GL_COLOR_ARRAY);
+ break;
+ case KX_TEXTURED:
+ case KX_SHADED:
+ case KX_SHADOW:
+ //glEnableClientState(GL_COLOR_ARRAY);
+ default:
break;
- }
- default:
- {
- }
}
}
-
-
void RAS_VAOpenGLRasterizer::Exit()
{
- glDisableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
- glDisableClientState(GL_NORMAL_ARRAY);
RAS_OpenGLRasterizer::Exit();
}
-
-
-void RAS_VAOpenGLRasterizer::IndexPrimitives( const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot)
+void RAS_VAOpenGLRasterizer::IndexPrimitives(RAS_MeshSlot& ms)
{
- static const GLsizei vtxstride = sizeof(RAS_TexVert);
+ static const GLsizei stride = sizeof(RAS_TexVert);
+ bool wireframe = m_drawingmode <= KX_WIREFRAME;
+ RAS_MeshSlot::iterator it;
GLenum drawmode;
- switch (mode)
- {
- case 0:
- {
- drawmode = GL_TRIANGLES;
- break;
- }
- case 2:
- {
- drawmode = GL_QUADS;
- break;
- }
- case 1: //lines
- {
- }
- default:
- {
- drawmode = GL_LINES;
- break;
- }
- }
- const RAS_TexVert* vertexarray;
- unsigned int numindices, vt;
- if (drawmode != GL_LINES)
- {
- if (useObjectColor)
- {
- glDisableClientState(GL_COLOR_ARRAY);
- glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]);
- } else
- {
- glColor4d(0,0,0,1.0);
- glEnableClientState(GL_COLOR_ARRAY);
- }
- }
- else
- {
- glColor3d(0,0,0);
- }
- // use glDrawElements to draw each vertexarray
- for (vt=0;vt<vertexarrays.size();vt++)
- {
- vertexarray = &((*vertexarrays[vt]) [0]);
- const KX_IndexArray & indexarray = (*indexarrays[vt]);
- numindices = indexarray.size();
+ if(!wireframe)
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- if (!numindices)
+ // use glDrawElements to draw each vertexarray
+ for(ms.begin(it); !ms.end(it); ms.next(it)) {
+ if(it.totindex == 0)
continue;
-
- glVertexPointer(3,GL_FLOAT,vtxstride,vertexarray->getLocalXYZ());
- glTexCoordPointer(2,GL_FLOAT,vtxstride,vertexarray->getUV1());
- glColorPointer(4,GL_UNSIGNED_BYTE,vtxstride,vertexarray->getRGBA());
- glNormalPointer(GL_FLOAT,vtxstride,vertexarray->getNormal());
- //if(m_Lock)
- // local->Begin(vertexarrays[vt]->size());
+ // drawing mode
+ if(it.array->m_type == RAS_DisplayArray::TRIANGLE)
+ drawmode = GL_TRIANGLES;
+ else if(it.array->m_type == RAS_DisplayArray::QUAD)
+ drawmode = GL_QUADS;
+ else
+ drawmode = GL_LINES;
+
+ // colors
+ if (drawmode != GL_LINES && !wireframe) {
+ if (ms.m_bObjectColor) {
+ const MT_Vector4& rgba = ms.m_RGBAcolor;
+
+ glDisableClientState(GL_COLOR_ARRAY);
+ glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
+ }
+ else {
+ glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
+ glEnableClientState(GL_COLOR_ARRAY);
+ }
+ }
+ else
+ glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
+
+ glVertexPointer(3, GL_FLOAT, stride, it.vertex->getXYZ());
+ glNormalPointer(GL_FLOAT, stride, it.vertex->getNormal());
+ if(!wireframe) {
+ glTexCoordPointer(2, GL_FLOAT, stride, it.vertex->getUV1());
+ if(glIsEnabled(GL_COLOR_ARRAY))
+ glColorPointer(4, GL_UNSIGNED_BYTE, stride, it.vertex->getRGBA());
+ }
// here the actual drawing takes places
- glDrawElements(drawmode,numindices,GL_UNSIGNED_SHORT,&(indexarray[0]));
-
- //if(m_Lock)
- // local->End();
-
+ glDrawElements(drawmode, it.totindex, GL_UNSIGNED_SHORT, it.index);
+ }
+ if(!wireframe) {
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ glDisableClientState(GL_COLOR_ARRAY);
}
}
-
-void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti( const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot)
+void RAS_VAOpenGLRasterizer::IndexPrimitivesMulti(RAS_MeshSlot& ms)
{
- static const GLsizei vtxstride = sizeof(RAS_TexVert);
+ static const GLsizei stride = sizeof(RAS_TexVert);
+ bool wireframe = m_drawingmode <= KX_WIREFRAME;
+ RAS_MeshSlot::iterator it;
GLenum drawmode;
- switch (mode)
- {
- case 0:
- {
- drawmode = GL_TRIANGLES;
- break;
- }
- case 2:
- {
- drawmode = GL_QUADS;
- break;
- }
- case 1: //lines
- {
- }
- default:
- {
- drawmode = GL_LINES;
- break;
- }
- }
- const RAS_TexVert* vertexarray;
- unsigned int numindices, vt;
- const unsigned int enabled = polymat->GetEnabled();
- if (drawmode != GL_LINES)
- {
- if (useObjectColor)
- {
- glDisableClientState(GL_COLOR_ARRAY);
- glColor4d(rgbacolor[0], rgbacolor[1], rgbacolor[2], rgbacolor[3]);
- } else
- {
- glColor4d(0,0,0,1.0);
- glEnableClientState(GL_COLOR_ARRAY);
- }
- }
- else
- {
- glColor3d(0,0,0);
- }
+ if(!wireframe)
+ EnableTextures(true);
// use glDrawElements to draw each vertexarray
- for (vt=0;vt<vertexarrays.size();vt++)
- {
- vertexarray = &((*vertexarrays[vt]) [0]);
- const KX_IndexArray & indexarray = (*indexarrays[vt]);
- numindices = indexarray.size();
-
- if (!numindices)
+ for(ms.begin(it); !ms.end(it); ms.next(it)) {
+ if(it.totindex == 0)
continue;
-
- glVertexPointer(3,GL_FLOAT,vtxstride,vertexarray->getLocalXYZ());
- TexCoordPtr(vertexarray, enabled);
- //glTexCoordPointer(2,GL_FLOAT,vtxstride,vertexarray->getUV1());
- glColorPointer(4,GL_UNSIGNED_BYTE,vtxstride,vertexarray->getRGBA());
- glNormalPointer(GL_FLOAT,vtxstride,vertexarray->getNormal());
-
- //if(m_Lock)
- // local->Begin(vertexarrays[vt]->size());
+ // drawing mode
+ if(it.array->m_type == RAS_DisplayArray::TRIANGLE)
+ drawmode = GL_TRIANGLES;
+ else if(it.array->m_type == RAS_DisplayArray::QUAD)
+ drawmode = GL_QUADS;
+ else
+ drawmode = GL_LINES;
+
+ // colors
+ if (drawmode != GL_LINES && !wireframe) {
+ if (ms.m_bObjectColor) {
+ const MT_Vector4& rgba = ms.m_RGBAcolor;
+
+ glDisableClientState(GL_COLOR_ARRAY);
+ glColor4d(rgba[0], rgba[1], rgba[2], rgba[3]);
+ }
+ else {
+ glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
+ glEnableClientState(GL_COLOR_ARRAY);
+ }
+ }
+ else
+ glColor4f(0.0f, 0.0f, 0.0f, 1.0f);
+
+ glVertexPointer(3, GL_FLOAT, stride, it.vertex->getXYZ());
+ glNormalPointer(GL_FLOAT, stride, it.vertex->getNormal());
+ if(!wireframe) {
+ TexCoordPtr(it.vertex);
+ if(glIsEnabled(GL_COLOR_ARRAY))
+ glColorPointer(4, GL_UNSIGNED_BYTE, stride, it.vertex->getRGBA());
+ }
// here the actual drawing takes places
- glDrawElements(drawmode,numindices,GL_UNSIGNED_SHORT,&(indexarray[0]));
-
- //if(m_Lock)
- // local->End();
+ glDrawElements(drawmode, it.totindex, GL_UNSIGNED_SHORT, it.index);
+ }
+
+ if(!wireframe) {
+ glDisableClientState(GL_COLOR_ARRAY);
+ EnableTextures(false);
}
}
-void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv, int enabled)
+void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv)
{
-#ifdef GL_ARB_multitexture
- if(bgl::RAS_EXT_support._ARB_multitexture)
+ /* note: this function must closely match EnableTextures to enable/disable
+ * the right arrays, otherwise coordinate and attribute pointers from other
+ * materials can still be used and cause crashes */
+ int unit;
+
+ if(GLEW_ARB_multitexture)
{
- for(int unit=0; unit<enabled; unit++)
+ for(unit=0; unit<m_texco_num; unit++)
{
- bgl::blClientActiveTextureARB(GL_TEXTURE0_ARB+unit);
-
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- if( tv->getFlag() & TV_2NDUV && tv->getUnit() == unit ) {
+ glClientActiveTextureARB(GL_TEXTURE0_ARB+unit);
+ if(tv->getFlag() & RAS_TexVert::SECOND_UV && (int)tv->getUnit() == unit) {
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert), tv->getUV2());
continue;
}
switch(m_texco[unit])
{
- case RAS_TEXCO_DISABLE:
- case RAS_TEXCO_OBJECT:
- case RAS_TEXCO_GEN:
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
- break;
case RAS_TEXCO_ORCO:
case RAS_TEXCO_GLOB:
- glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getLocalXYZ());
+ glTexCoordPointer(3, GL_FLOAT, sizeof(RAS_TexVert),tv->getXYZ());
break;
case RAS_TEXCO_UV1:
glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV1());
@@ -326,24 +252,121 @@ void RAS_VAOpenGLRasterizer::TexCoordPtr(const RAS_TexVert *tv, int enabled)
case RAS_TEXCO_UV2:
glTexCoordPointer(2, GL_FLOAT, sizeof(RAS_TexVert),tv->getUV2());
break;
+ default:
+ break;
}
}
- }
-#ifdef GL_ARB_vertex_program
- if(m_useTang && bgl::RAS_EXT_support._ARB_vertex_program)
- bgl::blVertexAttrib4fvARB(1/*tangent*/, tv->getTangent());
-#endif
+ glClientActiveTextureARB(GL_TEXTURE0_ARB);
+ }
-#endif
+ if(GLEW_ARB_vertex_program) {
+ for(unit=0; unit<m_attrib_num; unit++) {
+ switch(m_attrib[unit]) {
+ case RAS_TEXCO_ORCO:
+ case RAS_TEXCO_GLOB:
+ glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getXYZ());
+ break;
+ case RAS_TEXCO_UV1:
+ glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV1());
+ break;
+ case RAS_TEXCO_NORM:
+ glVertexAttribPointerARB(unit, 3, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getNormal());
+ break;
+ case RAS_TEXTANGENT:
+ glVertexAttribPointerARB(unit, 4, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getTangent());
+ break;
+ case RAS_TEXCO_UV2:
+ glVertexAttribPointerARB(unit, 2, GL_FLOAT, GL_FALSE, sizeof(RAS_TexVert), tv->getUV2());
+ break;
+ case RAS_TEXCO_VCOL:
+ glVertexAttribPointerARB(unit, 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(RAS_TexVert), tv->getRGBA());
+ break;
+ default:
+ break;
+ }
+ }
+ }
}
-
void RAS_VAOpenGLRasterizer::EnableTextures(bool enable)
{
- if (enable)
- glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- else
- glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ TexCoGen *texco, *attrib;
+ int unit, texco_num, attrib_num;
+
+ /* we cache last texcoords and attribs to ensure we disable the ones that
+ * were actually last set */
+ if(enable) {
+ texco = m_texco;
+ texco_num = m_texco_num;
+ attrib = m_attrib;
+ attrib_num = m_attrib_num;
+
+ memcpy(m_last_texco, m_texco, sizeof(TexCoGen)*m_texco_num);
+ m_last_texco_num = m_texco_num;
+ memcpy(m_last_attrib, m_attrib, sizeof(TexCoGen)*m_attrib_num);
+ m_last_attrib_num = m_attrib_num;
+ }
+ else {
+ texco = m_last_texco;
+ texco_num = m_last_texco_num;
+ attrib = m_last_attrib;
+ attrib_num = m_last_attrib_num;
+ }
+
+ if(GLEW_ARB_multitexture) {
+ for(unit=0; unit<texco_num; unit++) {
+ glClientActiveTextureARB(GL_TEXTURE0_ARB+unit);
+
+ switch(texco[unit])
+ {
+ case RAS_TEXCO_ORCO:
+ case RAS_TEXCO_GLOB:
+ case RAS_TEXCO_UV1:
+ case RAS_TEXCO_NORM:
+ case RAS_TEXTANGENT:
+ case RAS_TEXCO_UV2:
+ if(enable) glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ else glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ break;
+ default:
+ glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ break;
+ }
+ }
+
+ glClientActiveTextureARB(GL_TEXTURE0_ARB);
+ }
+ else {
+ if(texco_num) {
+ if(enable) glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ else glDisableClientState(GL_TEXTURE_COORD_ARRAY);
+ }
+ }
+
+ if(GLEW_ARB_vertex_program) {
+ for(unit=0; unit<attrib_num; unit++) {
+ switch(attrib[unit]) {
+ case RAS_TEXCO_ORCO:
+ case RAS_TEXCO_GLOB:
+ case RAS_TEXCO_UV1:
+ case RAS_TEXCO_NORM:
+ case RAS_TEXTANGENT:
+ case RAS_TEXCO_UV2:
+ case RAS_TEXCO_VCOL:
+ if(enable) glEnableVertexAttribArrayARB(unit);
+ else glDisableVertexAttribArrayARB(unit);
+ break;
+ default:
+ glDisableVertexAttribArrayARB(unit);
+ break;
+ }
+ }
+ }
+
+ if(!enable) {
+ m_last_texco_num = 0;
+ m_last_attrib_num = 0;
+ }
}
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h
index 4d478b0171f..766bbfbed0e 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_VAOpenGLRasterizer.h
@@ -33,9 +33,14 @@
class RAS_VAOpenGLRasterizer : public RAS_OpenGLRasterizer
{
- void TexCoordPtr(const RAS_TexVert *tv, int unit);
+ void TexCoordPtr(const RAS_TexVert *tv);
bool m_Lock;
+ TexCoGen m_last_texco[RAS_MAX_TEXCO];
+ TexCoGen m_last_attrib[RAS_MAX_ATTRIB];
+ int m_last_texco_num;
+ int m_last_attrib_num;
+
public:
RAS_VAOpenGLRasterizer(RAS_ICanvas* canvas, bool lock=false);
virtual ~RAS_VAOpenGLRasterizer();
@@ -45,26 +50,10 @@ public:
virtual void SetDrawingMode(int drawingmode);
- virtual void IndexPrimitives( const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot);
-
- virtual void IndexPrimitivesMulti(
- const vecVertexArray& vertexarrays,
- const vecIndexArrays & indexarrays,
- int mode,
- class RAS_IPolyMaterial* polymat,
- class RAS_IRenderTools* rendertools,
- bool useObjectColor,
- const MT_Vector4& rgbacolor,
- class KX_ListSlot** slot);
-
+ virtual void IndexPrimitives(class RAS_MeshSlot& ms);
+ virtual void IndexPrimitivesMulti(class RAS_MeshSlot& ms);
+private:
virtual void EnableTextures(bool enable);
//virtual bool QueryArrays(){return true;}
//virtual bool QueryLists(){return m_Lock;}
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
index b2b75ecb196..0f2a537265a 100644
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
+++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/SConscript
@@ -1,9 +1,9 @@
#!/usr/bin/python
Import ('env')
-sources = env.Glob('*.cpp') #'RAS_GLExtensionManager.cpp RAS_ListRasterizer.cpp RAS_OpenGLRasterizer.cpp RAS_VAOpenGLRasterizer.cpp'
+sources = env.Glob('*.cpp')
-incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer'
-incs += ' ' + env['BF_OPENGL_INC']
+incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/Rasterizer #source/gameengine/BlenderRoutines '
+incs += ' #source/blender/gpu #extern/glew/include ' + env['BF_OPENGL_INC']
env.BlenderLib ( 'bf_oglrasterizer', Split(sources), Split(incs), [], libtype=['game','player'], priority=[40, 115] )
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/glext.h b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/glext.h
deleted file mode 100644
index 7bb8e6e7cc7..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/glext.h
+++ /dev/null
@@ -1,6495 +0,0 @@
-#ifndef __glext_h_
-#define __glext_h_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
-** License Applicability. Except to the extent portions of this file are
-** made subject to an alternative license as permitted in the SGI Free
-** Software License B, Version 1.1 (the "License"), the contents of this
-** file are subject only to the provisions of the License. You may not use
-** this file except in compliance with the License. You may obtain a copy
-** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
-** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
-**
-** http://oss.sgi.com/projects/FreeB
-**
-** Note that, as provided in the License, the Software is distributed on an
-** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
-** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
-** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
-** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
-**
-** Original Code. The Original Code is: OpenGL Sample Implementation,
-** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
-** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc.
-** Copyright in any portions created by third parties is as indicated
-** elsewhere herein. All Rights Reserved.
-**
-** Additional Notice Provisions: This software was created using the
-** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
-** not been independently verified as being compliant with the OpenGL(R)
-** version 1.2.1 Specification.
-*/
-
-#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
-#define WIN32_LEAN_AND_MEAN 1
-#include <windows.h>
-#endif
-
-#ifndef APIENTRY
-#define APIENTRY
-#endif
-#ifndef APIENTRYP
-#define APIENTRYP APIENTRY *
-#endif
-#ifndef GLAPI
-#define GLAPI extern
-#endif
-
-/*************************************************************/
-
-/* Header file version number, required by OpenGL ABI for Linux */
-/* glext.h last updated 2005/06/20 */
-/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */
-#define GL_GLEXT_VERSION 29
-
-#ifndef GL_VERSION_1_2
-#define GL_UNSIGNED_BYTE_3_3_2 0x8032
-#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
-#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
-#define GL_UNSIGNED_INT_8_8_8_8 0x8035
-#define GL_UNSIGNED_INT_10_10_10_2 0x8036
-#define GL_RESCALE_NORMAL 0x803A
-#define GL_TEXTURE_BINDING_3D 0x806A
-#define GL_PACK_SKIP_IMAGES 0x806B
-#define GL_PACK_IMAGE_HEIGHT 0x806C
-#define GL_UNPACK_SKIP_IMAGES 0x806D
-#define GL_UNPACK_IMAGE_HEIGHT 0x806E
-#define GL_TEXTURE_3D 0x806F
-#define GL_PROXY_TEXTURE_3D 0x8070
-#define GL_TEXTURE_DEPTH 0x8071
-#define GL_TEXTURE_WRAP_R 0x8072
-#define GL_MAX_3D_TEXTURE_SIZE 0x8073
-#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
-#define GL_UNSIGNED_SHORT_5_6_5 0x8363
-#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
-#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
-#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
-#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
-#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
-#define GL_BGR 0x80E0
-#define GL_BGRA 0x80E1
-#define GL_MAX_ELEMENTS_VERTICES 0x80E8
-#define GL_MAX_ELEMENTS_INDICES 0x80E9
-#define GL_CLAMP_TO_EDGE 0x812F
-#define GL_TEXTURE_MIN_LOD 0x813A
-#define GL_TEXTURE_MAX_LOD 0x813B
-#define GL_TEXTURE_BASE_LEVEL 0x813C
-#define GL_TEXTURE_MAX_LEVEL 0x813D
-#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
-#define GL_SINGLE_COLOR 0x81F9
-#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
-#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
-#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
-#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
-#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
-#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
-#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
-#endif
-
-#ifndef GL_ARB_imaging
-#define GL_CONSTANT_COLOR 0x8001
-#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
-#define GL_CONSTANT_ALPHA 0x8003
-#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
-#define GL_BLEND_COLOR 0x8005
-#define GL_FUNC_ADD 0x8006
-#define GL_MIN 0x8007
-#define GL_MAX 0x8008
-#define GL_BLEND_EQUATION 0x8009
-#define GL_FUNC_SUBTRACT 0x800A
-#define GL_FUNC_REVERSE_SUBTRACT 0x800B
-#define GL_CONVOLUTION_1D 0x8010
-#define GL_CONVOLUTION_2D 0x8011
-#define GL_SEPARABLE_2D 0x8012
-#define GL_CONVOLUTION_BORDER_MODE 0x8013
-#define GL_CONVOLUTION_FILTER_SCALE 0x8014
-#define GL_CONVOLUTION_FILTER_BIAS 0x8015
-#define GL_REDUCE 0x8016
-#define GL_CONVOLUTION_FORMAT 0x8017
-#define GL_CONVOLUTION_WIDTH 0x8018
-#define GL_CONVOLUTION_HEIGHT 0x8019
-#define GL_MAX_CONVOLUTION_WIDTH 0x801A
-#define GL_MAX_CONVOLUTION_HEIGHT 0x801B
-#define GL_POST_CONVOLUTION_RED_SCALE 0x801C
-#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D
-#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E
-#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F
-#define GL_POST_CONVOLUTION_RED_BIAS 0x8020
-#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021
-#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022
-#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023
-#define GL_HISTOGRAM 0x8024
-#define GL_PROXY_HISTOGRAM 0x8025
-#define GL_HISTOGRAM_WIDTH 0x8026
-#define GL_HISTOGRAM_FORMAT 0x8027
-#define GL_HISTOGRAM_RED_SIZE 0x8028
-#define GL_HISTOGRAM_GREEN_SIZE 0x8029
-#define GL_HISTOGRAM_BLUE_SIZE 0x802A
-#define GL_HISTOGRAM_ALPHA_SIZE 0x802B
-#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C
-#define GL_HISTOGRAM_SINK 0x802D
-#define GL_MINMAX 0x802E
-#define GL_MINMAX_FORMAT 0x802F
-#define GL_MINMAX_SINK 0x8030
-#define GL_TABLE_TOO_LARGE 0x8031
-#define GL_COLOR_MATRIX 0x80B1
-#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2
-#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3
-#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4
-#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5
-#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6
-#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7
-#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8
-#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9
-#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA
-#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB
-#define GL_COLOR_TABLE 0x80D0
-#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1
-#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2
-#define GL_PROXY_COLOR_TABLE 0x80D3
-#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4
-#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5
-#define GL_COLOR_TABLE_SCALE 0x80D6
-#define GL_COLOR_TABLE_BIAS 0x80D7
-#define GL_COLOR_TABLE_FORMAT 0x80D8
-#define GL_COLOR_TABLE_WIDTH 0x80D9
-#define GL_COLOR_TABLE_RED_SIZE 0x80DA
-#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB
-#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC
-#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD
-#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE
-#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF
-#define GL_CONSTANT_BORDER 0x8151
-#define GL_REPLICATE_BORDER 0x8153
-#define GL_CONVOLUTION_BORDER_COLOR 0x8154
-#endif
-
-#ifndef GL_VERSION_1_3
-#define GL_TEXTURE0 0x84C0
-#define GL_TEXTURE1 0x84C1
-#define GL_TEXTURE2 0x84C2
-#define GL_TEXTURE3 0x84C3
-#define GL_TEXTURE4 0x84C4
-#define GL_TEXTURE5 0x84C5
-#define GL_TEXTURE6 0x84C6
-#define GL_TEXTURE7 0x84C7
-#define GL_TEXTURE8 0x84C8
-#define GL_TEXTURE9 0x84C9
-#define GL_TEXTURE10 0x84CA
-#define GL_TEXTURE11 0x84CB
-#define GL_TEXTURE12 0x84CC
-#define GL_TEXTURE13 0x84CD
-#define GL_TEXTURE14 0x84CE
-#define GL_TEXTURE15 0x84CF
-#define GL_TEXTURE16 0x84D0
-#define GL_TEXTURE17 0x84D1
-#define GL_TEXTURE18 0x84D2
-#define GL_TEXTURE19 0x84D3
-#define GL_TEXTURE20 0x84D4
-#define GL_TEXTURE21 0x84D5
-#define GL_TEXTURE22 0x84D6
-#define GL_TEXTURE23 0x84D7
-#define GL_TEXTURE24 0x84D8
-#define GL_TEXTURE25 0x84D9
-#define GL_TEXTURE26 0x84DA
-#define GL_TEXTURE27 0x84DB
-#define GL_TEXTURE28 0x84DC
-#define GL_TEXTURE29 0x84DD
-#define GL_TEXTURE30 0x84DE
-#define GL_TEXTURE31 0x84DF
-#define GL_ACTIVE_TEXTURE 0x84E0
-#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1
-#define GL_MAX_TEXTURE_UNITS 0x84E2
-#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3
-#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4
-#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5
-#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6
-#define GL_MULTISAMPLE 0x809D
-#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
-#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
-#define GL_SAMPLE_COVERAGE 0x80A0
-#define GL_SAMPLE_BUFFERS 0x80A8
-#define GL_SAMPLES 0x80A9
-#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
-#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
-#define GL_MULTISAMPLE_BIT 0x20000000
-#define GL_NORMAL_MAP 0x8511
-#define GL_REFLECTION_MAP 0x8512
-#define GL_TEXTURE_CUBE_MAP 0x8513
-#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
-#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
-#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
-#define GL_COMPRESSED_ALPHA 0x84E9
-#define GL_COMPRESSED_LUMINANCE 0x84EA
-#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
-#define GL_COMPRESSED_INTENSITY 0x84EC
-#define GL_COMPRESSED_RGB 0x84ED
-#define GL_COMPRESSED_RGBA 0x84EE
-#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
-#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
-#define GL_TEXTURE_COMPRESSED 0x86A1
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
-#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
-#define GL_CLAMP_TO_BORDER 0x812D
-#define GL_COMBINE 0x8570
-#define GL_COMBINE_RGB 0x8571
-#define GL_COMBINE_ALPHA 0x8572
-#define GL_SOURCE0_RGB 0x8580
-#define GL_SOURCE1_RGB 0x8581
-#define GL_SOURCE2_RGB 0x8582
-#define GL_SOURCE0_ALPHA 0x8588
-#define GL_SOURCE1_ALPHA 0x8589
-#define GL_SOURCE2_ALPHA 0x858A
-#define GL_OPERAND0_RGB 0x8590
-#define GL_OPERAND1_RGB 0x8591
-#define GL_OPERAND2_RGB 0x8592
-#define GL_OPERAND0_ALPHA 0x8598
-#define GL_OPERAND1_ALPHA 0x8599
-#define GL_OPERAND2_ALPHA 0x859A
-#define GL_RGB_SCALE 0x8573
-#define GL_ADD_SIGNED 0x8574
-#define GL_INTERPOLATE 0x8575
-#define GL_SUBTRACT 0x84E7
-#define GL_CONSTANT 0x8576
-#define GL_PRIMARY_COLOR 0x8577
-#define GL_PREVIOUS 0x8578
-#define GL_DOT3_RGB 0x86AE
-#define GL_DOT3_RGBA 0x86AF
-#endif
-
-#ifndef GL_VERSION_1_4
-#define GL_BLEND_DST_RGB 0x80C8
-#define GL_BLEND_SRC_RGB 0x80C9
-#define GL_BLEND_DST_ALPHA 0x80CA
-#define GL_BLEND_SRC_ALPHA 0x80CB
-#define GL_POINT_SIZE_MIN 0x8126
-#define GL_POINT_SIZE_MAX 0x8127
-#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
-#define GL_POINT_DISTANCE_ATTENUATION 0x8129
-#define GL_GENERATE_MIPMAP 0x8191
-#define GL_GENERATE_MIPMAP_HINT 0x8192
-#define GL_DEPTH_COMPONENT16 0x81A5
-#define GL_DEPTH_COMPONENT24 0x81A6
-#define GL_DEPTH_COMPONENT32 0x81A7
-#define GL_MIRRORED_REPEAT 0x8370
-#define GL_FOG_COORDINATE_SOURCE 0x8450
-#define GL_FOG_COORDINATE 0x8451
-#define GL_FRAGMENT_DEPTH 0x8452
-#define GL_CURRENT_FOG_COORDINATE 0x8453
-#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454
-#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455
-#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456
-#define GL_FOG_COORDINATE_ARRAY 0x8457
-#define GL_COLOR_SUM 0x8458
-#define GL_CURRENT_SECONDARY_COLOR 0x8459
-#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A
-#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B
-#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C
-#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D
-#define GL_SECONDARY_COLOR_ARRAY 0x845E
-#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
-#define GL_TEXTURE_FILTER_CONTROL 0x8500
-#define GL_TEXTURE_LOD_BIAS 0x8501
-#define GL_INCR_WRAP 0x8507
-#define GL_DECR_WRAP 0x8508
-#define GL_TEXTURE_DEPTH_SIZE 0x884A
-#define GL_DEPTH_TEXTURE_MODE 0x884B
-#define GL_TEXTURE_COMPARE_MODE 0x884C
-#define GL_TEXTURE_COMPARE_FUNC 0x884D
-#define GL_COMPARE_R_TO_TEXTURE 0x884E
-#endif
-
-#ifndef GL_VERSION_1_5
-#define GL_BUFFER_SIZE 0x8764
-#define GL_BUFFER_USAGE 0x8765
-#define GL_QUERY_COUNTER_BITS 0x8864
-#define GL_CURRENT_QUERY 0x8865
-#define GL_QUERY_RESULT 0x8866
-#define GL_QUERY_RESULT_AVAILABLE 0x8867
-#define GL_ARRAY_BUFFER 0x8892
-#define GL_ELEMENT_ARRAY_BUFFER 0x8893
-#define GL_ARRAY_BUFFER_BINDING 0x8894
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
-#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896
-#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897
-#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898
-#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899
-#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
-#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B
-#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C
-#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D
-#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E
-#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
-#define GL_READ_ONLY 0x88B8
-#define GL_WRITE_ONLY 0x88B9
-#define GL_READ_WRITE 0x88BA
-#define GL_BUFFER_ACCESS 0x88BB
-#define GL_BUFFER_MAPPED 0x88BC
-#define GL_BUFFER_MAP_POINTER 0x88BD
-#define GL_STREAM_DRAW 0x88E0
-#define GL_STREAM_READ 0x88E1
-#define GL_STREAM_COPY 0x88E2
-#define GL_STATIC_DRAW 0x88E4
-#define GL_STATIC_READ 0x88E5
-#define GL_STATIC_COPY 0x88E6
-#define GL_DYNAMIC_DRAW 0x88E8
-#define GL_DYNAMIC_READ 0x88E9
-#define GL_DYNAMIC_COPY 0x88EA
-#define GL_SAMPLES_PASSED 0x8914
-#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE
-#define GL_FOG_COORD GL_FOG_COORDINATE
-#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE
-#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE
-#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE
-#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER
-#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY
-#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING
-#define GL_SRC0_RGB GL_SOURCE0_RGB
-#define GL_SRC1_RGB GL_SOURCE1_RGB
-#define GL_SRC2_RGB GL_SOURCE2_RGB
-#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA
-#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA
-#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA
-#endif
-
-#ifndef GL_VERSION_2_0
-#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
-#define GL_CURRENT_VERTEX_ATTRIB 0x8626
-#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
-#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
-#define GL_STENCIL_BACK_FUNC 0x8800
-#define GL_STENCIL_BACK_FAIL 0x8801
-#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
-#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
-#define GL_MAX_DRAW_BUFFERS 0x8824
-#define GL_DRAW_BUFFER0 0x8825
-#define GL_DRAW_BUFFER1 0x8826
-#define GL_DRAW_BUFFER2 0x8827
-#define GL_DRAW_BUFFER3 0x8828
-#define GL_DRAW_BUFFER4 0x8829
-#define GL_DRAW_BUFFER5 0x882A
-#define GL_DRAW_BUFFER6 0x882B
-#define GL_DRAW_BUFFER7 0x882C
-#define GL_DRAW_BUFFER8 0x882D
-#define GL_DRAW_BUFFER9 0x882E
-#define GL_DRAW_BUFFER10 0x882F
-#define GL_DRAW_BUFFER11 0x8830
-#define GL_DRAW_BUFFER12 0x8831
-#define GL_DRAW_BUFFER13 0x8832
-#define GL_DRAW_BUFFER14 0x8833
-#define GL_DRAW_BUFFER15 0x8834
-#define GL_BLEND_EQUATION_ALPHA 0x883D
-#define GL_POINT_SPRITE 0x8861
-#define GL_COORD_REPLACE 0x8862
-#define GL_MAX_VERTEX_ATTRIBS 0x8869
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
-#define GL_MAX_TEXTURE_COORDS 0x8871
-#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
-#define GL_FRAGMENT_SHADER 0x8B30
-#define GL_VERTEX_SHADER 0x8B31
-#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
-#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
-#define GL_MAX_VARYING_FLOATS 0x8B4B
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
-#define GL_SHADER_TYPE 0x8B4F
-#define GL_FLOAT_VEC2 0x8B50
-#define GL_FLOAT_VEC3 0x8B51
-#define GL_FLOAT_VEC4 0x8B52
-#define GL_INT_VEC2 0x8B53
-#define GL_INT_VEC3 0x8B54
-#define GL_INT_VEC4 0x8B55
-#define GL_BOOL 0x8B56
-#define GL_BOOL_VEC2 0x8B57
-#define GL_BOOL_VEC3 0x8B58
-#define GL_BOOL_VEC4 0x8B59
-#define GL_FLOAT_MAT2 0x8B5A
-#define GL_FLOAT_MAT3 0x8B5B
-#define GL_FLOAT_MAT4 0x8B5C
-#define GL_SAMPLER_1D 0x8B5D
-#define GL_SAMPLER_2D 0x8B5E
-#define GL_SAMPLER_3D 0x8B5F
-#define GL_SAMPLER_CUBE 0x8B60
-#define GL_SAMPLER_1D_SHADOW 0x8B61
-#define GL_SAMPLER_2D_SHADOW 0x8B62
-#define GL_DELETE_STATUS 0x8B80
-#define GL_COMPILE_STATUS 0x8B81
-#define GL_LINK_STATUS 0x8B82
-#define GL_VALIDATE_STATUS 0x8B83
-#define GL_INFO_LOG_LENGTH 0x8B84
-#define GL_ATTACHED_SHADERS 0x8B85
-#define GL_ACTIVE_UNIFORMS 0x8B86
-#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
-#define GL_SHADER_SOURCE_LENGTH 0x8B88
-#define GL_ACTIVE_ATTRIBUTES 0x8B89
-#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
-#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
-#define GL_CURRENT_PROGRAM 0x8B8D
-#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
-#define GL_LOWER_LEFT 0x8CA1
-#define GL_UPPER_LEFT 0x8CA2
-#define GL_STENCIL_BACK_REF 0x8CA3
-#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
-#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
-#endif
-
-#ifndef GL_ARB_multitexture
-#define GL_TEXTURE0_ARB 0x84C0
-#define GL_TEXTURE1_ARB 0x84C1
-#define GL_TEXTURE2_ARB 0x84C2
-#define GL_TEXTURE3_ARB 0x84C3
-#define GL_TEXTURE4_ARB 0x84C4
-#define GL_TEXTURE5_ARB 0x84C5
-#define GL_TEXTURE6_ARB 0x84C6
-#define GL_TEXTURE7_ARB 0x84C7
-#define GL_TEXTURE8_ARB 0x84C8
-#define GL_TEXTURE9_ARB 0x84C9
-#define GL_TEXTURE10_ARB 0x84CA
-#define GL_TEXTURE11_ARB 0x84CB
-#define GL_TEXTURE12_ARB 0x84CC
-#define GL_TEXTURE13_ARB 0x84CD
-#define GL_TEXTURE14_ARB 0x84CE
-#define GL_TEXTURE15_ARB 0x84CF
-#define GL_TEXTURE16_ARB 0x84D0
-#define GL_TEXTURE17_ARB 0x84D1
-#define GL_TEXTURE18_ARB 0x84D2
-#define GL_TEXTURE19_ARB 0x84D3
-#define GL_TEXTURE20_ARB 0x84D4
-#define GL_TEXTURE21_ARB 0x84D5
-#define GL_TEXTURE22_ARB 0x84D6
-#define GL_TEXTURE23_ARB 0x84D7
-#define GL_TEXTURE24_ARB 0x84D8
-#define GL_TEXTURE25_ARB 0x84D9
-#define GL_TEXTURE26_ARB 0x84DA
-#define GL_TEXTURE27_ARB 0x84DB
-#define GL_TEXTURE28_ARB 0x84DC
-#define GL_TEXTURE29_ARB 0x84DD
-#define GL_TEXTURE30_ARB 0x84DE
-#define GL_TEXTURE31_ARB 0x84DF
-#define GL_ACTIVE_TEXTURE_ARB 0x84E0
-#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
-#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
-#endif
-
-#ifndef GL_ARB_transpose_matrix
-#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3
-#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4
-#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5
-#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6
-#endif
-
-#ifndef GL_ARB_multisample
-#define GL_MULTISAMPLE_ARB 0x809D
-#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E
-#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F
-#define GL_SAMPLE_COVERAGE_ARB 0x80A0
-#define GL_SAMPLE_BUFFERS_ARB 0x80A8
-#define GL_SAMPLES_ARB 0x80A9
-#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA
-#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB
-#define GL_MULTISAMPLE_BIT_ARB 0x20000000
-#endif
-
-#ifndef GL_ARB_texture_env_add
-#endif
-
-#ifndef GL_ARB_texture_cube_map
-#define GL_NORMAL_MAP_ARB 0x8511
-#define GL_REFLECTION_MAP_ARB 0x8512
-#define GL_TEXTURE_CUBE_MAP_ARB 0x8513
-#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A
-#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B
-#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C
-#endif
-
-#ifndef GL_ARB_texture_compression
-#define GL_COMPRESSED_ALPHA_ARB 0x84E9
-#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
-#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
-#define GL_COMPRESSED_INTENSITY_ARB 0x84EC
-#define GL_COMPRESSED_RGB_ARB 0x84ED
-#define GL_COMPRESSED_RGBA_ARB 0x84EE
-#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
-#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0
-#define GL_TEXTURE_COMPRESSED_ARB 0x86A1
-#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
-#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
-#endif
-
-#ifndef GL_ARB_texture_border_clamp
-#define GL_CLAMP_TO_BORDER_ARB 0x812D
-#endif
-
-#ifndef GL_ARB_point_parameters
-#define GL_POINT_SIZE_MIN_ARB 0x8126
-#define GL_POINT_SIZE_MAX_ARB 0x8127
-#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128
-#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129
-#endif
-
-#ifndef GL_ARB_vertex_blend
-#define GL_MAX_VERTEX_UNITS_ARB 0x86A4
-#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5
-#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6
-#define GL_VERTEX_BLEND_ARB 0x86A7
-#define GL_CURRENT_WEIGHT_ARB 0x86A8
-#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9
-#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA
-#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB
-#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC
-#define GL_WEIGHT_ARRAY_ARB 0x86AD
-#define GL_MODELVIEW0_ARB 0x1700
-#define GL_MODELVIEW1_ARB 0x850A
-#define GL_MODELVIEW2_ARB 0x8722
-#define GL_MODELVIEW3_ARB 0x8723
-#define GL_MODELVIEW4_ARB 0x8724
-#define GL_MODELVIEW5_ARB 0x8725
-#define GL_MODELVIEW6_ARB 0x8726
-#define GL_MODELVIEW7_ARB 0x8727
-#define GL_MODELVIEW8_ARB 0x8728
-#define GL_MODELVIEW9_ARB 0x8729
-#define GL_MODELVIEW10_ARB 0x872A
-#define GL_MODELVIEW11_ARB 0x872B
-#define GL_MODELVIEW12_ARB 0x872C
-#define GL_MODELVIEW13_ARB 0x872D
-#define GL_MODELVIEW14_ARB 0x872E
-#define GL_MODELVIEW15_ARB 0x872F
-#define GL_MODELVIEW16_ARB 0x8730
-#define GL_MODELVIEW17_ARB 0x8731
-#define GL_MODELVIEW18_ARB 0x8732
-#define GL_MODELVIEW19_ARB 0x8733
-#define GL_MODELVIEW20_ARB 0x8734
-#define GL_MODELVIEW21_ARB 0x8735
-#define GL_MODELVIEW22_ARB 0x8736
-#define GL_MODELVIEW23_ARB 0x8737
-#define GL_MODELVIEW24_ARB 0x8738
-#define GL_MODELVIEW25_ARB 0x8739
-#define GL_MODELVIEW26_ARB 0x873A
-#define GL_MODELVIEW27_ARB 0x873B
-#define GL_MODELVIEW28_ARB 0x873C
-#define GL_MODELVIEW29_ARB 0x873D
-#define GL_MODELVIEW30_ARB 0x873E
-#define GL_MODELVIEW31_ARB 0x873F
-#endif
-
-#ifndef GL_ARB_matrix_palette
-#define GL_MATRIX_PALETTE_ARB 0x8840
-#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841
-#define GL_MAX_PALETTE_MATRICES_ARB 0x8842
-#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843
-#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844
-#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845
-#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846
-#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847
-#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848
-#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849
-#endif
-
-#ifndef GL_ARB_texture_env_combine
-#define GL_COMBINE_ARB 0x8570
-#define GL_COMBINE_RGB_ARB 0x8571
-#define GL_COMBINE_ALPHA_ARB 0x8572
-#define GL_SOURCE0_RGB_ARB 0x8580
-#define GL_SOURCE1_RGB_ARB 0x8581
-#define GL_SOURCE2_RGB_ARB 0x8582
-#define GL_SOURCE0_ALPHA_ARB 0x8588
-#define GL_SOURCE1_ALPHA_ARB 0x8589
-#define GL_SOURCE2_ALPHA_ARB 0x858A
-#define GL_OPERAND0_RGB_ARB 0x8590
-#define GL_OPERAND1_RGB_ARB 0x8591
-#define GL_OPERAND2_RGB_ARB 0x8592
-#define GL_OPERAND0_ALPHA_ARB 0x8598
-#define GL_OPERAND1_ALPHA_ARB 0x8599
-#define GL_OPERAND2_ALPHA_ARB 0x859A
-#define GL_RGB_SCALE_ARB 0x8573
-#define GL_ADD_SIGNED_ARB 0x8574
-#define GL_INTERPOLATE_ARB 0x8575
-#define GL_SUBTRACT_ARB 0x84E7
-#define GL_CONSTANT_ARB 0x8576
-#define GL_PRIMARY_COLOR_ARB 0x8577
-#define GL_PREVIOUS_ARB 0x8578
-#endif
-
-#ifndef GL_ARB_texture_env_crossbar
-#endif
-
-#ifndef GL_ARB_texture_env_dot3
-#define GL_DOT3_RGB_ARB 0x86AE
-#define GL_DOT3_RGBA_ARB 0x86AF
-#endif
-
-#ifndef GL_ARB_texture_mirrored_repeat
-#define GL_MIRRORED_REPEAT_ARB 0x8370
-#endif
-
-#ifndef GL_ARB_depth_texture
-#define GL_DEPTH_COMPONENT16_ARB 0x81A5
-#define GL_DEPTH_COMPONENT24_ARB 0x81A6
-#define GL_DEPTH_COMPONENT32_ARB 0x81A7
-#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A
-#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
-#endif
-
-#ifndef GL_ARB_shadow
-#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C
-#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D
-#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E
-#endif
-
-#ifndef GL_ARB_shadow_ambient
-#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF
-#endif
-
-#ifndef GL_ARB_window_pos
-#endif
-
-#ifndef GL_ARB_vertex_program
-#define GL_COLOR_SUM_ARB 0x8458
-#define GL_VERTEX_PROGRAM_ARB 0x8620
-#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622
-#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623
-#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624
-#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625
-#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626
-#define GL_PROGRAM_LENGTH_ARB 0x8627
-#define GL_PROGRAM_STRING_ARB 0x8628
-#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E
-#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F
-#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640
-#define GL_CURRENT_MATRIX_ARB 0x8641
-#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642
-#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643
-#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645
-#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B
-#define GL_PROGRAM_BINDING_ARB 0x8677
-#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869
-#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A
-#define GL_PROGRAM_ERROR_STRING_ARB 0x8874
-#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875
-#define GL_PROGRAM_FORMAT_ARB 0x8876
-#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0
-#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1
-#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2
-#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3
-#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4
-#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5
-#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6
-#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7
-#define GL_PROGRAM_PARAMETERS_ARB 0x88A8
-#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9
-#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA
-#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB
-#define GL_PROGRAM_ATTRIBS_ARB 0x88AC
-#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD
-#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE
-#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF
-#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0
-#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1
-#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2
-#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3
-#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4
-#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5
-#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6
-#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7
-#define GL_MATRIX0_ARB 0x88C0
-#define GL_MATRIX1_ARB 0x88C1
-#define GL_MATRIX2_ARB 0x88C2
-#define GL_MATRIX3_ARB 0x88C3
-#define GL_MATRIX4_ARB 0x88C4
-#define GL_MATRIX5_ARB 0x88C5
-#define GL_MATRIX6_ARB 0x88C6
-#define GL_MATRIX7_ARB 0x88C7
-#define GL_MATRIX8_ARB 0x88C8
-#define GL_MATRIX9_ARB 0x88C9
-#define GL_MATRIX10_ARB 0x88CA
-#define GL_MATRIX11_ARB 0x88CB
-#define GL_MATRIX12_ARB 0x88CC
-#define GL_MATRIX13_ARB 0x88CD
-#define GL_MATRIX14_ARB 0x88CE
-#define GL_MATRIX15_ARB 0x88CF
-#define GL_MATRIX16_ARB 0x88D0
-#define GL_MATRIX17_ARB 0x88D1
-#define GL_MATRIX18_ARB 0x88D2
-#define GL_MATRIX19_ARB 0x88D3
-#define GL_MATRIX20_ARB 0x88D4
-#define GL_MATRIX21_ARB 0x88D5
-#define GL_MATRIX22_ARB 0x88D6
-#define GL_MATRIX23_ARB 0x88D7
-#define GL_MATRIX24_ARB 0x88D8
-#define GL_MATRIX25_ARB 0x88D9
-#define GL_MATRIX26_ARB 0x88DA
-#define GL_MATRIX27_ARB 0x88DB
-#define GL_MATRIX28_ARB 0x88DC
-#define GL_MATRIX29_ARB 0x88DD
-#define GL_MATRIX30_ARB 0x88DE
-#define GL_MATRIX31_ARB 0x88DF
-#endif
-
-#ifndef GL_ARB_fragment_program
-#define GL_FRAGMENT_PROGRAM_ARB 0x8804
-#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805
-#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806
-#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807
-#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808
-#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809
-#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A
-#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B
-#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C
-#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D
-#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E
-#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F
-#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810
-#define GL_MAX_TEXTURE_COORDS_ARB 0x8871
-#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872
-#endif
-
-#ifndef GL_ARB_vertex_buffer_object
-#define GL_BUFFER_SIZE_ARB 0x8764
-#define GL_BUFFER_USAGE_ARB 0x8765
-#define GL_ARRAY_BUFFER_ARB 0x8892
-#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893
-#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894
-#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
-#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
-#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
-#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
-#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
-#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
-#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
-#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
-#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
-#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
-#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
-#define GL_READ_ONLY_ARB 0x88B8
-#define GL_WRITE_ONLY_ARB 0x88B9
-#define GL_READ_WRITE_ARB 0x88BA
-#define GL_BUFFER_ACCESS_ARB 0x88BB
-#define GL_BUFFER_MAPPED_ARB 0x88BC
-#define GL_BUFFER_MAP_POINTER_ARB 0x88BD
-#define GL_STREAM_DRAW_ARB 0x88E0
-#define GL_STREAM_READ_ARB 0x88E1
-#define GL_STREAM_COPY_ARB 0x88E2
-#define GL_STATIC_DRAW_ARB 0x88E4
-#define GL_STATIC_READ_ARB 0x88E5
-#define GL_STATIC_COPY_ARB 0x88E6
-#define GL_DYNAMIC_DRAW_ARB 0x88E8
-#define GL_DYNAMIC_READ_ARB 0x88E9
-#define GL_DYNAMIC_COPY_ARB 0x88EA
-#endif
-
-#ifndef GL_ARB_occlusion_query
-#define GL_QUERY_COUNTER_BITS_ARB 0x8864
-#define GL_CURRENT_QUERY_ARB 0x8865
-#define GL_QUERY_RESULT_ARB 0x8866
-#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867
-#define GL_SAMPLES_PASSED_ARB 0x8914
-#endif
-
-#ifndef GL_ARB_shader_objects
-#define GL_PROGRAM_OBJECT_ARB 0x8B40
-#define GL_SHADER_OBJECT_ARB 0x8B48
-#define GL_OBJECT_TYPE_ARB 0x8B4E
-#define GL_OBJECT_SUBTYPE_ARB 0x8B4F
-#define GL_FLOAT_VEC2_ARB 0x8B50
-#define GL_FLOAT_VEC3_ARB 0x8B51
-#define GL_FLOAT_VEC4_ARB 0x8B52
-#define GL_INT_VEC2_ARB 0x8B53
-#define GL_INT_VEC3_ARB 0x8B54
-#define GL_INT_VEC4_ARB 0x8B55
-#define GL_BOOL_ARB 0x8B56
-#define GL_BOOL_VEC2_ARB 0x8B57
-#define GL_BOOL_VEC3_ARB 0x8B58
-#define GL_BOOL_VEC4_ARB 0x8B59
-#define GL_FLOAT_MAT2_ARB 0x8B5A
-#define GL_FLOAT_MAT3_ARB 0x8B5B
-#define GL_FLOAT_MAT4_ARB 0x8B5C
-#define GL_SAMPLER_1D_ARB 0x8B5D
-#define GL_SAMPLER_2D_ARB 0x8B5E
-#define GL_SAMPLER_3D_ARB 0x8B5F
-#define GL_SAMPLER_CUBE_ARB 0x8B60
-#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61
-#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62
-#define GL_SAMPLER_2D_RECT_ARB 0x8B63
-#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64
-#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80
-#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81
-#define GL_OBJECT_LINK_STATUS_ARB 0x8B82
-#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83
-#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84
-#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85
-#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86
-#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87
-#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88
-#endif
-
-#ifndef GL_ARB_vertex_shader
-#define GL_VERTEX_SHADER_ARB 0x8B31
-#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A
-#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B
-#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C
-#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D
-#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89
-#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A
-#endif
-
-#ifndef GL_ARB_fragment_shader
-#define GL_FRAGMENT_SHADER_ARB 0x8B30
-#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49
-#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B
-#endif
-
-#ifndef GL_ARB_shading_language_100
-#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C
-#endif
-
-#ifndef GL_ARB_texture_non_power_of_two
-#endif
-
-#ifndef GL_ARB_point_sprite
-#define GL_POINT_SPRITE_ARB 0x8861
-#define GL_COORD_REPLACE_ARB 0x8862
-#endif
-
-#ifndef GL_ARB_fragment_program_shadow
-#endif
-
-#ifndef GL_ARB_draw_buffers
-#define GL_MAX_DRAW_BUFFERS_ARB 0x8824
-#define GL_DRAW_BUFFER0_ARB 0x8825
-#define GL_DRAW_BUFFER1_ARB 0x8826
-#define GL_DRAW_BUFFER2_ARB 0x8827
-#define GL_DRAW_BUFFER3_ARB 0x8828
-#define GL_DRAW_BUFFER4_ARB 0x8829
-#define GL_DRAW_BUFFER5_ARB 0x882A
-#define GL_DRAW_BUFFER6_ARB 0x882B
-#define GL_DRAW_BUFFER7_ARB 0x882C
-#define GL_DRAW_BUFFER8_ARB 0x882D
-#define GL_DRAW_BUFFER9_ARB 0x882E
-#define GL_DRAW_BUFFER10_ARB 0x882F
-#define GL_DRAW_BUFFER11_ARB 0x8830
-#define GL_DRAW_BUFFER12_ARB 0x8831
-#define GL_DRAW_BUFFER13_ARB 0x8832
-#define GL_DRAW_BUFFER14_ARB 0x8833
-#define GL_DRAW_BUFFER15_ARB 0x8834
-#endif
-
-#ifndef GL_ARB_texture_rectangle
-#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
-#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6
-#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7
-#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
-#endif
-
-#ifndef GL_ARB_color_buffer_float
-#define GL_RGBA_FLOAT_MODE_ARB 0x8820
-#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A
-#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B
-#define GL_CLAMP_READ_COLOR_ARB 0x891C
-#define GL_FIXED_ONLY_ARB 0x891D
-#endif
-
-#ifndef GL_ARB_half_float_pixel
-#define GL_HALF_FLOAT_ARB 0x140B
-#endif
-
-#ifndef GL_ARB_texture_float
-#define GL_TEXTURE_RED_TYPE_ARB 0x8C10
-#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11
-#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12
-#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13
-#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14
-#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15
-#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16
-#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17
-#define GL_RGBA32F_ARB 0x8814
-#define GL_RGB32F_ARB 0x8815
-#define GL_ALPHA32F_ARB 0x8816
-#define GL_INTENSITY32F_ARB 0x8817
-#define GL_LUMINANCE32F_ARB 0x8818
-#define GL_LUMINANCE_ALPHA32F_ARB 0x8819
-#define GL_RGBA16F_ARB 0x881A
-#define GL_RGB16F_ARB 0x881B
-#define GL_ALPHA16F_ARB 0x881C
-#define GL_INTENSITY16F_ARB 0x881D
-#define GL_LUMINANCE16F_ARB 0x881E
-#define GL_LUMINANCE_ALPHA16F_ARB 0x881F
-#endif
-
-#ifndef GL_ARB_pixel_buffer_object
-#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
-#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
-#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED
-#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF
-#endif
-
-#ifndef GL_EXT_abgr
-#define GL_ABGR_EXT 0x8000
-#endif
-
-#ifndef GL_EXT_blend_color
-#define GL_CONSTANT_COLOR_EXT 0x8001
-#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002
-#define GL_CONSTANT_ALPHA_EXT 0x8003
-#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004
-#define GL_BLEND_COLOR_EXT 0x8005
-#endif
-
-#ifndef GL_EXT_polygon_offset
-#define GL_POLYGON_OFFSET_EXT 0x8037
-#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038
-#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039
-#endif
-
-#ifndef GL_EXT_texture
-#define GL_ALPHA4_EXT 0x803B
-#define GL_ALPHA8_EXT 0x803C
-#define GL_ALPHA12_EXT 0x803D
-#define GL_ALPHA16_EXT 0x803E
-#define GL_LUMINANCE4_EXT 0x803F
-#define GL_LUMINANCE8_EXT 0x8040
-#define GL_LUMINANCE12_EXT 0x8041
-#define GL_LUMINANCE16_EXT 0x8042
-#define GL_LUMINANCE4_ALPHA4_EXT 0x8043
-#define GL_LUMINANCE6_ALPHA2_EXT 0x8044
-#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
-#define GL_LUMINANCE12_ALPHA4_EXT 0x8046
-#define GL_LUMINANCE12_ALPHA12_EXT 0x8047
-#define GL_LUMINANCE16_ALPHA16_EXT 0x8048
-#define GL_INTENSITY_EXT 0x8049
-#define GL_INTENSITY4_EXT 0x804A
-#define GL_INTENSITY8_EXT 0x804B
-#define GL_INTENSITY12_EXT 0x804C
-#define GL_INTENSITY16_EXT 0x804D
-#define GL_RGB2_EXT 0x804E
-#define GL_RGB4_EXT 0x804F
-#define GL_RGB5_EXT 0x8050
-#define GL_RGB8_EXT 0x8051
-#define GL_RGB10_EXT 0x8052
-#define GL_RGB12_EXT 0x8053
-#define GL_RGB16_EXT 0x8054
-#define GL_RGBA2_EXT 0x8055
-#define GL_RGBA4_EXT 0x8056
-#define GL_RGB5_A1_EXT 0x8057
-#define GL_RGBA8_EXT 0x8058
-#define GL_RGB10_A2_EXT 0x8059
-#define GL_RGBA12_EXT 0x805A
-#define GL_RGBA16_EXT 0x805B
-#define GL_TEXTURE_RED_SIZE_EXT 0x805C
-#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D
-#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E
-#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F
-#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060
-#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061
-#define GL_REPLACE_EXT 0x8062
-#define GL_PROXY_TEXTURE_1D_EXT 0x8063
-#define GL_PROXY_TEXTURE_2D_EXT 0x8064
-#define GL_TEXTURE_TOO_LARGE_EXT 0x8065
-#endif
-
-#ifndef GL_EXT_texture3D
-#define GL_PACK_SKIP_IMAGES_EXT 0x806B
-#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C
-#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D
-#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E
-#define GL_TEXTURE_3D_EXT 0x806F
-#define GL_PROXY_TEXTURE_3D_EXT 0x8070
-#define GL_TEXTURE_DEPTH_EXT 0x8071
-#define GL_TEXTURE_WRAP_R_EXT 0x8072
-#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073
-#endif
-
-#ifndef GL_SGIS_texture_filter4
-#define GL_FILTER4_SGIS 0x8146
-#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147
-#endif
-
-#ifndef GL_EXT_subtexture
-#endif
-
-#ifndef GL_EXT_copy_texture
-#endif
-
-#ifndef GL_EXT_histogram
-#define GL_HISTOGRAM_EXT 0x8024
-#define GL_PROXY_HISTOGRAM_EXT 0x8025
-#define GL_HISTOGRAM_WIDTH_EXT 0x8026
-#define GL_HISTOGRAM_FORMAT_EXT 0x8027
-#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028
-#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029
-#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A
-#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B
-#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C
-#define GL_HISTOGRAM_SINK_EXT 0x802D
-#define GL_MINMAX_EXT 0x802E
-#define GL_MINMAX_FORMAT_EXT 0x802F
-#define GL_MINMAX_SINK_EXT 0x8030
-#define GL_TABLE_TOO_LARGE_EXT 0x8031
-#endif
-
-#ifndef GL_EXT_convolution
-#define GL_CONVOLUTION_1D_EXT 0x8010
-#define GL_CONVOLUTION_2D_EXT 0x8011
-#define GL_SEPARABLE_2D_EXT 0x8012
-#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013
-#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014
-#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015
-#define GL_REDUCE_EXT 0x8016
-#define GL_CONVOLUTION_FORMAT_EXT 0x8017
-#define GL_CONVOLUTION_WIDTH_EXT 0x8018
-#define GL_CONVOLUTION_HEIGHT_EXT 0x8019
-#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A
-#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B
-#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C
-#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D
-#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E
-#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F
-#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020
-#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021
-#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022
-#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023
-#endif
-
-#ifndef GL_SGI_color_matrix
-#define GL_COLOR_MATRIX_SGI 0x80B1
-#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2
-#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3
-#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4
-#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5
-#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6
-#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7
-#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8
-#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9
-#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA
-#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB
-#endif
-
-#ifndef GL_SGI_color_table
-#define GL_COLOR_TABLE_SGI 0x80D0
-#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1
-#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2
-#define GL_PROXY_COLOR_TABLE_SGI 0x80D3
-#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4
-#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5
-#define GL_COLOR_TABLE_SCALE_SGI 0x80D6
-#define GL_COLOR_TABLE_BIAS_SGI 0x80D7
-#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8
-#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9
-#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA
-#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB
-#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC
-#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD
-#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE
-#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF
-#endif
-
-#ifndef GL_SGIS_pixel_texture
-#define GL_PIXEL_TEXTURE_SGIS 0x8353
-#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354
-#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355
-#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356
-#endif
-
-#ifndef GL_SGIX_pixel_texture
-#define GL_PIXEL_TEX_GEN_SGIX 0x8139
-#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B
-#endif
-
-#ifndef GL_SGIS_texture4D
-#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130
-#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131
-#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132
-#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133
-#define GL_TEXTURE_4D_SGIS 0x8134
-#define GL_PROXY_TEXTURE_4D_SGIS 0x8135
-#define GL_TEXTURE_4DSIZE_SGIS 0x8136
-#define GL_TEXTURE_WRAP_Q_SGIS 0x8137
-#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138
-#define GL_TEXTURE_4D_BINDING_SGIS 0x814F
-#endif
-
-#ifndef GL_SGI_texture_color_table
-#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC
-#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD
-#endif
-
-#ifndef GL_EXT_cmyka
-#define GL_CMYK_EXT 0x800C
-#define GL_CMYKA_EXT 0x800D
-#define GL_PACK_CMYK_HINT_EXT 0x800E
-#define GL_UNPACK_CMYK_HINT_EXT 0x800F
-#endif
-
-#ifndef GL_EXT_texture_object
-#define GL_TEXTURE_PRIORITY_EXT 0x8066
-#define GL_TEXTURE_RESIDENT_EXT 0x8067
-#define GL_TEXTURE_1D_BINDING_EXT 0x8068
-#define GL_TEXTURE_2D_BINDING_EXT 0x8069
-#define GL_TEXTURE_3D_BINDING_EXT 0x806A
-#endif
-
-#ifndef GL_SGIS_detail_texture
-#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095
-#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096
-#define GL_LINEAR_DETAIL_SGIS 0x8097
-#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098
-#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099
-#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A
-#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B
-#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C
-#endif
-
-#ifndef GL_SGIS_sharpen_texture
-#define GL_LINEAR_SHARPEN_SGIS 0x80AD
-#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE
-#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF
-#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0
-#endif
-
-#ifndef GL_EXT_packed_pixels
-#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032
-#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033
-#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034
-#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035
-#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036
-#endif
-
-#ifndef GL_SGIS_texture_lod
-#define GL_TEXTURE_MIN_LOD_SGIS 0x813A
-#define GL_TEXTURE_MAX_LOD_SGIS 0x813B
-#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C
-#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D
-#endif
-
-#ifndef GL_SGIS_multisample
-#define GL_MULTISAMPLE_SGIS 0x809D
-#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E
-#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F
-#define GL_SAMPLE_MASK_SGIS 0x80A0
-#define GL_1PASS_SGIS 0x80A1
-#define GL_2PASS_0_SGIS 0x80A2
-#define GL_2PASS_1_SGIS 0x80A3
-#define GL_4PASS_0_SGIS 0x80A4
-#define GL_4PASS_1_SGIS 0x80A5
-#define GL_4PASS_2_SGIS 0x80A6
-#define GL_4PASS_3_SGIS 0x80A7
-#define GL_SAMPLE_BUFFERS_SGIS 0x80A8
-#define GL_SAMPLES_SGIS 0x80A9
-#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA
-#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB
-#define GL_SAMPLE_PATTERN_SGIS 0x80AC
-#endif
-
-#ifndef GL_EXT_rescale_normal
-#define GL_RESCALE_NORMAL_EXT 0x803A
-#endif
-
-#ifndef GL_EXT_vertex_array
-#define GL_VERTEX_ARRAY_EXT 0x8074
-#define GL_NORMAL_ARRAY_EXT 0x8075
-#define GL_COLOR_ARRAY_EXT 0x8076
-#define GL_INDEX_ARRAY_EXT 0x8077
-#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078
-#define GL_EDGE_FLAG_ARRAY_EXT 0x8079
-#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A
-#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B
-#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C
-#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D
-#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E
-#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F
-#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080
-#define GL_COLOR_ARRAY_SIZE_EXT 0x8081
-#define GL_COLOR_ARRAY_TYPE_EXT 0x8082
-#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083
-#define GL_COLOR_ARRAY_COUNT_EXT 0x8084
-#define GL_INDEX_ARRAY_TYPE_EXT 0x8085
-#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086
-#define GL_INDEX_ARRAY_COUNT_EXT 0x8087
-#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088
-#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089
-#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A
-#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B
-#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C
-#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D
-#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E
-#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F
-#define GL_COLOR_ARRAY_POINTER_EXT 0x8090
-#define GL_INDEX_ARRAY_POINTER_EXT 0x8091
-#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092
-#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093
-#endif
-
-#ifndef GL_EXT_misc_attribute
-#endif
-
-#ifndef GL_SGIS_generate_mipmap
-#define GL_GENERATE_MIPMAP_SGIS 0x8191
-#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
-#endif
-
-#ifndef GL_SGIX_clipmap
-#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170
-#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171
-#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172
-#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173
-#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174
-#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175
-#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176
-#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177
-#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178
-#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D
-#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E
-#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F
-#endif
-
-#ifndef GL_SGIX_shadow
-#define GL_TEXTURE_COMPARE_SGIX 0x819A
-#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B
-#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C
-#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D
-#endif
-
-#ifndef GL_SGIS_texture_edge_clamp
-#define GL_CLAMP_TO_EDGE_SGIS 0x812F
-#endif
-
-#ifndef GL_SGIS_texture_border_clamp
-#define GL_CLAMP_TO_BORDER_SGIS 0x812D
-#endif
-
-#ifndef GL_EXT_blend_minmax
-#define GL_FUNC_ADD_EXT 0x8006
-#define GL_MIN_EXT 0x8007
-#define GL_MAX_EXT 0x8008
-#define GL_BLEND_EQUATION_EXT 0x8009
-#endif
-
-#ifndef GL_EXT_blend_subtract
-#define GL_FUNC_SUBTRACT_EXT 0x800A
-#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B
-#endif
-
-#ifndef GL_EXT_blend_logic_op
-#endif
-
-#ifndef GL_SGIX_interlace
-#define GL_INTERLACE_SGIX 0x8094
-#endif
-
-#ifndef GL_SGIX_pixel_tiles
-#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E
-#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F
-#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140
-#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141
-#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142
-#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143
-#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144
-#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145
-#endif
-
-#ifndef GL_SGIS_texture_select
-#define GL_DUAL_ALPHA4_SGIS 0x8110
-#define GL_DUAL_ALPHA8_SGIS 0x8111
-#define GL_DUAL_ALPHA12_SGIS 0x8112
-#define GL_DUAL_ALPHA16_SGIS 0x8113
-#define GL_DUAL_LUMINANCE4_SGIS 0x8114
-#define GL_DUAL_LUMINANCE8_SGIS 0x8115
-#define GL_DUAL_LUMINANCE12_SGIS 0x8116
-#define GL_DUAL_LUMINANCE16_SGIS 0x8117
-#define GL_DUAL_INTENSITY4_SGIS 0x8118
-#define GL_DUAL_INTENSITY8_SGIS 0x8119
-#define GL_DUAL_INTENSITY12_SGIS 0x811A
-#define GL_DUAL_INTENSITY16_SGIS 0x811B
-#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C
-#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D
-#define GL_QUAD_ALPHA4_SGIS 0x811E
-#define GL_QUAD_ALPHA8_SGIS 0x811F
-#define GL_QUAD_LUMINANCE4_SGIS 0x8120
-#define GL_QUAD_LUMINANCE8_SGIS 0x8121
-#define GL_QUAD_INTENSITY4_SGIS 0x8122
-#define GL_QUAD_INTENSITY8_SGIS 0x8123
-#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124
-#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125
-#endif
-
-#ifndef GL_SGIX_sprite
-#define GL_SPRITE_SGIX 0x8148
-#define GL_SPRITE_MODE_SGIX 0x8149
-#define GL_SPRITE_AXIS_SGIX 0x814A
-#define GL_SPRITE_TRANSLATION_SGIX 0x814B
-#define GL_SPRITE_AXIAL_SGIX 0x814C
-#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D
-#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E
-#endif
-
-#ifndef GL_SGIX_texture_multi_buffer
-#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E
-#endif
-
-#ifndef GL_EXT_point_parameters
-#define GL_POINT_SIZE_MIN_EXT 0x8126
-#define GL_POINT_SIZE_MAX_EXT 0x8127
-#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128
-#define GL_DISTANCE_ATTENUATION_EXT 0x8129
-#endif
-
-#ifndef GL_SGIS_point_parameters
-#define GL_POINT_SIZE_MIN_SGIS 0x8126
-#define GL_POINT_SIZE_MAX_SGIS 0x8127
-#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128
-#define GL_DISTANCE_ATTENUATION_SGIS 0x8129
-#endif
-
-#ifndef GL_SGIX_instruments
-#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180
-#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181
-#endif
-
-#ifndef GL_SGIX_texture_scale_bias
-#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179
-#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A
-#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B
-#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C
-#endif
-
-#ifndef GL_SGIX_framezoom
-#define GL_FRAMEZOOM_SGIX 0x818B
-#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C
-#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D
-#endif
-
-#ifndef GL_SGIX_tag_sample_buffer
-#endif
-
-#ifndef GL_FfdMaskSGIX
-#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001
-#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002
-#endif
-
-#ifndef GL_SGIX_polynomial_ffd
-#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194
-#define GL_TEXTURE_DEFORMATION_SGIX 0x8195
-#define GL_DEFORMATIONS_MASK_SGIX 0x8196
-#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197
-#endif
-
-#ifndef GL_SGIX_reference_plane
-#define GL_REFERENCE_PLANE_SGIX 0x817D
-#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E
-#endif
-
-#ifndef GL_SGIX_flush_raster
-#endif
-
-#ifndef GL_SGIX_depth_texture
-#define GL_DEPTH_COMPONENT16_SGIX 0x81A5
-#define GL_DEPTH_COMPONENT24_SGIX 0x81A6
-#define GL_DEPTH_COMPONENT32_SGIX 0x81A7
-#endif
-
-#ifndef GL_SGIS_fog_function
-#define GL_FOG_FUNC_SGIS 0x812A
-#define GL_FOG_FUNC_POINTS_SGIS 0x812B
-#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C
-#endif
-
-#ifndef GL_SGIX_fog_offset
-#define GL_FOG_OFFSET_SGIX 0x8198
-#define GL_FOG_OFFSET_VALUE_SGIX 0x8199
-#endif
-
-#ifndef GL_HP_image_transform
-#define GL_IMAGE_SCALE_X_HP 0x8155
-#define GL_IMAGE_SCALE_Y_HP 0x8156
-#define GL_IMAGE_TRANSLATE_X_HP 0x8157
-#define GL_IMAGE_TRANSLATE_Y_HP 0x8158
-#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159
-#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A
-#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B
-#define GL_IMAGE_MAG_FILTER_HP 0x815C
-#define GL_IMAGE_MIN_FILTER_HP 0x815D
-#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E
-#define GL_CUBIC_HP 0x815F
-#define GL_AVERAGE_HP 0x8160
-#define GL_IMAGE_TRANSFORM_2D_HP 0x8161
-#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162
-#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163
-#endif
-
-#ifndef GL_HP_convolution_border_modes
-#define GL_IGNORE_BORDER_HP 0x8150
-#define GL_CONSTANT_BORDER_HP 0x8151
-#define GL_REPLICATE_BORDER_HP 0x8153
-#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154
-#endif
-
-#ifndef GL_INGR_palette_buffer
-#endif
-
-#ifndef GL_SGIX_texture_add_env
-#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE
-#endif
-
-#ifndef GL_EXT_color_subtable
-#endif
-
-#ifndef GL_PGI_vertex_hints
-#define GL_VERTEX_DATA_HINT_PGI 0x1A22A
-#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B
-#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C
-#define GL_MAX_VERTEX_HINT_PGI 0x1A22D
-#define GL_COLOR3_BIT_PGI 0x00010000
-#define GL_COLOR4_BIT_PGI 0x00020000
-#define GL_EDGEFLAG_BIT_PGI 0x00040000
-#define GL_INDEX_BIT_PGI 0x00080000
-#define GL_MAT_AMBIENT_BIT_PGI 0x00100000
-#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000
-#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000
-#define GL_MAT_EMISSION_BIT_PGI 0x00800000
-#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000
-#define GL_MAT_SHININESS_BIT_PGI 0x02000000
-#define GL_MAT_SPECULAR_BIT_PGI 0x04000000
-#define GL_NORMAL_BIT_PGI 0x08000000
-#define GL_TEXCOORD1_BIT_PGI 0x10000000
-#define GL_TEXCOORD2_BIT_PGI 0x20000000
-#define GL_TEXCOORD3_BIT_PGI 0x40000000
-#define GL_TEXCOORD4_BIT_PGI 0x80000000
-#define GL_VERTEX23_BIT_PGI 0x00000004
-#define GL_VERTEX4_BIT_PGI 0x00000008
-#endif
-
-#ifndef GL_PGI_misc_hints
-#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8
-#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD
-#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE
-#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202
-#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203
-#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204
-#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C
-#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D
-#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E
-#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F
-#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210
-#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211
-#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216
-#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217
-#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218
-#define GL_FULL_STIPPLE_HINT_PGI 0x1A219
-#define GL_CLIP_NEAR_HINT_PGI 0x1A220
-#define GL_CLIP_FAR_HINT_PGI 0x1A221
-#define GL_WIDE_LINE_HINT_PGI 0x1A222
-#define GL_BACK_NORMALS_HINT_PGI 0x1A223
-#endif
-
-#ifndef GL_EXT_paletted_texture
-#define GL_COLOR_INDEX1_EXT 0x80E2
-#define GL_COLOR_INDEX2_EXT 0x80E3
-#define GL_COLOR_INDEX4_EXT 0x80E4
-#define GL_COLOR_INDEX8_EXT 0x80E5
-#define GL_COLOR_INDEX12_EXT 0x80E6
-#define GL_COLOR_INDEX16_EXT 0x80E7
-#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
-#endif
-
-#ifndef GL_EXT_clip_volume_hint
-#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0
-#endif
-
-#ifndef GL_SGIX_list_priority
-#define GL_LIST_PRIORITY_SGIX 0x8182
-#endif
-
-#ifndef GL_SGIX_ir_instrument1
-#define GL_IR_INSTRUMENT1_SGIX 0x817F
-#endif
-
-#ifndef GL_SGIX_calligraphic_fragment
-#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183
-#endif
-
-#ifndef GL_SGIX_texture_lod_bias
-#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E
-#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F
-#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190
-#endif
-
-#ifndef GL_SGIX_shadow_ambient
-#define GL_SHADOW_AMBIENT_SGIX 0x80BF
-#endif
-
-#ifndef GL_EXT_index_texture
-#endif
-
-#ifndef GL_EXT_index_material
-#define GL_INDEX_MATERIAL_EXT 0x81B8
-#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9
-#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA
-#endif
-
-#ifndef GL_EXT_index_func
-#define GL_INDEX_TEST_EXT 0x81B5
-#define GL_INDEX_TEST_FUNC_EXT 0x81B6
-#define GL_INDEX_TEST_REF_EXT 0x81B7
-#endif
-
-#ifndef GL_EXT_index_array_formats
-#define GL_IUI_V2F_EXT 0x81AD
-#define GL_IUI_V3F_EXT 0x81AE
-#define GL_IUI_N3F_V2F_EXT 0x81AF
-#define GL_IUI_N3F_V3F_EXT 0x81B0
-#define GL_T2F_IUI_V2F_EXT 0x81B1
-#define GL_T2F_IUI_V3F_EXT 0x81B2
-#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3
-#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4
-#endif
-
-#ifndef GL_EXT_compiled_vertex_array
-#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8
-#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9
-#endif
-
-#ifndef GL_EXT_cull_vertex
-#define GL_CULL_VERTEX_EXT 0x81AA
-#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB
-#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC
-#endif
-
-#ifndef GL_SGIX_ycrcb
-#define GL_YCRCB_422_SGIX 0x81BB
-#define GL_YCRCB_444_SGIX 0x81BC
-#endif
-
-#ifndef GL_SGIX_fragment_lighting
-#define GL_FRAGMENT_LIGHTING_SGIX 0x8400
-#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401
-#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402
-#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403
-#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404
-#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405
-#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406
-#define GL_LIGHT_ENV_MODE_SGIX 0x8407
-#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408
-#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409
-#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A
-#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B
-#define GL_FRAGMENT_LIGHT0_SGIX 0x840C
-#define GL_FRAGMENT_LIGHT1_SGIX 0x840D
-#define GL_FRAGMENT_LIGHT2_SGIX 0x840E
-#define GL_FRAGMENT_LIGHT3_SGIX 0x840F
-#define GL_FRAGMENT_LIGHT4_SGIX 0x8410
-#define GL_FRAGMENT_LIGHT5_SGIX 0x8411
-#define GL_FRAGMENT_LIGHT6_SGIX 0x8412
-#define GL_FRAGMENT_LIGHT7_SGIX 0x8413
-#endif
-
-#ifndef GL_IBM_rasterpos_clip
-#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262
-#endif
-
-#ifndef GL_HP_texture_lighting
-#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167
-#define GL_TEXTURE_POST_SPECULAR_HP 0x8168
-#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169
-#endif
-
-#ifndef GL_EXT_draw_range_elements
-#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8
-#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9
-#endif
-
-#ifndef GL_WIN_phong_shading
-#define GL_PHONG_WIN 0x80EA
-#define GL_PHONG_HINT_WIN 0x80EB
-#endif
-
-#ifndef GL_WIN_specular_fog
-#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC
-#endif
-
-#ifndef GL_EXT_light_texture
-#define GL_FRAGMENT_MATERIAL_EXT 0x8349
-#define GL_FRAGMENT_NORMAL_EXT 0x834A
-#define GL_FRAGMENT_COLOR_EXT 0x834C
-#define GL_ATTENUATION_EXT 0x834D
-#define GL_SHADOW_ATTENUATION_EXT 0x834E
-#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F
-#define GL_TEXTURE_LIGHT_EXT 0x8350
-#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351
-#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352
-/* reuse GL_FRAGMENT_DEPTH_EXT */
-#endif
-
-#ifndef GL_SGIX_blend_alpha_minmax
-#define GL_ALPHA_MIN_SGIX 0x8320
-#define GL_ALPHA_MAX_SGIX 0x8321
-#endif
-
-#ifndef GL_SGIX_impact_pixel_texture
-#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184
-#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185
-#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186
-#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187
-#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188
-#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189
-#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A
-#endif
-
-#ifndef GL_EXT_bgra
-#define GL_BGR_EXT 0x80E0
-#define GL_BGRA_EXT 0x80E1
-#endif
-
-#ifndef GL_SGIX_async
-#define GL_ASYNC_MARKER_SGIX 0x8329
-#endif
-
-#ifndef GL_SGIX_async_pixel
-#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C
-#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D
-#define GL_ASYNC_READ_PIXELS_SGIX 0x835E
-#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F
-#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360
-#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361
-#endif
-
-#ifndef GL_SGIX_async_histogram
-#define GL_ASYNC_HISTOGRAM_SGIX 0x832C
-#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D
-#endif
-
-#ifndef GL_INTEL_texture_scissor
-#endif
-
-#ifndef GL_INTEL_parallel_arrays
-#define GL_PARALLEL_ARRAYS_INTEL 0x83F4
-#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5
-#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6
-#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7
-#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8
-#endif
-
-#ifndef GL_HP_occlusion_test
-#define GL_OCCLUSION_TEST_HP 0x8165
-#define GL_OCCLUSION_TEST_RESULT_HP 0x8166
-#endif
-
-#ifndef GL_EXT_pixel_transform
-#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330
-#define GL_PIXEL_MAG_FILTER_EXT 0x8331
-#define GL_PIXEL_MIN_FILTER_EXT 0x8332
-#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333
-#define GL_CUBIC_EXT 0x8334
-#define GL_AVERAGE_EXT 0x8335
-#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336
-#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337
-#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338
-#endif
-
-#ifndef GL_EXT_pixel_transform_color_table
-#endif
-
-#ifndef GL_EXT_shared_texture_palette
-#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
-#endif
-
-#ifndef GL_EXT_separate_specular_color
-#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8
-#define GL_SINGLE_COLOR_EXT 0x81F9
-#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA
-#endif
-
-#ifndef GL_EXT_secondary_color
-#define GL_COLOR_SUM_EXT 0x8458
-#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459
-#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A
-#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B
-#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C
-#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D
-#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E
-#endif
-
-#ifndef GL_EXT_texture_perturb_normal
-#define GL_PERTURB_EXT 0x85AE
-#define GL_TEXTURE_NORMAL_EXT 0x85AF
-#endif
-
-#ifndef GL_EXT_multi_draw_arrays
-#endif
-
-#ifndef GL_EXT_fog_coord
-#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450
-#define GL_FOG_COORDINATE_EXT 0x8451
-#define GL_FRAGMENT_DEPTH_EXT 0x8452
-#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453
-#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454
-#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455
-#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456
-#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457
-#endif
-
-#ifndef GL_REND_screen_coordinates
-#define GL_SCREEN_COORDINATES_REND 0x8490
-#define GL_INVERTED_SCREEN_W_REND 0x8491
-#endif
-
-#ifndef GL_EXT_coordinate_frame
-#define GL_TANGENT_ARRAY_EXT 0x8439
-#define GL_BINORMAL_ARRAY_EXT 0x843A
-#define GL_CURRENT_TANGENT_EXT 0x843B
-#define GL_CURRENT_BINORMAL_EXT 0x843C
-#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E
-#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F
-#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440
-#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441
-#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442
-#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443
-#define GL_MAP1_TANGENT_EXT 0x8444
-#define GL_MAP2_TANGENT_EXT 0x8445
-#define GL_MAP1_BINORMAL_EXT 0x8446
-#define GL_MAP2_BINORMAL_EXT 0x8447
-#endif
-
-#ifndef GL_EXT_texture_env_combine
-#define GL_COMBINE_EXT 0x8570
-#define GL_COMBINE_RGB_EXT 0x8571
-#define GL_COMBINE_ALPHA_EXT 0x8572
-#define GL_RGB_SCALE_EXT 0x8573
-#define GL_ADD_SIGNED_EXT 0x8574
-#define GL_INTERPOLATE_EXT 0x8575
-#define GL_CONSTANT_EXT 0x8576
-#define GL_PRIMARY_COLOR_EXT 0x8577
-#define GL_PREVIOUS_EXT 0x8578
-#define GL_SOURCE0_RGB_EXT 0x8580
-#define GL_SOURCE1_RGB_EXT 0x8581
-#define GL_SOURCE2_RGB_EXT 0x8582
-#define GL_SOURCE0_ALPHA_EXT 0x8588
-#define GL_SOURCE1_ALPHA_EXT 0x8589
-#define GL_SOURCE2_ALPHA_EXT 0x858A
-#define GL_OPERAND0_RGB_EXT 0x8590
-#define GL_OPERAND1_RGB_EXT 0x8591
-#define GL_OPERAND2_RGB_EXT 0x8592
-#define GL_OPERAND0_ALPHA_EXT 0x8598
-#define GL_OPERAND1_ALPHA_EXT 0x8599
-#define GL_OPERAND2_ALPHA_EXT 0x859A
-#endif
-
-#ifndef GL_APPLE_specular_vector
-#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0
-#endif
-
-#ifndef GL_APPLE_transform_hint
-#define GL_TRANSFORM_HINT_APPLE 0x85B1
-#endif
-
-#ifndef GL_SGIX_fog_scale
-#define GL_FOG_SCALE_SGIX 0x81FC
-#define GL_FOG_SCALE_VALUE_SGIX 0x81FD
-#endif
-
-#ifndef GL_SUNX_constant_data
-#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5
-#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6
-#endif
-
-#ifndef GL_SUN_global_alpha
-#define GL_GLOBAL_ALPHA_SUN 0x81D9
-#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA
-#endif
-
-#ifndef GL_SUN_triangle_list
-#define GL_RESTART_SUN 0x0001
-#define GL_REPLACE_MIDDLE_SUN 0x0002
-#define GL_REPLACE_OLDEST_SUN 0x0003
-#define GL_TRIANGLE_LIST_SUN 0x81D7
-#define GL_REPLACEMENT_CODE_SUN 0x81D8
-#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0
-#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1
-#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2
-#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3
-#define GL_R1UI_V3F_SUN 0x85C4
-#define GL_R1UI_C4UB_V3F_SUN 0x85C5
-#define GL_R1UI_C3F_V3F_SUN 0x85C6
-#define GL_R1UI_N3F_V3F_SUN 0x85C7
-#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8
-#define GL_R1UI_T2F_V3F_SUN 0x85C9
-#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA
-#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB
-#endif
-
-#ifndef GL_SUN_vertex
-#endif
-
-#ifndef GL_EXT_blend_func_separate
-#define GL_BLEND_DST_RGB_EXT 0x80C8
-#define GL_BLEND_SRC_RGB_EXT 0x80C9
-#define GL_BLEND_DST_ALPHA_EXT 0x80CA
-#define GL_BLEND_SRC_ALPHA_EXT 0x80CB
-#endif
-
-#ifndef GL_INGR_color_clamp
-#define GL_RED_MIN_CLAMP_INGR 0x8560
-#define GL_GREEN_MIN_CLAMP_INGR 0x8561
-#define GL_BLUE_MIN_CLAMP_INGR 0x8562
-#define GL_ALPHA_MIN_CLAMP_INGR 0x8563
-#define GL_RED_MAX_CLAMP_INGR 0x8564
-#define GL_GREEN_MAX_CLAMP_INGR 0x8565
-#define GL_BLUE_MAX_CLAMP_INGR 0x8566
-#define GL_ALPHA_MAX_CLAMP_INGR 0x8567
-#endif
-
-#ifndef GL_INGR_interlace_read
-#define GL_INTERLACE_READ_INGR 0x8568
-#endif
-
-#ifndef GL_EXT_stencil_wrap
-#define GL_INCR_WRAP_EXT 0x8507
-#define GL_DECR_WRAP_EXT 0x8508
-#endif
-
-#ifndef GL_EXT_422_pixels
-#define GL_422_EXT 0x80CC
-#define GL_422_REV_EXT 0x80CD
-#define GL_422_AVERAGE_EXT 0x80CE
-#define GL_422_REV_AVERAGE_EXT 0x80CF
-#endif
-
-#ifndef GL_NV_texgen_reflection
-#define GL_NORMAL_MAP_NV 0x8511
-#define GL_REFLECTION_MAP_NV 0x8512
-#endif
-
-#ifndef GL_EXT_texture_cube_map
-#define GL_NORMAL_MAP_EXT 0x8511
-#define GL_REFLECTION_MAP_EXT 0x8512
-#define GL_TEXTURE_CUBE_MAP_EXT 0x8513
-#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518
-#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519
-#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A
-#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B
-#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C
-#endif
-
-#ifndef GL_SUN_convolution_border_modes
-#define GL_WRAP_BORDER_SUN 0x81D4
-#endif
-
-#ifndef GL_EXT_texture_env_add
-#endif
-
-#ifndef GL_EXT_texture_lod_bias
-#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD
-#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500
-#define GL_TEXTURE_LOD_BIAS_EXT 0x8501
-#endif
-
-#ifndef GL_EXT_texture_filter_anisotropic
-#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
-#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
-#endif
-
-#ifndef GL_EXT_vertex_weighting
-#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH
-#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502
-#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX
-#define GL_MODELVIEW1_MATRIX_EXT 0x8506
-#define GL_VERTEX_WEIGHTING_EXT 0x8509
-#define GL_MODELVIEW0_EXT GL_MODELVIEW
-#define GL_MODELVIEW1_EXT 0x850A
-#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B
-#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C
-#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D
-#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E
-#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F
-#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510
-#endif
-
-#ifndef GL_NV_light_max_exponent
-#define GL_MAX_SHININESS_NV 0x8504
-#define GL_MAX_SPOT_EXPONENT_NV 0x8505
-#endif
-
-#ifndef GL_NV_vertex_array_range
-#define GL_VERTEX_ARRAY_RANGE_NV 0x851D
-#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E
-#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F
-#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520
-#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521
-#endif
-
-#ifndef GL_NV_register_combiners
-#define GL_REGISTER_COMBINERS_NV 0x8522
-#define GL_VARIABLE_A_NV 0x8523
-#define GL_VARIABLE_B_NV 0x8524
-#define GL_VARIABLE_C_NV 0x8525
-#define GL_VARIABLE_D_NV 0x8526
-#define GL_VARIABLE_E_NV 0x8527
-#define GL_VARIABLE_F_NV 0x8528
-#define GL_VARIABLE_G_NV 0x8529
-#define GL_CONSTANT_COLOR0_NV 0x852A
-#define GL_CONSTANT_COLOR1_NV 0x852B
-#define GL_PRIMARY_COLOR_NV 0x852C
-#define GL_SECONDARY_COLOR_NV 0x852D
-#define GL_SPARE0_NV 0x852E
-#define GL_SPARE1_NV 0x852F
-#define GL_DISCARD_NV 0x8530
-#define GL_E_TIMES_F_NV 0x8531
-#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532
-#define GL_UNSIGNED_IDENTITY_NV 0x8536
-#define GL_UNSIGNED_INVERT_NV 0x8537
-#define GL_EXPAND_NORMAL_NV 0x8538
-#define GL_EXPAND_NEGATE_NV 0x8539
-#define GL_HALF_BIAS_NORMAL_NV 0x853A
-#define GL_HALF_BIAS_NEGATE_NV 0x853B
-#define GL_SIGNED_IDENTITY_NV 0x853C
-#define GL_SIGNED_NEGATE_NV 0x853D
-#define GL_SCALE_BY_TWO_NV 0x853E
-#define GL_SCALE_BY_FOUR_NV 0x853F
-#define GL_SCALE_BY_ONE_HALF_NV 0x8540
-#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541
-#define GL_COMBINER_INPUT_NV 0x8542
-#define GL_COMBINER_MAPPING_NV 0x8543
-#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544
-#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545
-#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546
-#define GL_COMBINER_MUX_SUM_NV 0x8547
-#define GL_COMBINER_SCALE_NV 0x8548
-#define GL_COMBINER_BIAS_NV 0x8549
-#define GL_COMBINER_AB_OUTPUT_NV 0x854A
-#define GL_COMBINER_CD_OUTPUT_NV 0x854B
-#define GL_COMBINER_SUM_OUTPUT_NV 0x854C
-#define GL_MAX_GENERAL_COMBINERS_NV 0x854D
-#define GL_NUM_GENERAL_COMBINERS_NV 0x854E
-#define GL_COLOR_SUM_CLAMP_NV 0x854F
-#define GL_COMBINER0_NV 0x8550
-#define GL_COMBINER1_NV 0x8551
-#define GL_COMBINER2_NV 0x8552
-#define GL_COMBINER3_NV 0x8553
-#define GL_COMBINER4_NV 0x8554
-#define GL_COMBINER5_NV 0x8555
-#define GL_COMBINER6_NV 0x8556
-#define GL_COMBINER7_NV 0x8557
-/* reuse GL_TEXTURE0_ARB */
-/* reuse GL_TEXTURE1_ARB */
-/* reuse GL_ZERO */
-/* reuse GL_NONE */
-/* reuse GL_FOG */
-#endif
-
-#ifndef GL_NV_fog_distance
-#define GL_FOG_DISTANCE_MODE_NV 0x855A
-#define GL_EYE_RADIAL_NV 0x855B
-#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C
-/* reuse GL_EYE_PLANE */
-#endif
-
-#ifndef GL_NV_texgen_emboss
-#define GL_EMBOSS_LIGHT_NV 0x855D
-#define GL_EMBOSS_CONSTANT_NV 0x855E
-#define GL_EMBOSS_MAP_NV 0x855F
-#endif
-
-#ifndef GL_NV_blend_square
-#endif
-
-#ifndef GL_NV_texture_env_combine4
-#define GL_COMBINE4_NV 0x8503
-#define GL_SOURCE3_RGB_NV 0x8583
-#define GL_SOURCE3_ALPHA_NV 0x858B
-#define GL_OPERAND3_RGB_NV 0x8593
-#define GL_OPERAND3_ALPHA_NV 0x859B
-#endif
-
-#ifndef GL_MESA_resize_buffers
-#endif
-
-#ifndef GL_MESA_window_pos
-#endif
-
-#ifndef GL_EXT_texture_compression_s3tc
-#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
-#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
-#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
-#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
-#endif
-
-#ifndef GL_IBM_cull_vertex
-#define GL_CULL_VERTEX_IBM 103050
-#endif
-
-#ifndef GL_IBM_multimode_draw_arrays
-#endif
-
-#ifndef GL_IBM_vertex_array_lists
-#define GL_VERTEX_ARRAY_LIST_IBM 103070
-#define GL_NORMAL_ARRAY_LIST_IBM 103071
-#define GL_COLOR_ARRAY_LIST_IBM 103072
-#define GL_INDEX_ARRAY_LIST_IBM 103073
-#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074
-#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075
-#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076
-#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077
-#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080
-#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081
-#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082
-#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083
-#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084
-#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085
-#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086
-#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087
-#endif
-
-#ifndef GL_SGIX_subsample
-#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0
-#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1
-#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2
-#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3
-#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4
-#endif
-
-#ifndef GL_SGIX_ycrcb_subsample
-#endif
-
-#ifndef GL_SGIX_ycrcba
-#define GL_YCRCB_SGIX 0x8318
-#define GL_YCRCBA_SGIX 0x8319
-#endif
-
-#ifndef GL_SGI_depth_pass_instrument
-#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310
-#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311
-#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312
-#endif
-
-#ifndef GL_3DFX_texture_compression_FXT1
-#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0
-#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1
-#endif
-
-#ifndef GL_3DFX_multisample
-#define GL_MULTISAMPLE_3DFX 0x86B2
-#define GL_SAMPLE_BUFFERS_3DFX 0x86B3
-#define GL_SAMPLES_3DFX 0x86B4
-#define GL_MULTISAMPLE_BIT_3DFX 0x20000000
-#endif
-
-#ifndef GL_3DFX_tbuffer
-#endif
-
-#ifndef GL_EXT_multisample
-#define GL_MULTISAMPLE_EXT 0x809D
-#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E
-#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F
-#define GL_SAMPLE_MASK_EXT 0x80A0
-#define GL_1PASS_EXT 0x80A1
-#define GL_2PASS_0_EXT 0x80A2
-#define GL_2PASS_1_EXT 0x80A3
-#define GL_4PASS_0_EXT 0x80A4
-#define GL_4PASS_1_EXT 0x80A5
-#define GL_4PASS_2_EXT 0x80A6
-#define GL_4PASS_3_EXT 0x80A7
-#define GL_SAMPLE_BUFFERS_EXT 0x80A8
-#define GL_SAMPLES_EXT 0x80A9
-#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA
-#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB
-#define GL_SAMPLE_PATTERN_EXT 0x80AC
-#define GL_MULTISAMPLE_BIT_EXT 0x20000000
-#endif
-
-#ifndef GL_SGIX_vertex_preclip
-#define GL_VERTEX_PRECLIP_SGIX 0x83EE
-#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF
-#endif
-
-#ifndef GL_SGIX_convolution_accuracy
-#define GL_CONVOLUTION_HINT_SGIX 0x8316
-#endif
-
-#ifndef GL_SGIX_resample
-#define GL_PACK_RESAMPLE_SGIX 0x842C
-#define GL_UNPACK_RESAMPLE_SGIX 0x842D
-#define GL_RESAMPLE_REPLICATE_SGIX 0x842E
-#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F
-#define GL_RESAMPLE_DECIMATE_SGIX 0x8430
-#endif
-
-#ifndef GL_SGIS_point_line_texgen
-#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0
-#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1
-#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2
-#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3
-#define GL_EYE_POINT_SGIS 0x81F4
-#define GL_OBJECT_POINT_SGIS 0x81F5
-#define GL_EYE_LINE_SGIS 0x81F6
-#define GL_OBJECT_LINE_SGIS 0x81F7
-#endif
-
-#ifndef GL_SGIS_texture_color_mask
-#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF
-#endif
-
-#ifndef GL_EXT_texture_env_dot3
-#define GL_DOT3_RGB_EXT 0x8740
-#define GL_DOT3_RGBA_EXT 0x8741
-#endif
-
-#ifndef GL_ATI_texture_mirror_once
-#define GL_MIRROR_CLAMP_ATI 0x8742
-#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743
-#endif
-
-#ifndef GL_NV_fence
-#define GL_ALL_COMPLETED_NV 0x84F2
-#define GL_FENCE_STATUS_NV 0x84F3
-#define GL_FENCE_CONDITION_NV 0x84F4
-#endif
-
-#ifndef GL_IBM_texture_mirrored_repeat
-#define GL_MIRRORED_REPEAT_IBM 0x8370
-#endif
-
-#ifndef GL_NV_evaluators
-#define GL_EVAL_2D_NV 0x86C0
-#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1
-#define GL_MAP_TESSELLATION_NV 0x86C2
-#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3
-#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4
-#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5
-#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6
-#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7
-#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8
-#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9
-#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA
-#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB
-#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC
-#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD
-#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE
-#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF
-#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0
-#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1
-#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2
-#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3
-#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4
-#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5
-#define GL_MAX_MAP_TESSELLATION_NV 0x86D6
-#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7
-#endif
-
-#ifndef GL_NV_packed_depth_stencil
-#define GL_DEPTH_STENCIL_NV 0x84F9
-#define GL_UNSIGNED_INT_24_8_NV 0x84FA
-#endif
-
-#ifndef GL_NV_register_combiners2
-#define GL_PER_STAGE_CONSTANTS_NV 0x8535
-#endif
-
-#ifndef GL_NV_texture_compression_vtc
-#endif
-
-#ifndef GL_NV_texture_rectangle
-#define GL_TEXTURE_RECTANGLE_NV 0x84F5
-#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6
-#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7
-#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8
-#endif
-
-#ifndef GL_NV_texture_shader
-#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C
-#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D
-#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E
-#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9
-#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA
-#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB
-#define GL_DSDT_MAG_INTENSITY_NV 0x86DC
-#define GL_SHADER_CONSISTENT_NV 0x86DD
-#define GL_TEXTURE_SHADER_NV 0x86DE
-#define GL_SHADER_OPERATION_NV 0x86DF
-#define GL_CULL_MODES_NV 0x86E0
-#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1
-#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2
-#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3
-#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV
-#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV
-#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV
-#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4
-#define GL_CONST_EYE_NV 0x86E5
-#define GL_PASS_THROUGH_NV 0x86E6
-#define GL_CULL_FRAGMENT_NV 0x86E7
-#define GL_OFFSET_TEXTURE_2D_NV 0x86E8
-#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9
-#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA
-#define GL_DOT_PRODUCT_NV 0x86EC
-#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED
-#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE
-#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0
-#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1
-#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2
-#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3
-#define GL_HILO_NV 0x86F4
-#define GL_DSDT_NV 0x86F5
-#define GL_DSDT_MAG_NV 0x86F6
-#define GL_DSDT_MAG_VIB_NV 0x86F7
-#define GL_HILO16_NV 0x86F8
-#define GL_SIGNED_HILO_NV 0x86F9
-#define GL_SIGNED_HILO16_NV 0x86FA
-#define GL_SIGNED_RGBA_NV 0x86FB
-#define GL_SIGNED_RGBA8_NV 0x86FC
-#define GL_SIGNED_RGB_NV 0x86FE
-#define GL_SIGNED_RGB8_NV 0x86FF
-#define GL_SIGNED_LUMINANCE_NV 0x8701
-#define GL_SIGNED_LUMINANCE8_NV 0x8702
-#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703
-#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704
-#define GL_SIGNED_ALPHA_NV 0x8705
-#define GL_SIGNED_ALPHA8_NV 0x8706
-#define GL_SIGNED_INTENSITY_NV 0x8707
-#define GL_SIGNED_INTENSITY8_NV 0x8708
-#define GL_DSDT8_NV 0x8709
-#define GL_DSDT8_MAG8_NV 0x870A
-#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B
-#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C
-#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D
-#define GL_HI_SCALE_NV 0x870E
-#define GL_LO_SCALE_NV 0x870F
-#define GL_DS_SCALE_NV 0x8710
-#define GL_DT_SCALE_NV 0x8711
-#define GL_MAGNITUDE_SCALE_NV 0x8712
-#define GL_VIBRANCE_SCALE_NV 0x8713
-#define GL_HI_BIAS_NV 0x8714
-#define GL_LO_BIAS_NV 0x8715
-#define GL_DS_BIAS_NV 0x8716
-#define GL_DT_BIAS_NV 0x8717
-#define GL_MAGNITUDE_BIAS_NV 0x8718
-#define GL_VIBRANCE_BIAS_NV 0x8719
-#define GL_TEXTURE_BORDER_VALUES_NV 0x871A
-#define GL_TEXTURE_HI_SIZE_NV 0x871B
-#define GL_TEXTURE_LO_SIZE_NV 0x871C
-#define GL_TEXTURE_DS_SIZE_NV 0x871D
-#define GL_TEXTURE_DT_SIZE_NV 0x871E
-#define GL_TEXTURE_MAG_SIZE_NV 0x871F
-#endif
-
-#ifndef GL_NV_texture_shader2
-#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF
-#endif
-
-#ifndef GL_NV_vertex_array_range2
-#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533
-#endif
-
-#ifndef GL_NV_vertex_program
-#define GL_VERTEX_PROGRAM_NV 0x8620
-#define GL_VERTEX_STATE_PROGRAM_NV 0x8621
-#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623
-#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624
-#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625
-#define GL_CURRENT_ATTRIB_NV 0x8626
-#define GL_PROGRAM_LENGTH_NV 0x8627
-#define GL_PROGRAM_STRING_NV 0x8628
-#define GL_MODELVIEW_PROJECTION_NV 0x8629
-#define GL_IDENTITY_NV 0x862A
-#define GL_INVERSE_NV 0x862B
-#define GL_TRANSPOSE_NV 0x862C
-#define GL_INVERSE_TRANSPOSE_NV 0x862D
-#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E
-#define GL_MAX_TRACK_MATRICES_NV 0x862F
-#define GL_MATRIX0_NV 0x8630
-#define GL_MATRIX1_NV 0x8631
-#define GL_MATRIX2_NV 0x8632
-#define GL_MATRIX3_NV 0x8633
-#define GL_MATRIX4_NV 0x8634
-#define GL_MATRIX5_NV 0x8635
-#define GL_MATRIX6_NV 0x8636
-#define GL_MATRIX7_NV 0x8637
-#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640
-#define GL_CURRENT_MATRIX_NV 0x8641
-#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642
-#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643
-#define GL_PROGRAM_PARAMETER_NV 0x8644
-#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645
-#define GL_PROGRAM_TARGET_NV 0x8646
-#define GL_PROGRAM_RESIDENT_NV 0x8647
-#define GL_TRACK_MATRIX_NV 0x8648
-#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649
-#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A
-#define GL_PROGRAM_ERROR_POSITION_NV 0x864B
-#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650
-#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651
-#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652
-#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653
-#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654
-#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655
-#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656
-#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657
-#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658
-#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659
-#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A
-#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B
-#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C
-#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D
-#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E
-#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F
-#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660
-#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661
-#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662
-#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663
-#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664
-#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665
-#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666
-#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667
-#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668
-#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669
-#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A
-#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B
-#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C
-#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D
-#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E
-#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F
-#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670
-#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671
-#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672
-#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673
-#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674
-#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675
-#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676
-#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677
-#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678
-#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679
-#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A
-#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B
-#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C
-#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D
-#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E
-#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F
-#endif
-
-#ifndef GL_SGIX_texture_coordinate_clamp
-#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369
-#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A
-#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B
-#endif
-
-#ifndef GL_SGIX_scalebias_hint
-#define GL_SCALEBIAS_HINT_SGIX 0x8322
-#endif
-
-#ifndef GL_OML_interlace
-#define GL_INTERLACE_OML 0x8980
-#define GL_INTERLACE_READ_OML 0x8981
-#endif
-
-#ifndef GL_OML_subsample
-#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982
-#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983
-#endif
-
-#ifndef GL_OML_resample
-#define GL_PACK_RESAMPLE_OML 0x8984
-#define GL_UNPACK_RESAMPLE_OML 0x8985
-#define GL_RESAMPLE_REPLICATE_OML 0x8986
-#define GL_RESAMPLE_ZERO_FILL_OML 0x8987
-#define GL_RESAMPLE_AVERAGE_OML 0x8988
-#define GL_RESAMPLE_DECIMATE_OML 0x8989
-#endif
-
-#ifndef GL_NV_copy_depth_to_color
-#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E
-#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F
-#endif
-
-#ifndef GL_ATI_envmap_bumpmap
-#define GL_BUMP_ROT_MATRIX_ATI 0x8775
-#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776
-#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777
-#define GL_BUMP_TEX_UNITS_ATI 0x8778
-#define GL_DUDV_ATI 0x8779
-#define GL_DU8DV8_ATI 0x877A
-#define GL_BUMP_ENVMAP_ATI 0x877B
-#define GL_BUMP_TARGET_ATI 0x877C
-#endif
-
-#ifndef GL_ATI_fragment_shader
-#define GL_FRAGMENT_SHADER_ATI 0x8920
-#define GL_REG_0_ATI 0x8921
-#define GL_REG_1_ATI 0x8922
-#define GL_REG_2_ATI 0x8923
-#define GL_REG_3_ATI 0x8924
-#define GL_REG_4_ATI 0x8925
-#define GL_REG_5_ATI 0x8926
-#define GL_REG_6_ATI 0x8927
-#define GL_REG_7_ATI 0x8928
-#define GL_REG_8_ATI 0x8929
-#define GL_REG_9_ATI 0x892A
-#define GL_REG_10_ATI 0x892B
-#define GL_REG_11_ATI 0x892C
-#define GL_REG_12_ATI 0x892D
-#define GL_REG_13_ATI 0x892E
-#define GL_REG_14_ATI 0x892F
-#define GL_REG_15_ATI 0x8930
-#define GL_REG_16_ATI 0x8931
-#define GL_REG_17_ATI 0x8932
-#define GL_REG_18_ATI 0x8933
-#define GL_REG_19_ATI 0x8934
-#define GL_REG_20_ATI 0x8935
-#define GL_REG_21_ATI 0x8936
-#define GL_REG_22_ATI 0x8937
-#define GL_REG_23_ATI 0x8938
-#define GL_REG_24_ATI 0x8939
-#define GL_REG_25_ATI 0x893A
-#define GL_REG_26_ATI 0x893B
-#define GL_REG_27_ATI 0x893C
-#define GL_REG_28_ATI 0x893D
-#define GL_REG_29_ATI 0x893E
-#define GL_REG_30_ATI 0x893F
-#define GL_REG_31_ATI 0x8940
-#define GL_CON_0_ATI 0x8941
-#define GL_CON_1_ATI 0x8942
-#define GL_CON_2_ATI 0x8943
-#define GL_CON_3_ATI 0x8944
-#define GL_CON_4_ATI 0x8945
-#define GL_CON_5_ATI 0x8946
-#define GL_CON_6_ATI 0x8947
-#define GL_CON_7_ATI 0x8948
-#define GL_CON_8_ATI 0x8949
-#define GL_CON_9_ATI 0x894A
-#define GL_CON_10_ATI 0x894B
-#define GL_CON_11_ATI 0x894C
-#define GL_CON_12_ATI 0x894D
-#define GL_CON_13_ATI 0x894E
-#define GL_CON_14_ATI 0x894F
-#define GL_CON_15_ATI 0x8950
-#define GL_CON_16_ATI 0x8951
-#define GL_CON_17_ATI 0x8952
-#define GL_CON_18_ATI 0x8953
-#define GL_CON_19_ATI 0x8954
-#define GL_CON_20_ATI 0x8955
-#define GL_CON_21_ATI 0x8956
-#define GL_CON_22_ATI 0x8957
-#define GL_CON_23_ATI 0x8958
-#define GL_CON_24_ATI 0x8959
-#define GL_CON_25_ATI 0x895A
-#define GL_CON_26_ATI 0x895B
-#define GL_CON_27_ATI 0x895C
-#define GL_CON_28_ATI 0x895D
-#define GL_CON_29_ATI 0x895E
-#define GL_CON_30_ATI 0x895F
-#define GL_CON_31_ATI 0x8960
-#define GL_MOV_ATI 0x8961
-#define GL_ADD_ATI 0x8963
-#define GL_MUL_ATI 0x8964
-#define GL_SUB_ATI 0x8965
-#define GL_DOT3_ATI 0x8966
-#define GL_DOT4_ATI 0x8967
-#define GL_MAD_ATI 0x8968
-#define GL_LERP_ATI 0x8969
-#define GL_CND_ATI 0x896A
-#define GL_CND0_ATI 0x896B
-#define GL_DOT2_ADD_ATI 0x896C
-#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D
-#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E
-#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F
-#define GL_NUM_PASSES_ATI 0x8970
-#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971
-#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972
-#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973
-#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974
-#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975
-#define GL_SWIZZLE_STR_ATI 0x8976
-#define GL_SWIZZLE_STQ_ATI 0x8977
-#define GL_SWIZZLE_STR_DR_ATI 0x8978
-#define GL_SWIZZLE_STQ_DQ_ATI 0x8979
-#define GL_SWIZZLE_STRQ_ATI 0x897A
-#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B
-#define GL_RED_BIT_ATI 0x00000001
-#define GL_GREEN_BIT_ATI 0x00000002
-#define GL_BLUE_BIT_ATI 0x00000004
-#define GL_2X_BIT_ATI 0x00000001
-#define GL_4X_BIT_ATI 0x00000002
-#define GL_8X_BIT_ATI 0x00000004
-#define GL_HALF_BIT_ATI 0x00000008
-#define GL_QUARTER_BIT_ATI 0x00000010
-#define GL_EIGHTH_BIT_ATI 0x00000020
-#define GL_SATURATE_BIT_ATI 0x00000040
-#define GL_COMP_BIT_ATI 0x00000002
-#define GL_NEGATE_BIT_ATI 0x00000004
-#define GL_BIAS_BIT_ATI 0x00000008
-#endif
-
-#ifndef GL_ATI_pn_triangles
-#define GL_PN_TRIANGLES_ATI 0x87F0
-#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1
-#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2
-#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3
-#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4
-#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5
-#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6
-#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7
-#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8
-#endif
-
-#ifndef GL_ATI_vertex_array_object
-#define GL_STATIC_ATI 0x8760
-#define GL_DYNAMIC_ATI 0x8761
-#define GL_PRESERVE_ATI 0x8762
-#define GL_DISCARD_ATI 0x8763
-#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764
-#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765
-#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766
-#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767
-#endif
-
-#ifndef GL_EXT_vertex_shader
-#define GL_VERTEX_SHADER_EXT 0x8780
-#define GL_VERTEX_SHADER_BINDING_EXT 0x8781
-#define GL_OP_INDEX_EXT 0x8782
-#define GL_OP_NEGATE_EXT 0x8783
-#define GL_OP_DOT3_EXT 0x8784
-#define GL_OP_DOT4_EXT 0x8785
-#define GL_OP_MUL_EXT 0x8786
-#define GL_OP_ADD_EXT 0x8787
-#define GL_OP_MADD_EXT 0x8788
-#define GL_OP_FRAC_EXT 0x8789
-#define GL_OP_MAX_EXT 0x878A
-#define GL_OP_MIN_EXT 0x878B
-#define GL_OP_SET_GE_EXT 0x878C
-#define GL_OP_SET_LT_EXT 0x878D
-#define GL_OP_CLAMP_EXT 0x878E
-#define GL_OP_FLOOR_EXT 0x878F
-#define GL_OP_ROUND_EXT 0x8790
-#define GL_OP_EXP_BASE_2_EXT 0x8791
-#define GL_OP_LOG_BASE_2_EXT 0x8792
-#define GL_OP_POWER_EXT 0x8793
-#define GL_OP_RECIP_EXT 0x8794
-#define GL_OP_RECIP_SQRT_EXT 0x8795
-#define GL_OP_SUB_EXT 0x8796
-#define GL_OP_CROSS_PRODUCT_EXT 0x8797
-#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798
-#define GL_OP_MOV_EXT 0x8799
-#define GL_OUTPUT_VERTEX_EXT 0x879A
-#define GL_OUTPUT_COLOR0_EXT 0x879B
-#define GL_OUTPUT_COLOR1_EXT 0x879C
-#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D
-#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E
-#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F
-#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0
-#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1
-#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2
-#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3
-#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4
-#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5
-#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6
-#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7
-#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8
-#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9
-#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA
-#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB
-#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC
-#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD
-#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE
-#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF
-#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0
-#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1
-#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2
-#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3
-#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4
-#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5
-#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6
-#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7
-#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8
-#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9
-#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA
-#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB
-#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC
-#define GL_OUTPUT_FOG_EXT 0x87BD
-#define GL_SCALAR_EXT 0x87BE
-#define GL_VECTOR_EXT 0x87BF
-#define GL_MATRIX_EXT 0x87C0
-#define GL_VARIANT_EXT 0x87C1
-#define GL_INVARIANT_EXT 0x87C2
-#define GL_LOCAL_CONSTANT_EXT 0x87C3
-#define GL_LOCAL_EXT 0x87C4
-#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5
-#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6
-#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7
-#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8
-#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD
-#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE
-#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF
-#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0
-#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1
-#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2
-#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3
-#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4
-#define GL_X_EXT 0x87D5
-#define GL_Y_EXT 0x87D6
-#define GL_Z_EXT 0x87D7
-#define GL_W_EXT 0x87D8
-#define GL_NEGATIVE_X_EXT 0x87D9
-#define GL_NEGATIVE_Y_EXT 0x87DA
-#define GL_NEGATIVE_Z_EXT 0x87DB
-#define GL_NEGATIVE_W_EXT 0x87DC
-#define GL_ZERO_EXT 0x87DD
-#define GL_ONE_EXT 0x87DE
-#define GL_NEGATIVE_ONE_EXT 0x87DF
-#define GL_NORMALIZED_RANGE_EXT 0x87E0
-#define GL_FULL_RANGE_EXT 0x87E1
-#define GL_CURRENT_VERTEX_EXT 0x87E2
-#define GL_MVP_MATRIX_EXT 0x87E3
-#define GL_VARIANT_VALUE_EXT 0x87E4
-#define GL_VARIANT_DATATYPE_EXT 0x87E5
-#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6
-#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7
-#define GL_VARIANT_ARRAY_EXT 0x87E8
-#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9
-#define GL_INVARIANT_VALUE_EXT 0x87EA
-#define GL_INVARIANT_DATATYPE_EXT 0x87EB
-#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC
-#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED
-#endif
-
-#ifndef GL_ATI_vertex_streams
-#define GL_MAX_VERTEX_STREAMS_ATI 0x876B
-#define GL_VERTEX_STREAM0_ATI 0x876C
-#define GL_VERTEX_STREAM1_ATI 0x876D
-#define GL_VERTEX_STREAM2_ATI 0x876E
-#define GL_VERTEX_STREAM3_ATI 0x876F
-#define GL_VERTEX_STREAM4_ATI 0x8770
-#define GL_VERTEX_STREAM5_ATI 0x8771
-#define GL_VERTEX_STREAM6_ATI 0x8772
-#define GL_VERTEX_STREAM7_ATI 0x8773
-#define GL_VERTEX_SOURCE_ATI 0x8774
-#endif
-
-#ifndef GL_ATI_element_array
-#define GL_ELEMENT_ARRAY_ATI 0x8768
-#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769
-#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A
-#endif
-
-#ifndef GL_SUN_mesh_array
-#define GL_QUAD_MESH_SUN 0x8614
-#define GL_TRIANGLE_MESH_SUN 0x8615
-#endif
-
-#ifndef GL_SUN_slice_accum
-#define GL_SLICE_ACCUM_SUN 0x85CC
-#endif
-
-#ifndef GL_NV_multisample_filter_hint
-#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534
-#endif
-
-#ifndef GL_NV_depth_clamp
-#define GL_DEPTH_CLAMP_NV 0x864F
-#endif
-
-#ifndef GL_NV_occlusion_query
-#define GL_PIXEL_COUNTER_BITS_NV 0x8864
-#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865
-#define GL_PIXEL_COUNT_NV 0x8866
-#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867
-#endif
-
-#ifndef GL_NV_point_sprite
-#define GL_POINT_SPRITE_NV 0x8861
-#define GL_COORD_REPLACE_NV 0x8862
-#define GL_POINT_SPRITE_R_MODE_NV 0x8863
-#endif
-
-#ifndef GL_NV_texture_shader3
-#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850
-#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851
-#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852
-#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853
-#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854
-#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855
-#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856
-#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857
-#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858
-#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859
-#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A
-#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B
-#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C
-#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D
-#define GL_HILO8_NV 0x885E
-#define GL_SIGNED_HILO8_NV 0x885F
-#define GL_FORCE_BLUE_TO_ONE_NV 0x8860
-#endif
-
-#ifndef GL_NV_vertex_program1_1
-#endif
-
-#ifndef GL_EXT_shadow_funcs
-#endif
-
-#ifndef GL_EXT_stencil_two_side
-#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910
-#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911
-#endif
-
-#ifndef GL_ATI_text_fragment_shader
-#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200
-#endif
-
-#ifndef GL_APPLE_client_storage
-#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2
-#endif
-
-#ifndef GL_APPLE_element_array
-#define GL_ELEMENT_ARRAY_APPLE 0x8768
-#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769
-#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A
-#endif
-
-#ifndef GL_APPLE_fence
-#define GL_DRAW_PIXELS_APPLE 0x8A0A
-#define GL_FENCE_APPLE 0x8A0B
-#endif
-
-#ifndef GL_APPLE_vertex_array_object
-#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5
-#endif
-
-#ifndef GL_APPLE_vertex_array_range
-#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D
-#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E
-#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F
-#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521
-#define GL_STORAGE_CACHED_APPLE 0x85BE
-#define GL_STORAGE_SHARED_APPLE 0x85BF
-#endif
-
-#ifndef GL_APPLE_ycbcr_422
-#define GL_YCBCR_422_APPLE 0x85B9
-#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
-#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
-#endif
-
-#ifndef GL_S3_s3tc
-#define GL_RGB_S3TC 0x83A0
-#define GL_RGB4_S3TC 0x83A1
-#define GL_RGBA_S3TC 0x83A2
-#define GL_RGBA4_S3TC 0x83A3
-#endif
-
-#ifndef GL_ATI_draw_buffers
-#define GL_MAX_DRAW_BUFFERS_ATI 0x8824
-#define GL_DRAW_BUFFER0_ATI 0x8825
-#define GL_DRAW_BUFFER1_ATI 0x8826
-#define GL_DRAW_BUFFER2_ATI 0x8827
-#define GL_DRAW_BUFFER3_ATI 0x8828
-#define GL_DRAW_BUFFER4_ATI 0x8829
-#define GL_DRAW_BUFFER5_ATI 0x882A
-#define GL_DRAW_BUFFER6_ATI 0x882B
-#define GL_DRAW_BUFFER7_ATI 0x882C
-#define GL_DRAW_BUFFER8_ATI 0x882D
-#define GL_DRAW_BUFFER9_ATI 0x882E
-#define GL_DRAW_BUFFER10_ATI 0x882F
-#define GL_DRAW_BUFFER11_ATI 0x8830
-#define GL_DRAW_BUFFER12_ATI 0x8831
-#define GL_DRAW_BUFFER13_ATI 0x8832
-#define GL_DRAW_BUFFER14_ATI 0x8833
-#define GL_DRAW_BUFFER15_ATI 0x8834
-#endif
-
-#ifndef GL_ATI_pixel_format_float
-#define GL_TYPE_RGBA_FLOAT_ATI 0x8820
-#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835
-#endif
-
-#ifndef GL_ATI_texture_env_combine3
-#define GL_MODULATE_ADD_ATI 0x8744
-#define GL_MODULATE_SIGNED_ADD_ATI 0x8745
-#define GL_MODULATE_SUBTRACT_ATI 0x8746
-#endif
-
-#ifndef GL_ATI_texture_float
-#define GL_RGBA_FLOAT32_ATI 0x8814
-#define GL_RGB_FLOAT32_ATI 0x8815
-#define GL_ALPHA_FLOAT32_ATI 0x8816
-#define GL_INTENSITY_FLOAT32_ATI 0x8817
-#define GL_LUMINANCE_FLOAT32_ATI 0x8818
-#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819
-#define GL_RGBA_FLOAT16_ATI 0x881A
-#define GL_RGB_FLOAT16_ATI 0x881B
-#define GL_ALPHA_FLOAT16_ATI 0x881C
-#define GL_INTENSITY_FLOAT16_ATI 0x881D
-#define GL_LUMINANCE_FLOAT16_ATI 0x881E
-#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F
-#endif
-
-#ifndef GL_NV_float_buffer
-#define GL_FLOAT_R_NV 0x8880
-#define GL_FLOAT_RG_NV 0x8881
-#define GL_FLOAT_RGB_NV 0x8882
-#define GL_FLOAT_RGBA_NV 0x8883
-#define GL_FLOAT_R16_NV 0x8884
-#define GL_FLOAT_R32_NV 0x8885
-#define GL_FLOAT_RG16_NV 0x8886
-#define GL_FLOAT_RG32_NV 0x8887
-#define GL_FLOAT_RGB16_NV 0x8888
-#define GL_FLOAT_RGB32_NV 0x8889
-#define GL_FLOAT_RGBA16_NV 0x888A
-#define GL_FLOAT_RGBA32_NV 0x888B
-#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C
-#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D
-#define GL_FLOAT_RGBA_MODE_NV 0x888E
-#endif
-
-#ifndef GL_NV_fragment_program
-#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868
-#define GL_FRAGMENT_PROGRAM_NV 0x8870
-#define GL_MAX_TEXTURE_COORDS_NV 0x8871
-#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872
-#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873
-#define GL_PROGRAM_ERROR_STRING_NV 0x8874
-#endif
-
-#ifndef GL_NV_half_float
-#define GL_HALF_FLOAT_NV 0x140B
-#endif
-
-#ifndef GL_NV_pixel_data_range
-#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878
-#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879
-#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A
-#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B
-#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C
-#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D
-#endif
-
-#ifndef GL_NV_primitive_restart
-#define GL_PRIMITIVE_RESTART_NV 0x8558
-#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559
-#endif
-
-#ifndef GL_NV_texture_expand_normal
-#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F
-#endif
-
-#ifndef GL_NV_vertex_program2
-#endif
-
-#ifndef GL_ATI_map_object_buffer
-#endif
-
-#ifndef GL_ATI_separate_stencil
-#define GL_STENCIL_BACK_FUNC_ATI 0x8800
-#define GL_STENCIL_BACK_FAIL_ATI 0x8801
-#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802
-#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803
-#endif
-
-#ifndef GL_ATI_vertex_attrib_array_object
-#endif
-
-#ifndef GL_OES_read_format
-#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
-#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
-#endif
-
-#ifndef GL_EXT_depth_bounds_test
-#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890
-#define GL_DEPTH_BOUNDS_EXT 0x8891
-#endif
-
-#ifndef GL_EXT_texture_mirror_clamp
-#define GL_MIRROR_CLAMP_EXT 0x8742
-#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
-#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912
-#endif
-
-#ifndef GL_EXT_blend_equation_separate
-#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION
-#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D
-#endif
-
-#ifndef GL_MESA_pack_invert
-#define GL_PACK_INVERT_MESA 0x8758
-#endif
-
-#ifndef GL_MESA_ycbcr_texture
-#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA
-#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB
-#define GL_YCBCR_MESA 0x8757
-#endif
-
-#ifndef GL_EXT_pixel_buffer_object
-#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB
-#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC
-#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED
-#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF
-#endif
-
-#ifndef GL_NV_fragment_program_option
-#endif
-
-#ifndef GL_NV_fragment_program2
-#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4
-#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5
-#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6
-#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7
-#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8
-#endif
-
-#ifndef GL_NV_vertex_program2_option
-/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
-/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */
-#endif
-
-#ifndef GL_NV_vertex_program3
-/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
-#endif
-
-#ifndef GL_EXT_framebuffer_object
-#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
-#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
-#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6
-#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0
-#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
-#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
-#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
-#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
-#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
-#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8
-#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9
-#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA
-#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
-#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
-#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
-#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
-#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
-#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
-#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
-#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
-#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
-#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
-#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
-#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
-#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
-#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
-#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
-#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
-#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
-#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
-#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
-#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
-#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
-#define GL_STENCIL_ATTACHMENT_EXT 0x8D20
-#define GL_FRAMEBUFFER_EXT 0x8D40
-#define GL_RENDERBUFFER_EXT 0x8D41
-#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
-#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
-#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
-#define GL_STENCIL_INDEX1_EXT 0x8D46
-#define GL_STENCIL_INDEX4_EXT 0x8D47
-#define GL_STENCIL_INDEX8_EXT 0x8D48
-#define GL_STENCIL_INDEX16_EXT 0x8D49
-#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
-#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51
-#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52
-#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53
-#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54
-#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
-#endif
-
-#ifndef GL_GREMEDY_string_marker
-#endif
-
-
-/*************************************************************/
-
-#include <stddef.h>
-#ifndef GL_VERSION_2_0
-/* GL type for program/shader text */
-typedef char GLchar; /* native character */
-#endif
-
-#ifndef GL_VERSION_1_5
-/* GL types for handling large vertex buffer objects */
-typedef ptrdiff_t GLintptr;
-typedef ptrdiff_t GLsizeiptr;
-#endif
-
-#ifndef GL_ARB_vertex_buffer_object
-/* GL types for handling large vertex buffer objects */
-typedef ptrdiff_t GLintptrARB;
-typedef ptrdiff_t GLsizeiptrARB;
-#endif
-
-#ifndef GL_ARB_shader_objects
-/* GL types for handling shader object handles and program/shader text */
-typedef char GLcharARB; /* native character */
-typedef unsigned int GLhandleARB; /* shader object handle */
-#endif
-
-/* GL types for "half" precision (s10e5) float data in host memory */
-#ifndef GL_ARB_half_float_pixel
-typedef unsigned short GLhalfARB;
-#endif
-
-#ifndef GL_NV_half_float
-typedef unsigned short GLhalfNV;
-#endif
-
-#ifndef GL_VERSION_1_2
-#define GL_VERSION_1_2 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf);
-GLAPI void APIENTRY glBlendEquation (GLenum);
-GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);
-GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *);
-GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *);
-GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei);
-GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *);
-GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei);
-GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat);
-GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *);
-GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint);
-GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *);
-GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei);
-GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei);
-GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *);
-GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *);
-GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *);
-GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
-GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
-GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean);
-GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean);
-GLAPI void APIENTRY glResetHistogram (GLenum);
-GLAPI void APIENTRY glResetMinmax (GLenum);
-GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
-typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
-typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
-typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
-typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
-typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
-typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);
-typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-#endif
-
-#ifndef GL_VERSION_1_3
-#define GL_VERSION_1_3 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glActiveTexture (GLenum);
-GLAPI void APIENTRY glClientActiveTexture (GLenum);
-GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble);
-GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *);
-GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat);
-GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *);
-GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint);
-GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *);
-GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort);
-GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *);
-GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble);
-GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *);
-GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat);
-GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *);
-GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint);
-GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *);
-GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort);
-GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *);
-GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *);
-GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *);
-GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint);
-GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *);
-GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *);
-GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *);
-GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *);
-GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint);
-GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *);
-GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *);
-GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *);
-GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *);
-GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *);
-GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *);
-GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean);
-GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
-typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m);
-typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m);
-typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m);
-typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m);
-typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img);
-#endif
-
-#ifndef GL_VERSION_1_4
-#define GL_VERSION_1_4 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum);
-GLAPI void APIENTRY glFogCoordf (GLfloat);
-GLAPI void APIENTRY glFogCoordfv (const GLfloat *);
-GLAPI void APIENTRY glFogCoordd (GLdouble);
-GLAPI void APIENTRY glFogCoorddv (const GLdouble *);
-GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei);
-GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
-GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat);
-GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *);
-GLAPI void APIENTRY glPointParameteri (GLenum, GLint);
-GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *);
-GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte);
-GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *);
-GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *);
-GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *);
-GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint);
-GLAPI void APIENTRY glSecondaryColor3iv (const GLint *);
-GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *);
-GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte);
-GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *);
-GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *);
-GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort);
-GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *);
-GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble);
-GLAPI void APIENTRY glWindowPos2dv (const GLdouble *);
-GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat);
-GLAPI void APIENTRY glWindowPos2fv (const GLfloat *);
-GLAPI void APIENTRY glWindowPos2i (GLint, GLint);
-GLAPI void APIENTRY glWindowPos2iv (const GLint *);
-GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort);
-GLAPI void APIENTRY glWindowPos2sv (const GLshort *);
-GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glWindowPos3dv (const GLdouble *);
-GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glWindowPos3fv (const GLfloat *);
-GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint);
-GLAPI void APIENTRY glWindowPos3iv (const GLint *);
-GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glWindowPos3sv (const GLshort *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord);
-typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord);
-typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord);
-typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord);
-typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
-typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v);
-#endif
-
-#ifndef GL_VERSION_1_5
-#define GL_VERSION_1_5 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *);
-GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *);
-GLAPI GLboolean APIENTRY glIsQuery (GLuint);
-GLAPI void APIENTRY glBeginQuery (GLenum, GLuint);
-GLAPI void APIENTRY glEndQuery (GLenum);
-GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *);
-GLAPI void APIENTRY glBindBuffer (GLenum, GLuint);
-GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *);
-GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *);
-GLAPI GLboolean APIENTRY glIsBuffer (GLuint);
-GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum);
-GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *);
-GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *);
-GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum);
-GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum);
-GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids);
-typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids);
-typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id);
-typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params);
-typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
-typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
-typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
-typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer);
-typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
-typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
-typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
-typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access);
-typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params);
-#endif
-
-#ifndef GL_VERSION_2_0
-#define GL_VERSION_2_0 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum);
-GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *);
-GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum);
-GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint);
-GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint);
-GLAPI void APIENTRY glAttachShader (GLuint, GLuint);
-GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *);
-GLAPI void APIENTRY glCompileShader (GLuint);
-GLAPI GLuint APIENTRY glCreateProgram (void);
-GLAPI GLuint APIENTRY glCreateShader (GLenum);
-GLAPI void APIENTRY glDeleteProgram (GLuint);
-GLAPI void APIENTRY glDeleteShader (GLuint);
-GLAPI void APIENTRY glDetachShader (GLuint, GLuint);
-GLAPI void APIENTRY glDisableVertexAttribArray (GLuint);
-GLAPI void APIENTRY glEnableVertexAttribArray (GLuint);
-GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);
-GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);
-GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *);
-GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *);
-GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *);
-GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *);
-GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *);
-GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *);
-GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *);
-GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *);
-GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *);
-GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *);
-GLAPI GLboolean APIENTRY glIsProgram (GLuint);
-GLAPI GLboolean APIENTRY glIsShader (GLuint);
-GLAPI void APIENTRY glLinkProgram (GLuint);
-GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *);
-GLAPI void APIENTRY glUseProgram (GLuint);
-GLAPI void APIENTRY glUniform1f (GLint, GLfloat);
-GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat);
-GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glUniform1i (GLint, GLint);
-GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint);
-GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint);
-GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint);
-GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *);
-GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *);
-GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *);
-GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *);
-GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *);
-GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *);
-GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *);
-GLAPI void APIENTRY glValidateProgram (GLuint);
-GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble);
-GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *);
-GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat);
-GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *);
-GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort);
-GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble);
-GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *);
-GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat);
-GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *);
-GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort);
-GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *);
-GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *);
-GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *);
-GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *);
-GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
-GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *);
-GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *);
-GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *);
-GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *);
-GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *);
-GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *);
-GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *);
-GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *);
-GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *);
-GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *);
-GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
-typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs);
-typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
-typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
-typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask);
-typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
-typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name);
-typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);
-typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void);
-typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);
-typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);
-typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader);
-typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
-typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
-typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
-typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
-typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
-typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
-typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
-typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
-typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
-typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
-typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
-typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program);
-typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader);
-typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
-typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length);
-typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program);
-typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);
-typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);
-typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
-typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);
-typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);
-typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
-#endif
-
-#ifndef GL_ARB_multitexture
-#define GL_ARB_multitexture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glActiveTextureARB (GLenum);
-GLAPI void APIENTRY glClientActiveTextureARB (GLenum);
-GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble);
-GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *);
-GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat);
-GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *);
-GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint);
-GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *);
-GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort);
-GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *);
-GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble);
-GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *);
-GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat);
-GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *);
-GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint);
-GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *);
-GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort);
-GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *);
-GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *);
-GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *);
-GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint);
-GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *);
-GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *);
-GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *);
-GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *);
-GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint);
-GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *);
-GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
-typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
-#endif
-
-#ifndef GL_ARB_transpose_matrix
-#define GL_ARB_transpose_matrix 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *);
-GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *);
-GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *);
-GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
-typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
-typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
-typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
-#endif
-
-#ifndef GL_ARB_multisample
-#define GL_ARB_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert);
-#endif
-
-#ifndef GL_ARB_texture_env_add
-#define GL_ARB_texture_env_add 1
-#endif
-
-#ifndef GL_ARB_texture_cube_map
-#define GL_ARB_texture_cube_map 1
-#endif
-
-#ifndef GL_ARB_texture_compression
-#define GL_ARB_texture_compression 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
-typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img);
-#endif
-
-#ifndef GL_ARB_texture_border_clamp
-#define GL_ARB_texture_border_clamp 1
-#endif
-
-#ifndef GL_ARB_point_parameters
-#define GL_ARB_point_parameters 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat);
-GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params);
-#endif
-
-#ifndef GL_ARB_vertex_blend
-#define GL_ARB_vertex_blend 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *);
-GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *);
-GLAPI void APIENTRY glWeightivARB (GLint, const GLint *);
-GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *);
-GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *);
-GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *);
-GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *);
-GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *);
-GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glVertexBlendARB (GLint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights);
-typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights);
-typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights);
-typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights);
-typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights);
-typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights);
-typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights);
-typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights);
-typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count);
-#endif
-
-#ifndef GL_ARB_matrix_palette
-#define GL_ARB_matrix_palette 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint);
-GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *);
-GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *);
-GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *);
-GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index);
-typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices);
-typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices);
-typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices);
-typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif
-
-#ifndef GL_ARB_texture_env_combine
-#define GL_ARB_texture_env_combine 1
-#endif
-
-#ifndef GL_ARB_texture_env_crossbar
-#define GL_ARB_texture_env_crossbar 1
-#endif
-
-#ifndef GL_ARB_texture_env_dot3
-#define GL_ARB_texture_env_dot3 1
-#endif
-
-#ifndef GL_ARB_texture_mirrored_repeat
-#define GL_ARB_texture_mirrored_repeat 1
-#endif
-
-#ifndef GL_ARB_depth_texture
-#define GL_ARB_depth_texture 1
-#endif
-
-#ifndef GL_ARB_shadow
-#define GL_ARB_shadow 1
-#endif
-
-#ifndef GL_ARB_shadow_ambient
-#define GL_ARB_shadow_ambient 1
-#endif
-
-#ifndef GL_ARB_window_pos
-#define GL_ARB_window_pos 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble);
-GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *);
-GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat);
-GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *);
-GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint);
-GLAPI void APIENTRY glWindowPos2ivARB (const GLint *);
-GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort);
-GLAPI void APIENTRY glWindowPos2svARB (const GLshort *);
-GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *);
-GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *);
-GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint);
-GLAPI void APIENTRY glWindowPos3ivARB (const GLint *);
-GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glWindowPos3svARB (const GLshort *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v);
-#endif
-
-#ifndef GL_ARB_vertex_program
-#define GL_ARB_vertex_program 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble);
-GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *);
-GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat);
-GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *);
-GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort);
-GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble);
-GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *);
-GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat);
-GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *);
-GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort);
-GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *);
-GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *);
-GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *);
-GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *);
-GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
-GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *);
-GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *);
-GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *);
-GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *);
-GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *);
-GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *);
-GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *);
-GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *);
-GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *);
-GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *);
-GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint);
-GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint);
-GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint);
-GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *);
-GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *);
-GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *);
-GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *);
-GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *);
-GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *);
-GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *);
-GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *);
-GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *);
-GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *);
-GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *);
-GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *);
-GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *);
-GLAPI GLboolean APIENTRY glIsProgramARB (GLuint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
-typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
-typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string);
-typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program);
-typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs);
-typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
-typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program);
-#endif
-
-#ifndef GL_ARB_fragment_program
-#define GL_ARB_fragment_program 1
-/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */
-#endif
-
-#ifndef GL_ARB_vertex_buffer_object
-#define GL_ARB_vertex_buffer_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint);
-GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *);
-GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *);
-GLAPI GLboolean APIENTRY glIsBufferARB (GLuint);
-GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum);
-GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *);
-GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *);
-GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum);
-GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum);
-GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
-typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
-typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
-typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer);
-typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
-typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data);
-typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data);
-typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access);
-typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params);
-#endif
-
-#ifndef GL_ARB_occlusion_query
-#define GL_ARB_occlusion_query 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *);
-GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *);
-GLAPI GLboolean APIENTRY glIsQueryARB (GLuint);
-GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint);
-GLAPI void APIENTRY glEndQueryARB (GLenum);
-GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids);
-typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids);
-typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id);
-typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params);
-#endif
-
-#ifndef GL_ARB_shader_objects
-#define GL_ARB_shader_objects 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB);
-GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum);
-GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB);
-GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum);
-GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *);
-GLAPI void APIENTRY glCompileShaderARB (GLhandleARB);
-GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void);
-GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB);
-GLAPI void APIENTRY glLinkProgramARB (GLhandleARB);
-GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB);
-GLAPI void APIENTRY glValidateProgramARB (GLhandleARB);
-GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat);
-GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat);
-GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glUniform1iARB (GLint, GLint);
-GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint);
-GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint);
-GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint);
-GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *);
-GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *);
-GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *);
-GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *);
-GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
-GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
-GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
-GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *);
-GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
-GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *);
-GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *);
-GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
-GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *);
-GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *);
-GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj);
-typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname);
-typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj);
-typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType);
-typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length);
-typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj);
-typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void);
-typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj);
-typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj);
-typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj);
-typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj);
-typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0);
-typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1);
-typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
-typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
-typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0);
-typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1);
-typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2);
-typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
-typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
-typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
-typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);
-typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
-typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
-typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params);
-typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);
-#endif
-
-#ifndef GL_ARB_vertex_shader
-#define GL_ARB_vertex_shader 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *);
-GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
-GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name);
-typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
-typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
-#endif
-
-#ifndef GL_ARB_fragment_shader
-#define GL_ARB_fragment_shader 1
-#endif
-
-#ifndef GL_ARB_shading_language_100
-#define GL_ARB_shading_language_100 1
-#endif
-
-#ifndef GL_ARB_texture_non_power_of_two
-#define GL_ARB_texture_non_power_of_two 1
-#endif
-
-#ifndef GL_ARB_point_sprite
-#define GL_ARB_point_sprite 1
-#endif
-
-#ifndef GL_ARB_fragment_program_shadow
-#define GL_ARB_fragment_program_shadow 1
-#endif
-
-#ifndef GL_ARB_draw_buffers
-#define GL_ARB_draw_buffers 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs);
-#endif
-
-#ifndef GL_ARB_texture_rectangle
-#define GL_ARB_texture_rectangle 1
-#endif
-
-#ifndef GL_ARB_color_buffer_float
-#define GL_ARB_color_buffer_float 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glClampColorARB (GLenum, GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp);
-#endif
-
-#ifndef GL_ARB_half_float_pixel
-#define GL_ARB_half_float_pixel 1
-#endif
-
-#ifndef GL_ARB_texture_float
-#define GL_ARB_texture_float 1
-#endif
-
-#ifndef GL_ARB_pixel_buffer_object
-#define GL_ARB_pixel_buffer_object 1
-#endif
-
-#ifndef GL_EXT_abgr
-#define GL_EXT_abgr 1
-#endif
-
-#ifndef GL_EXT_blend_color
-#define GL_EXT_blend_color 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
-#endif
-
-#ifndef GL_EXT_polygon_offset
-#define GL_EXT_polygon_offset 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias);
-#endif
-
-#ifndef GL_EXT_texture
-#define GL_EXT_texture 1
-#endif
-
-#ifndef GL_EXT_texture3D
-#define GL_EXT_texture3D 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
-#endif
-
-#ifndef GL_SGIS_texture_filter4
-#define GL_SGIS_texture_filter4 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights);
-typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights);
-#endif
-
-#ifndef GL_EXT_subtexture
-#define GL_EXT_subtexture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
-#endif
-
-#ifndef GL_EXT_copy_texture
-#define GL_EXT_copy_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint);
-GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
-GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei);
-GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
-GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
-typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
-#endif
-
-#ifndef GL_EXT_histogram
-#define GL_EXT_histogram 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
-GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
-GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean);
-GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean);
-GLAPI void APIENTRY glResetHistogramEXT (GLenum);
-GLAPI void APIENTRY glResetMinmaxEXT (GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
-typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
-typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink);
-typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target);
-#endif
-
-#ifndef GL_EXT_convolution
-#define GL_EXT_convolution 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat);
-GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *);
-GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint);
-GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *);
-GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei);
-GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei);
-GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *);
-GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *);
-GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
-typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params);
-typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
-typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
-#endif
-
-#ifndef GL_EXT_color_matrix
-#define GL_EXT_color_matrix 1
-#endif
-
-#ifndef GL_SGI_color_table
-#define GL_SGI_color_table 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *);
-GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *);
-GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei);
-GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *);
-GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
-typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
-typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params);
-#endif
-
-#ifndef GL_SGIX_pixel_texture
-#define GL_SGIX_pixel_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPixelTexGenSGIX (GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode);
-#endif
-
-#ifndef GL_SGIS_pixel_texture
-#define GL_SGIS_pixel_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint);
-GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *);
-GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat);
-GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *);
-GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *);
-GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params);
-#endif
-
-#ifndef GL_SGIS_texture4D
-#define GL_SGIS_texture4D 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
-typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels);
-#endif
-
-#ifndef GL_SGI_texture_color_table
-#define GL_SGI_texture_color_table 1
-#endif
-
-#ifndef GL_EXT_cmyka
-#define GL_EXT_cmyka 1
-#endif
-
-#ifndef GL_EXT_texture_object
-#define GL_EXT_texture_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *);
-GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint);
-GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *);
-GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *);
-GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint);
-GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences);
-typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture);
-typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures);
-typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures);
-typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture);
-typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities);
-#endif
-
-#ifndef GL_SGIS_detail_texture
-#define GL_SGIS_detail_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
-typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
-#endif
-
-#ifndef GL_SGIS_sharpen_texture
-#define GL_SGIS_sharpen_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
-typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
-#endif
-
-#ifndef GL_EXT_packed_pixels
-#define GL_EXT_packed_pixels 1
-#endif
-
-#ifndef GL_SGIS_texture_lod
-#define GL_SGIS_texture_lod 1
-#endif
-
-#ifndef GL_SGIS_multisample
-#define GL_SGIS_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean);
-GLAPI void APIENTRY glSamplePatternSGIS (GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert);
-typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern);
-#endif
-
-#ifndef GL_EXT_rescale_normal
-#define GL_EXT_rescale_normal 1
-#endif
-
-#ifndef GL_EXT_vertex_array
-#define GL_EXT_vertex_array 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glArrayElementEXT (GLint);
-GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei);
-GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *);
-GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *);
-GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i);
-typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count);
-typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer);
-typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params);
-typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
-#endif
-
-#ifndef GL_EXT_misc_attribute
-#define GL_EXT_misc_attribute 1
-#endif
-
-#ifndef GL_SGIS_generate_mipmap
-#define GL_SGIS_generate_mipmap 1
-#endif
-
-#ifndef GL_SGIX_clipmap
-#define GL_SGIX_clipmap 1
-#endif
-
-#ifndef GL_SGIX_shadow
-#define GL_SGIX_shadow 1
-#endif
-
-#ifndef GL_SGIS_texture_edge_clamp
-#define GL_SGIS_texture_edge_clamp 1
-#endif
-
-#ifndef GL_SGIS_texture_border_clamp
-#define GL_SGIS_texture_border_clamp 1
-#endif
-
-#ifndef GL_EXT_blend_minmax
-#define GL_EXT_blend_minmax 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendEquationEXT (GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode);
-#endif
-
-#ifndef GL_EXT_blend_subtract
-#define GL_EXT_blend_subtract 1
-#endif
-
-#ifndef GL_EXT_blend_logic_op
-#define GL_EXT_blend_logic_op 1
-#endif
-
-#ifndef GL_SGIX_interlace
-#define GL_SGIX_interlace 1
-#endif
-
-#ifndef GL_SGIX_pixel_tiles
-#define GL_SGIX_pixel_tiles 1
-#endif
-
-#ifndef GL_SGIX_texture_select
-#define GL_SGIX_texture_select 1
-#endif
-
-#ifndef GL_SGIX_sprite
-#define GL_SGIX_sprite 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat);
-GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *);
-GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint);
-GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params);
-#endif
-
-#ifndef GL_SGIX_texture_multi_buffer
-#define GL_SGIX_texture_multi_buffer 1
-#endif
-
-#ifndef GL_EXT_point_parameters
-#define GL_EXT_point_parameters 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat);
-GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
-#endif
-
-#ifndef GL_SGIS_point_parameters
-#define GL_SGIS_point_parameters 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat);
-GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
-#endif
-
-#ifndef GL_SGIX_instruments
-#define GL_SGIX_instruments 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLint APIENTRY glGetInstrumentsSGIX (void);
-GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *);
-GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *);
-GLAPI void APIENTRY glReadInstrumentsSGIX (GLint);
-GLAPI void APIENTRY glStartInstrumentsSGIX (void);
-GLAPI void APIENTRY glStopInstrumentsSGIX (GLint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void);
-typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer);
-typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p);
-typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker);
-typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void);
-typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker);
-#endif
-
-#ifndef GL_SGIX_texture_scale_bias
-#define GL_SGIX_texture_scale_bias 1
-#endif
-
-#ifndef GL_SGIX_framezoom
-#define GL_SGIX_framezoom 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFrameZoomSGIX (GLint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor);
-#endif
-
-#ifndef GL_SGIX_tag_sample_buffer
-#define GL_SGIX_tag_sample_buffer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTagSampleBufferSGIX (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void);
-#endif
-
-#ifndef GL_SGIX_polynomial_ffd
-#define GL_SGIX_polynomial_ffd 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *);
-GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *);
-GLAPI void APIENTRY glDeformSGIX (GLbitfield);
-GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points);
-typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points);
-typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask);
-typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask);
-#endif
-
-#ifndef GL_SGIX_reference_plane
-#define GL_SGIX_reference_plane 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation);
-#endif
-
-#ifndef GL_SGIX_flush_raster
-#define GL_SGIX_flush_raster 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFlushRasterSGIX (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void);
-#endif
-
-#ifndef GL_SGIX_depth_texture
-#define GL_SGIX_depth_texture 1
-#endif
-
-#ifndef GL_SGIS_fog_function
-#define GL_SGIS_fog_function 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *);
-GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points);
-typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points);
-#endif
-
-#ifndef GL_SGIX_fog_offset
-#define GL_SGIX_fog_offset 1
-#endif
-
-#ifndef GL_HP_image_transform
-#define GL_HP_image_transform 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint);
-GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat);
-GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *);
-GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *);
-GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params);
-#endif
-
-#ifndef GL_HP_convolution_border_modes
-#define GL_HP_convolution_border_modes 1
-#endif
-
-#ifndef GL_SGIX_texture_add_env
-#define GL_SGIX_texture_add_env 1
-#endif
-
-#ifndef GL_EXT_color_subtable
-#define GL_EXT_color_subtable 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
-typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
-#endif
-
-#ifndef GL_PGI_vertex_hints
-#define GL_PGI_vertex_hints 1
-#endif
-
-#ifndef GL_PGI_misc_hints
-#define GL_PGI_misc_hints 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glHintPGI (GLenum, GLint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode);
-#endif
-
-#ifndef GL_EXT_paletted_texture
-#define GL_EXT_paletted_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
-GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *);
-GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
-#endif
-
-#ifndef GL_EXT_clip_volume_hint
-#define GL_EXT_clip_volume_hint 1
-#endif
-
-#ifndef GL_SGIX_list_priority
-#define GL_SGIX_list_priority 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat);
-GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *);
-GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint);
-GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params);
-#endif
-
-#ifndef GL_SGIX_ir_instrument1
-#define GL_SGIX_ir_instrument1 1
-#endif
-
-#ifndef GL_SGIX_calligraphic_fragment
-#define GL_SGIX_calligraphic_fragment 1
-#endif
-
-#ifndef GL_SGIX_texture_lod_bias
-#define GL_SGIX_texture_lod_bias 1
-#endif
-
-#ifndef GL_SGIX_shadow_ambient
-#define GL_SGIX_shadow_ambient 1
-#endif
-
-#ifndef GL_EXT_index_texture
-#define GL_EXT_index_texture 1
-#endif
-
-#ifndef GL_EXT_index_material
-#define GL_EXT_index_material 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode);
-#endif
-
-#ifndef GL_EXT_index_func
-#define GL_EXT_index_func 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref);
-#endif
-
-#ifndef GL_EXT_index_array_formats
-#define GL_EXT_index_array_formats 1
-#endif
-
-#ifndef GL_EXT_compiled_vertex_array
-#define GL_EXT_compiled_vertex_array 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei);
-GLAPI void APIENTRY glUnlockArraysEXT (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count);
-typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void);
-#endif
-
-#ifndef GL_EXT_cull_vertex
-#define GL_EXT_cull_vertex 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *);
-GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params);
-typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params);
-#endif
-
-#ifndef GL_SGIX_ycrcb
-#define GL_SGIX_ycrcb 1
-#endif
-
-#ifndef GL_SGIX_fragment_lighting
-#define GL_SGIX_fragment_lighting 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum);
-GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat);
-GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *);
-GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint);
-GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *);
-GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat);
-GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *);
-GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint);
-GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *);
-GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat);
-GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *);
-GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint);
-GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *);
-GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param);
-#endif
-
-#ifndef GL_IBM_rasterpos_clip
-#define GL_IBM_rasterpos_clip 1
-#endif
-
-#ifndef GL_HP_texture_lighting
-#define GL_HP_texture_lighting 1
-#endif
-
-#ifndef GL_EXT_draw_range_elements
-#define GL_EXT_draw_range_elements 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
-#endif
-
-#ifndef GL_WIN_phong_shading
-#define GL_WIN_phong_shading 1
-#endif
-
-#ifndef GL_WIN_specular_fog
-#define GL_WIN_specular_fog 1
-#endif
-
-#ifndef GL_EXT_light_texture
-#define GL_EXT_light_texture 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glApplyTextureEXT (GLenum);
-GLAPI void APIENTRY glTextureLightEXT (GLenum);
-GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode);
-typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname);
-typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode);
-#endif
-
-#ifndef GL_SGIX_blend_alpha_minmax
-#define GL_SGIX_blend_alpha_minmax 1
-#endif
-
-#ifndef GL_EXT_bgra
-#define GL_EXT_bgra 1
-#endif
-
-#ifndef GL_SGIX_async
-#define GL_SGIX_async 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint);
-GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *);
-GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *);
-GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei);
-GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei);
-GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker);
-typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp);
-typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp);
-typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range);
-typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range);
-typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker);
-#endif
-
-#ifndef GL_SGIX_async_pixel
-#define GL_SGIX_async_pixel 1
-#endif
-
-#ifndef GL_SGIX_async_histogram
-#define GL_SGIX_async_histogram 1
-#endif
-
-#ifndef GL_INTEL_parallel_arrays
-#define GL_INTEL_parallel_arrays 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *);
-GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *);
-GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *);
-GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
-typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer);
-typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
-typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
-#endif
-
-#ifndef GL_HP_occlusion_test
-#define GL_HP_occlusion_test 1
-#endif
-
-#ifndef GL_EXT_pixel_transform
-#define GL_EXT_pixel_transform 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint);
-GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat);
-GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *);
-GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
-#endif
-
-#ifndef GL_EXT_pixel_transform_color_table
-#define GL_EXT_pixel_transform_color_table 1
-#endif
-
-#ifndef GL_EXT_shared_texture_palette
-#define GL_EXT_shared_texture_palette 1
-#endif
-
-#ifndef GL_EXT_separate_specular_color
-#define GL_EXT_separate_specular_color 1
-#endif
-
-#ifndef GL_EXT_secondary_color
-#define GL_EXT_secondary_color 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte);
-GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *);
-GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *);
-GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *);
-GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint);
-GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *);
-GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *);
-GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte);
-GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *);
-GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *);
-GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort);
-GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *);
-GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v);
-typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif
-
-#ifndef GL_EXT_texture_perturb_normal
-#define GL_EXT_texture_perturb_normal 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTextureNormalEXT (GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode);
-#endif
-
-#ifndef GL_EXT_multi_draw_arrays
-#define GL_EXT_multi_draw_arrays 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
-GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
-typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
-#endif
-
-#ifndef GL_EXT_fog_coord
-#define GL_EXT_fog_coord 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFogCoordfEXT (GLfloat);
-GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *);
-GLAPI void APIENTRY glFogCoorddEXT (GLdouble);
-GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *);
-GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord);
-typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord);
-typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord);
-typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord);
-typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif
-
-#ifndef GL_REND_screen_coordinates
-#define GL_REND_screen_coordinates 1
-#endif
-
-#ifndef GL_EXT_coordinate_frame
-#define GL_EXT_coordinate_frame 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte);
-GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *);
-GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *);
-GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *);
-GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint);
-GLAPI void APIENTRY glTangent3ivEXT (const GLint *);
-GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glTangent3svEXT (const GLshort *);
-GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte);
-GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *);
-GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *);
-GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *);
-GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint);
-GLAPI void APIENTRY glBinormal3ivEXT (const GLint *);
-GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glBinormal3svEXT (const GLshort *);
-GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz);
-typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v);
-typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz);
-typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz);
-typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz);
-typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz);
-typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz);
-typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v);
-typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz);
-typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz);
-typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz);
-typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz);
-typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif
-
-#ifndef GL_EXT_texture_env_combine
-#define GL_EXT_texture_env_combine 1
-#endif
-
-#ifndef GL_APPLE_specular_vector
-#define GL_APPLE_specular_vector 1
-#endif
-
-#ifndef GL_APPLE_transform_hint
-#define GL_APPLE_transform_hint 1
-#endif
-
-#ifndef GL_SGIX_fog_scale
-#define GL_SGIX_fog_scale 1
-#endif
-
-#ifndef GL_SUNX_constant_data
-#define GL_SUNX_constant_data 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFinishTextureSUNX (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void);
-#endif
-
-#ifndef GL_SUN_global_alpha
-#define GL_SUN_global_alpha 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte);
-GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort);
-GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint);
-GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat);
-GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble);
-GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte);
-GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort);
-GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor);
-typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor);
-#endif
-
-#ifndef GL_SUN_triangle_list
-#define GL_SUN_triangle_list 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint);
-GLAPI void APIENTRY glReplacementCodeusSUN (GLushort);
-GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte);
-GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *);
-GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *);
-GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *);
-GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer);
-#endif
-
-#ifndef GL_SUN_vertex
-#define GL_SUN_vertex 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat);
-GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *);
-GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *);
-GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *);
-GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *);
-GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *);
-GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *);
-GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
-#endif
-
-#ifndef GL_EXT_blend_func_separate
-#define GL_EXT_blend_func_separate 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-#endif
-
-#ifndef GL_INGR_blend_func_separate
-#define GL_INGR_blend_func_separate 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
-#endif
-
-#ifndef GL_INGR_color_clamp
-#define GL_INGR_color_clamp 1
-#endif
-
-#ifndef GL_INGR_interlace_read
-#define GL_INGR_interlace_read 1
-#endif
-
-#ifndef GL_EXT_stencil_wrap
-#define GL_EXT_stencil_wrap 1
-#endif
-
-#ifndef GL_EXT_422_pixels
-#define GL_EXT_422_pixels 1
-#endif
-
-#ifndef GL_NV_texgen_reflection
-#define GL_NV_texgen_reflection 1
-#endif
-
-#ifndef GL_SUN_convolution_border_modes
-#define GL_SUN_convolution_border_modes 1
-#endif
-
-#ifndef GL_EXT_texture_env_add
-#define GL_EXT_texture_env_add 1
-#endif
-
-#ifndef GL_EXT_texture_lod_bias
-#define GL_EXT_texture_lod_bias 1
-#endif
-
-#ifndef GL_EXT_texture_filter_anisotropic
-#define GL_EXT_texture_filter_anisotropic 1
-#endif
-
-#ifndef GL_EXT_vertex_weighting
-#define GL_EXT_vertex_weighting 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexWeightfEXT (GLfloat);
-GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *);
-GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight);
-typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight);
-typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer);
-#endif
-
-#ifndef GL_NV_light_max_exponent
-#define GL_NV_light_max_exponent 1
-#endif
-
-#ifndef GL_NV_vertex_array_range
-#define GL_NV_vertex_array_range 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glFlushVertexArrayRangeNV (void);
-GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void);
-typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer);
-#endif
-
-#ifndef GL_NV_register_combiners
-#define GL_NV_register_combiners 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *);
-GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat);
-GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *);
-GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint);
-GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum);
-GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean);
-GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum);
-GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);
-typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
-typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
-typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
-typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params);
-#endif
-
-#ifndef GL_NV_fog_distance
-#define GL_NV_fog_distance 1
-#endif
-
-#ifndef GL_NV_texgen_emboss
-#define GL_NV_texgen_emboss 1
-#endif
-
-#ifndef GL_NV_blend_square
-#define GL_NV_blend_square 1
-#endif
-
-#ifndef GL_NV_texture_env_combine4
-#define GL_NV_texture_env_combine4 1
-#endif
-
-#ifndef GL_MESA_resize_buffers
-#define GL_MESA_resize_buffers 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glResizeBuffersMESA (void);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void);
-#endif
-
-#ifndef GL_MESA_window_pos
-#define GL_MESA_window_pos 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble);
-GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *);
-GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat);
-GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *);
-GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint);
-GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *);
-GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort);
-GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *);
-GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *);
-GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *);
-GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint);
-GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *);
-GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *);
-GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *);
-GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *);
-GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint);
-GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *);
-GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w);
-typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v);
-typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w);
-typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v);
-#endif
-
-#ifndef GL_IBM_cull_vertex
-#define GL_IBM_cull_vertex 1
-#endif
-
-#ifndef GL_IBM_multimode_draw_arrays
-#define GL_IBM_multimode_draw_arrays 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint);
-GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);
-typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride);
-#endif
-
-#ifndef GL_IBM_vertex_array_lists
-#define GL_IBM_vertex_array_lists 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
-GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
-GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint);
-GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint);
-GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint);
-GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint);
-GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
-GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
-#endif
-
-#ifndef GL_SGIX_subsample
-#define GL_SGIX_subsample 1
-#endif
-
-#ifndef GL_SGIX_ycrcba
-#define GL_SGIX_ycrcba 1
-#endif
-
-#ifndef GL_SGIX_ycrcb_subsample
-#define GL_SGIX_ycrcb_subsample 1
-#endif
-
-#ifndef GL_SGIX_depth_pass_instrument
-#define GL_SGIX_depth_pass_instrument 1
-#endif
-
-#ifndef GL_3DFX_texture_compression_FXT1
-#define GL_3DFX_texture_compression_FXT1 1
-#endif
-
-#ifndef GL_3DFX_multisample
-#define GL_3DFX_multisample 1
-#endif
-
-#ifndef GL_3DFX_tbuffer
-#define GL_3DFX_tbuffer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTbufferMask3DFX (GLuint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask);
-#endif
-
-#ifndef GL_EXT_multisample
-#define GL_EXT_multisample 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean);
-GLAPI void APIENTRY glSamplePatternEXT (GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert);
-typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern);
-#endif
-
-#ifndef GL_SGIX_vertex_preclip
-#define GL_SGIX_vertex_preclip 1
-#endif
-
-#ifndef GL_SGIX_convolution_accuracy
-#define GL_SGIX_convolution_accuracy 1
-#endif
-
-#ifndef GL_SGIX_resample
-#define GL_SGIX_resample 1
-#endif
-
-#ifndef GL_SGIS_point_line_texgen
-#define GL_SGIS_point_line_texgen 1
-#endif
-
-#ifndef GL_SGIS_texture_color_mask
-#define GL_SGIS_texture_color_mask 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
-#endif
-
-#ifndef GL_SGIX_igloo_interface
-#define GL_SGIX_igloo_interface 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params);
-#endif
-
-#ifndef GL_EXT_texture_env_dot3
-#define GL_EXT_texture_env_dot3 1
-#endif
-
-#ifndef GL_ATI_texture_mirror_once
-#define GL_ATI_texture_mirror_once 1
-#endif
-
-#ifndef GL_NV_fence
-#define GL_NV_fence 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *);
-GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *);
-GLAPI GLboolean APIENTRY glIsFenceNV (GLuint);
-GLAPI GLboolean APIENTRY glTestFenceNV (GLuint);
-GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glFinishFenceNV (GLuint);
-GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
-typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
-typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
-typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
-typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
-typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
-#endif
-
-#ifndef GL_NV_evaluators
-#define GL_NV_evaluators 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *);
-GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *);
-GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *);
-GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *);
-GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *);
-GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points);
-typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params);
-typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points);
-typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode);
-#endif
-
-#ifndef GL_NV_packed_depth_stencil
-#define GL_NV_packed_depth_stencil 1
-#endif
-
-#ifndef GL_NV_register_combiners2
-#define GL_NV_register_combiners2 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *);
-GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params);
-typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params);
-#endif
-
-#ifndef GL_NV_texture_compression_vtc
-#define GL_NV_texture_compression_vtc 1
-#endif
-
-#ifndef GL_NV_texture_rectangle
-#define GL_NV_texture_rectangle 1
-#endif
-
-#ifndef GL_NV_texture_shader
-#define GL_NV_texture_shader 1
-#endif
-
-#ifndef GL_NV_texture_shader2
-#define GL_NV_texture_shader2 1
-#endif
-
-#ifndef GL_NV_vertex_array_range2
-#define GL_NV_vertex_array_range2 1
-#endif
-
-#ifndef GL_NV_vertex_program
-#define GL_NV_vertex_program 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *);
-GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint);
-GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *);
-GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *);
-GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *);
-GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *);
-GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *);
-GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *);
-GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *);
-GLAPI GLboolean APIENTRY glIsProgramNV (GLuint);
-GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *);
-GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *);
-GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *);
-GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *);
-GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *);
-GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *);
-GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum);
-GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *);
-GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble);
-GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *);
-GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat);
-GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *);
-GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort);
-GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble);
-GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *);
-GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat);
-GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *);
-GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort);
-GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *);
-GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *);
-GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *);
-GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *);
-GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *);
-GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
-GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *);
-GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *);
-GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *);
-GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *);
-GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *);
-GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *);
-GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *);
-GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *);
-GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *);
-GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *);
-GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences);
-typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id);
-typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);
-typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params);
-typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs);
-typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program);
-typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
-typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v);
-typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v);
-typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);
-typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v);
-#endif
-
-#ifndef GL_SGIX_texture_coordinate_clamp
-#define GL_SGIX_texture_coordinate_clamp 1
-#endif
-
-#ifndef GL_SGIX_scalebias_hint
-#define GL_SGIX_scalebias_hint 1
-#endif
-
-#ifndef GL_OML_interlace
-#define GL_OML_interlace 1
-#endif
-
-#ifndef GL_OML_subsample
-#define GL_OML_subsample 1
-#endif
-
-#ifndef GL_OML_resample
-#define GL_OML_resample 1
-#endif
-
-#ifndef GL_NV_copy_depth_to_color
-#define GL_NV_copy_depth_to_color 1
-#endif
-
-#ifndef GL_ATI_envmap_bumpmap
-#define GL_ATI_envmap_bumpmap 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *);
-GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *);
-GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *);
-GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param);
-typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param);
-typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param);
-typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param);
-#endif
-
-#ifndef GL_ATI_fragment_shader
-#define GL_ATI_fragment_shader 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint);
-GLAPI void APIENTRY glBindFragmentShaderATI (GLuint);
-GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint);
-GLAPI void APIENTRY glBeginFragmentShaderATI (void);
-GLAPI void APIENTRY glEndFragmentShaderATI (void);
-GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum);
-GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum);
-GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range);
-typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void);
-typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void);
-typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle);
-typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle);
-typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
-typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
-typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
-typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
-typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
-typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
-typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value);
-#endif
-
-#ifndef GL_ATI_pn_triangles
-#define GL_ATI_pn_triangles 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint);
-GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param);
-#endif
-
-#ifndef GL_ATI_vertex_array_object
-#define GL_ATI_vertex_array_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum);
-GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint);
-GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum);
-GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glFreeObjectBufferATI (GLuint);
-GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint);
-GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint);
-GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage);
-typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer);
-typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve);
-typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer);
-typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
-typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
-typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params);
-#endif
-
-#ifndef GL_EXT_vertex_shader
-#define GL_EXT_vertex_shader 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBeginVertexShaderEXT (void);
-GLAPI void APIENTRY glEndVertexShaderEXT (void);
-GLAPI void APIENTRY glBindVertexShaderEXT (GLuint);
-GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint);
-GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint);
-GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint);
-GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum);
-GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum);
-GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint);
-GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint);
-GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint);
-GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *);
-GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *);
-GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *);
-GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *);
-GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *);
-GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *);
-GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *);
-GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *);
-GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *);
-GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *);
-GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *);
-GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint);
-GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint);
-GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum);
-GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum);
-GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum);
-GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum);
-GLAPI GLuint APIENTRY glBindParameterEXT (GLenum);
-GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum);
-GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *);
-GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *);
-GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *);
-GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *);
-GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void);
-typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void);
-typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id);
-typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range);
-typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1);
-typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2);
-typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);
-typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
-typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
-typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);
-typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);
-typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components);
-typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr);
-typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr);
-typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr);
-typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr);
-typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr);
-typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr);
-typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr);
-typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr);
-typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr);
-typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr);
-typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr);
-typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);
-typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value);
-typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value);
-typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value);
-typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value);
-typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value);
-typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap);
-typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
-typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
-typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
-typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data);
-typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
-typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
-typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
-typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
-typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
-typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
-#endif
-
-#ifndef GL_ATI_vertex_streams
-#define GL_ATI_vertex_streams 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort);
-GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *);
-GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint);
-GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *);
-GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat);
-GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *);
-GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble);
-GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *);
-GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort);
-GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *);
-GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint);
-GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *);
-GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat);
-GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *);
-GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble);
-GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *);
-GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *);
-GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint);
-GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *);
-GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *);
-GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *);
-GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *);
-GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint);
-GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *);
-GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *);
-GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *);
-GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte);
-GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *);
-GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort);
-GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *);
-GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint);
-GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *);
-GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *);
-GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *);
-GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum);
-GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint);
-GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz);
-typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);
-typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream);
-typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param);
-#endif
-
-#ifndef GL_ATI_element_array
-#define GL_ATI_element_array 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *);
-GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei);
-GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count);
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count);
-#endif
-
-#ifndef GL_SUN_mesh_array
-#define GL_SUN_mesh_array 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width);
-#endif
-
-#ifndef GL_SUN_slice_accum
-#define GL_SUN_slice_accum 1
-#endif
-
-#ifndef GL_NV_multisample_filter_hint
-#define GL_NV_multisample_filter_hint 1
-#endif
-
-#ifndef GL_NV_depth_clamp
-#define GL_NV_depth_clamp 1
-#endif
-
-#ifndef GL_NV_occlusion_query
-#define GL_NV_occlusion_query 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *);
-GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *);
-GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint);
-GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint);
-GLAPI void APIENTRY glEndOcclusionQueryNV (void);
-GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *);
-GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids);
-typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids);
-typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id);
-typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void);
-typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params);
-#endif
-
-#ifndef GL_NV_point_sprite
-#define GL_NV_point_sprite 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint);
-GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param);
-typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
-#endif
-
-#ifndef GL_NV_texture_shader3
-#define GL_NV_texture_shader3 1
-#endif
-
-#ifndef GL_NV_vertex_program1_1
-#define GL_NV_vertex_program1_1 1
-#endif
-
-#ifndef GL_EXT_shadow_funcs
-#define GL_EXT_shadow_funcs 1
-#endif
-
-#ifndef GL_EXT_stencil_two_side
-#define GL_EXT_stencil_two_side 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face);
-#endif
-
-#ifndef GL_ATI_text_fragment_shader
-#define GL_ATI_text_fragment_shader 1
-#endif
-
-#ifndef GL_APPLE_client_storage
-#define GL_APPLE_client_storage 1
-#endif
-
-#ifndef GL_APPLE_element_array
-#define GL_APPLE_element_array 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *);
-GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei);
-GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei);
-GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei);
-GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer);
-typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count);
-typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count);
-typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
-typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount);
-#endif
-
-#ifndef GL_APPLE_fence
-#define GL_APPLE_fence 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *);
-GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *);
-GLAPI void APIENTRY glSetFenceAPPLE (GLuint);
-GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint);
-GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint);
-GLAPI void APIENTRY glFinishFenceAPPLE (GLuint);
-GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint);
-GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences);
-typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences);
-typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence);
-typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence);
-typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence);
-typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence);
-typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name);
-typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name);
-#endif
-
-#ifndef GL_APPLE_vertex_array_object
-#define GL_APPLE_vertex_array_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint);
-GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *);
-GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *);
-GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array);
-typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays);
-typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays);
-typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array);
-#endif
-
-#ifndef GL_APPLE_vertex_array_range
-#define GL_APPLE_vertex_array_range 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *);
-GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *);
-GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer);
-typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer);
-typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param);
-#endif
-
-#ifndef GL_APPLE_ycbcr_422
-#define GL_APPLE_ycbcr_422 1
-#endif
-
-#ifndef GL_S3_s3tc
-#define GL_S3_s3tc 1
-#endif
-
-#ifndef GL_ATI_draw_buffers
-#define GL_ATI_draw_buffers 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs);
-#endif
-
-#ifndef GL_ATI_pixel_format_float
-#define GL_ATI_pixel_format_float 1
-/* This is really a WGL extension, but defines some associated GL enums.
- * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string.
- */
-#endif
-
-#ifndef GL_ATI_texture_env_combine3
-#define GL_ATI_texture_env_combine3 1
-#endif
-
-#ifndef GL_ATI_texture_float
-#define GL_ATI_texture_float 1
-#endif
-
-#ifndef GL_NV_float_buffer
-#define GL_NV_float_buffer 1
-#endif
-
-#ifndef GL_NV_fragment_program
-#define GL_NV_fragment_program 1
-/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat);
-GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble);
-GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *);
-GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *);
-GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *);
-GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
-typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
-typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v);
-typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v);
-typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params);
-#endif
-
-#ifndef GL_NV_half_float
-#define GL_NV_half_float 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *);
-GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *);
-GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *);
-GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *);
-GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *);
-GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *);
-GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV);
-GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *);
-GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *);
-GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *);
-GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *);
-GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV);
-GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *);
-GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *);
-GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *);
-GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *);
-GLAPI void APIENTRY glFogCoordhNV (GLhalfNV);
-GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *);
-GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *);
-GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV);
-GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *);
-GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV);
-GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *);
-GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *);
-GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *);
-GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
-GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *);
-GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *);
-GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *);
-GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *);
-GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y);
-typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z);
-typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
-typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);
-typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
-typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);
-typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s);
-typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t);
-typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r);
-typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
-typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
-typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog);
-typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
-typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight);
-typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
-typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
-typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
-#endif
-
-#ifndef GL_NV_pixel_data_range
-#define GL_NV_pixel_data_range 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *);
-GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer);
-typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target);
-#endif
-
-#ifndef GL_NV_primitive_restart
-#define GL_NV_primitive_restart 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glPrimitiveRestartNV (void);
-GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void);
-typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index);
-#endif
-
-#ifndef GL_NV_texture_expand_normal
-#define GL_NV_texture_expand_normal 1
-#endif
-
-#ifndef GL_NV_vertex_program2
-#define GL_NV_vertex_program2 1
-#endif
-
-#ifndef GL_ATI_map_object_buffer
-#define GL_ATI_map_object_buffer 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint);
-GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer);
-typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer);
-#endif
-
-#ifndef GL_ATI_separate_stencil
-#define GL_ATI_separate_stencil 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum);
-GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
-typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
-#endif
-
-#ifndef GL_ATI_vertex_attrib_array_object
-#define GL_ATI_vertex_attrib_array_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint);
-GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *);
-GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params);
-typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params);
-#endif
-
-#ifndef GL_OES_read_format
-#define GL_OES_read_format 1
-#endif
-
-#ifndef GL_EXT_depth_bounds_test
-#define GL_EXT_depth_bounds_test 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax);
-#endif
-
-#ifndef GL_EXT_texture_mirror_clamp
-#define GL_EXT_texture_mirror_clamp 1
-#endif
-
-#ifndef GL_EXT_blend_equation_separate
-#define GL_EXT_blend_equation_separate 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha);
-#endif
-
-#ifndef GL_MESA_pack_invert
-#define GL_MESA_pack_invert 1
-#endif
-
-#ifndef GL_MESA_ycbcr_texture
-#define GL_MESA_ycbcr_texture 1
-#endif
-
-#ifndef GL_EXT_pixel_buffer_object
-#define GL_EXT_pixel_buffer_object 1
-#endif
-
-#ifndef GL_NV_fragment_program_option
-#define GL_NV_fragment_program_option 1
-#endif
-
-#ifndef GL_NV_fragment_program2
-#define GL_NV_fragment_program2 1
-#endif
-
-#ifndef GL_NV_vertex_program2_option
-#define GL_NV_vertex_program2_option 1
-#endif
-
-#ifndef GL_NV_vertex_program3
-#define GL_NV_vertex_program3 1
-#endif
-
-#ifndef GL_EXT_framebuffer_object
-#define GL_EXT_framebuffer_object 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint);
-GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint);
-GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *);
-GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *);
-GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei);
-GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *);
-GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint);
-GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint);
-GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *);
-GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *);
-GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum);
-GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint);
-GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint);
-GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint);
-GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint);
-GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *);
-GLAPI void APIENTRY glGenerateMipmapEXT (GLenum);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer);
-typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer);
-typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers);
-typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers);
-typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
-typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
-typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer);
-typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer);
-typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers);
-typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers);
-typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
-typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
-typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
-typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target);
-#endif
-
-#ifndef GL_GREMEDY_string_marker
-#define GL_GREMEDY_string_marker 1
-#ifdef GL_GLEXT_PROTOTYPES
-GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *);
-#endif /* GL_GLEXT_PROTOTYPES */
-typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string);
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py
deleted file mode 100644
index 8f4065b3d6a..00000000000
--- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/mkglext.py
+++ /dev/null
@@ -1,627 +0,0 @@
-#!/usr/bin/python
-#
-# $Id$
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# 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
-# of the License, or (at your option) any later version.
-#
-# 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,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-#
-# 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.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-#
-# mkglext.py generates code for linking extensions.
-#
-# It reads the glext.h header from stdin and writes code to stdout.
-#
-# Usage: mkglext.py < glext.h > tmp
-# Code can be copied & pasted from tmp to GL_ExtensionManager.cpp.
-#
-# glext.h is available here: http://oss.sgi.com/projects/ogl-sample/ABI/glext.h
-#
-
-from sys import stdin
-import string, re
-
-glext_h = string.split(stdin.read(), '\n')
-
-# These extensions have been incorporated into the core GL or been superceded.
-# Code will not be generated for these extensions
-blacklist = [
- "GL_EXT_multisample",
- "GL_INGR_blend_func_separate",
- "GL_SGIX_fragment_lighting",
- "GL_SGIX_polynomial_ffd",
- "GL_SGIS_point_parameters",
- "GL_EXT_texture_object",
- "GL_EXT_subtexture",
- "GL_EXT_copy_texture",
- "GL_EXT_vertex_array",
- "GL_EXT_point_parameters",
- "GL_EXT_blend_color",
- "GL_EXT_polygon_offset",
- "GL_EXT_texture"]
-
-# Only code for these extensions will be generated. Extensions on both the
-# blacklist & whitelist will not have code generated.
-# This list is from http://oss.sgi.com/projects/ogl-sample/registry/ at 14-Mar-04
-whitelist = [
- # ARB Extensions
- "GL_ARB_multitexture",
- "GLX_ARB_get_proc_address",
- "GL_ARB_transpose_matrix",
- "WGL_ARB_buffer_region",
- "GL_ARB_multisample",
- "GL_ARB_texture_env_add",
- "GL_ARB_texture_cube_map",
- "WGL_ARB_extensions_string",
- "WGL_ARB_pixel_format",
- "WGL_ARB_make_current_read",
- "WGL_ARB_pbuffer",
- "GL_ARB_texture_compression",
- "GL_ARB_texture_border_clamp",
- "GL_ARB_point_parameters",
- "GL_ARB_vertex_blend",
- "GL_ARB_matrix_palette",
- "GL_ARB_texture_env_combine",
- "GL_ARB_texture_env_crossbar",
- "GL_ARB_texture_env_dot3",
- "WGL_ARB_render_texture",
- "GL_ARB_texture_mirrored_repeat",
- "GL_ARB_depth_texture",
- "GL_ARB_shadow",
- "GL_ARB_shadow_ambient",
- "GL_ARB_window_pos",
- "GL_ARB_vertex_program",
- "GL_ARB_fragment_program",
- "GL_ARB_vertex_buffer_object",
- "GL_ARB_occlusion_query",
- "GL_ARB_shader_objects",
- "GL_ARB_vertex_shader",
- "GL_ARB_fragment_shader",
- "GL_ARB_shading_language_100",
- "GL_ARB_texture_non_power_of_two",
- "GL_ARB_point_sprite",
- "GL_ARB_fragment_program_shadow",
-
- # Non ARB Extensions
- "GL_EXT_abgr",
- "GL_EXT_blend_color",
- "GL_EXT_polygon_offset",
- "GL_EXT_texture",
- "GL_EXT_texture3D",
- "GL_SGIS_texture_filter4",
- "GL_EXT_subtexture",
- "GL_EXT_copy_texture",
- "GL_EXT_histogram",
- "GL_EXT_convolution",
- "GL_SGI_color_matrix",
- "GL_SGI_color_table",
- "GL_SGIS_pixel_texture",
- "GL_SGIS_texture4D",
- "GL_SGI_texture_color_table",
- "GL_EXT_cmyka",
- "GL_EXT_texture_object",
- "GL_SGIS_detail_texture",
- "GL_SGIS_sharpen_texture",
- "GL_EXT_packed_pixels",
- "GL_SGIS_texture_lod",
- "GL_SGIS_multisample",
- "GL_EXT_rescale_normal",
- "GLX_EXT_visual_info",
- "GL_EXT_vertex_array",
- "GL_EXT_misc_attribute",
- "GL_SGIS_generate_mipmap",
- "GL_SGIX_clipmap",
- "GL_SGIX_shadow",
- "GL_SGIS_texture_edge_clamp",
- "GL_SGIS_texture_border_clamp",
- "GL_EXT_blend_minmax",
- "GL_EXT_blend_subtract",
- "GL_EXT_blend_logic_op",
- "GLX_SGI_swap_control",
- "GLX_SGI_video_sync",
- "GLX_SGI_make_current_read",
- "GLX_SGIX_video_source",
- "GLX_EXT_visual_rating",
- "GL_SGIX_interlace",
- "GLX_EXT_import_context",
- "GLX_SGIX_fbconfig",
- "GLX_SGIX_pbuffer",
- "GL_SGIS_texture_select",
- "GL_SGIX_sprite",
- "GL_SGIX_texture_multi_buffer",
- "GL_EXT_point_parameters",
- "GL_SGIX_instruments",
- "GL_SGIX_texture_scale_bias",
- "GL_SGIX_framezoom",
- "GL_SGIX_tag_sample_buffer",
- "GL_SGIX_reference_plane",
- "GL_SGIX_flush_raster",
- "GLX_SGI_cushion",
- "GL_SGIX_depth_texture",
- "GL_SGIS_fog_function",
- "GL_SGIX_fog_offset",
- "GL_HP_image_transform",
- "GL_HP_convolution_border_modes",
- "GL_SGIX_texture_add_env",
- "GL_EXT_color_subtable",
- "GLU_EXT_object_space_tess",
- "GL_PGI_vertex_hints",
- "GL_PGI_misc_hints",
- "GL_EXT_paletted_texture",
- "GL_EXT_clip_volume_hint",
- "GL_SGIX_list_priority",
- "GL_SGIX_ir_instrument1",
- "GLX_SGIX_video_resize",
- "GL_SGIX_texture_lod_bias",
- "GLU_SGI_filter4_parameters",
- "GLX_SGIX_dm_buffer",
- "GL_SGIX_shadow_ambient",
- "GLX_SGIX_swap_group",
- "GLX_SGIX_swap_barrier",
- "GL_EXT_index_texture",
- "GL_EXT_index_material",
- "GL_EXT_index_func",
- "GL_EXT_index_array_formats",
- "GL_EXT_compiled_vertex_array",
- "GL_EXT_cull_vertex",
- "GLU_EXT_nurbs_tessellator",
- "GL_SGIX_ycrcb",
- "GL_EXT_fragment_lighting",
- "GL_IBM_rasterpos_clip",
- "GL_HP_texture_lighting",
- "GL_EXT_draw_range_elements",
- "GL_WIN_phong_shading",
- "GL_WIN_specular_fog",
- "GLX_SGIS_color_range",
- "GL_EXT_light_texture",
- "GL_SGIX_blend_alpha_minmax",
- "GL_EXT_scene_marker",
- "GL_SGIX_pixel_texture_bits",
- "GL_EXT_bgra",
- "GL_SGIX_async",
- "GL_SGIX_async_pixel",
- "GL_SGIX_async_histogram",
- "GL_INTEL_texture_scissor",
- "GL_INTEL_parallel_arrays",
- "GL_HP_occlusion_test",
- "GL_EXT_pixel_transform",
- "GL_EXT_pixel_transform_color_table",
- "GL_EXT_shared_texture_palette",
- "GLX_SGIS_blended_overlay",
- "GL_EXT_separate_specular_color",
- "GL_EXT_secondary_color",
- "GL_EXT_texture_env",
- "GL_EXT_texture_perturb_normal",
- "GL_EXT_multi_draw_arrays",
- "GL_EXT_fog_coord",
- "GL_REND_screen_coordinates",
- "GL_EXT_coordinate_frame",
- "GL_EXT_texture_env_combine",
- "GL_APPLE_specular_vector",
- "GL_SGIX_pixel_texture",
- "GL_APPLE_transform_hint",
- "GL_SUNX_constant_data",
- "GL_SUN_global_alpha",
- "GL_SUN_triangle_list",
- "GL_SUN_vertex",
- "WGL_EXT_display_color_table",
- "WGL_EXT_extensions_string",
- "WGL_EXT_make_current_read",
- "WGL_EXT_pixel_format",
- "WGL_EXT_pbuffer",
- "WGL_EXT_swap_control",
- "GL_EXT_blend_func_separate",
- "GL_INGR_color_clamp",
- "GL_INGR_interlace_read",
- "GL_EXT_stencil_wrap",
- "WGL_EXT_depth_float",
- "GL_EXT_422_pixels",
- "GL_NV_texgen_reflection",
- "GL_SGIX_texture_range",
- "GL_SUN_convolution_border_modes",
- "GLX_SUN_get_transparent_index",
- "GL_EXT_texture_env_add",
- "GL_EXT_texture_lod_bias",
- "GL_EXT_texture_filter_anisotropic",
- "GL_EXT_vertex_weighting",
- "GL_NV_light_max_exponent",
- "GL_NV_vertex_array_range",
- "GL_NV_register_combiners",
- "GL_NV_fog_distance",
- "GL_NV_texgen_emboss",
- "GL_NV_blend_square",
- "GL_NV_texture_env_combine4",
- "GL_MESA_resize_buffers",
- "GL_MESA_window_pos",
- "GL_EXT_texture_compression_s3tc",
- "GL_IBM_cull_vertex",
- "GL_IBM_multimode_draw_arrays",
- "GL_IBM_vertex_array_lists",
- "GL_3DFX_texture_compression_FXT1",
- "GL_3DFX_multisample",
- "GL_3DFX_tbuffer",
- "WGL_EXT_multisample",
- "GL_SGIX_vertex_preclip",
- "GL_SGIX_resample",
- "GL_SGIS_texture_color_mask",
- "GLX_MESA_copy_sub_buffer",
- "GLX_MESA_pixmap_colormap",
- "GLX_MESA_release_buffers",
- "GLX_MESA_set_3dfx_mode",
- "GL_EXT_texture_env_dot3",
- "GL_ATI_texture_mirror_once",
- "GL_NV_fence",
- "GL_IBM_static_data",
- "GL_IBM_texture_mirrored_repeat",
- "GL_NV_evaluators",
- "GL_NV_packed_depth_stencil",
- "GL_NV_register_combiners2",
- "GL_NV_texture_compression_vtc",
- "GL_NV_texture_rectangle",
- "GL_NV_texture_shader",
- "GL_NV_texture_shader2",
- "GL_NV_vertex_array_range2",
- "GL_NV_vertex_program",
- "GLX_SGIX_visual_select_group",
- "GL_SGIX_texture_coordinate_clamp",
- "GLX_OML_swap_method",
- "GLX_OML_sync_control",
- "GL_OML_interlace",
- "GL_OML_subsample",
- "GL_OML_resample",
- "WGL_OML_sync_control",
- "GL_NV_copy_depth_to_color",
- "GL_ATI_envmap_bumpmap",
- "GL_ATI_fragment_shader",
- "GL_ATI_pn_triangles",
- "GL_ATI_vertex_array_object",
- "GL_EXT_vertex_shader",
- "GL_ATI_vertex_streams",
- "WGL_I3D_digital_video_control",
- "WGL_I3D_gamma",
- "WGL_I3D_genlock",
- "WGL_I3D_image_buffer",
- "WGL_I3D_swap_frame_lock",
- "WGL_I3D_swap_frame_usage",
- "GL_ATI_element_array",
- "GL_SUN_mesh_array",
- "GL_SUN_slice_accum",
- "GL_NV_multisample_filter_hint",
- "GL_NV_depth_clamp",
- "GL_NV_occlusion_query",
- "GL_NV_point_sprite",
- "WGL_NV_render_depth_texture",
- "WGL_NV_render_texture_rectangle",
- "GL_NV_texture_shader3",
- "GL_NV_vertex_program1_1",
- "GL_EXT_shadow_funcs",
- "GL_EXT_stencil_two_side",
- "GL_ATI_text_fragment_shader",
- "GL_APPLE_client_storage",
- "GL_APPLE_element_array",
- "GL_APPLE_fence",
- "GL_APPLE_vertex_array_object",
- "GL_APPLE_vertex_array_range",
- "GL_APPLE_ycbcr_422",
- "GL_S3_s3tc",
- "GL_ATI_draw_buffers",
- "WGL_ATI_pixel_format_float",
- "GL_ATI_texture_env_combine3",
- "GL_ATI_texture_float",
- "GL_NV_float_buffer",
- "GL_NV_fragment_program",
- "GL_NV_half_float",
- "GL_NV_pixel_data_range",
- "GL_NV_primitive_restart",
- "GL_NV_texture_expand_normal",
- "GL_NV_vertex_program2",
- "GL_ATI_map_object_buffer",
- "GL_ATI_separate_stencil",
- "GL_ATI_vertex_attrib_array_object",
- "GL_OES_byte_coordinates",
- "GL_OES_fixed_point",
- "GL_OES_single_precision",
- "GL_OES_compressed_paletted_texture",
- "GL_OES_read_format",
- "GL_OES_query_matrix",
- "GL_EXT_depth_bounds_test",
- "GL_EXT_texture_mirror_clamp",
- "GL_EXT_blend_equation_separate",
- "GL_MESA_pack_invert",
- "GL_MESA_ycbcr_texture"]
-
-"""
-Example code output:
-#ifdef GL_EXT_compiled_vertex_array
- if (QueryExtension("GL_EXT_compiled_vertex_array"))
- {
- glUnlockArraysEXT = reinterpret_cast<PFNGLUNLOCKARRAYSEXTPROC>(bglGetProcAddress((const GLubyte *) "glUnlockArraysEXT"));
- glLockArraysEXT = reinterpret_cast<PFNGLLOCKARRAYSEXTPROC>(bglGetProcAddress((const GLubyte *) "glLockArraysEXT"));
- if (glUnlockArraysEXT && glLockArraysEXT)
- {
- EnableExtension(_GL_EXT_compiled_vertex_array);
- if (doDebugMessages)
- std::cout << "Detected GL_EXT_compiled_vertex_array" << std::endl;
- } else {
- std::cout << "ERROR: GL_EXT_compiled_vertex_array implementation is broken!" << std::endl;
- }
- }
-#endif
-"""
-def writeext(ext, fnlist):
- if (find(blacklist, ext)):
- return
- if (len(fnlist) == 0):
- # This extension has no functions to detect - don't need to wrap in
- # #ifdef GL_extension names
- print "\tif (QueryExtension(\"" + ext + "\"))"
- print "\t{"
- print "\t\tEnableExtension(_" + ext + ");"
- print "\t\tif (doDebugMessages)"
- print "\t\t\tstd::cout << \"Detected " + ext + "\" << std::endl;"
- print "\t}"
- print
- return
- print "#if defined(" + ext + ")"
- print "\tif (QueryExtension(\"" + ext + "\"))"
- print "\t{"
- for fn in fnlist:
- print "\t\t" + fn[0] + " = reinterpret_cast<" + fn[1] + ">(bglGetProcAddress((const GLubyte *) \"" + fn[0] + "\"));"
- errcheck = ""
- for fn in fnlist:
- if (errcheck == ""):
- errcheck = fn[0]
- else:
- errcheck = errcheck + " && " + fn[0]
- print "\t\tif (" + errcheck + ") {"
- print "\t\t\tEnableExtension(_" + ext + ");"
- print "\t\t\tif (doDebugMessages)"
- print "\t\t\t\tstd::cout << \"Enabled " + ext + "\" << std::endl;"
- print "\t\t} else {"
- print "\t\t\tstd::cout << \"ERROR: " + ext + " implementation is broken!\" << std::endl;"
- print "\t\t}"
- print "\t}"
- print "#endif"
- print
-
-"""
-Example Output:
-#if defined(GL_EXT_compiled_vertex_array)
-PFNGLLOCKARRAYSEXTPROC glLockArraysEXT;
-PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT;
-#endif
-"""
-def writeproto(ext, fnlist):
- if (find(blacklist, ext) or not find(whitelist, ext)):
- return
- print "#if defined(" + ext + ")"
- for fn in fnlist:
- print fn[1] + " " + fn[0] + ";"
- print "#endif"
- print
-
-"""
-#ifdef GL_EXT_compiled_vertex_array
-extern PFNGLLOCKARRAYSEXTPROC glLockArraysEXT;
-extern PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT;
-#endif
-"""
-def writeheader(ext, fnlisti):
- if (find(blacklist, ext) or not find(whitelist, ext)):
- return
- print "#if defined(" + ext + ")"
- for fn in fnlist:
- print "extern " + fn[1] + " " + fn[0] + ";"
- print "#endif"
- print
-
-def find(l, x):
- for i in l:
- if (i == x):
- return 1
- return 0
-
-
-# Write Prototypes
-ext = ""
-fns = []
-fnlist = []
-ifdef = 0
-for i in glext_h:
- line = re.search('^#ifn?def', i)
- if (line):
- ifdef = ifdef + 1
-
- line = re.search('^#ifndef (GL_.*)', i)
- if (line):
- if (not re.search('GL_VERSION.*', line.group(1)) and find(whitelist, line.group(1))):
- ext = line.group(1)
-
- line = re.search('^#endif', i)
- if (line):
- ifdef = ifdef - 1
- if (ifdef == 0 and ext != ""):
- writeproto(ext, fnlist)
- ext = ""
- fns = []
- fnlist = []
- if (ext != ""):
- line = re.search('.* (gl.*) \(.*\);', i)
- if (line):
- fns += [line.group(1)]
- line = re.search('.*PFN(.*)PROC.*', i)
- if (line):
- for j in fns:
- if (string.lower(line.group(1)) == string.lower(j)):
- fnlist += [(j, "PFN" + line.group(1) + "PROC")]
-
-# Write link code
-ext = ""
-fns = []
-fnlist = []
-ifdef = 0
-for i in glext_h:
- line = re.search('^#ifn?def', i)
- if (line):
- ifdef = ifdef + 1
-
- line = re.search('^#ifndef (GL_.*)', i)
- if (line):
- if (not re.search('GL_VERSION.*', line.group(1)) and find(whitelist, line.group(1))):
- ext = line.group(1)
-
- line = re.search('^#endif', i)
- if (line):
- ifdef = ifdef - 1
- if (ifdef == 0 and ext != ""):
- writeext(ext, fnlist)
- ext = ""
- fns = []
- fnlist = []
- if (ext != ""):
- line = re.search('.* (gl.*) \(.*\);', i)
- if (line):
- fns += [line.group(1)]
- line = re.search('.*PFN(.*)PROC.*', i)
- if (line):
- for j in fns:
- if (string.lower(line.group(1)) == string.lower(j)):
- fnlist += [(j, "PFN" + line.group(1) + "PROC")]
-
-# Write header code
-ext = ""
-fns = []
-fnlist = []
-ifdef = 0
-for i in glext_h:
- line = re.search('^#ifn?def', i)
- if (line):
- ifdef = ifdef + 1
-
- line = re.search('^#ifndef (GL_.*)', i)
- if (line):
- if (not re.search('GL_VERSION.*', line.group(1)) and find(whitelist, line.group(1))):
- ext = line.group(1)
-
- line = re.search('^#endif', i)
- if (line):
- ifdef = ifdef - 1
- if (ifdef == 0 and ext != ""):
- writeheader(ext, fnlist)
- ext = ""
- fns = []
- fnlist = []
- if (ext != ""):
- line = re.search('.* (gl.*) \(.*\);', i)
- if (line):
- fns += [line.group(1)]
- line = re.search('.*PFN(.*)PROC.*', i)
- if (line):
- for j in fns:
- if (string.lower(line.group(1)) == string.lower(j)):
- fnlist += [(j, "PFN" + line.group(1) + "PROC")]
-
-# Write Python link code
-ext = ""
-extensions = []
-fns = []
-defines = []
-ifdef = 0
-for i in glext_h:
- line = re.search('^#ifn?def', i)
- if (line):
- ifdef = ifdef + 1
-
- line = re.search('^#ifndef (GL_.*)', i)
- if (line):
- if (not re.search('GL_VERSION.*', line.group(1)) and find(whitelist, line.group(1))):
- ext = line.group(1)
-
- line = re.search('^#endif', i)
- if (line):
- ifdef = ifdef - 1
- if (ifdef == 0 and ext != ""):
- done = 0
- for e in range(len(extensions)):
- if extensions[e][0] == ext:
- extensions[e] = (ext, defines + extensions[e][1], fns + extensions[e][2])
- done = 1
- if not done:
- extensions = extensions + [(ext, defines, fns)]
- ext = ""
- fns = []
- defines = []
- if (ext != ""):
- line = re.search('#define +(GL.*) +(0x.*)', i) # #define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
- if (line):
- defines += [(line.group(1), line.group(2))]
-
- line = re.search('(.* )(gl.*)(\(.*\));', i) # GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat);
- if (line):
- fns += [(line.group(1), line.group(2), line.group(3))]
-
-for ext in extensions:
- if (find(blacklist, ext[0]) or not find(whitelist, ext[0])):
- continue
- print "#if defined(" + ext[0] + ")"
- for fn in ext[2]:
- line = re.search('gl(.*)', fn[1])
- # BGL_Wrap(2, RasterPos2f, void, (GLfloat, GLfloat))
- rtype = ""
- for r in string.split(fn[0]):
- if r != "GLAPI" and r != "APIENTRY":
- rtype = rtype + " " + r
- params = ""
- for p in string.split(fn[2], ','):
- pline = re.search('(.*) \*', p)
- if (pline):
- p = pline.group(1) + "P"
- if params == "":
- params = p
- else:
- params = params + "," + p
- if not params[-1] == ")":
- params = params + ")"
- print "BGL_Wrap(" + str(len(string.split(fn[2], ','))) + ", " + line.group(1) + ",\t" + rtype + ",\t" + params + ")"
- print "#endif"
- print
-
-for ext in extensions:
- if (find(blacklist, ext[0]) or not find(whitelist, ext[0])):
- continue
- print 'PyDict_SetItemString(dict, "' + ext[0] + '", PyInt_FromLong(_' + ext[0] + '))'
- print "#if defined(" + ext[0] + ")"
- print "if (bglQueryExtension(_" + ext[0] + ")) {"
- if len(ext[2]) > 0:
- for fn in ext[2]:
- line = re.search('gl(.*)', fn[1])
- # MethodDef(Vertex3iv),
- print " BGL_AddMethod(" + line.group(1) + ");"
- print
-
- for define in ext[1]:
- print " BGL_AddConst(" + define[0] + ");"
- print
-
- print "}"
- print "#endif"
- print
diff --git a/source/gameengine/Rasterizer/RAS_Polygon.cpp b/source/gameengine/Rasterizer/RAS_Polygon.cpp
index 852c94def3f..50331d7a664 100644
--- a/source/gameengine/Rasterizer/RAS_Polygon.cpp
+++ b/source/gameengine/Rasterizer/RAS_Polygon.cpp
@@ -26,117 +26,82 @@
* ***** END GPL LICENSE BLOCK *****
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#ifdef WIN32
-
#pragma warning (disable:4786)
#endif
#include "RAS_Polygon.h"
-/*
-RAS_TexVert* RAS_Polygon::GetVertex(int index)
-{
- if (m_bucket)
- return m_bucket->GetVertex(m_vertexindexbase.m_vtxarray, m_vertexindexbase.m_indexarray[index]);
- else
- return NULL;
-}
-*/
-
-/*void RAS_Polygon::Bucketize(double* oglmatrix)
+RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray *darray, int numvert)
{
- //Transform(trans);
- if (m_bucket)
- m_bucket->AddPolygon(this,oglmatrix);
-}
-*/
-
-RAS_Polygon::RAS_Polygon(RAS_MaterialBucket* bucket,
- bool visible,
- int numverts,
- int vtxarrayindex)
- :m_bucket(bucket),
- m_vertexindexbase(numverts),
- m_numverts(numverts),
- m_edgecode(65535)
-{
- m_vertexindexbase.m_vtxarray = vtxarrayindex ;//m_bucket->FindVertexArray(numverts);
- m_polyFlags.Visible = visible;
-}
-
+ m_bucket = bucket;
+ m_darray = darray;
+ m_offset[0]= m_offset[1]= m_offset[2]= m_offset[3]= 0;
+ m_numvert = numvert;
+ m_edgecode = 255;
+ m_polyflags = 0;
+}
int RAS_Polygon::VertexCount()
{
- return m_numverts;
+ return m_numvert;
}
-
-
-void RAS_Polygon::SetVertex(int i,
- unsigned int vertexindex ) //const MT_Point3& xyz,const MT_Point2& uv,const unsigned int rgbacolor,const MT_Vector3& normal)
+void RAS_Polygon::SetVertexOffset(int i, unsigned short offset)
{
- m_vertexindexbase.SetIndex(i,vertexindex); //m_bucket->FindOrAddVertex(m_vertexindexbase.m_vtxarray,
- //xyz,uv,rgbacolor,normal));
+ m_offset[i] = offset;
}
-
-
-const KX_VertexIndex& RAS_Polygon::GetIndexBase()
+RAS_TexVert *RAS_Polygon::GetVertex(int i)
{
- return m_vertexindexbase;
+ return &m_darray->m_vertex[m_offset[i]];
}
-
-
-void RAS_Polygon::SetVisibleWireframeEdges(int edgecode)
+int RAS_Polygon::GetVertexOffset(int i)
{
- m_edgecode = edgecode;
+ return m_offset[i];
}
-
-
-// each bit is for a visible edge, starting with bit 1 for the first edge, bit 2 for second etc.
int RAS_Polygon::GetEdgeCode()
{
return m_edgecode;
}
+void RAS_Polygon::SetEdgeCode(int edgecode)
+{
+ m_edgecode = edgecode;
+}
bool RAS_Polygon::IsVisible()
{
- return m_polyFlags.Visible;
+ return (m_polyflags & VISIBLE) != 0;
}
-
+void RAS_Polygon::SetVisible(bool visible)
+{
+ if(visible) m_polyflags |= VISIBLE;
+ else m_polyflags &= ~VISIBLE;
+}
bool RAS_Polygon::IsCollider()
{
- return m_polyFlags.Collider;
+ return (m_polyflags & COLLIDER) != 0;
}
-
-
-void RAS_Polygon::SetCollider(bool col)
+void RAS_Polygon::SetCollider(bool visible)
{
- m_polyFlags.Collider = col;
+ if(visible) m_polyflags |= COLLIDER;
+ else m_polyflags &= ~COLLIDER;
}
-
-
-KX_VertexIndex& RAS_Polygon::GetVertexIndexBase()
+RAS_MaterialBucket* RAS_Polygon::GetMaterial()
{
- return m_vertexindexbase;
+ return m_bucket;
}
-
-
-RAS_MaterialBucket* RAS_Polygon::GetMaterial()
+RAS_DisplayArray* RAS_Polygon::GetDisplayArray()
{
- return m_bucket;
+ return m_darray;
}
diff --git a/source/gameengine/Rasterizer/RAS_Polygon.h b/source/gameengine/Rasterizer/RAS_Polygon.h
index 7ce7926a816..18526ba45f7 100644
--- a/source/gameengine/Rasterizer/RAS_Polygon.h
+++ b/source/gameengine/Rasterizer/RAS_Polygon.h
@@ -35,55 +35,47 @@
#include <vector>
using namespace std;
-
-//
-// Bitfield that stores the flags for each CValue derived class
-//
-struct PolygonFlags {
- PolygonFlags() :
- Visible(true),
- Collider(true)
- {
- }
- unsigned char Visible : 1;
- unsigned char Collider : 1;
- //int Visible : 1;
- //int Collider : 1;
-};
+/* polygon flags */
class RAS_Polygon
{
+ /* location */
RAS_MaterialBucket* m_bucket;
- KX_VertexIndex m_vertexindexbase;
- int m_numverts;
- int m_edgecode;
- PolygonFlags m_polyFlags;
-
+ RAS_DisplayArray* m_darray;
+ unsigned short m_offset[4];
+ unsigned short m_numvert;
+
+ /* flags */
+ unsigned char m_edgecode;
+ unsigned char m_polyflags;
public:
- RAS_Polygon(RAS_MaterialBucket* bucket,
- bool visible,
- int numverts,
- int vtxarrayindex) ;
+ enum {
+ VISIBLE = 1,
+ COLLIDER = 2
+ };
+
+ RAS_Polygon(RAS_MaterialBucket* bucket, RAS_DisplayArray* darray, int numvert);
virtual ~RAS_Polygon() {};
-// RAS_TexVert* GetVertex(int index);
int VertexCount();
- void SetVertex(int i, unsigned int vertexindex); //const MT_Point3& xyz,const MT_Point2& uv,const unsigned int rgbacolor,const MT_Vector3& normal)
-
- const KX_VertexIndex& GetIndexBase();
+ RAS_TexVert* GetVertex(int i);
- void SetVisibleWireframeEdges(int edgecode);
+ void SetVertexOffset(int i, unsigned short offset);
+ int GetVertexOffset(int i);
+
// each bit is for a visible edge, starting with bit 1 for the first edge, bit 2 for second etc.
int GetEdgeCode();
+ void SetEdgeCode(int edgecode);
bool IsVisible();
+ void SetVisible(bool visible);
+
bool IsCollider();
- void SetCollider(bool col);
+ void SetCollider(bool collider);
- KX_VertexIndex& GetVertexIndexBase();
RAS_MaterialBucket* GetMaterial();
-
+ RAS_DisplayArray* GetDisplayArray();
};
#endif
diff --git a/source/gameengine/Rasterizer/RAS_TexVert.cpp b/source/gameengine/Rasterizer/RAS_TexVert.cpp
index 61ac456b2bc..b92965ed1cc 100644
--- a/source/gameengine/Rasterizer/RAS_TexVert.cpp
+++ b/source/gameengine/Rasterizer/RAS_TexVert.cpp
@@ -27,12 +27,7 @@
*/
#include "RAS_TexVert.h"
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#define SHORT(x) short(x*32767.0)
+#include "MT_Matrix4x4.h"
RAS_TexVert::RAS_TexVert(const MT_Point3& xyz,
const MT_Point2& uv,
@@ -40,7 +35,8 @@ RAS_TexVert::RAS_TexVert(const MT_Point3& xyz,
const MT_Vector4& tangent,
const unsigned int rgba,
const MT_Vector3& normal,
- const short flag)
+ const bool flat,
+ const unsigned int origindex)
{
xyz.getValue(m_localxyz);
uv.getValue(m_uv1);
@@ -48,8 +44,10 @@ RAS_TexVert::RAS_TexVert(const MT_Point3& xyz,
SetRGBA(rgba);
SetNormal(normal);
tangent.getValue(m_tangent);
- m_flag = flag;
+ m_flag = (flat)? FLAT: 0;
+ m_origindex = origindex;
m_unit = 2;
+ m_softBodyIndex = -1;
}
const MT_Point3& RAS_TexVert::xyz()
@@ -99,7 +97,7 @@ void RAS_TexVert::SetFlag(const short flag)
void RAS_TexVert::SetUnit(const unsigned int u)
{
- m_unit = u<=TV_MAX?u:TV_MAX;
+ m_unit = u<=MAX_UNIT?u:MAX_UNIT;
}
void RAS_TexVert::SetNormal(const MT_Vector3& normal)
@@ -107,50 +105,18 @@ void RAS_TexVert::SetNormal(const MT_Vector3& normal)
normal.getValue(m_normal);
}
-#ifndef RAS_TexVert_INLINE
-
-// leave multiline for debugging
-const float* RAS_TexVert::getUV1 () const
-{
- return m_uv1;
-}
-
-const float* RAS_TexVert::getUV2 () const
-{
- return m_uv2;
-}
-
-
-
-const float* RAS_TexVert::getNormal() const
-{
- return m_normal;
-}
-
-const float* RAS_TexVert::getTangent() const
+void RAS_TexVert::SetTangent(const MT_Vector3& tangent)
{
- return m_tangent;
-}
-
-
-const float* RAS_TexVert::getLocalXYZ() const
-{
- return m_localxyz;
-}
-
-const unsigned char* RAS_TexVert::getRGBA() const
-{
- return (unsigned char*) &m_rgba;
+ tangent.getValue(m_tangent);
}
-#endif
-
// compare two vertices, and return TRUE if both are almost identical (they can be shared)
bool RAS_TexVert::closeTo(const RAS_TexVert* other)
{
return (m_flag == other->m_flag &&
m_rgba == other->m_rgba &&
MT_fuzzyEqual(MT_Vector3(m_normal), MT_Vector3(other->m_normal)) &&
+ MT_fuzzyEqual(MT_Vector3(m_tangent), MT_Vector3(other->m_tangent)) &&
MT_fuzzyEqual(MT_Vector2(m_uv1), MT_Vector2(other->m_uv1)) &&
MT_fuzzyEqual(MT_Vector2(m_uv2), MT_Vector2(other->m_uv2)) && // p --
MT_fuzzyEqual(MT_Vector3(m_localxyz), MT_Vector3(other->m_localxyz))) ;
@@ -167,11 +133,10 @@ unsigned int RAS_TexVert::getUnit() const
return m_unit;
}
-
-void RAS_TexVert::getOffsets(void* &xyz, void* &uv1, void* &rgba, void* &normal) const
+void RAS_TexVert::Transform(const MT_Matrix4x4& mat, const MT_Matrix4x4& nmat)
{
- xyz = (void *) m_localxyz;
- uv1 = (void *) m_uv1;
- rgba = (void *) &m_rgba;
- normal = (void *) m_normal;
+ SetXYZ((mat*MT_Vector4(m_localxyz[0], m_localxyz[1], m_localxyz[2], 1.0)).getValue());
+ SetNormal((nmat*MT_Vector4(m_normal[0], m_normal[1], m_normal[2], 1.0)).getValue());
+ SetTangent((nmat*MT_Vector4(m_tangent[0], m_tangent[1], m_tangent[2], 1.0)).getValue());
}
+
diff --git a/source/gameengine/Rasterizer/RAS_TexVert.h b/source/gameengine/Rasterizer/RAS_TexVert.h
index 84135db918f..54da109cbf1 100644
--- a/source/gameengine/Rasterizer/RAS_TexVert.h
+++ b/source/gameengine/Rasterizer/RAS_TexVert.h
@@ -37,13 +37,6 @@
static MT_Point3 g_pt3;
static MT_Point2 g_pt2;
-#define TV_CALCFACENORMAL 0x0001
-#define TV_2NDUV 0x0002
-
-#define TV_MAX 3//match Def in BL_Material.h
-
-#define RAS_TexVert_INLINE 1
-
class RAS_TexVert
{
@@ -51,15 +44,23 @@ class RAS_TexVert
float m_uv1[2]; // 2*4 = 8
float m_uv2[2]; // 2*4 = 8
unsigned int m_rgba; // 4
- float m_tangent[4]; // 4*2 = 8
- float m_normal[3]; // 3*2 = 6
+ float m_tangent[4]; // 4*4 = 16
+ float m_normal[3]; // 3*4 = 12
short m_flag; // 2
+ short m_softBodyIndex; //2
unsigned int m_unit; // 4
+ unsigned int m_origindex; // 4
//---------
- // 52
- //32 bytes total size, fits nice = 52 = not fit nice.
- // We'll go for 64 bytes total size - 24 bytes left.
+ // 56+6+8+2=72
+ // 32 bytes total size, fits nice = 56 = not fit nice.
+
public:
+ enum {
+ FLAT = 1,
+ SECOND_UV = 2,
+ MAX_UNIT = 8
+ };
+
short getFlag() const;
unsigned int getUnit() const;
@@ -71,11 +72,10 @@ public:
const MT_Vector4& tangent,
const unsigned int rgba,
const MT_Vector3& normal,
- const short flag);
+ const bool flat,
+ const unsigned int origindex);
~RAS_TexVert() {};
- // leave multiline for debugging
-#ifdef RAS_TexVert_INLINE
const float* getUV1 () const {
return m_uv1;
};
@@ -84,7 +84,7 @@ public:
return m_uv2;
};
- const float* getLocalXYZ() const {
+ const float* getXYZ() const {
return m_localxyz;
};
@@ -92,6 +92,16 @@ public:
return m_normal;
}
+ short int getSoftBodyIndex() const
+ {
+ return m_softBodyIndex;
+ }
+
+ void setSoftBodyIndex(short int sbIndex)
+ {
+ m_softBodyIndex = sbIndex;
+ }
+
const float* getTangent() const {
return m_tangent;
}
@@ -99,33 +109,30 @@ public:
const unsigned char* getRGBA() const {
return (unsigned char *) &m_rgba;
}
-#else
- const float* getUV1 () const;
- const float* getUV2 () const;
- const float* getNormal() const;
- const float* getLocalXYZ() const;
- const unsigned char* getRGBA() const;
-#endif
+
+ const unsigned int getOrigIndex() const {
+ return m_origindex;
+ }
+
void SetXYZ(const MT_Point3& xyz);
void SetUV(const MT_Point2& uv);
void SetUV2(const MT_Point2& uv);
void SetRGBA(const unsigned int rgba);
void SetNormal(const MT_Vector3& normal);
+ void SetTangent(const MT_Vector3& tangent);
void SetFlag(const short flag);
void SetUnit(const unsigned u);
void SetRGBA(const MT_Vector4& rgba);
const MT_Point3& xyz();
- // compare two vertices, and return TRUE if both are almost identical (they can be shared)
- bool closeTo(const RAS_TexVert* other);
+ void Transform(const class MT_Matrix4x4& mat,
+ const class MT_Matrix4x4& nmat);
- bool closeTo(const MT_Point3& otherxyz,
- const MT_Point2& otheruv,
- const unsigned int otherrgba,
- short othernormal[3]) const;
- void getOffsets(void*&xyz, void *&uv1, void *&rgba, void *&normal) const;
+ // compare two vertices, to test if they can be shared, used for
+ // splitting up based on uv's, colors, etc
+ bool closeTo(const RAS_TexVert* other);
};
#endif //__RAS_TEXVERT
diff --git a/source/gameengine/Rasterizer/SConscript b/source/gameengine/Rasterizer/SConscript
index 62325bc80a9..a024f7e0ee6 100644
--- a/source/gameengine/Rasterizer/SConscript
+++ b/source/gameengine/Rasterizer/SConscript
@@ -3,11 +3,13 @@ Import ('env')
sources = env.Glob('*.cpp')
-incs = '. #source/kernel/gen_system #intern/string #intern/moto/include'
+
+incs = '. #source/kernel/gen_system #intern/string #intern/moto/include #source/gameengine/BlenderRoutines #extern/glew/include #source/gameengine/Expressions #source/blender/blenkernel #source/blender/makesdna'
+incs += ' ' + env['BF_PYTHON_INC']
if env['OURPLATFORM']=='win32-vc':
cflags = []
cflags.append('/Ox')
- env.BlenderLib ( 'bf_rasterizer', sources, Split(incs), [], libtype=['game','player'], priority=[35,110], compileflags = cflags )
+ env.BlenderLib ( 'bf_rasterizer', sources, Split(incs), [], libtype=['game','player'], priority=[35,115], compileflags = cflags )
else:
- env.BlenderLib ( 'bf_rasterizer', sources, Split(incs), [], libtype=['game','player'], priority=[35,110] )
+ env.BlenderLib ( 'bf_rasterizer', sources, Split(incs), [], libtype=['game','player'], priority=[35,115] )
diff --git a/source/gameengine/SConscript b/source/gameengine/SConscript
index 3578e74ea55..e841f206eee 100644
--- a/source/gameengine/SConscript
+++ b/source/gameengine/SConscript
@@ -2,26 +2,27 @@
Import ('env')
SConscript(['BlenderRoutines/SConscript',
- 'Converter/SConscript',
- 'Expressions/SConscript',
- 'GameLogic/SConscript',
- 'Ketsji/SConscript',
- 'Ketsji/KXNetwork/SConscript',
- 'Network/SConscript',
- 'Network/LoopBackNetwork/SConscript',
- 'Physics/common/SConscript',
- 'Physics/Dummy/SConscript',
- 'Rasterizer/SConscript',
- 'Rasterizer/RAS_OpenGLRasterizer/SConscript',
- 'SceneGraph/SConscript',
- 'Physics/Bullet/SConscript',
- 'Physics/Sumo/SConscript'
- ])
+ 'Converter/SConscript',
+ 'Expressions/SConscript',
+ 'GameLogic/SConscript',
+ 'Ketsji/SConscript',
+ 'Ketsji/KXNetwork/SConscript',
+ 'Network/SConscript',
+ 'Network/LoopBackNetwork/SConscript',
+ 'Physics/common/SConscript',
+ 'Physics/Dummy/SConscript',
+ 'Rasterizer/SConscript',
+ 'Rasterizer/RAS_OpenGLRasterizer/SConscript',
+ 'SceneGraph/SConscript',
+ 'Physics/Bullet/SConscript',
+ 'Physics/Sumo/SConscript',
+ 'VideoTexture/SConscript'
+ ])
if env['WITH_BF_PLAYER']:
- SConscript(['GamePlayer/SConscript'])
+ SConscript(['GamePlayer/SConscript'])
#if user_options_dict['USE_PHYSICS'] == 'solid':
-# SConscript(['Physics/Sumo/SConscript'])
+# SConscript(['Physics/Sumo/SConscript'])
#elif user_options_dict['USE_PHYSICS'] == 'ode':
-# SConscript(['Physics/BlOde/SConscript'])
+# SConscript(['Physics/BlOde/SConscript'])
diff --git a/source/gameengine/SceneGraph/SG_Controller.h b/source/gameengine/SceneGraph/SG_Controller.h
index d65a2f0c256..c32885b915f 100644
--- a/source/gameengine/SceneGraph/SG_Controller.h
+++ b/source/gameengine/SceneGraph/SG_Controller.h
@@ -101,7 +101,9 @@ public:
enum SG_Controller_option {
SG_CONTR_NODEF = 0,
SG_CONTR_IPO_IPO_AS_FORCE,
- SG_CONTR_IPO_FORCES_ACT_LOCAL,
+ SG_CONTR_IPO_IPO_ADD,
+ SG_CONTR_IPO_LOCAL,
+ SG_CONTR_IPO_RESET,
SG_CONTR_CAMIPO_LENS,
SG_CONTR_CAMIPO_CLIPEND,
SG_CONTR_CAMIPO_CLIPSTART,
diff --git a/source/gameengine/SceneGraph/SG_IObject.cpp b/source/gameengine/SceneGraph/SG_IObject.cpp
index 1a8dc894ce9..d0bdac5c8f0 100644
--- a/source/gameengine/SceneGraph/SG_IObject.cpp
+++ b/source/gameengine/SceneGraph/SG_IObject.cpp
@@ -104,7 +104,7 @@ SetSGClientObject(
}
- void
+ bool
SG_IObject::
ActivateReplicationCallback(
SG_IObject *replica
@@ -112,8 +112,10 @@ ActivateReplicationCallback(
if (m_callbacks.m_replicafunc)
{
// Call client provided replication func
- m_callbacks.m_replicafunc(replica,m_SGclientObject,m_SGclientInfo);
+ if (m_callbacks.m_replicafunc(replica,m_SGclientObject,m_SGclientInfo) == NULL)
+ return false;
}
+ return true;
};
void
@@ -125,6 +127,11 @@ ActivateDestructionCallback(
// Call client provided destruction function on this!
m_callbacks.m_destructionfunc(this,m_SGclientObject,m_SGclientInfo);
}
+ else
+ {
+ // no callback but must still destroy the node to avoid memory leak
+ delete this;
+ }
}
void
diff --git a/source/gameengine/SceneGraph/SG_IObject.h b/source/gameengine/SceneGraph/SG_IObject.h
index 438ab48c556..7f6bdfbbb1c 100644
--- a/source/gameengine/SceneGraph/SG_IObject.h
+++ b/source/gameengine/SceneGraph/SG_IObject.h
@@ -202,7 +202,7 @@ public:
protected :
- void
+ bool
ActivateReplicationCallback(
SG_IObject *replica
);
diff --git a/source/gameengine/SceneGraph/SG_Node.cpp b/source/gameengine/SceneGraph/SG_Node.cpp
index 73e16863173..8de7ac83477 100644
--- a/source/gameengine/SceneGraph/SG_Node.cpp
+++ b/source/gameengine/SceneGraph/SG_Node.cpp
@@ -68,7 +68,7 @@ SG_Node* SG_Node::GetSGReplica()
SG_Node* replica = new SG_Node(*this);
if (replica == NULL) return NULL;
- ProcessSGReplica(replica);
+ ProcessSGReplica(&replica);
return replica;
}
@@ -76,25 +76,42 @@ SG_Node* SG_Node::GetSGReplica()
void
SG_Node::
ProcessSGReplica(
- SG_Node* replica
+ SG_Node** replica
){
// Apply the replication call back function.
- ActivateReplicationCallback(replica);
+ if (!ActivateReplicationCallback(*replica))
+ {
+ delete (*replica);
+ *replica = NULL;
+ return;
+ }
// clear the replica node of it's parent.
- static_cast<SG_Node*>(replica)->m_SGparent = NULL;
+ static_cast<SG_Node*>(*replica)->m_SGparent = NULL;
if (m_children.begin() != m_children.end())
{
// if this node has children, the replica has too, so clear and clone children
- replica->ClearSGChildren();
+ (*replica)->ClearSGChildren();
NodeList::iterator childit;
for (childit = m_children.begin();childit!=m_children.end();++childit)
{
- replica->AddChild((*childit)->GetSGReplica());
+ SG_Node* childnode = (*childit)->GetSGReplica();
+ if (childnode)
+ (*replica)->AddChild(childnode);
}
}
+ // Nodes without children and without client object are
+ // not worth to keep, they will just take up CPU
+ // This can happen in partial replication of hierarchy
+ // during group duplication.
+ if ((*replica)->m_children.empty() &&
+ (*replica)->GetSGClientObject() == NULL)
+ {
+ delete (*replica);
+ *replica = NULL;
+ }
}
@@ -148,6 +165,27 @@ GetRootSGParent(
return (m_SGparent ? (const SG_Node*) m_SGparent->GetRootSGParent() : (const SG_Node*) this);
}
+ bool
+SG_Node::
+IsVertexParent()
+{
+ if (m_parent_relation)
+ {
+ return m_parent_relation->IsVertexRelation();
+ }
+ return false;
+}
+
+ bool
+SG_Node::
+IsSlowParent()
+{
+ if (m_parent_relation)
+ {
+ return m_parent_relation->IsSlowRelation();
+ }
+ return false;
+}
void
SG_Node::
diff --git a/source/gameengine/SceneGraph/SG_Node.h b/source/gameengine/SceneGraph/SG_Node.h
index 4808f6f7d94..ffaaad861e2 100644
--- a/source/gameengine/SceneGraph/SG_Node.h
+++ b/source/gameengine/SceneGraph/SG_Node.h
@@ -152,6 +152,22 @@ public:
) ;
+ /**
+ * Return vertex parent status.
+ */
+
+ bool
+ IsVertexParent(
+ ) ;
+
+ /**
+ * Return slow parent status.
+ */
+
+ bool
+ IsSlowParent(
+ ) ;
+
/**
* Update the spatial data of this node. Iterate through
* the children of this node and update their world data.
@@ -189,7 +205,7 @@ private:
void
ProcessSGReplica(
- SG_Node* replica
+ SG_Node** replica
);
/**
diff --git a/source/gameengine/SceneGraph/SG_ParentRelation.h b/source/gameengine/SceneGraph/SG_ParentRelation.h
index 1d211a9f39f..6507cb98519 100644
--- a/source/gameengine/SceneGraph/SG_ParentRelation.h
+++ b/source/gameengine/SceneGraph/SG_ParentRelation.h
@@ -90,6 +90,25 @@ public :
NewCopy(
) = 0;
+ /**
+ * Vertex Parent Relation are special: they don't propagate rotation
+ */
+ virtual
+ bool
+ IsVertexRelation(
+ ) {
+ return false;
+ }
+
+ /**
+ * Need this to see if we are able to adjust time-offset from the python api
+ */
+ virtual
+ bool
+ IsSlowRelation(
+ ) {
+ return false;
+ }
protected :
/**
diff --git a/source/gameengine/SceneGraph/SG_Spatial.cpp b/source/gameengine/SceneGraph/SG_Spatial.cpp
index 18049592977..5ba116e59db 100644
--- a/source/gameengine/SceneGraph/SG_Spatial.cpp
+++ b/source/gameengine/SceneGraph/SG_Spatial.cpp
@@ -87,6 +87,13 @@ SG_Spatial::
delete (m_parent_relation);
}
+ SG_ParentRelation *
+SG_Spatial::
+GetParentRelation(
+){
+ return m_parent_relation;
+}
+
void
SG_Spatial::
SetParentRelation(
diff --git a/source/gameengine/SceneGraph/SG_Spatial.h b/source/gameengine/SceneGraph/SG_Spatial.h
index a70784472a7..28848b0f933 100644
--- a/source/gameengine/SceneGraph/SG_Spatial.h
+++ b/source/gameengine/SceneGraph/SG_Spatial.h
@@ -83,6 +83,10 @@ public:
SetParentRelation(
SG_ParentRelation *relation
);
+
+ SG_ParentRelation *
+ GetParentRelation(
+ );
/**
diff --git a/source/gameengine/VideoTexture/BlendType.h b/source/gameengine/VideoTexture/BlendType.h
new file mode 100644
index 00000000000..ac3ed8812a6
--- /dev/null
+++ b/source/gameengine/VideoTexture/BlendType.h
@@ -0,0 +1,75 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2006 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined BLENDTYPE_H
+#define BLENDTYPE_H
+
+
+/// class allows check type of blender python object and access its contained object
+template <class PyObj> class BlendType
+{
+public:
+ /// constructor
+ BlendType (char * name) : m_name(name) {}
+
+ /// check blender type and return pointer to contained object or NULL (if type is not valid)
+ PyObj * checkType (PyObject * obj)
+ {
+ // if pointer to type isn't set
+ if (m_objType == NULL)
+ {
+ // compare names of type
+ if (strcmp(obj->ob_type->tp_name, m_name) == 0)
+ // if name of type match, save pointer to type
+ m_objType = obj->ob_type;
+ else
+ // if names of type don't match, return NULL
+ return NULL;
+ }
+ // if pointer to type is set and don't match to type of provided object, return NULL
+ else if (obj->ob_type != m_objType)
+ return NULL;
+ // return pointer to object
+ return (PyObj*)obj;
+ }
+
+ /// parse arguments to get object
+ PyObj * parseArg (PyObject * args)
+ {
+ // parse arguments
+ PyObject * obj;
+ if (PyArg_ParseTuple(args, "O", &obj))
+ // if successfully parsed, return pointer to object
+ return checkType(obj);
+ // otherwise return NULL
+ return NULL;
+ }
+
+protected:
+ /// name of Python type
+ char * m_name;
+ /// pointer to Python type
+ PyTypeObject * m_objType;
+};
+
+
+#endif
diff --git a/source/gameengine/VideoTexture/CMakeLists.txt b/source/gameengine/VideoTexture/CMakeLists.txt
new file mode 100644
index 00000000000..1674602edd7
--- /dev/null
+++ b/source/gameengine/VideoTexture/CMakeLists.txt
@@ -0,0 +1,61 @@
+# $Id$
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# 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
+# of the License, or (at your option) any later version.
+#
+# 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,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# The Original Code is Copyright (C) 2006, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Jacques Beaurain.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+FILE(GLOB SRC *.cpp)
+
+SET(INC
+ .
+ ../../../source/gameengine/Ketsji
+ ../../../source/gameengine/Expressions
+ ../../../source/gameengine/GameLogic
+ ../../../source/gameengine/SceneGraph
+ ../../../source/gameengine/Rasterizer
+ ../../../source/gameengine/Rasterizer/RAS_OpenGLRasterizer
+ ../../../source/gameengine/BlenderRoutines
+ ../../../source/blender/include
+ ../../../source/blender/blenlib
+ ../../../source/blender/blenkernel
+ ../../../source/blender/makesdna
+ ../../../source/blender/imbuf
+ ../../../source/blender/python
+ ../../../source/blender/gpu
+ ../../../source/kernel/gen_system
+ ../../../intern/string
+ ../../../intern/moto/include
+ ../../../intern/guardedalloc
+ ../../../intern/SoundSystem
+ ../../../extern/glew/include
+ ${PYTHON_INC}
+)
+
+IF(WITH_FFMPEG)
+ SET(INC ${INC} ${FFMPEG_INC})
+ ADD_DEFINITIONS(-DWITH_FFMPEG)
+ ADD_DEFINITIONS(-D__STDC_CONSTANT_MACROS)
+ENDIF(WITH_FFMPEG)
+
+BLENDERLIB(bf_videotex "${SRC}" "${INC}")
+#env.BlenderLib ( 'bf_videotex', sources, Split(incs), [], libtype=['game','player'], priority=[25, 72], compileflags = cflags )
diff --git a/source/gameengine/VideoTexture/Common.h b/source/gameengine/VideoTexture/Common.h
new file mode 100644
index 00000000000..f771077bbba
--- /dev/null
+++ b/source/gameengine/VideoTexture/Common.h
@@ -0,0 +1,55 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2006 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if defined WIN32
+#define WINDOWS_LEAN_AND_MEAN
+#endif
+
+#if !defined NULL
+#define NULL 0
+#endif
+
+#if !defined HRESULT
+#define HRESULT long
+#endif
+
+#if !defined DWORD
+#define DWORD unsigned long
+#endif
+
+#if !defined S_OK
+#define S_OK ((HRESULT)0L)
+#endif
+
+#if !defined BYTE
+#define BYTE unsigned char
+#endif
+
+#if !defined WIN32
+#define Sleep(time) sleep(time)
+#endif
+
+#if !defined FAILED
+#define FAILED(Status) ((HRESULT)(Status)<0)
+#endif
+
+#include <iostream>
diff --git a/source/gameengine/VideoTexture/Exception.cpp b/source/gameengine/VideoTexture/Exception.cpp
new file mode 100644
index 00000000000..3f939de6bc2
--- /dev/null
+++ b/source/gameengine/VideoTexture/Exception.cpp
@@ -0,0 +1,209 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2006 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+
+#include <strstream>
+#include <fstream>
+
+#include <PyObjectPlus.h>
+
+#include "Exception.h"
+
+
+// exception identificators
+ExceptionID ErrGeneral, ErrNotFound;
+
+// exception descriptions
+ExpDesc errGenerDesc (ErrGeneral, "General Error");
+ExpDesc errNFoundDesc (ErrNotFound, "Error description not found");
+
+
+
+// implementation of ExpDesc
+
+// constructor
+ExpDesc::ExpDesc (ExceptionID & exp, char * desc, RESULT hres)
+: m_expID(exp), m_hRslt(hres), m_description(desc)
+{
+}
+
+// destructor
+ExpDesc::~ExpDesc (void) {}
+
+// list of descriptions
+std::vector<ExpDesc*> ExpDesc::m_expDescs;
+
+
+// class Exception
+
+
+// last exception description
+std::string Exception::m_lastError;
+
+// log file name
+char * Exception::m_logFile = NULL;
+
+
+// basic constructor
+Exception::Exception ()
+{
+ // default values
+ m_expID = &ErrNotFound;
+ m_hRslt = S_OK;
+ m_line = 0;
+}
+
+
+// destructor
+Exception::~Exception () throw() { }
+
+
+// copy constructor
+Exception::Exception (const Exception & xpt)
+{ copy (xpt); }
+
+
+// assignment operator
+Exception & Exception::operator= (const Exception & xpt)
+{ copy (xpt); return *this; }
+
+
+// get exception description
+const char * Exception::what()
+{
+ // set exception description
+ setXptDesc();
+ // return c string
+ return m_desc.c_str();
+}
+
+
+// debug version - with file and line of exception
+Exception::Exception (ExceptionID & expID, RESULT rslt, char * fil, int lin)
+: m_expID (&expID), m_hRslt (rslt)
+{
+ // set file and line
+ if (strlen(fil) > 0 || lin > 0)
+ setFileLine (fil, lin);
+}
+
+
+// set file and line
+void Exception::setFileLine (char * fil, int lin)
+{
+ if (fil != NULL) m_fileName = fil;
+ m_line = lin;
+}
+
+
+// report exception
+void Exception::report(void)
+{
+ // set exception description
+ setXptDesc();
+ // set python error
+ PyErr_SetString(PyExc_RuntimeError, what());
+ // if log file is set
+ if (m_logFile != NULL)
+ {
+ // write description to log
+ std::ofstream logf (m_logFile, std::ios_base::app);
+ logf << m_fileName << ':' << m_line << ':' << m_desc << std::endl;
+ logf.flush();
+ logf.close();
+ }
+}
+
+
+// set exception description
+void Exception::setXptDesc (void)
+{
+ // if description is not set
+ if (m_desc.size() == 0)
+ {
+ // start of search -1
+ // found description "NotFound" 0
+ // found description without matching result 1
+ // found description with matching result 2
+ int best = -1;
+ // find exception description
+ for (std::vector<ExpDesc*>::iterator it = ExpDesc::m_expDescs.begin(); it != ExpDesc::m_expDescs.end(); ++it)
+ {
+ // use "NotFound", if there is not better
+ if (best < 0 && (*it)->isExp(&ErrNotFound) > 0)
+ {
+ (*it)->loadDesc(m_desc);
+ best = 0;
+ }
+ // match exception
+ int nBest = (*it)->isExp(m_expID, m_hRslt);
+ // if exception is matching better
+ if (nBest > 0 && best < nBest)
+ {
+ // set description
+ (*it)->loadDesc(m_desc);
+ best = nBest;
+ // if matching exactly, finish search
+ if (best == 2) break;
+ }
+ }
+ // add result code
+ // length of result code
+ const size_t rsltSize = 11;
+ // delimit description
+ const char delimRslt[] = ": ";
+ // set text of description
+ char rsltTxt[rsltSize];
+ std::ostrstream os(rsltTxt, rsltSize);
+ os << std::hex << m_hRslt << delimRslt << '\0';
+ // copy result to description
+ m_desc.insert(0, rsltTxt);
+ // copy exception description to last exception string
+ m_lastError = m_desc;
+ }
+}
+
+
+// copy exception data
+void Exception::copy (const Exception & xpt)
+{
+ // standard data
+ m_expID = xpt.m_expID;
+ m_hRslt = xpt.m_hRslt;
+ m_desc = xpt.m_desc;
+
+ // debug data
+ m_fileName = xpt.m_fileName;
+ m_line = xpt.m_line;
+}
+
+void registerAllExceptions(void)
+{
+ errGenerDesc.registerDesc();
+ errNFoundDesc.registerDesc();
+ MaterialNotAvailDesc.registerDesc();
+ ImageSizesNotMatchDesc.registerDesc();
+ SceneInvalidDesc.registerDesc();
+ CameraInvalidDesc.registerDesc();
+ SourceVideoEmptyDesc.registerDesc();
+ SourceVideoCreationDesc.registerDesc();
+}
diff --git a/source/gameengine/VideoTexture/Exception.h b/source/gameengine/VideoTexture/Exception.h
new file mode 100644
index 00000000000..5345e87f199
--- /dev/null
+++ b/source/gameengine/VideoTexture/Exception.h
@@ -0,0 +1,210 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2006 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+
+#if !defined EXCEPTION_H
+#define EXCEPTION_H
+
+#include <exception>
+#include <vector>
+#include <string>
+#include <algorithm>
+
+#include "Common.h"
+
+
+#define CHCKHRSLTV(fnc,val,err) \
+{ \
+ HRESULT macroHRslt = (fnc); \
+ if (macroHRslt != val) \
+ throw Exception (err, macroHRslt, __FILE__, __LINE__); \
+}
+
+#define THRWEXCP(err,hRslt) throw Exception (err, hRslt, __FILE__, __LINE__);
+
+
+#if defined WIN32
+
+#define CHCKHRSLT(fnc,err) \
+{ \
+ HRESULT macroHRslt = (fnc); \
+ if (FAILED(macroHRslt)) \
+ throw Exception (err, macroHRslt, __FILE__, __LINE__); \
+}
+
+#else
+
+#define CHCKHRSLT(fnc,err) CHCKHRSLTV(fnc,S_OK,err)
+
+#endif
+
+
+// forward declarations
+class ExceptionID;
+class Exception;
+
+
+// exception identificators
+extern ExceptionID ErrGeneral, ErrNotFound;
+
+
+// result type
+typedef long RESULT;
+
+
+// class ExceptionID for exception identification
+class ExceptionID
+{
+public:
+ // constructor a destructor
+ ExceptionID (void) {}
+ ~ExceptionID (void) {}
+
+private:
+ // not allowed
+ ExceptionID (const ExceptionID & obj) throw() {}
+ ExceptionID & operator= (const ExceptionID & obj) throw() { return *this; }
+};
+
+
+// class ExpDesc for exception description
+class ExpDesc
+{
+public:
+ // constructor a destructor
+ ExpDesc (ExceptionID & exp, char * desc, RESULT hres = S_OK);
+ ~ExpDesc (void);
+
+ // comparision function
+ // returns 0, if exception identification don't match at all
+ // returns 1, if only exception identification is matching
+ // returns 2, if both exception identification and result are matching
+ int isExp (ExceptionID * exp, RESULT hres = S_OK) throw()
+ {
+ // check exception identification
+ if (&m_expID == exp)
+ {
+ // check result value
+ if (m_hRslt == hres) return 2;
+ // only identification match
+ if (m_hRslt == S_OK) return 1;
+ }
+ // no match
+ return 0;
+ }
+
+ // get exception description
+ void loadDesc (std::string & desc) throw()
+ {
+ desc = m_description;
+ }
+
+ void registerDesc(void)
+ {
+ if (std::find(m_expDescs.begin(), m_expDescs.end(), this) == m_expDescs.end())
+ m_expDescs.push_back(this);
+ }
+ // list of exception descriptions
+ static std::vector<ExpDesc*> m_expDescs;
+
+private:
+ // exception ID
+ ExceptionID & m_expID;
+ // result
+ RESULT m_hRslt;
+ // description
+ char * m_description;
+
+ // not allowed
+ ExpDesc (const ExpDesc & obj) : m_expID (ErrNotFound) {}
+ ExpDesc & operator= (const ExpDesc & obj) { return *this; }
+};
+
+
+
+// class Exception
+class Exception : public std::exception
+{
+public:
+ // constructor
+ Exception ();
+ // destructor
+ virtual ~Exception () throw();
+ // copy constructor
+ Exception (const Exception & xpt);
+ // assignment operator
+ Exception & operator= (const Exception & xpt);
+ // get exception description
+ virtual const char * what(void);
+
+ // debug version of constructor
+ Exception (ExceptionID & expID, RESULT rslt, char * fil, int lin);
+ // set source file and line of exception
+ void setFileLine (char * fil, int lin);
+
+ // get description in string
+ std::string & getDesc (void) throw() { return m_desc; }
+
+ // report exception
+ virtual void report (void);
+
+ // get exception id
+ ExceptionID * getID (void) throw() { return m_expID; }
+
+ /// last exception description
+ static std::string m_lastError;
+
+ /// log file name
+ static char * m_logFile;
+
+protected:
+ // exception identification
+ ExceptionID * m_expID;
+ // RESULT code
+ RESULT m_hRslt;
+
+ // exception description
+ std::string m_desc;
+
+ // set exception description
+ virtual void setXptDesc (void);
+
+ // copy exception
+ void copy (const Exception & xpt);
+
+ // file name where exception was thrown
+ std::string m_fileName;
+ // line number in file
+ int m_line;
+
+};
+
+extern ExpDesc MaterialNotAvailDesc;
+extern ExpDesc ImageSizesNotMatchDesc;
+extern ExpDesc SceneInvalidDesc;
+extern ExpDesc CameraInvalidDesc;
+extern ExpDesc SourceVideoEmptyDesc;
+extern ExpDesc SourceVideoCreationDesc;
+
+
+void registerAllExceptions(void);
+#endif
diff --git a/source/gameengine/VideoTexture/FilterBase.cpp b/source/gameengine/VideoTexture/FilterBase.cpp
new file mode 100644
index 00000000000..b0112cd355b
--- /dev/null
+++ b/source/gameengine/VideoTexture/FilterBase.cpp
@@ -0,0 +1,150 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#include "FilterBase.h"
+
+#include <PyObjectPlus.h>
+#include <structmember.h>
+
+
+// FilterBase class implementation
+
+// constructor
+FilterBase::FilterBase (void) : m_previous(NULL) {}
+
+
+// destructor
+FilterBase::~FilterBase (void)
+{
+ // release Python objects, if not released yet
+ release();
+}
+
+
+// release python objects
+void FilterBase::release (void)
+{
+ // release previous filter object
+ setPrevious(NULL);
+}
+
+
+// set new previous filter
+void FilterBase::setPrevious (PyFilter * filt, bool useRefCnt)
+{
+ // if reference counting has to be used
+ if (useRefCnt)
+ {
+ // reference new filter
+ if (filt != NULL) Py_INCREF(filt);
+ // release old filter
+ Py_XDECREF(m_previous);
+ }
+ // set new previous filter
+ m_previous = filt;
+}
+
+
+// find first filter
+FilterBase * FilterBase::findFirst (void)
+{
+ // find first filter in chain
+ FilterBase * frst;
+ for (frst = this; frst->m_previous != NULL; frst = frst->m_previous->m_filter);
+ // set first filter
+ return frst;
+}
+
+
+
+// list offilter types
+PyTypeList pyFilterTypes;
+
+
+
+// functions for python interface
+
+
+// object allocation
+PyObject * Filter_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwds)
+{
+ // allocate object
+ PyFilter * self = reinterpret_cast<PyFilter*>(type->tp_alloc(type, 0));
+ // initialize object structure
+ self->m_filter = NULL;
+ // return allocated object
+ return reinterpret_cast<PyObject*>(self);
+}
+
+// object deallocation
+void Filter_dealloc (PyFilter * self)
+{
+ // release object attributes
+ if (self->m_filter != NULL)
+ {
+ self->m_filter->release();
+ delete self->m_filter;
+ self->m_filter = NULL;
+ }
+}
+
+
+// get previous pixel filter object
+PyObject * Filter_getPrevious (PyFilter * self, void * closure)
+{
+ // if filter object is available
+ if (self->m_filter != NULL)
+ {
+ // pixel filter object
+ PyObject * filt = reinterpret_cast<PyObject*>(self->m_filter->getPrevious());
+ // if filter is present
+ if (filt != NULL)
+ {
+ // return it
+ Py_INCREF(filt);
+ return filt;
+ }
+ }
+ // otherwise return none
+ Py_RETURN_NONE;
+}
+
+
+// set previous pixel filter object
+int Filter_setPrevious (PyFilter * self, PyObject * value, void * closure)
+{
+ // if filter object is available
+ if (self->m_filter != NULL)
+ {
+ // check new value
+ if (value == NULL || !pyFilterTypes.in(value->ob_type))
+ {
+ // report value error
+ PyErr_SetString(PyExc_TypeError, "Invalid type of value");
+ return -1;
+ }
+ // set new value
+ self->m_filter->setPrevious(reinterpret_cast<PyFilter*>(value));
+ }
+ // return success
+ return 0;
+}
diff --git a/source/gameengine/VideoTexture/FilterBase.h b/source/gameengine/VideoTexture/FilterBase.h
new file mode 100644
index 00000000000..b6080f018d5
--- /dev/null
+++ b/source/gameengine/VideoTexture/FilterBase.h
@@ -0,0 +1,138 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined FILTERBASE_H
+#define FILTERBASE_H
+
+#include "Common.h"
+
+#include <PyObjectPlus.h>
+
+#include "PyTypeList.h"
+
+#define VT_C(v,idx) ((unsigned char*)&v)[idx]
+#define VT_R(v) ((unsigned char*)&v)[0]
+#define VT_G(v) ((unsigned char*)&v)[1]
+#define VT_B(v) ((unsigned char*)&v)[2]
+#define VT_A(v) ((unsigned char*)&v)[3]
+#define VT_RGBA(v,r,g,b,a) VT_R(v)=(unsigned char)r, VT_G(v)=(unsigned char)g, VT_B(v)=(unsigned char)b, VT_A(v)=(unsigned char)a
+
+// forward declaration
+class FilterBase;
+
+
+// python structure for filter
+struct PyFilter
+{
+ PyObject_HEAD
+ // source object
+ FilterBase * m_filter;
+};
+
+
+/// base class for pixel filters
+class FilterBase
+{
+public:
+ /// constructor
+ FilterBase (void);
+ /// destructor
+ virtual ~FilterBase (void);
+ // release python objects
+ virtual void release (void);
+
+ /// convert pixel
+ template <class SRC> unsigned int convert (SRC src, short x, short y,
+ short * size, unsigned int pixSize)
+ {
+ return filter(src, x, y, size, pixSize,
+ convertPrevious(src, x, y, size, pixSize));
+ }
+
+ /// get previous filter
+ PyFilter * getPrevious (void) { return m_previous; }
+ /// set previous filter
+ void setPrevious (PyFilter * filt, bool useRefCnt = true);
+
+ /// find first filter in chain
+ FilterBase * findFirst (void);
+
+ /// get first filter's source pixel size
+ unsigned int firstPixelSize (void) { return findFirst()->getPixelSize(); }
+
+protected:
+ /// previous pixel filter
+ PyFilter * m_previous;
+
+ /// filter pixel, source byte buffer
+ virtual unsigned int filter (unsigned char * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ { return val; }
+ /// filter pixel, source int buffer
+ virtual unsigned int filter (unsigned int * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ { return val; }
+
+ /// get source pixel size
+ virtual unsigned int getPixelSize (void) { return 1; }
+
+ /// get converted pixel from previous filters
+ template <class SRC> unsigned int convertPrevious (SRC src, short x, short y,
+ short * size, unsigned int pixSize)
+ {
+ // if previous filter doesn't exists, return source pixel
+ if (m_previous == NULL) return *src;
+ // otherwise return converted pixel
+ return m_previous->m_filter->convert(src, x, y, size, pixSize);
+ }
+};
+
+
+// list of python filter types
+extern PyTypeList pyFilterTypes;
+
+
+// functions for python interface
+
+// object initialization
+template <class T> static int Filter_init (PyObject * pySelf, PyObject * args, PyObject * kwds)
+{
+ PyFilter * self = reinterpret_cast<PyFilter*>(pySelf);
+ // create filter object
+ if (self->m_filter != NULL) delete self->m_filter;
+ self->m_filter = new T();
+ // initialization succeded
+ return 0;
+}
+
+// object allocation
+PyObject * Filter_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwds);
+// object deallocation
+void Filter_dealloc (PyFilter * self);
+
+// get previous pixel filter object
+PyObject * Filter_getPrevious (PyFilter * self, void * closure);
+// set previous pixel filter object
+int Filter_setPrevious (PyFilter * self, PyObject * value, void * closure);
+
+
+#endif
diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.cpp b/source/gameengine/VideoTexture/FilterBlueScreen.cpp
new file mode 100644
index 00000000000..43d7566102a
--- /dev/null
+++ b/source/gameengine/VideoTexture/FilterBlueScreen.cpp
@@ -0,0 +1,178 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+
+#include <PyObjectPlus.h>
+#include <structmember.h>
+
+#include "FilterBlueScreen.h"
+
+#include "FilterBase.h"
+#include "PyTypeList.h"
+
+// implementation FilterBlueScreen
+
+// constructor
+FilterBlueScreen::FilterBlueScreen (void)
+{
+ // set color to blue
+ setColor(0, 0, 255);
+ // set limits
+ setLimits(64, 64);
+}
+
+// set color
+void FilterBlueScreen::setColor (unsigned char red, unsigned char green, unsigned char blue)
+{
+ m_color[0] = red;
+ m_color[1] = green;
+ m_color[2] = blue;
+}
+
+// set limits for color variation
+void FilterBlueScreen::setLimits (unsigned short minLimit, unsigned short maxLimit)
+{
+ m_limits[0] = minLimit;
+ m_limits[1] = maxLimit > minLimit ? maxLimit : minLimit;
+ // calculate square values
+ for (short idx = 0; idx < 2; ++idx)
+ m_squareLimits[idx] = m_limits[idx] * m_limits[idx];
+ // limits distance
+ m_limitDist = m_squareLimits[1] - m_squareLimits[0];
+}
+
+
+
+// cast Filter pointer to FilterBlueScreen
+inline FilterBlueScreen * getFilter (PyFilter * self)
+{ return static_cast<FilterBlueScreen*>(self->m_filter); }
+
+
+// python methods and get/sets
+
+// get color
+static PyObject * getColor (PyFilter * self, void * closure)
+{
+ return Py_BuildValue("[BBB]", getFilter(self)->getColor()[0],
+ getFilter(self)->getColor()[1], getFilter(self)->getColor()[2]);
+}
+
+// set color
+static int setColor (PyFilter * self, PyObject * value, void * closure)
+{
+ // check validity of parameter
+ if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 3
+ || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0))
+ || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1))
+ || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 2)))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 3 ints");
+ return -1;
+ }
+ // set color
+ getFilter(self)->setColor((unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
+ (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))),
+ (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 2))));
+ // success
+ return 0;
+}
+
+// get limits
+static PyObject * getLimits (PyFilter * self, void * closure)
+{
+ return Py_BuildValue("[II]", getFilter(self)->getLimits()[0],
+ getFilter(self)->getLimits()[1]);
+}
+
+// set limit
+static int setLimits (PyFilter * self, PyObject * value, void * closure)
+{
+ // check validity of parameter
+ if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2
+ || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0))
+ || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1)))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints");
+ return -1;
+ }
+ // set limits
+ getFilter(self)->setLimits((unsigned short)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
+ (unsigned short)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))));
+ // success
+ return 0;
+}
+
+
+// attributes structure
+static PyGetSetDef filterBSGetSets[] =
+{
+ {(char*)"color", (getter)getColor, (setter)setColor, (char*)"blue screen color", NULL},
+ {(char*)"limits", (getter)getLimits, (setter)setLimits, (char*)"blue screen color limits", NULL},
+ // attributes from FilterBase class
+ {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
+ {NULL}
+};
+
+// define python type
+PyTypeObject FilterBlueScreenType =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.FilterBlueScreen", /*tp_name*/
+ sizeof(PyFilter), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Filter_dealloc,/*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Filter for Blue Screen objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ NULL, /* tp_methods */
+ 0, /* tp_members */
+ filterBSGetSets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Filter_init<FilterBlueScreen>, /* tp_init */
+ 0, /* tp_alloc */
+ Filter_allocNew, /* tp_new */
+};
+
diff --git a/source/gameengine/VideoTexture/FilterBlueScreen.h b/source/gameengine/VideoTexture/FilterBlueScreen.h
new file mode 100644
index 00000000000..820e4a44501
--- /dev/null
+++ b/source/gameengine/VideoTexture/FilterBlueScreen.h
@@ -0,0 +1,97 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of blendTex library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined FILTERBLUESCREEN_H
+#define FILTERBLUESCREEN_H
+
+#include "Common.h"
+
+#include "FilterBase.h"
+
+
+/// pixel filter for blue screen
+class FilterBlueScreen : public FilterBase
+{
+public:
+ /// constructor
+ FilterBlueScreen (void);
+ /// destructor
+ virtual ~FilterBlueScreen (void) {}
+
+ /// get color
+ unsigned char * getColor (void) { return m_color; }
+ /// set color
+ void setColor (unsigned char red, unsigned char green, unsigned char blue);
+
+ /// get limits for color variation
+ unsigned short * getLimits (void) { return m_limits; }
+ /// set limits for color variation
+ void setLimits (unsigned short minLimit, unsigned short maxLimit);
+
+protected:
+ /// blue screen color (red component first)
+ unsigned char m_color[3];
+ /// limits for color variation - first defines, where ends fully transparent
+ /// color, second defines, where begins fully opaque color
+ unsigned short m_limits[2];
+ /// squared limits for color variation
+ unsigned int m_squareLimits[2];
+ /// distance between squared limits
+ unsigned int m_limitDist;
+
+ /// filter pixel template, source int buffer
+ template <class SRC> unsigned int tFilter (SRC src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val)
+ {
+ // calculate differences
+ int difRed = int(VT_R(val)) - int(m_color[0]);
+ int difGreen = int(VT_G(val)) - int(m_color[1]);
+ int difBlue = int(VT_B(val)) - int(m_color[2]);
+ // calc distance from "blue screen" color
+ unsigned int dist = (unsigned int)(difRed * difRed + difGreen * difGreen
+ + difBlue * difBlue);
+ // condition for fully transparent color
+ if (m_squareLimits[0] >= dist)
+ // return color with zero alpha
+ VT_A(val) = 0;
+ // condition for fully opaque color
+ else if (m_squareLimits[1] <= dist)
+ // return normal colour
+ VT_A(val) = 0xFF;
+ // otherwise calc alpha
+ else
+ VT_A(val) = (((dist - m_squareLimits[0]) << 8) / m_limitDist);
+ return val;
+ }
+
+ /// virtual filtering function for byte source
+ virtual unsigned int filter (unsigned char * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ { return tFilter(src, x, y, size, pixSize, val); }
+ /// virtual filtering function for unsigned int source
+ virtual unsigned int filter (unsigned int * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ { return tFilter(src, x, y, size, pixSize, val); }
+};
+
+
+#endif
diff --git a/source/gameengine/VideoTexture/FilterColor.cpp b/source/gameengine/VideoTexture/FilterColor.cpp
new file mode 100644
index 00000000000..22ee729b200
--- /dev/null
+++ b/source/gameengine/VideoTexture/FilterColor.cpp
@@ -0,0 +1,350 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+
+#include <PyObjectPlus.h>
+#include <structmember.h>
+
+#include "FilterColor.h"
+
+#include "FilterBase.h"
+#include "PyTypeList.h"
+
+// implementation FilterGray
+
+// attributes structure
+static PyGetSetDef filterGrayGetSets[] =
+{ // attributes from FilterBase class
+ {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
+ {NULL}
+};
+
+// define python type
+PyTypeObject FilterGrayType =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.FilterGray", /*tp_name*/
+ sizeof(PyFilter), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Filter_dealloc,/*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Filter for gray scale effect", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ NULL, /* tp_methods */
+ 0, /* tp_members */
+ filterGrayGetSets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Filter_init<FilterGray>, /* tp_init */
+ 0, /* tp_alloc */
+ Filter_allocNew, /* tp_new */
+};
+
+
+// implementation FilterColor
+
+// constructor
+FilterColor::FilterColor (void)
+{
+ // reset color matrix to identity
+ for (int r = 0; r < 4; ++r)
+ for (int c = 0; c < 5; ++c)
+ m_matrix[r][c] = (r == c) ? 256 : 0;
+}
+
+// set color matrix
+void FilterColor::setMatrix (ColorMatrix & mat)
+{
+ // copy matrix
+ for (int r = 0; r < 4; ++r)
+ for (int c = 0; c < 5; ++c)
+ m_matrix[r][c] = mat[r][c];
+}
+
+
+
+// cast Filter pointer to FilterColor
+inline FilterColor * getFilterColor (PyFilter * self)
+{ return static_cast<FilterColor*>(self->m_filter); }
+
+
+// python methods and get/sets
+
+// get color matrix
+static PyObject * getMatrix (PyFilter * self, void * closure)
+{
+ ColorMatrix & mat = getFilterColor(self)->getMatrix();
+ return Py_BuildValue("((hhhhh)(hhhhh)(hhhhh)(hhhhh))",
+ mat[0][0], mat[0][1], mat[0][2], mat[0][3], mat[0][4],
+ mat[1][0], mat[1][1], mat[1][2], mat[1][3], mat[1][4],
+ mat[2][0], mat[2][1], mat[2][2], mat[2][3], mat[2][4],
+ mat[3][0], mat[3][1], mat[3][2], mat[3][3], mat[3][4]);
+}
+
+// set color matrix
+static int setMatrix (PyFilter * self, PyObject * value, void * closure)
+{
+ // matrix to store items
+ ColorMatrix mat;
+ // check validity of parameter
+ bool valid = value != NULL && PySequence_Check(value)
+ && PySequence_Length(value) == 4;
+ // check rows
+ for (int r = 0; valid && r < 4; ++r)
+ {
+ // get row object
+ PyObject * row = PySequence_Fast_GET_ITEM(value, r);
+ // check sequence
+ valid = PySequence_Check(row) && PySequence_Length(row) == 5;
+ // check items
+ for (int c = 0; valid && c < 5; ++c)
+ {
+ // item must be int
+ valid = PyInt_Check(PySequence_Fast_GET_ITEM(row, c));
+ // if it is valid, save it in matrix
+ if (valid)
+ mat[r][c] = short(PyInt_AsLong(PySequence_Fast_GET_ITEM(row, c)));
+ }
+ }
+ // if parameter is not valid, report error
+ if (!valid)
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a matrix [4][5] of ints");
+ return -1;
+ }
+ // set color matrix
+ getFilterColor(self)->setMatrix(mat);
+ // success
+ return 0;
+}
+
+
+// attributes structure
+static PyGetSetDef filterColorGetSets[] =
+{
+ {(char*)"matrix", (getter)getMatrix, (setter)setMatrix, (char*)"matrix [4][5] for color calculation", NULL},
+ // attributes from FilterBase class
+ {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
+ {NULL}
+};
+
+// define python type
+PyTypeObject FilterColorType =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.FilterColor", /*tp_name*/
+ sizeof(PyFilter), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Filter_dealloc,/*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Filter for color calculations", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ NULL, /* tp_methods */
+ 0, /* tp_members */
+ filterColorGetSets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Filter_init<FilterColor>, /* tp_init */
+ 0, /* tp_alloc */
+ Filter_allocNew, /* tp_new */
+};
+
+// implementation FilterLevel
+
+// constructor
+FilterLevel::FilterLevel (void)
+{
+ // reset color levels
+ for (int r = 0; r < 4; ++r)
+ {
+ levels[r][0] = 0;
+ levels[r][1] = 0xFF;
+ levels[r][2] = 0xFF;
+ }
+}
+
+// set color levels
+void FilterLevel::setLevels (ColorLevel & lev)
+{
+ // copy levels
+ for (int r = 0; r < 4; ++r)
+ {
+ for (int c = 0; c < 2; ++c)
+ levels[r][c] = lev[r][c];
+ levels[r][2] = lev[r][0] < lev[r][1] ? lev[r][1] - lev[r][0] : 1;
+ }
+}
+
+
+// cast Filter pointer to FilterLevel
+inline FilterLevel * getFilterLevel (PyFilter * self)
+{ return static_cast<FilterLevel*>(self->m_filter); }
+
+
+// python methods and get/sets
+
+// get color levels
+static PyObject * getLevels (PyFilter * self, void * closure)
+{
+ ColorLevel & lev = getFilterLevel(self)->getLevels();
+ return Py_BuildValue("((HH)(HH)(HH)(HH))",
+ lev[0][0], lev[0][1], lev[1][0], lev[1][1],
+ lev[2][0], lev[2][1], lev[3][0], lev[3][1]);
+}
+
+// set color levels
+static int setLevels (PyFilter * self, PyObject * value, void * closure)
+{
+ // matrix to store items
+ ColorLevel lev;
+ // check validity of parameter
+ bool valid = value != NULL && PySequence_Check(value)
+ && PySequence_Length(value) == 4;
+ // check rows
+ for (int r = 0; valid && r < 4; ++r)
+ {
+ // get row object
+ PyObject * row = PySequence_Fast_GET_ITEM(value, r);
+ // check sequence
+ valid = PySequence_Check(row) && PySequence_Length(row) == 2;
+ // check items
+ for (int c = 0; valid && c < 2; ++c)
+ {
+ // item must be int
+ valid = PyInt_Check(PySequence_Fast_GET_ITEM(row, c));
+ // if it is valid, save it in matrix
+ if (valid)
+ lev[r][c] = (unsigned short)(PyInt_AsLong(PySequence_Fast_GET_ITEM(row, c)));
+ }
+ }
+ // if parameter is not valid, report error
+ if (!valid)
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a matrix [4][2] of ints");
+ return -1;
+ }
+ // set color matrix
+ getFilterLevel(self)->setLevels(lev);
+ // success
+ return 0;
+}
+
+
+// attributes structure
+static PyGetSetDef filterLevelGetSets[] =
+{
+ {(char*)"levels", (getter)getLevels, (setter)setLevels, (char*)"levels matrix [4] (min, max)", NULL},
+ // attributes from FilterBase class
+ {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
+ {NULL}
+};
+
+// define python type
+PyTypeObject FilterLevelType =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.FilterLevel", /*tp_name*/
+ sizeof(PyFilter), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Filter_dealloc,/*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Filter for levels calculations", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ NULL, /* tp_methods */
+ 0, /* tp_members */
+ filterLevelGetSets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Filter_init<FilterLevel>, /* tp_init */
+ 0, /* tp_alloc */
+ Filter_allocNew, /* tp_new */
+};
+
diff --git a/source/gameengine/VideoTexture/FilterColor.h b/source/gameengine/VideoTexture/FilterColor.h
new file mode 100644
index 00000000000..b7e52c4521c
--- /dev/null
+++ b/source/gameengine/VideoTexture/FilterColor.h
@@ -0,0 +1,168 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of blendTex library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined FILTERCOLOR_H
+#define FILTERCOLOR_H
+
+#include "Common.h"
+
+#include "FilterBase.h"
+
+
+/// pixel filter for gray scale
+class FilterGray : public FilterBase
+{
+public:
+ /// constructor
+ FilterGray (void) {}
+ /// destructor
+ virtual ~FilterGray (void) {}
+
+protected:
+ /// filter pixel template, source int buffer
+ template <class SRC> unsigned int tFilter (SRC src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val)
+ {
+ // calculate gray value
+ unsigned int gray = (28 * (VT_B(val)) + 151 * (VT_G(val))
+ + 77 * (VT_R(val))) >> 8;
+ // return gray scale value
+ VT_R(val) = gray;
+ VT_G(val) = gray;
+ VT_B(val) = gray;
+ return val;
+ }
+
+ /// virtual filtering function for byte source
+ virtual unsigned int filter (unsigned char * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ { return tFilter(src, x, y, size, pixSize, val); }
+ /// virtual filtering function for unsigned int source
+ virtual unsigned int filter (unsigned int * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ { return tFilter(src, x, y, size, pixSize, val); }
+};
+
+
+/// type for color matrix
+typedef short ColorMatrix[4][5];
+
+/// pixel filter for color calculation
+class FilterColor : public FilterBase
+{
+public:
+ /// constructor
+ FilterColor (void);
+ /// destructor
+ virtual ~FilterColor (void) {}
+
+ /// get color matrix
+ ColorMatrix & getMatrix (void) { return m_matrix; }
+ /// set color matrix
+ void setMatrix (ColorMatrix & mat);
+
+protected:
+ /// color calculation matrix
+ ColorMatrix m_matrix;
+
+ /// calculate one color component
+ unsigned char calcColor (unsigned int val, short idx)
+ {
+ return (((m_matrix[idx][0] * (VT_R(val)) + m_matrix[idx][1] * (VT_G(val))
+ + m_matrix[idx][2] * (VT_B(val)) + m_matrix[idx][3] * (VT_A(val))
+ + m_matrix[idx][4]) >> 8) & 0xFF);
+ }
+
+ /// filter pixel template, source int buffer
+ template <class SRC> unsigned int tFilter (SRC src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val)
+ {
+ // return calculated color
+ int color;
+ VT_RGBA(color, calcColor(val, 0), calcColor(val, 1), calcColor(val, 2), calcColor(val, 3));
+ return color;
+ }
+
+ /// virtual filtering function for byte source
+ virtual unsigned int filter (unsigned char * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ { return tFilter(src, x, y, size, pixSize, val); }
+ /// virtual filtering function for unsigned int source
+ virtual unsigned int filter (unsigned int * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ { return tFilter(src, x, y, size, pixSize, val); }
+};
+
+
+/// type for color levels
+typedef unsigned short ColorLevel[4][3];
+
+/// pixel filter for color calculation
+class FilterLevel : public FilterBase
+{
+public:
+ /// constructor
+ FilterLevel (void);
+ /// destructor
+ virtual ~FilterLevel (void) {}
+
+ /// get color matrix
+ ColorLevel & getLevels (void) { return levels; }
+ /// set color matrix
+ void setLevels (ColorLevel & lev);
+
+protected:
+ /// color calculation matrix
+ ColorLevel levels;
+
+ /// calculate one color component
+ unsigned int calcColor (unsigned int val, short idx)
+ {
+ unsigned int col = VT_C(val,idx);;
+ if (col <= levels[idx][0]) col = 0;
+ else if (col >= levels[idx][1]) col = 0xFF;
+ else col = (((col - levels[idx][0]) << 8) / levels[idx][2]) & 0xFF;
+ return col;
+ }
+
+ /// filter pixel template, source int buffer
+ template <class SRC> unsigned int tFilter (SRC src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val)
+ {
+ // return calculated color
+ int color;
+ VT_RGBA(color, calcColor(val, 0), calcColor(val, 1), calcColor(val, 2), calcColor(val, 3));
+ return color;
+ }
+
+ /// virtual filtering function for byte source
+ virtual unsigned int filter (unsigned char * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ { return tFilter(src, x, y, size, pixSize, val); }
+ /// virtual filtering function for unsigned int source
+ virtual unsigned int filter (unsigned int * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ { return tFilter(src, x, y, size, pixSize, val); }
+};
+
+
+#endif
diff --git a/source/gameengine/VideoTexture/FilterNormal.cpp b/source/gameengine/VideoTexture/FilterNormal.cpp
new file mode 100644
index 00000000000..03a79c1c8ce
--- /dev/null
+++ b/source/gameengine/VideoTexture/FilterNormal.cpp
@@ -0,0 +1,162 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+
+#include <PyObjectPlus.h>
+#include <structmember.h>
+
+#include "FilterNormal.h"
+
+#include "FilterBase.h"
+#include "PyTypeList.h"
+
+// implementation FilterNormal
+
+// constructor
+FilterNormal::FilterNormal (void) : m_colIdx(0)
+{
+ // set default depth
+ setDepth(4);
+}
+
+// set color shift
+void FilterNormal::setColor (unsigned short colIdx)
+{
+ // check validity of index
+ if (colIdx < 3)
+ // set color shift
+ m_colIdx = colIdx;
+}
+
+// set depth
+void FilterNormal::setDepth (float depth)
+{
+ m_depth = depth;
+ m_depthScale = depth / depthScaleKoef;
+}
+
+
+// cast Filter pointer to FilterNormal
+inline FilterNormal * getFilter (PyFilter * self)
+{ return static_cast<FilterNormal*>(self->m_filter); }
+
+
+// python methods and get/sets
+
+// get index of color used to calculate normal
+static PyObject * getColor (PyFilter * self, void * closure)
+{
+ return Py_BuildValue("H", getFilter(self)->getColor());
+}
+
+// set index of color used to calculate normal
+static int setColor (PyFilter * self, PyObject * value, void * closure)
+{
+ // check validity of parameter
+ if (value == NULL || !PyInt_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a int");
+ return -1;
+ }
+ // set color index
+ getFilter(self)->setColor((unsigned short)(PyInt_AsLong(value)));
+ // success
+ return 0;
+}
+
+
+// get depth
+static PyObject * getDepth (PyFilter * self, void * closure)
+{
+ return Py_BuildValue("f", getFilter(self)->getDepth());
+}
+
+// set depth
+static int setDepth (PyFilter * self, PyObject * value, void * closure)
+{
+ // check validity of parameter
+ if (value == NULL || !PyFloat_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a float");
+ return -1;
+ }
+ // set depth
+ getFilter(self)->setDepth(float(PyFloat_AsDouble(value)));
+ // success
+ return 0;
+}
+
+
+// attributes structure
+static PyGetSetDef filterNormalGetSets[] =
+{
+ {(char*)"colorIdx", (getter)getColor, (setter)setColor, (char*)"index of color used to calculate normal (0 - red, 1 - green, 2 - blue)", NULL},
+ {(char*)"depth", (getter)getDepth, (setter)setDepth, (char*)"depth of relief", NULL},
+ // attributes from FilterBase class
+ {(char*)"previous", (getter)Filter_getPrevious, (setter)Filter_setPrevious, (char*)"previous pixel filter", NULL},
+ {NULL}
+};
+
+// define python type
+PyTypeObject FilterNormalType =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.FilterNormal", /*tp_name*/
+ sizeof(PyFilter), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Filter_dealloc,/*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Filter for Blue Screen objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ NULL, /* tp_methods */
+ 0, /* tp_members */
+ filterNormalGetSets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Filter_init<FilterNormal>, /* tp_init */
+ 0, /* tp_alloc */
+ Filter_allocNew, /* tp_new */
+};
+
diff --git a/source/gameengine/VideoTexture/FilterNormal.h b/source/gameengine/VideoTexture/FilterNormal.h
new file mode 100644
index 00000000000..840043be9a1
--- /dev/null
+++ b/source/gameengine/VideoTexture/FilterNormal.h
@@ -0,0 +1,107 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of blendTex library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined FILTERNORMAL_H
+#define FILTERNORMAL_H
+
+#include "Common.h"
+
+#include "FilterBase.h"
+
+
+// scale constants for normals
+const float depthScaleKoef = 255.0;
+const float normScaleKoef = float(depthScaleKoef / 2.0);
+
+
+/// pixel filter for normal mapping
+class FilterNormal : public FilterBase
+{
+public:
+ /// constructor
+ FilterNormal (void);
+ /// destructor
+ virtual ~FilterNormal (void) {}
+
+ /// get index of color used to calculate normals
+ unsigned short getColor (void) { return m_colIdx; }
+ /// set index of color used to calculate normals
+ void setColor (unsigned short colIdx);
+
+ /// get depth
+ float getDepth (void) { return m_depth; }
+ /// set depth
+ void setDepth (float depth);
+
+protected:
+ /// depth of normal relief
+ float m_depth;
+ /// scale to calculate normals
+ float m_depthScale;
+
+ /// color index, 0=red, 1=green, 2=blue, 3=alpha
+ unsigned short m_colIdx;
+
+ /// filter pixel, source int buffer
+ template <class SRC> unsigned int tFilter (SRC * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ {
+ // get value of required color
+ int actPix = int(VT_C(val,m_colIdx));
+ int upPix = actPix;
+ int leftPix = actPix;
+ // get upper and left pixel from actual pixel
+ if (y > 0)
+ {
+ val = convertPrevious(src - pixSize * size[0], x, y - 1, size, pixSize);
+ upPix = VT_C(val,m_colIdx);
+ }
+ if (x > 0)
+ {
+ val = convertPrevious(src - pixSize, x - 1, y, size, pixSize);
+ leftPix = VT_C(val,m_colIdx);
+ }
+ // height differences (from blue color)
+ float dx = (actPix - leftPix) * m_depthScale;
+ float dy = (actPix - upPix) * m_depthScale;
+ // normalize vector
+ float dz = float(normScaleKoef / sqrt(dx * dx + dy * dy + 1.0));
+ dx = dx * dz + normScaleKoef;
+ dy = dy * dz + normScaleKoef;
+ dz += normScaleKoef;
+ // return normal vector converted to color
+ VT_RGBA(val, dx, dy, dz, 0xFF);
+ return val;
+ }
+
+ /// filter pixel, source byte buffer
+ virtual unsigned int filter (unsigned char * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ { return tFilter(src, x, y, size, pixSize, val); }
+ /// filter pixel, source int buffer
+ virtual unsigned int filter (unsigned int * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ { return tFilter(src, x, y, size, pixSize, val); }
+};
+
+
+#endif
diff --git a/source/gameengine/VideoTexture/FilterSource.cpp b/source/gameengine/VideoTexture/FilterSource.cpp
new file mode 100644
index 00000000000..f3676e93a6d
--- /dev/null
+++ b/source/gameengine/VideoTexture/FilterSource.cpp
@@ -0,0 +1,171 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+// implementation
+
+#include <PyObjectPlus.h>
+#include <structmember.h>
+
+#include "FilterSource.h"
+
+#include "FilterBase.h"
+#include "PyTypeList.h"
+
+
+// FilterRGB24
+
+// define python type
+PyTypeObject FilterRGB24Type =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.FilterRGB24", /*tp_name*/
+ sizeof(PyFilter), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Filter_dealloc,/*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Source filter RGB24 objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ NULL, /* tp_methods */
+ 0, /* tp_members */
+ NULL, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Filter_init<FilterRGB24>, /* tp_init */
+ 0, /* tp_alloc */
+ Filter_allocNew, /* tp_new */
+};
+
+// FilterRGBA32
+
+// define python type
+PyTypeObject FilterRGBA32Type =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.FilterRGBA32", /*tp_name*/
+ sizeof(PyFilter), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Filter_dealloc,/*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Source filter RGBA32 objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ NULL, /* tp_methods */
+ 0, /* tp_members */
+ NULL, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Filter_init<FilterRGBA32>, /* tp_init */
+ 0, /* tp_alloc */
+ Filter_allocNew, /* tp_new */
+};
+
+// FilterBGR24
+
+// define python type
+PyTypeObject FilterBGR24Type =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.FilterBGR24", /*tp_name*/
+ sizeof(PyFilter), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Filter_dealloc,/*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Source filter BGR24 objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ NULL, /* tp_methods */
+ 0, /* tp_members */
+ NULL, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Filter_init<FilterBGR24>, /* tp_init */
+ 0, /* tp_alloc */
+ Filter_allocNew, /* tp_new */
+};
+
diff --git a/source/gameengine/VideoTexture/FilterSource.h b/source/gameengine/VideoTexture/FilterSource.h
new file mode 100644
index 00000000000..7e90747d252
--- /dev/null
+++ b/source/gameengine/VideoTexture/FilterSource.h
@@ -0,0 +1,258 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of blendTex library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined FILTERSOURCE_H
+#define FILTERSOURCE_H
+
+#include "Common.h"
+
+#include "FilterBase.h"
+
+
+/// class for RGB24 conversion
+class FilterRGB24 : public FilterBase
+{
+public:
+ /// constructor
+ FilterRGB24 (void) {}
+ /// destructor
+ virtual ~FilterRGB24 (void) {}
+
+ /// get source pixel size
+ virtual unsigned int getPixelSize (void) { return 3; }
+
+protected:
+ /// filter pixel, source byte buffer
+ virtual unsigned int filter (unsigned char * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val)
+ { VT_RGBA(val,src[0],src[1],src[2],0xFF); return val; }
+};
+
+/// class for RGBA32 conversion
+class FilterRGBA32 : public FilterBase
+{
+public:
+ /// constructor
+ FilterRGBA32 (void) {}
+ /// destructor
+ virtual ~FilterRGBA32 (void) {}
+
+ /// get source pixel size
+ virtual unsigned int getPixelSize (void) { return 4; }
+
+protected:
+ /// filter pixel, source byte buffer
+ virtual unsigned int filter (unsigned char * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val)
+ {
+ if ((intptr_t(src)&0x3) == 0)
+ return *(unsigned int*)src;
+ else
+ {
+ VT_RGBA(val,src[0],src[1],src[2],src[3]);
+ return val;
+ }
+ }
+};
+
+/// class for BGR24 conversion
+class FilterBGR24 : public FilterBase
+{
+public:
+ /// constructor
+ FilterBGR24 (void) {}
+ /// destructor
+ virtual ~FilterBGR24 (void) {}
+
+ /// get source pixel size
+ virtual unsigned int getPixelSize (void) { return 3; }
+
+protected:
+ /// filter pixel, source byte buffer
+ virtual unsigned int filter (unsigned char * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val)
+ { VT_RGBA(val,src[2],src[1],src[0],0xFF); return val; }
+};
+
+/// class for YV12 conversion
+class FilterYV12 : public FilterBase
+{
+public:
+ /// constructor
+ FilterYV12 (void) {}
+ /// destructor
+ virtual ~FilterYV12 (void) {}
+
+ /// get source pixel size
+ virtual unsigned int getPixelSize (void) { return 1; }
+
+ /// set pointers to color buffers
+ void setBuffs (unsigned char * buff, short * size)
+ {
+ unsigned int buffSize = size[0] * size[1];
+ m_buffV = buff + buffSize;
+ m_buffU = m_buffV + (buffSize >> 2);
+ m_pitchUV = size[0] >> 1;
+ }
+
+protected:
+ /// begin of V buffer
+ unsigned char * m_buffV;
+ /// begin of U buffer
+ unsigned char * m_buffU;
+ /// pitch for V & U buffers
+ short m_pitchUV;
+
+ /// interpolation function
+ int interpol (int a, int b, int c, int d)
+ { return (9 * (b + c) - a - d + 8) >> 4; }
+
+ /// common horizontal interpolation
+ int interpolH (unsigned char * src)
+ { return interpol(*(src-1), *src, *(src+1), *(src+2)); }
+
+ /// common vertical interpolation
+ int interpolV (unsigned char * src)
+ { return interpol(*(src-m_pitchUV), *src, *(src+m_pitchUV), *(src+2*m_pitchUV)); }
+
+ /// common joined vertical and horizontal interpolation
+ int interpolVH (unsigned char * src)
+ {
+ return interpol(interpolV(src-1), interpolV(src), interpolV(src+1),
+ interpolV(src+2));
+ }
+
+ /// is pixel on edge
+ bool isEdge (short x, short y, short * size)
+ { return x <= 1 || x >= size[0] - 4 || y <= 1 || y >= size[1] - 4; }
+
+ /// get the first parameter on the low edge
+ unsigned char * interParA (unsigned char * src, short x, short size, short shift)
+ { return x > 1 ? src - shift : src; }
+ /// get the third parameter on the high edge
+ unsigned char * interParC (unsigned char * src, short x, short size, short shift)
+ { return x < size - 2 ? src + shift : src; }
+ /// get the fourth parameter on the high edge
+ unsigned char * interParD (unsigned char * src, short x, short size, short shift)
+ { return x < size - 4 ? src + 2 * shift : x < size - 2 ? src + shift : src; }
+
+ /// horizontal interpolation on edges
+ int interpolEH (unsigned char * src, short x, short size)
+ {
+ return interpol(*interParA(src, x, size, 1), *src,
+ *interParC(src, x, size, 1), *interParD(src, x, size, 1));
+ }
+
+ /// vertical interpolation on edges
+ int interpolEV (unsigned char * src, short y, short size)
+ {
+ return interpol(*interParA(src, y, size, m_pitchUV), *src,
+ *interParC(src, y, size, m_pitchUV), *interParD(src, y, size, m_pitchUV));
+ }
+
+ /// joined vertical and horizontal interpolation on edges
+ int interpolEVH (unsigned char * src, short x, short y, short * size)
+ {
+ return interpol(interpolEV(interParA(src, x, size[0], 1), y, size[1]),
+ interpolEV(src, y, size[1]), interpolEV(interParC(src, x, size[0], 1), y, size[1]),
+ interpolEV(interParD(src, x, size[0], 1), y, size[1]));
+ }
+
+
+ /// filter pixel, source byte buffer
+ virtual unsigned int filter (unsigned char * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val)
+ {
+ // V & U offset
+ long offset = (x >> 1) + m_pitchUV * (y >> 1);
+ // get modified YUV -> CDE: C = Y - 16; D = U - 128; E = V - 128
+ int c = *src - 16;
+ int d = m_buffU[offset] - 128;
+ int e = m_buffV[offset] - 128;
+ // if horizontal interpolation is needed
+ if ((x & 1) == 1)
+ // if vertical interpolation is needed too
+ if ((y & 1) == 1)
+ // if this pixel is on the edge
+ if (isEdge(x, y, size))
+ {
+ // get U & V from edge
+ d = interpolEVH(m_buffU + offset, x, y, size) - 128;
+ e = interpolEVH(m_buffV + offset, x, y, size) - 128;
+ }
+ // otherwise get U & V from inner range
+ else
+ {
+ d = interpolVH(m_buffU + offset) - 128;
+ e = interpolVH(m_buffV + offset) - 128;
+ }
+ // otherwise use horizontal interpolation only
+ else
+ // if this pixel is on the edge
+ if (isEdge(x, y, size))
+ {
+ // get U & V from edge
+ d = interpolEH(m_buffU + offset, x, size[0]) - 128;
+ e = interpolEH(m_buffV + offset, x, size[0]) - 128;
+ }
+ // otherwise get U & V from inner range
+ else
+ {
+ d = interpolH(m_buffU + offset) - 128;
+ e = interpolH(m_buffV + offset) - 128;
+ }
+ // otherwise if only vertical interpolation is needed
+ else if ((y & 1) == 1)
+ // if this pixel is on the edge
+ if (isEdge(x, y, size))
+ {
+ // get U & V from edge
+ d = interpolEV(m_buffU + offset, y, size[1]) - 128;
+ e = interpolEV(m_buffV + offset, y, size[1]) - 128;
+ }
+ // otherwise get U & V from inner range
+ else
+ {
+ d = interpolV(m_buffU + offset) - 128;
+ e = interpolV(m_buffV + offset) - 128;
+ }
+ // convert to RGB
+ // R = clip(( 298 * C + 409 * E + 128) >> 8)
+ // G = clip(( 298 * C - 100 * D - 208 * E + 128) >> 8)
+ // B = clip(( 298 * C + 516 * D + 128) >> 8)
+ int red = (298 * c + 409 * e + 128) >> 8;
+ if (red >= 0x100) red = 0xFF;
+ else if (red < 0) red = 0;
+ int green = (298 * c - 100 * d - 208 * e) >> 8;
+ if (green >= 0x100) green = 0xFF;
+ else if (green < 0) green = 0;
+ int blue = (298 * c + 516 * d + 128) >> 8;
+ if (blue >= 0x100) blue = 0xFF;
+ else if (blue < 0) blue = 0;
+ // return result
+ VT_RGBA(val, red, green, blue, 0xFF);
+ return val;
+ }
+};
+
+
+#endif
diff --git a/source/gameengine/VideoTexture/ImageBase.cpp b/source/gameengine/VideoTexture/ImageBase.cpp
new file mode 100644
index 00000000000..dcca20de24a
--- /dev/null
+++ b/source/gameengine/VideoTexture/ImageBase.cpp
@@ -0,0 +1,529 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#include "ImageBase.h"
+
+#include <vector>
+#include <string.h>
+
+#include <PyObjectPlus.h>
+#include <structmember.h>
+
+#include "FilterBase.h"
+
+#include "Exception.h"
+
+
+
+// ImageBase class implementation
+
+// constructor
+ImageBase::ImageBase (bool staticSrc) : m_image(NULL), m_imgSize(0),
+m_avail(false), m_scale(false), m_scaleChange(false), m_flip(false),
+m_staticSources(staticSrc), m_pyfilter(NULL)
+{
+ m_size[0] = m_size[1] = 0;
+}
+
+
+// destructor
+ImageBase::~ImageBase (void)
+{
+ // release image
+ delete [] m_image;
+}
+
+
+// release python objects
+bool ImageBase::release (void)
+{
+ // iterate sources
+ for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
+ {
+ // release source object
+ delete *it;
+ *it = NULL;
+ }
+ // release filter object
+ Py_XDECREF(m_pyfilter);
+ m_pyfilter = NULL;
+ return true;
+}
+
+
+// get image
+unsigned int * ImageBase::getImage (unsigned int texId)
+{
+ // if image is not available
+ if (!m_avail)
+ {
+ // if there are any sources
+ if (!m_sources.empty())
+ {
+ // get images from sources
+ for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
+ // get source image
+ (*it)->getImage();
+ // init image
+ init(m_sources[0]->getSize()[0], m_sources[0]->getSize()[1]);
+ }
+ // calculate new image
+ calcImage(texId);
+ }
+ // if image is available, return it, otherwise NULL
+ return m_avail ? m_image : NULL;
+}
+
+
+// refresh image source
+void ImageBase::refresh (void)
+{
+ // invalidate this image
+ m_avail = false;
+ // refresh all sources
+ for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
+ (*it)->refresh();
+}
+
+
+// get source object
+PyImage * ImageBase::getSource (const char * id)
+{
+ // find source
+ ImageSourceList::iterator src = findSource(id);
+ // return it, if found
+ return src != m_sources.end() ? (*src)->getSource() : NULL;
+}
+
+
+// set source object
+bool ImageBase::setSource (const char * id, PyImage * source)
+{
+ // find source
+ ImageSourceList::iterator src = findSource(id);
+ // check source loop
+ if (source != NULL && source->m_image->loopDetect(this))
+ return false;
+ // if found, set new object
+ if (src != m_sources.end())
+ // if new object is not empty or sources are static
+ if (source != NULL || m_staticSources)
+ // replace previous source
+ (*src)->setSource(source);
+ // otherwise delete source
+ else
+ m_sources.erase(src);
+ // if source is not found and adding is allowed
+ else
+ if (!m_staticSources)
+ {
+ // create new source
+ ImageSource * newSrc = newSource(id);
+ newSrc->setSource(source);
+ // if source was created, add it to source list
+ if (newSrc != NULL) m_sources.push_back(newSrc);
+ }
+ // otherwise source wasn't set
+ else
+ return false;
+ // source was set
+ return true;
+}
+
+
+// set pixel filter
+void ImageBase::setFilter (PyFilter * filt)
+{
+ // reference new filter
+ if (filt != NULL) Py_INCREF(filt);
+ // release previous filter
+ Py_XDECREF(m_pyfilter);
+ // set new filter
+ m_pyfilter = filt;
+}
+
+
+// initialize image data
+void ImageBase::init (short width, short height)
+{
+ // if image has to be scaled
+ if (m_scale)
+ {
+ // recalc sizes of image
+ width = calcSize(width);
+ height = calcSize(height);
+ }
+ // if sizes differ
+ if (width != m_size[0] || height != m_size[1])
+ {
+ // new buffer size
+ unsigned int newSize = width * height;
+ // if new buffer is larger than previous
+ if (newSize > m_imgSize)
+ {
+ // set new buffer size
+ m_imgSize = newSize;
+ // release previous and create new buffer
+ delete [] m_image;
+ m_image = new unsigned int[m_imgSize];
+ }
+ // new image size
+ m_size[0] = width;
+ m_size[1] = height;
+ // scale was processed
+ m_scaleChange = false;
+ }
+}
+
+
+// find source
+ImageSourceList::iterator ImageBase::findSource (const char * id)
+{
+ // iterate sources
+ ImageSourceList::iterator it;
+ for (it = m_sources.begin(); it != m_sources.end(); ++it)
+ // if id matches, return iterator
+ if ((*it)->is(id)) return it;
+ // source not found
+ return it;
+}
+
+
+// check sources sizes
+bool ImageBase::checkSourceSizes (void)
+{
+ // reference size
+ short * refSize = NULL;
+ // iterate sources
+ for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
+ {
+ // get size of current source
+ short * curSize = (*it)->getSize();
+ // if size is available and is not empty
+ if (curSize[0] != 0 && curSize[1] != 0)
+ // if reference size is not set
+ if (refSize == NULL)
+ // set current size as reference
+ refSize = curSize;
+ // otherwise check with current size
+ else if (curSize[0] != refSize[0] || curSize[1] != refSize[1])
+ // if they don't match, report it
+ return false;
+ }
+ // all sizes match
+ return true;
+}
+
+
+// compute nearest power of 2 value
+short ImageBase::calcSize (short size)
+{
+ // while there is more than 1 bit in size value
+ while ((size & (size - 1)) != 0)
+ // clear last bit
+ size = size & (size - 1);
+ // return result
+ return size;
+}
+
+
+// perform loop detection
+bool ImageBase::loopDetect (ImageBase * img)
+{
+ // if this object is the same as parameter, loop is detected
+ if (this == img) return true;
+ // check all sources
+ for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
+ // if source detected loop, return this result
+ if ((*it)->getSource() != NULL && (*it)->getSource()->m_image->loopDetect(img))
+ return true;
+ // no loop detected
+ return false;
+}
+
+
+// ImageSource class implementation
+
+// constructor
+ImageSource::ImageSource (const char * id) : m_source(NULL), m_image(NULL)
+{
+ // copy id
+ int idx;
+ for (idx = 0; id[idx] != '\0' && idx < SourceIdSize - 1; ++idx)
+ m_id[idx] = id[idx];
+ m_id[idx] = '\0';
+}
+
+// destructor
+ImageSource::~ImageSource (void)
+{
+ // release source
+ setSource(NULL);
+}
+
+
+// compare id
+bool ImageSource::is (const char * id)
+{
+ for (char * myId = m_id; *myId != '\0'; ++myId, ++id)
+ if (*myId != *id) return false;
+ return *id == '\0';
+}
+
+
+// set source object
+void ImageSource::setSource (PyImage * source)
+{
+ // reference new source
+ if (source != NULL) Py_INCREF(source);
+ // release previous source
+ Py_XDECREF(m_source);
+ // set new source
+ m_source = source;
+}
+
+
+// get image from source
+unsigned int * ImageSource::getImage (void)
+{
+ // if source is available
+ if (m_source != NULL)
+ // get image from source
+ m_image = m_source->m_image->getImage();
+ // otherwise reset buffer
+ else
+ m_image = NULL;
+ // return image
+ return m_image;
+}
+
+
+// refresh source
+void ImageSource::refresh (void)
+{
+ // if source is available, refresh it
+ if (m_source != NULL) m_source->m_image->refresh();
+}
+
+
+
+// list of image types
+PyTypeList pyImageTypes;
+
+
+
+// functions for python interface
+
+// object allocation
+PyObject * Image_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwds)
+{
+ // allocate object
+ PyImage * self = reinterpret_cast<PyImage*>(type->tp_alloc(type, 0));
+ // initialize object structure
+ self->m_image = NULL;
+ // return allocated object
+ return reinterpret_cast<PyObject*>(self);
+}
+
+// object deallocation
+void Image_dealloc (PyImage * self)
+{
+ // release object attributes
+ if (self->m_image != NULL)
+ {
+ // if release requires deleting of object, do it
+ if (self->m_image->release())
+ delete self->m_image;
+ self->m_image = NULL;
+ }
+}
+
+// get image data
+PyObject * Image_getImage (PyImage * self, void * closure)
+{
+ try
+ {
+ // get image
+ unsigned int * image = self->m_image->getImage();
+ return Py_BuildValue("s#", image, self->m_image->getBuffSize());
+ }
+ catch (Exception & exp)
+ {
+ exp.report();
+ }
+ Py_RETURN_NONE;
+}
+
+// get image size
+PyObject * Image_getSize (PyImage * self, void * closure)
+{
+ return Py_BuildValue("(hh)", self->m_image->getSize()[0],
+ self->m_image->getSize()[1]);
+}
+
+// refresh image
+PyObject * Image_refresh (PyImage * self)
+{
+ self->m_image->refresh();
+ Py_RETURN_NONE;
+}
+
+// get scale
+PyObject * Image_getScale (PyImage * self, void * closure)
+{
+ if (self->m_image != NULL && self->m_image->getScale()) Py_RETURN_TRUE;
+ else Py_RETURN_FALSE;
+}
+
+// set scale
+int Image_setScale (PyImage * self, PyObject * value, void * closure)
+{
+ // check parameter, report failure
+ if (value == NULL || !PyBool_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a bool");
+ return -1;
+ }
+ // set scale
+ if (self->m_image != NULL) self->m_image->setScale(value == Py_True);
+ // success
+ return 0;
+}
+
+// get flip
+PyObject * Image_getFlip (PyImage * self, void * closure)
+{
+ if (self->m_image != NULL && self->m_image->getFlip()) Py_RETURN_TRUE;
+ else Py_RETURN_FALSE;
+}
+
+// set flip
+int Image_setFlip (PyImage * self, PyObject * value, void * closure)
+{
+ // check parameter, report failure
+ if (value == NULL || !PyBool_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a bool");
+ return -1;
+ }
+ // set scale
+ if (self->m_image != NULL) self->m_image->setFlip(value == Py_True);
+ // success
+ return 0;
+}
+
+
+// get filter source object
+PyObject * Image_getSource (PyImage * self, PyObject * args)
+{
+ // get arguments
+ char * id;
+ if (self->m_image != NULL && PyArg_ParseTuple(args, "s", &id))
+ {
+ // get source object
+ PyObject * src = reinterpret_cast<PyObject*>(self->m_image->getSource(id));
+ // if source is available
+ if (src != NULL)
+ {
+ // return source
+ Py_INCREF(src);
+ return src;
+ }
+ }
+ // source was not found
+ Py_RETURN_NONE;
+}
+
+
+// set filter source object
+PyObject * Image_setSource (PyImage * self, PyObject * args)
+{
+ // get arguments
+ char * id;
+ PyObject * obj;
+ if (self->m_image != NULL && PyArg_ParseTuple(args, "sO", &id, &obj))
+ {
+ // check type of object
+ if (pyImageTypes.in(obj->ob_type))
+ {
+ // convert to image struct
+ PyImage * img = reinterpret_cast<PyImage*>(obj);
+ // set source
+ if (!self->m_image->setSource(id, img))
+ {
+ // if not set, retport error
+ PyErr_SetString(PyExc_RuntimeError, "Invalid source or id");
+ return NULL;
+ }
+ }
+ // else report error
+ else
+ {
+ PyErr_SetString(PyExc_RuntimeError, "Invalid type of object");
+ return NULL;
+ }
+ }
+ // return none
+ Py_RETURN_NONE;
+}
+
+
+// get pixel filter object
+PyObject * Image_getFilter (PyImage * self, void * closure)
+{
+ // if image object is available
+ if (self->m_image != NULL)
+ {
+ // pixel filter object
+ PyObject * filt = reinterpret_cast<PyObject*>(self->m_image->getFilter());
+ // if filter is present
+ if (filt != NULL)
+ {
+ // return it
+ Py_INCREF(filt);
+ return filt;
+ }
+ }
+ // otherwise return none
+ Py_RETURN_NONE;
+}
+
+
+// set pixel filter object
+int Image_setFilter (PyImage * self, PyObject * value, void * closure)
+{
+ // if image object is available
+ if (self->m_image != NULL)
+ {
+ // check new value
+ if (value == NULL || !pyFilterTypes.in(value->ob_type))
+ {
+ // report value error
+ PyErr_SetString(PyExc_TypeError, "Invalid type of value");
+ return -1;
+ }
+ // set new value
+ self->m_image->setFilter(reinterpret_cast<PyFilter*>(value));
+ }
+ // return success
+ return 0;
+}
diff --git a/source/gameengine/VideoTexture/ImageBase.h b/source/gameengine/VideoTexture/ImageBase.h
new file mode 100644
index 00000000000..138580ce701
--- /dev/null
+++ b/source/gameengine/VideoTexture/ImageBase.h
@@ -0,0 +1,349 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of blendTex library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined IMAGEBASE_H
+#define IMAGEBASE_H
+
+#include "Common.h"
+
+#include <vector>
+#include <PyObjectPlus.h>
+
+#include "PyTypeList.h"
+
+#include "FilterBase.h"
+
+
+// forward declarations
+struct PyImage;
+class ImageSource;
+
+
+/// type for list of image sources
+typedef std::vector<ImageSource*> ImageSourceList;
+
+
+/// base class for image filters
+class ImageBase
+{
+public:
+ /// constructor
+ ImageBase (bool staticSrc = false);
+ /// destructor
+ virtual ~ImageBase (void);
+ /// release contained objects, if returns true, object should be deleted
+ virtual bool release (void);
+
+ /// get image
+ unsigned int * getImage (unsigned int texId = 0);
+ /// get image size
+ short * getSize (void) { return m_size; }
+ /// get image buffer size
+ unsigned long getBuffSize (void)
+ { return m_size[0] * m_size[1] * sizeof(unsigned int); }
+ /// refresh image - invalidate its current content
+ virtual void refresh (void);
+
+ /// get scale
+ bool getScale (void) { return m_scale; }
+ /// set scale
+ void setScale (bool scale) { m_scale = scale; m_scaleChange = true; }
+ /// get vertical flip
+ bool getFlip (void) { return m_flip; }
+ /// set vertical flip
+ void setFlip (bool flip) { m_flip = flip; }
+
+ /// get source object
+ PyImage * getSource (const char * id);
+ /// set source object, return true, if source was set
+ bool setSource (const char * id, PyImage * source);
+
+ /// get pixel filter
+ PyFilter * getFilter (void) { return m_pyfilter; }
+ /// set pixel filter
+ void setFilter (PyFilter * filt);
+
+ /// calculate size (nearest power of 2)
+ static short calcSize (short size);
+
+protected:
+ /// image buffer
+ unsigned int * m_image;
+ /// image buffer size
+ unsigned int m_imgSize;
+ /// image size
+ short m_size[2];
+ /// image is available
+ bool m_avail;
+
+ /// scale image to power 2 sizes
+ bool m_scale;
+ /// scale was changed
+ bool m_scaleChange;
+ /// flip image vertically
+ bool m_flip;
+
+ /// source image list
+ ImageSourceList m_sources;
+ /// flag for disabling addition and deletion of sources
+ bool m_staticSources;
+
+ /// pixel filter
+ PyFilter * m_pyfilter;
+
+ /// initialize image data
+ void init (short width, short height);
+
+ /// find source
+ ImageSourceList::iterator findSource (const char * id);
+
+ /// create new source
+ virtual ImageSource * newSource (const char * id) { return NULL; }
+
+ /// check source sizes
+ bool checkSourceSizes (void);
+
+ /// calculate image from sources and set its availability
+ virtual void calcImage (unsigned int texId) {}
+
+ /// perform loop detection
+ bool loopDetect (ImageBase * img);
+
+ /// template for image conversion
+ template<class FLT, class SRC> void convImage (FLT & filter, SRC srcBuff,
+ short * srcSize)
+ {
+ // destination buffer
+ unsigned int * dstBuff = m_image;
+ // pixel size from filter
+ unsigned int pixSize = filter.firstPixelSize();
+ // if no scaling is needed
+ if (srcSize[0] == m_size[0] && srcSize[1] == m_size[1])
+ // if flipping isn't required
+ if (!m_flip)
+ // copy bitmap
+ for (short y = 0; y < m_size[1]; ++y)
+ for (short x = 0; x < m_size[0]; ++x, ++dstBuff, srcBuff += pixSize)
+ // copy pixel
+ *dstBuff = filter.convert(srcBuff, x, y, srcSize, pixSize);
+ // otherwise flip image top to bottom
+ else
+ {
+ // go to last row of image
+ srcBuff += srcSize[0] * (srcSize[1] - 1) * pixSize;
+ // copy bitmap
+ for (short y = m_size[1] - 1; y >= 0; --y, srcBuff -= 2 * srcSize[0] * pixSize)
+ for (short x = 0; x < m_size[0]; ++x, ++dstBuff, srcBuff += pixSize)
+ // copy pixel
+ *dstBuff = filter.convert(srcBuff, x, y, srcSize, pixSize);
+ }
+ // else scale picture (nearest neighbour)
+ else
+ {
+ // interpolation accumulator
+ int accHeight = srcSize[1] >> 1;
+ // if flipping is required
+ if (m_flip)
+ // go to last row of image
+ srcBuff += srcSize[0] * (srcSize[1] - 1) * pixSize;
+ // process image rows
+ for (int y = 0; y < srcSize[1]; ++y)
+ {
+ // increase height accum
+ accHeight += m_size[1];
+ // if pixel row has to be drawn
+ if (accHeight >= srcSize[1])
+ {
+ // decrease accum
+ accHeight -= srcSize[1];
+ // width accum
+ int accWidth = srcSize[0] >> 1;
+ // process row
+ for (int x = 0; x < srcSize[0]; ++x)
+ {
+ // increase width accum
+ accWidth += m_size[0];
+ // if pixel has to be drawn
+ if (accWidth >= srcSize[0])
+ {
+ // decrease accum
+ accWidth -= srcSize[0];
+ // convert pixel
+ *dstBuff = filter.convert(srcBuff, x, m_flip ? srcSize[1] - y - 1 : y,
+ srcSize, pixSize);
+ // next pixel
+ ++dstBuff;
+ }
+ // shift source pointer
+ srcBuff += pixSize;
+ }
+ }
+ // if pixel row will not be drawn
+ else
+ // move source pointer to next row
+ srcBuff += pixSize * srcSize[0];
+ // if y flipping is required
+ if (m_flip)
+ // go to previous row of image
+ srcBuff -= 2 * pixSize * srcSize[0];
+ }
+ }
+ }
+
+ // template for specific filter preprocessing
+ template <class F, class SRC> void filterImage (F & filt, SRC srcBuff, short * srcSize)
+ {
+ // find first filter in chain
+ FilterBase * firstFilter = NULL;
+ if (m_pyfilter != NULL) firstFilter = m_pyfilter->m_filter->findFirst();
+ // if first filter is available
+ if (firstFilter != NULL)
+ {
+ // python wrapper for filter
+ PyFilter pyFilt;
+ pyFilt.m_filter = &filt;
+ // set specified filter as first in chain
+ firstFilter->setPrevious(&pyFilt, false);
+ // convert video image
+ convImage(*(m_pyfilter->m_filter), srcBuff, srcSize);
+ // delete added filter
+ firstFilter->setPrevious(NULL, false);
+ }
+ // otherwise use given filter for conversion
+ else convImage(filt, srcBuff, srcSize);
+ // source was processed
+ m_avail = true;
+ }
+};
+
+
+// python structure for image filter
+struct PyImage
+{
+ PyObject_HEAD
+ // source object
+ ImageBase * m_image;
+};
+
+
+// size of id
+const int SourceIdSize = 32;
+
+
+/// class for source of image
+class ImageSource
+{
+public:
+ /// constructor
+ ImageSource (const char * id);
+ /// destructor
+ virtual ~ImageSource (void);
+
+ /// get id
+ const char * getId (void) { return m_id; }
+ /// compare id to argument
+ bool is (const char * id);
+
+ /// get source object
+ PyImage * getSource (void) { return m_source; }
+ /// set source object
+ void setSource (PyImage * source);
+
+ /// get image from source
+ unsigned int * getImage (void);
+ /// get buffered image
+ unsigned int * getImageBuf (void) { return m_image; }
+ /// refresh source
+ void refresh (void);
+
+ /// get image size
+ short * getSize (void)
+ {
+ static short defSize [] = {0, 0};
+ return m_source != NULL ? m_source->m_image->getSize() : defSize;
+ }
+
+protected:
+ /// id of source
+ char m_id [SourceIdSize];
+ /// pointer to source structure
+ PyImage * m_source;
+ /// buffered image from source
+ unsigned int * m_image;
+
+private:
+ /// default constructor is forbidden
+ ImageSource (void) {}
+};
+
+
+
+// list of python image types
+extern PyTypeList pyImageTypes;
+
+
+// functions for python interface
+
+// object initialization
+template <class T> static int Image_init (PyObject * pySelf, PyObject * args, PyObject * kwds)
+{
+ PyImage * self = reinterpret_cast<PyImage*>(pySelf);
+ // create source object
+ if (self->m_image != NULL) delete self->m_image;
+ self->m_image = new T();
+ // initialization succeded
+ return 0;
+}
+
+// object allocation
+PyObject * Image_allocNew (PyTypeObject * type, PyObject * args, PyObject * kwds);
+// object deallocation
+void Image_dealloc (PyImage * self);
+
+// get image data
+PyObject * Image_getImage (PyImage * self, void * closure);
+// get image size
+PyObject * Image_getSize (PyImage * self, void * closure);
+// refresh image - invalidate current content
+PyObject * Image_refresh (PyImage * self);
+
+// get scale
+PyObject * Image_getScale (PyImage * self, void * closure);
+// set scale
+int Image_setScale (PyImage * self, PyObject * value, void * closure);
+// get flip
+PyObject * Image_getFlip (PyImage * self, void * closure);
+// set flip
+int Image_setFlip (PyImage * self, PyObject * value, void * closure);
+
+// get filter source object
+PyObject * Image_getSource (PyImage * self, PyObject * args);
+// set filter source object
+PyObject * Image_setSource (PyImage * self, PyObject * args);
+
+// get pixel filter object
+PyObject * Image_getFilter (PyImage * self, void * closure);
+// set pixel filter object
+int Image_setFilter (PyImage * self, PyObject * value, void * closure);
+
+
+#endif
diff --git a/source/gameengine/VideoTexture/ImageBuff.cpp b/source/gameengine/VideoTexture/ImageBuff.cpp
new file mode 100644
index 00000000000..19ad17ac643
--- /dev/null
+++ b/source/gameengine/VideoTexture/ImageBuff.cpp
@@ -0,0 +1,166 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+// implementation
+
+#include <PyObjectPlus.h>
+#include <structmember.h>
+
+#include "ImageBuff.h"
+
+#include "ImageBase.h"
+#include "FilterSource.h"
+
+
+// default filter
+FilterRGB24 defFilter;
+
+
+// load image from buffer
+void ImageBuff::load (unsigned char * img, short width, short height)
+{
+ // initialize image buffer
+ init(width, height);
+ // original size
+ short orgSize[2] = {width, height};
+ // is filter available
+ if (m_pyfilter != NULL)
+ // use it to process image
+ convImage(*(m_pyfilter->m_filter), img, orgSize);
+ else
+ // otherwise use default filter
+ convImage(defFilter, img, orgSize);
+ // image is available
+ m_avail = true;
+}
+
+
+
+// cast Image pointer to ImageBuff
+inline ImageBuff * getImageBuff (PyImage * self)
+{ return static_cast<ImageBuff*>(self->m_image); }
+
+
+// python methods
+
+// load image
+static PyObject * load (PyImage * self, PyObject * args)
+{
+ // parameters: string image buffer, its size, width, height
+ unsigned char * buff;
+ unsigned int buffSize;
+ short width;
+ short height;
+ // parse parameters
+ if (!PyArg_ParseTuple(args, "s#hh", &buff, &buffSize, &width, &height))
+ {
+ // report error
+ PyErr_SetString(PyExc_TypeError, "Parameters are not correct");
+ return NULL;
+ }
+ // else check buffer size
+ else
+ {
+ // calc proper buffer size
+ unsigned int propSize = width * height;
+ // use pixel size from filter
+ if (self->m_image->getFilter() != NULL)
+ propSize *= self->m_image->getFilter()->m_filter->firstPixelSize();
+ else
+ propSize *= defFilter.firstPixelSize();
+ // check if buffer size is correct
+ if (propSize != buffSize)
+ {
+ // if not, report error
+ PyErr_SetString(PyExc_TypeError, "Buffer hasn't correct size");
+ return NULL;
+ }
+ else
+ // if correct, load image
+ getImageBuff(self)->load(buff, width, height);
+ }
+ Py_RETURN_NONE;
+}
+
+
+// methods structure
+static PyMethodDef imageBuffMethods[] =
+{
+ {"load", (PyCFunction)load, METH_VARARGS, "Load image from buffer"},
+ {NULL}
+};
+// attributes structure
+static PyGetSetDef imageBuffGetSets[] =
+{ // attributes from ImageBase class
+ {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
+ {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
+ {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL},
+ {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
+ {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
+ {NULL}
+};
+
+
+// define python type
+PyTypeObject ImageBuffType =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.ImageBuff", /*tp_name*/
+ sizeof(PyImage), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Image_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Image source from image buffer", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ imageBuffMethods, /* tp_methods */
+ 0, /* tp_members */
+ imageBuffGetSets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Image_init<ImageBuff>, /* tp_init */
+ 0, /* tp_alloc */
+ Image_allocNew, /* tp_new */
+};
+
diff --git a/source/gameengine/VideoTexture/ImageBuff.h b/source/gameengine/VideoTexture/ImageBuff.h
new file mode 100644
index 00000000000..fa2025fa8c4
--- /dev/null
+++ b/source/gameengine/VideoTexture/ImageBuff.h
@@ -0,0 +1,51 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined IMAGEBUFF_H
+#define IMAGEBUFF_H
+
+
+#include "Common.h"
+
+#include "ImageBase.h"
+
+
+/// class for image buffer
+class ImageBuff : public ImageBase
+{
+public:
+ /// constructor
+ ImageBuff (void) : ImageBase(true) {}
+
+ /// destructor
+ virtual ~ImageBuff (void) {}
+
+ /// load image from buffer
+ void load (unsigned char * img, short width, short height);
+
+ /// refresh image - do nothing
+ virtual void refresh (void) {}
+};
+
+
+#endif
+
diff --git a/source/gameengine/VideoTexture/ImageMix.cpp b/source/gameengine/VideoTexture/ImageMix.cpp
new file mode 100644
index 00000000000..b07b362818c
--- /dev/null
+++ b/source/gameengine/VideoTexture/ImageMix.cpp
@@ -0,0 +1,205 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+// implementation
+
+#include <PyObjectPlus.h>
+#include <structmember.h>
+
+#include "ImageMix.h"
+
+#include "ImageBase.h"
+
+#include "Exception.h"
+
+
+// cast ImageSource pointer to ImageSourceMix
+inline ImageSourceMix * getImageSourceMix (ImageSource * src)
+{ return static_cast<ImageSourceMix*>(src); }
+
+
+// get weight
+short ImageMix::getWeight (const char * id)
+{
+ // find source
+ ImageSourceList::iterator src = findSource(id);
+ // if found, return its weight
+ return src != m_sources.end() ? getImageSourceMix(*src)->getWeight() : 0;
+}
+
+// set weight
+bool ImageMix::setWeight (const char * id, short weight)
+{
+ // find source
+ ImageSourceList::iterator src = findSource(id);
+ // if source isn't found, report it
+ if (src == m_sources.end()) return false;
+ // set its weight
+ getImageSourceMix(*src)->setWeight(weight);
+ return true;
+}
+
+ExceptionID ImageSizesNotMatch;
+
+ExpDesc ImageSizesNotMatchDesc (ImageSizesNotMatch, "Image sizes of sources are different");
+
+// calculate image from sources and set its availability
+void ImageMix::calcImage (unsigned int texId)
+{
+ // check source sizes
+ if (!checkSourceSizes()) THRWEXCP(ImageSizesNotMatch, S_OK);
+ // set offsets to image buffers
+ for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
+ // if image buffer is available
+ if ((*it)->getImageBuf() != NULL)
+ // set its offset
+ getImageSourceMix(*it)->setOffset(m_sources[0]->getImageBuf());
+ // otherwise don't calculate image
+ else
+ return;
+ // if there is only single source
+ if (m_sources.size() == 1)
+ {
+ // use single filter
+ FilterBase mixFilt;
+ // fiter and convert image
+ filterImage(mixFilt, m_sources[0]->getImageBuf(), m_sources[0]->getSize());
+ }
+ // otherwise use mix filter to merge source images
+ else
+ {
+ FilterImageMix mixFilt (m_sources);
+ // fiter and convert image
+ filterImage(mixFilt, m_sources[0]->getImageBuf(), m_sources[0]->getSize());
+ }
+}
+
+
+
+// cast Image pointer to ImageMix
+inline ImageMix * getImageMix (PyImage * self)
+{ return static_cast<ImageMix*>(self->m_image); }
+
+
+// python methods
+
+// get source weight
+PyObject * getWeight (PyImage * self, PyObject * args)
+{
+ // weight
+ short weight = 0;
+ // get arguments
+ char * id;
+ if (self->m_image != NULL && PyArg_ParseTuple(args, "s", &id))
+ // get weight
+ weight = getImageMix(self)->getWeight(id);
+ // return weight
+ return Py_BuildValue("h", weight);
+}
+
+
+// set source weight
+PyObject * setWeight (PyImage * self, PyObject * args)
+{
+ // get arguments
+ char * id;
+ short weight = 0;
+ if (self->m_image != NULL && PyArg_ParseTuple(args, "sh", &id, &weight))
+ // set weight
+ if (!getImageMix(self)->setWeight(id, weight))
+ {
+ // if not set, report error
+ PyErr_SetString(PyExc_RuntimeError, "Invalid id of source");;
+ return NULL;
+ }
+ // return none
+ Py_RETURN_NONE;
+}
+
+
+// methods structure
+static PyMethodDef imageMixMethods[] =
+{
+ {"getSource", (PyCFunction)Image_getSource, METH_VARARGS, "get image source"},
+ {"setSource", (PyCFunction)Image_setSource, METH_VARARGS, "set image source"},
+ {"getWeight", (PyCFunction)getWeight, METH_VARARGS, "get image source weight"},
+ {"setWeight", (PyCFunction)setWeight, METH_VARARGS, "set image source weight"},
+ // methods from ImageBase class
+ {"refresh", (PyCFunction)Image_refresh, METH_NOARGS, "Refresh image - invalidate its current content"},
+ {NULL}
+};
+// attributes structure
+static PyGetSetDef imageMixGetSets[] =
+{ // attributes from ImageBase class
+ {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
+ {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
+ {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL},
+ {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
+ {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
+ {NULL}
+};
+
+
+// define python type
+PyTypeObject ImageMixType =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.ImageMix", /*tp_name*/
+ sizeof(PyImage), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Image_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Image mixer", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ imageMixMethods, /* tp_methods */
+ 0, /* tp_members */
+ imageMixGetSets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Image_init<ImageMix>, /* tp_init */
+ 0, /* tp_alloc */
+ Image_allocNew, /* tp_new */
+};
+
diff --git a/source/gameengine/VideoTexture/ImageMix.h b/source/gameengine/VideoTexture/ImageMix.h
new file mode 100644
index 00000000000..b4842bd6b40
--- /dev/null
+++ b/source/gameengine/VideoTexture/ImageMix.h
@@ -0,0 +1,123 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined IMAGEMIX_H
+#define IMAGEMIX_H
+
+
+#include "Common.h"
+
+#include "ImageBase.h"
+#include "FilterBase.h"
+
+
+/// class for source mixing
+class ImageSourceMix : public ImageSource
+{
+public:
+ /// constructor
+ ImageSourceMix (const char * id) : ImageSource(id), m_weight(0x100) {}
+ /// destructor
+ virtual ~ImageSourceMix (void) {}
+
+ /// get offset
+ long long getOffset (void) { return m_offset; }
+ /// set offset
+ void setOffset (unsigned int * firstImg) { m_offset = m_image - firstImg; }
+
+ /// get weight
+ short getWeight (void) { return m_weight; }
+ /// set weight
+ void setWeight (short weight) { m_weight = weight; }
+
+protected:
+ /// buffer offset to the first source buffer
+ long long m_offset;
+ /// source weight
+ short m_weight;
+};
+
+
+/// class for image mixer
+class ImageMix : public ImageBase
+{
+public:
+ /// constructor
+ ImageMix (void) : ImageBase(false) {}
+
+ /// destructor
+ virtual ~ImageMix (void) {}
+
+ /// get weight
+ short getWeight (const char * id);
+ /// set weight
+ bool setWeight (const char * id, short weight);
+
+protected:
+
+ /// create new source
+ virtual ImageSource * newSource (const char * id) { return new ImageSourceMix(id); }
+
+ /// calculate image from sources and set its availability
+ virtual void calcImage (unsigned int texId);
+};
+
+
+/// pixel filter for image mixer
+class FilterImageMix : public FilterBase
+{
+public:
+ /// constructor
+ FilterImageMix (ImageSourceList & sources) : m_sources(sources) {}
+ /// destructor
+ virtual ~FilterImageMix (void) {}
+
+protected:
+ /// source list
+ ImageSourceList & m_sources;
+
+ /// filter pixel, source int buffer
+ virtual unsigned int filter (unsigned int * src, short x, short y,
+ short * size, unsigned int pixSize, unsigned int val = 0)
+ {
+ // resulting pixel color
+ int color[] = {0, 0, 0, 0};
+ // iterate sources
+ for (ImageSourceList::iterator it = m_sources.begin(); it != m_sources.end(); ++it)
+ {
+ // get pointer to mixer source
+ ImageSourceMix * mixSrc = static_cast<ImageSourceMix*>(*it);
+ // add weighted source pixel to result
+ color[0] += mixSrc->getWeight() * (src[mixSrc->getOffset()] & 0xFF);
+ color[1] += mixSrc->getWeight() * ((src[mixSrc->getOffset()] >> 8) & 0xFF);
+ color[2] += mixSrc->getWeight() * ((src[mixSrc->getOffset()] >> 16) & 0xFF);
+ color[3] += mixSrc->getWeight() * ((src[mixSrc->getOffset()] >> 24) & 0xFF);
+ }
+ // return resulting color
+ return ((color[0] >> 8) & 0xFF) | (color[1] & 0xFF00)
+ | ((color[2] << 8) & 0xFF0000) | ((color[3] << 16) & 0xFF000000);
+ }
+};
+
+
+#endif
+
diff --git a/source/gameengine/VideoTexture/ImageRender.cpp b/source/gameengine/VideoTexture/ImageRender.cpp
new file mode 100644
index 00000000000..a8f7871fa21
--- /dev/null
+++ b/source/gameengine/VideoTexture/ImageRender.cpp
@@ -0,0 +1,267 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+// implementation
+
+#include <PyObjectPlus.h>
+#include <structmember.h>
+
+#include <KX_BlenderCanvas.h>
+#include <KX_BlenderRenderTools.h>
+#include <RAS_IRasterizer.h>
+#include <RAS_OpenGLRasterizer.h>
+#include <KX_WorldInfo.h>
+#include <KX_Light.h>
+
+#include "ImageRender.h"
+
+#include "ImageBase.h"
+#include "BlendType.h"
+#include "Exception.h"
+
+ExceptionID SceneInvalid, CameraInvalid;
+ExpDesc SceneInvalidDesc (SceneInvalid, "Scene object is invalid");
+ExpDesc CameraInvalidDesc (CameraInvalid, "Camera object is invalid");
+
+#if 0 // not yet supported
+
+// constructor
+ImageRender::ImageRender (KX_Scene * scene, KX_Camera * camera) : m_scene(scene),
+m_camera(camera)
+{
+ // create screen area
+ m_area.winrct.xmin = m_upLeft[0];
+ m_area.winrct.ymin = m_upLeft[1];
+ m_area.winx = m_size[0];
+ m_area.winy = m_size[1];
+ // create canvas
+ m_canvas = new KX_BlenderCanvas(&m_area);
+ // create render tools
+ m_rendertools = new KX_BlenderRenderTools();
+ // create rasterizer
+ m_rasterizer = new RAS_OpenGLRasterizer(m_canvas);
+ m_rasterizer->Init();
+ // initialize background colour
+ setBackground(0, 0, 255);
+ // refresh lights
+ refreshLights();
+}
+
+// destructor
+ImageRender::~ImageRender (void)
+{
+ // release allocated objects
+ delete m_rasterizer;
+ delete m_rendertools;
+ delete m_canvas;
+}
+
+
+// set background color
+void ImageRender::setBackground (unsigned char red, unsigned char green, unsigned char blue)
+{
+ m_background[0] = red;
+ m_background[1] = green;
+ m_background[2] = blue;
+ m_rasterizer->SetBackColor(m_background[0], m_background[1], m_background[2], 1.0);
+}
+
+
+// capture image from viewport
+void ImageRender::calcImage (unsigned int texId)
+{
+ // setup camera
+ bool cameraPasive = !m_camera->GetViewport();
+ // render scene
+ Render();
+ // reset camera
+ if (cameraPasive) m_camera->EnableViewport(false);
+ // get image from viewport
+ ImageViewport::calcImage(texId);
+}
+
+void ImageRender::Render()
+{
+ //
+}
+
+// refresh lights
+void ImageRender::refreshLights (void)
+{
+ // clear lights list
+ //m_rendertools->RemoveAllLights();
+ // set lights
+ //for (int idx = 0; idx < scene->GetLightList()->GetCount(); ++idx)
+ // m_rendertools->AddLight(((KX_LightObject*)(scene->GetLightList()->GetValue(idx)))->GetLightData());
+}
+
+
+
+// cast Image pointer to ImageRender
+inline ImageRender * getImageRender (PyImage * self)
+{ return static_cast<ImageRender*>(self->m_image); }
+
+
+// python methods
+
+// Blender Scene type
+BlendType<KX_Scene> sceneType ("KX_Scene");
+// Blender Camera type
+BlendType<KX_Camera> cameraType ("KX_Camera");
+
+
+// object initialization
+static int ImageRender_init (PyObject * pySelf, PyObject * args, PyObject * kwds)
+{
+ // parameters - scene object
+ PyObject * scene;
+ // camera object
+ PyObject * camera;
+ // parameter keywords
+ static char *kwlist[] = {"sceneObj", "cameraObj", NULL};
+ // get parameters
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO", kwlist, &scene, &camera))
+ return -1;
+ try
+ {
+ // get scene pointer
+ KX_Scene * scenePtr (NULL);
+ if (scene != NULL) scenePtr = sceneType.checkType(scene);
+ // throw exception if scene is not available
+ if (scenePtr == NULL) THRWEXCP(SceneInvalid, S_OK);
+
+ // get camera pointer
+ KX_Camera * cameraPtr (NULL);
+ if (camera != NULL) cameraPtr = cameraType.checkType(camera);
+ // throw exception if camera is not available
+ if (cameraPtr == NULL) THRWEXCP(CameraInvalid, S_OK);
+
+ // get pointer to image structure
+ PyImage * self = reinterpret_cast<PyImage*>(pySelf);
+ // create source object
+ if (self->m_image != NULL) delete self->m_image;
+ self->m_image = new ImageRender(scenePtr, cameraPtr);
+ }
+ catch (Exception & exp)
+ {
+ exp.report();
+ return -1;
+ }
+ // initialization succeded
+ return 0;
+}
+
+
+// get background color
+PyObject * getBackground (PyImage * self, void * closure)
+{
+ return Py_BuildValue("[BBB]", getImageRender(self)->getBackground()[0],
+ getImageRender(self)->getBackground()[1], getImageRender(self)->getBackground()[2]);
+}
+
+// set color
+static int setBackground (PyImage * self, PyObject * value, void * closure)
+{
+ // check validity of parameter
+ if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 3
+ || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0))
+ || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1))
+ || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 2)))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 3 ints");
+ return -1;
+ }
+ // set background color
+ getImageRender(self)->setBackground((unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
+ (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1))),
+ (unsigned char)(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 2))));
+ // success
+ return 0;
+}
+
+
+// methods structure
+static PyMethodDef imageRenderMethods[] =
+{ // methods from ImageBase class
+ {"refresh", (PyCFunction)Image_refresh, METH_NOARGS, "Refresh image - invalidate its current content"},
+ {NULL}
+};
+// attributes structure
+static PyGetSetDef imageRenderGetSets[] =
+{
+ {(char*)"background", (getter)getBackground, (setter)setBackground, (char*)"background color", NULL},
+ // attributes from ImageBase class
+ {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
+ {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
+ {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL},
+ {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
+ {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
+ {NULL}
+};
+
+
+// define python type
+PyTypeObject ImageRenderType =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.ImageRender", /*tp_name*/
+ sizeof(PyImage), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Image_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Image source from render", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ imageRenderMethods, /* tp_methods */
+ 0, /* tp_members */
+ imageRenderGetSets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ImageRender_init, /* tp_init */
+ 0, /* tp_alloc */
+ Image_allocNew, /* tp_new */
+};
+
+
+#endif // #if 0
diff --git a/source/gameengine/VideoTexture/ImageRender.h b/source/gameengine/VideoTexture/ImageRender.h
new file mode 100644
index 00000000000..66255f04d2c
--- /dev/null
+++ b/source/gameengine/VideoTexture/ImageRender.h
@@ -0,0 +1,90 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined IMAGERENDER_H
+#define IMAGERENDER_H
+
+
+#include "Common.h"
+
+#include <KX_Scene.h>
+#include <KX_Camera.h>
+#include <DNA_screen_types.h>
+#include <RAS_ICanvas.h>
+#include <RAS_IRasterizer.h>
+#include <RAS_IRenderTools.h>
+
+#include "ImageViewport.h"
+
+
+/// class for render 3d scene
+class ImageRender : public ImageViewport
+{
+public:
+ /// constructor
+ ImageRender (KX_Scene * scene, KX_Camera * camera);
+
+ /// destructor
+ virtual ~ImageRender (void);
+
+ /// get background color
+ unsigned char * getBackground (void) { return m_background; }
+ /// set background color
+ void setBackground (unsigned char red, unsigned char green, unsigned char blue);
+
+protected:
+ /// rendered scene
+ KX_Scene * m_scene;
+ /// camera for render
+ KX_Camera * m_camera;
+
+ /// screen area for rendering
+ ScrArea m_area;
+ /// rendering device
+ RAS_ICanvas * m_canvas;
+ /// rasterizer
+ RAS_IRasterizer * m_rasterizer;
+ /// render tools
+ RAS_IRenderTools * m_rendertools;
+
+ /// background colour
+ unsigned char m_background[3];
+
+
+ /// render 3d scene to image
+ virtual void calcImage (unsigned int texId);
+
+ /// refresh lights
+ void refreshLights (void);
+ /// methods from KX_KetsjiEngine
+ bool BeginFrame();
+ void EndFrame();
+ void Render();
+ void SetupRenderFrame(KX_Scene *scene, KX_Camera* cam);
+ void RenderFrame(KX_Scene* scene, KX_Camera* cam);
+ void SetBackGround(KX_WorldInfo* wi);
+ void SetWorldSettings(KX_WorldInfo* wi);
+};
+
+
+#endif
+
diff --git a/source/gameengine/VideoTexture/ImageViewport.cpp b/source/gameengine/VideoTexture/ImageViewport.cpp
new file mode 100644
index 00000000000..deb66ffb6ba
--- /dev/null
+++ b/source/gameengine/VideoTexture/ImageViewport.cpp
@@ -0,0 +1,297 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+// implementation
+
+#include <PyObjectPlus.h>
+#include <structmember.h>
+
+#include <BIF_gl.h>
+
+#include "Texture.h"
+#include "ImageBase.h"
+#include "FilterSource.h"
+#include "ImageViewport.h"
+
+
+// constructor
+ImageViewport::ImageViewport (void) : m_texInit(false)
+{
+ // get viewport rectangle
+ glGetIntegerv(GL_VIEWPORT, m_viewport);
+ // create buffer for viewport image
+ m_viewportImage = new BYTE [3 * getViewportSize()[0] * getViewportSize()[1]];
+ // set attributes
+ setWhole(false);
+}
+
+// destructor
+ImageViewport::~ImageViewport (void)
+{ delete m_viewportImage; }
+
+
+// use whole viewport to capture image
+void ImageViewport::setWhole (bool whole)
+{
+ // set whole
+ m_whole = whole;
+ // set capture size to viewport size, if whole,
+ // otherwise place area in the middle of viewport
+ for (int idx = 0; idx < 2; ++idx)
+ {
+ // capture size
+ m_capSize[idx] = whole ? short(getViewportSize()[idx])
+ : calcSize(short(getViewportSize()[idx]));
+ // position
+ m_position[idx] = whole ? 0 : (getViewportSize()[idx] - m_capSize[idx]) >> 1;
+ }
+ // init image
+ init(m_capSize[0], m_capSize[1]);
+ // set capture position
+ setPosition();
+}
+
+void ImageViewport::setCaptureSize (short * size)
+{
+ m_whole = false;
+ if (size == NULL)
+ size = m_capSize;
+ for (int idx = 0; idx < 2; ++idx)
+ {
+ if (size[idx] < 1)
+ m_capSize[idx] = 1;
+ else if (size[idx] > getViewportSize()[idx])
+ m_capSize[idx] = short(getViewportSize()[idx]);
+ else
+ m_capSize[idx] = size[idx];
+ }
+ init(m_capSize[0], m_capSize[1]);
+ // set capture position
+ setPosition();
+}
+
+// set position of capture rectangle
+void ImageViewport::setPosition (GLint * pos)
+{
+ // if new position is not provided, use existing position
+ if (pos == NULL) pos = m_position;
+ // save position
+ for (int idx = 0; idx < 2; ++idx)
+ m_position[idx] = pos[idx] < 0 ? 0 : pos[idx] >= getViewportSize()[idx]
+ - m_capSize[idx] ? getViewportSize()[idx] - m_capSize[idx] : pos[idx];
+ // recalc up left corner
+ for (int idx = 0; idx < 2; ++idx)
+ m_upLeft[idx] = m_position[idx] + m_viewport[idx];
+}
+
+
+// capture image from viewport
+void ImageViewport::calcImage (unsigned int texId)
+{
+ // if scale was changed
+ if (m_scaleChange)
+ // reset image
+ init(m_capSize[0], m_capSize[1]);
+ // if texture wasn't initialized
+ if (!m_texInit)
+ {
+ // initialize it
+ loadTexture(texId, m_image, m_size);
+ m_texInit = true;
+ }
+ // if texture can be directly created
+ if (texId != 0 && m_pyfilter == NULL && m_capSize[0] == calcSize(m_capSize[0])
+ && m_capSize[1] == calcSize(m_capSize[1]) && !m_flip)
+ {
+ // just copy current viewport to texture
+ glBindTexture(GL_TEXTURE_2D, texId);
+ glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1]);
+ // image is not available
+ m_avail = false;
+ }
+ // otherwise copy viewport to buffer, if image is not available
+ else if (!m_avail)
+ {
+ // get frame buffer data
+ glReadPixels(m_upLeft[0], m_upLeft[1], (GLsizei)m_capSize[0], (GLsizei)m_capSize[1], GL_RGB,
+ GL_UNSIGNED_BYTE, m_viewportImage);
+ // filter loaded data
+ FilterRGB24 filt;
+ filterImage(filt, m_viewportImage, m_capSize);
+ }
+}
+
+
+
+// cast Image pointer to ImageViewport
+inline ImageViewport * getImageViewport (PyImage * self)
+{ return static_cast<ImageViewport*>(self->m_image); }
+
+
+// python methods
+
+
+// get whole
+static PyObject * ImageViewport_getWhole (PyImage * self, void * closure)
+{
+ if (self->m_image != NULL && getImageViewport(self)->getWhole()) Py_RETURN_TRUE;
+ else Py_RETURN_FALSE;
+}
+
+// set whole
+static int ImageViewport_setWhole (PyImage * self, PyObject * value, void * closure)
+{
+ // check parameter, report failure
+ if (value == NULL || !PyBool_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a bool");
+ return -1;
+ }
+ // set whole
+ if (self->m_image != NULL) getImageViewport(self)->setWhole(value == Py_True);
+ // success
+ return 0;
+}
+
+
+// get position
+static PyObject * ImageViewport_getPosition (PyImage * self, void * closure)
+{
+ return Py_BuildValue("(ii)", getImageViewport(self)->getPosition()[0],
+ getImageViewport(self)->getPosition()[1]);
+}
+
+// set position
+static int ImageViewport_setPosition (PyImage * self, PyObject * value, void * closure)
+{
+ // check validity of parameter
+ if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2
+ || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0))
+ || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1)))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints");
+ return -1;
+ }
+ // set position
+ GLint pos [] = {
+ GLint(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
+ GLint(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1)))
+ };
+ getImageViewport(self)->setPosition(pos);
+ // success
+ return 0;
+}
+
+// get capture size
+static PyObject * ImageViewport_getCaptureSize (PyImage * self, void * closure)
+{
+ return Py_BuildValue("(ii)", getImageViewport(self)->getCaptureSize()[0],
+ getImageViewport(self)->getCaptureSize()[1]);
+}
+
+// set capture size
+static int ImageViewport_setCaptureSize (PyImage * self, PyObject * value, void * closure)
+{
+ // check validity of parameter
+ if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2
+ || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 0))
+ || !PyInt_Check(PySequence_Fast_GET_ITEM(value, 1)))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints");
+ return -1;
+ }
+ // set capture size
+ short size [] = {
+ short(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 0))),
+ short(PyInt_AsLong(PySequence_Fast_GET_ITEM(value, 1)))
+ };
+ getImageViewport(self)->setCaptureSize(size);
+ // success
+ return 0;
+}
+
+
+// methods structure
+static PyMethodDef imageViewportMethods[] =
+{ // methods from ImageBase class
+ {"refresh", (PyCFunction)Image_refresh, METH_NOARGS, "Refresh image - invalidate its current content"},
+ {NULL}
+};
+// attributes structure
+static PyGetSetDef imageViewportGetSets[] =
+{
+ {(char*)"whole", (getter)ImageViewport_getWhole, (setter)ImageViewport_setWhole, (char*)"use whole viewport to capture", NULL},
+ {(char*)"position", (getter)ImageViewport_getPosition, (setter)ImageViewport_setPosition, (char*)"upper left corner of captured area", NULL},
+ {(char*)"capsize", (getter)ImageViewport_getCaptureSize, (setter)ImageViewport_setCaptureSize, (char*)"size of viewport area being captured", NULL},
+ // attributes from ImageBase class
+ {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
+ {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
+ {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL},
+ {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
+ {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
+ {NULL}
+};
+
+
+// define python type
+PyTypeObject ImageViewportType =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.ImageViewport", /*tp_name*/
+ sizeof(PyImage), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Image_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Image source from viewport", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ imageViewportMethods, /* tp_methods */
+ 0, /* tp_members */
+ imageViewportGetSets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Image_init<ImageViewport>, /* tp_init */
+ 0, /* tp_alloc */
+ Image_allocNew, /* tp_new */
+};
diff --git a/source/gameengine/VideoTexture/ImageViewport.h b/source/gameengine/VideoTexture/ImageViewport.h
new file mode 100644
index 00000000000..4265906b8f5
--- /dev/null
+++ b/source/gameengine/VideoTexture/ImageViewport.h
@@ -0,0 +1,84 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined IMAGEVIEWPORT_H
+#define IMAGEVIEWPORT_H
+
+
+#include "Common.h"
+
+#include "ImageBase.h"
+
+
+/// class for viewport access
+class ImageViewport : public ImageBase
+{
+public:
+ /// constructor
+ ImageViewport (void);
+
+ /// destructor
+ virtual ~ImageViewport (void);
+
+ /// is whole buffer used
+ bool getWhole (void) { return m_whole; }
+ /// set whole buffer use
+ void setWhole (bool whole);
+ /// get capture size in viewport
+ short * getCaptureSize (void) { return m_capSize; }
+ /// set capture size in viewport
+ void setCaptureSize (short * size = NULL);
+
+ /// get position in viewport
+ GLint * getPosition (void) { return m_position; }
+ /// set position in viewport
+ void setPosition (GLint * pos = NULL);
+
+protected:
+ /// frame buffer rectangle
+ GLint m_viewport[4];
+
+ /// size of captured area
+ short m_capSize[2];
+ /// use whole viewport
+ bool m_whole;
+
+ /// position of capture rectangle in viewport
+ GLint m_position[2];
+ /// upper left point for capturing
+ GLint m_upLeft[2];
+
+ /// buffer to copy viewport
+ BYTE * m_viewportImage;
+ /// texture is initialized
+ bool m_texInit;
+
+ /// capture image from viewport
+ virtual void calcImage (unsigned int texId);
+
+ /// get viewport size
+ GLint * getViewportSize (void) { return m_viewport + 2; }
+};
+
+
+#endif
+
diff --git a/source/gameengine/VideoTexture/Makefile b/source/gameengine/VideoTexture/Makefile
new file mode 100644
index 00000000000..bead176808b
--- /dev/null
+++ b/source/gameengine/VideoTexture/Makefile
@@ -0,0 +1,65 @@
+#
+# $Id$
+#
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# 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
+# of the License, or (at your option) any later version.
+#
+# 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,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# 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.
+#
+# ***** END GPL LICENSE BLOCK *****
+#
+#
+
+LIBNAME = videotex
+DIR = $(OCGDIR)/gameengine/$(LIBNAME)
+SOURCEDIR = source/gameengine/VideoTexture
+
+include nan_compile.mk
+
+CCFLAGS += $(LEVEL_1_CPP_WARNINGS)
+
+CPPFLAGS += $(OGL_CPPFLAGS)
+CPPFLAGS += -I$(NAN_GLEW)/include
+CPPFLAGS += -I$(OPENGL_HEADERS)
+CPPFLAGS += -I$(NAN_PYTHON)/include/python$(NAN_PYTHON_VERSION)
+CPPFLAGS += -I../../blender/python
+CPPFLAGS += -I$(NAN_STRING)/include
+CPPFLAGS += -I$(NAN_SOUNDSYSTEM)/include
+CPPFLAGS += -I$(NAN_MOTO)/include
+CPPFLAGS += -I../Rasterizer/RAS_OpenGLRasterizer
+CPPFLAGS += -I../Rasterizer -I../GameLogic -I../SceneGraph
+CPPFLAGS += -I../BlenderRoutines -I../Expressions -I../Ketsji
+CPPFLAGS += -I../../kernel/gen_system
+CPPFLAGS += -I.
+CPPFLAGS += -I../../blender/blenkernel
+CPPFLAGS += -I../../blender/blenlib
+CPPFLAGS += -I../../blender/include
+CPPFLAGS += -I../../blender/makesdna
+CPPFLAGS += -I../../blender/imbuf
+CPPFLAGS += -I../../blender/gpu
+CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include
+
+ifeq ($(WITH_FFMPEG),true)
+ CPPFLAGS += -DWITH_FFMPEG
+ CPPFLAGS += $(NAN_FFMPEGCFLAGS)
+endif
+
+
diff --git a/source/gameengine/VideoTexture/PyTypeList.cpp b/source/gameengine/VideoTexture/PyTypeList.cpp
new file mode 100644
index 00000000000..6d2676dce09
--- /dev/null
+++ b/source/gameengine/VideoTexture/PyTypeList.cpp
@@ -0,0 +1,83 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of blendTex library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+
+#include "PyTypeList.h"
+
+#include <memory>
+#include <vector>
+
+#include <PyObjectPlus.h>
+
+
+/// check, if type is in list
+bool PyTypeList::in (PyTypeObject * type)
+{
+ // if list exists
+ if (m_list.get() != NULL)
+ // iterate items in list
+ for (PyTypeListType::iterator it = m_list->begin(); it != m_list->end(); ++it)
+ // if item is found, return with success
+ if ((*it)->getType() == type) return true;
+ // otherwise return not found
+ return false;
+}
+
+/// add type to list
+void PyTypeList::add (PyTypeObject * type, const char * name)
+{
+ PyTypeListItem * typeItem;
+ // if list doesn't exist, create it
+ if (m_list.get() == NULL)
+ m_list.reset(new PyTypeListType());
+ if (!in(type))
+ // add new item to list
+ m_list->push_back(new PyTypeListItem(type, name));
+}
+
+/// prepare types
+bool PyTypeList::ready (void)
+{
+ // if list exists
+ if (m_list.get() != NULL)
+ // iterate items in list
+ for (PyTypeListType::iterator it = m_list->begin(); it != m_list->end(); ++it)
+ // if preparation failed, report it
+ if (PyType_Ready((*it)->getType()) < 0) return false;
+ // success
+ return true;
+}
+
+/// register types to module
+void PyTypeList::reg (PyObject * module)
+{
+ // if list exists
+ if (m_list.get() != NULL)
+ // iterate items in list
+ for (PyTypeListType::iterator it = m_list->begin(); it != m_list->end(); ++it)
+ {
+ // increase ref count
+ Py_INCREF((*it)->getType());
+ // add type to module
+ PyModule_AddObject(module, (char*)(*it)->getName(), (PyObject*)(*it)->getType());
+ }
+}
diff --git a/source/gameengine/VideoTexture/PyTypeList.h b/source/gameengine/VideoTexture/PyTypeList.h
new file mode 100644
index 00000000000..4daf88bfa19
--- /dev/null
+++ b/source/gameengine/VideoTexture/PyTypeList.h
@@ -0,0 +1,85 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of blendTex library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined PYTYPELIST_H
+#define PYTYPELIST_H
+
+#include "Common.h"
+
+#include <memory>
+#include <vector>
+
+#include <PyObjectPlus.h>
+
+// forward declaration
+class PyTypeListItem;
+
+// type for list of types
+typedef std::vector<PyTypeListItem*> PyTypeListType;
+
+
+/// class to store list of python types
+class PyTypeList
+{
+public:
+ /// check, if type is in list
+ bool in (PyTypeObject * type);
+
+ /// add type to list
+ void add (PyTypeObject * type, const char * name);
+
+ /// prepare types
+ bool ready (void);
+
+ /// register types to module
+ void reg (PyObject * module);
+
+protected:
+ /// pointer to list of types
+ std::auto_ptr<PyTypeListType> m_list;
+};
+
+
+/// class for item of python type list
+class PyTypeListItem
+{
+public:
+ /// constructor adds type into list
+ PyTypeListItem (PyTypeObject * type, const char * name)
+ : m_type(type), m_name(name)
+ { }
+
+ /// does type match
+ PyTypeObject * getType (void) { return m_type; }
+
+ /// get name of type
+ const char * getName (void) { return m_name; }
+
+protected:
+ /// pointer to type object
+ PyTypeObject * m_type;
+ /// name of type
+ const char * m_name;
+};
+
+
+#endif
diff --git a/source/gameengine/VideoTexture/SConscript b/source/gameengine/VideoTexture/SConscript
new file mode 100644
index 00000000000..91a74516bc5
--- /dev/null
+++ b/source/gameengine/VideoTexture/SConscript
@@ -0,0 +1,32 @@
+#!/usr/bin/python
+import sys
+
+Import ('env')
+
+sources = env.Glob('*.cpp')
+
+incs = '. #source/gameengine/Ketsji #source/gameengine/Expressions'
+incs += ' #source/gameengine/GameLogic #source/gameengine/SceneGraph #source/gameengine/Rasterizer'
+incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer'
+incs += ' #source/gameengine/BlenderRoutines'
+incs += ' #source/blender/editors/include #source/blender/blenlib #source/blender/blenkernel'
+incs += ' #source/blender/makesdna #source/blender/imbuf #source/blender/python'
+incs += ' #source/blender/gpu #source/kernel/gen_system #intern/string #intern/moto/include'
+incs += ' #intern/guardedalloc #intern/SoundSystem'
+incs += ' #extern/glew/include'
+
+cflags = []
+defs = ''
+if env['OURPLATFORM'] == 'win32-vc':
+ cflags.append('/GR')
+ cflags.append('/Ox')
+
+incs += ' ' + env['BF_PYTHON_INC']
+#incs += ' ' + env['BF_OPENGL_INC']
+
+if env['WITH_BF_FFMPEG']:
+ defs += ' WITH_FFMPEG'
+ incs += ' ' + env['BF_FFMPEG_INC']
+ defs += ' __STDC_CONSTANT_MACROS'
+
+env.BlenderLib ( 'bf_videotex', sources, Split(incs), Split(defs), libtype=['game','player'], priority=[25, 72], compileflags = cflags )
diff --git a/source/gameengine/VideoTexture/Texture.cpp b/source/gameengine/VideoTexture/Texture.cpp
new file mode 100644
index 00000000000..12d4e79ad89
--- /dev/null
+++ b/source/gameengine/VideoTexture/Texture.cpp
@@ -0,0 +1,475 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+// implementation
+
+#include <PyObjectPlus.h>
+#include <structmember.h>
+
+#include <KX_GameObject.h>
+#include <RAS_MeshObject.h>
+#include <DNA_mesh_types.h>
+#include <DNA_meshdata_types.h>
+#include <DNA_image_types.h>
+#include <IMB_imbuf_types.h>
+#include <KX_PolygonMaterial.h>
+
+#include <MEM_guardedalloc.h>
+
+#include <KX_BlenderMaterial.h>
+#include <BL_Texture.h>
+
+#include "KX_KetsjiEngine.h"
+#include "KX_PythonInit.h"
+#include "Texture.h"
+#include "ImageBase.h"
+#include "Exception.h"
+
+#include <memory.h>
+#include <BIF_gl.h>
+
+
+// macro for exception handling and logging
+#define CATCH_EXCP catch (Exception & exp) \
+{ exp.report(); }
+
+
+// Blender GameObject type
+BlendType<KX_GameObject> gameObjectType ("KX_GameObject");
+
+
+// load texture
+void loadTexture (unsigned int texId, unsigned int * texture, short * size,
+ bool mipmap)
+{
+ // load texture for rendering
+ glBindTexture(GL_TEXTURE_2D, texId);
+ if (mipmap)
+ {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, size[0], size[1], GL_RGBA, GL_UNSIGNED_BYTE, texture);
+ }
+ else
+ {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, size[0], size[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, texture);
+ }
+ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+}
+
+
+// get pointer to material
+RAS_IPolyMaterial * getMaterial (PyObject *obj, short matID)
+{
+ // if object is available
+ if (obj != NULL)
+ {
+ // get pointer to texture image
+ KX_GameObject * gameObj = gameObjectType.checkType(obj);
+ if (gameObj != NULL && gameObj->GetMeshCount() > 0)
+ {
+ // get material from mesh
+ RAS_MeshObject * mesh = gameObj->GetMesh(0);
+ RAS_MeshMaterial *meshMat = mesh->GetMeshMaterial(matID);
+ if (meshMat != NULL && meshMat->m_bucket != NULL)
+ // return pointer to polygon or blender material
+ return meshMat->m_bucket->GetPolyMaterial();
+ }
+ }
+ // otherwise material was not found
+ return NULL;
+}
+
+
+// get material ID
+short getMaterialID (PyObject * obj, char * name)
+{
+ // search for material
+ for (short matID = 0;; ++matID)
+ {
+ // get material
+ RAS_IPolyMaterial * mat = getMaterial(obj, matID);
+ // if material is not available, report that no material was found
+ if (mat == NULL)
+ break;
+ // name is a material name if it starts with MA and a UV texture name if it starts with IM
+ if (name[0] == 'I' && name[1] == 'M')
+ {
+ // if texture name matches
+ if (strcmp(mat->GetTextureName().ReadPtr(), name) == 0)
+ return matID;
+ } else
+ {
+ // if material name matches
+ if (strcmp(mat->GetMaterialName().ReadPtr(), name) == 0)
+ return matID;
+ }
+ }
+ // material was not found
+ return -1;
+}
+
+
+// Texture object allocation
+PyObject * Texture_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+ // allocate object
+ Texture * self = reinterpret_cast<Texture*>(type->tp_alloc(type, 0));
+ // initialize object structure
+ self->m_actTex = 0;
+ self->m_orgSaved = false;
+ self->m_imgTexture = NULL;
+ self->m_matTexture = NULL;
+ self->m_mipmap = false;
+ self->m_scaledImg = NULL;
+ self->m_scaledImgSize = 0;
+ self->m_source = NULL;
+ self->m_lastClock = 0.0;
+ // return allocated object
+ return reinterpret_cast<PyObject*>(self);
+}
+
+
+// forward declaration
+PyObject * Texture_close(Texture * self);
+int Texture_setSource (Texture * self, PyObject * value, void * closure);
+
+
+// Texture object deallocation
+void Texture_dealloc (Texture * self)
+{
+ // release renderer
+ Py_XDECREF(self->m_source);
+ // close texture
+ Texture_close(self);
+ // release scaled image buffer
+ delete [] self->m_scaledImg;
+ // release object
+ self->ob_type->tp_free((PyObject*)self);
+}
+
+
+ExceptionID MaterialNotAvail;
+ExpDesc MaterialNotAvailDesc (MaterialNotAvail, "Texture material is not available");
+
+// Texture object initialization
+int Texture_init (Texture *self, PyObject *args, PyObject *kwds)
+{
+ // parameters - game object with video texture
+ PyObject * obj = NULL;
+ // material ID
+ short matID = 0;
+ // texture ID
+ short texID = 0;
+ // texture object with shared texture ID
+ Texture * texObj = NULL;
+
+ static char *kwlist[] = {"gameObj", "materialID", "textureID", "textureObj", NULL};
+
+ // get parameters
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|hhO!", kwlist, &obj, &matID,
+ &texID, &TextureType, &texObj))
+ return -1;
+
+ // if parameters are available
+ if (obj != NULL)
+ {
+ // process polygon material or blender material
+ try
+ {
+ // get pointer to texture image
+ RAS_IPolyMaterial * mat = getMaterial(obj, matID);
+ if (mat != NULL)
+ {
+ // is it blender material or polygon material
+ if (mat->GetFlag() & RAS_BLENDERGLSL)
+ {
+ self->m_imgTexture = static_cast<KX_BlenderMaterial*>(mat)->getImage(texID);
+ self->m_useMatTexture = false;
+ } else if (mat->GetFlag() & RAS_BLENDERMAT)
+ {
+ // get blender material texture
+ self->m_matTexture = static_cast<KX_BlenderMaterial*>(mat)->getTex(texID);
+ self->m_useMatTexture = true;
+ }
+ else
+ {
+ // get texture pointer from polygon material
+ MTFace * tface = static_cast<KX_PolygonMaterial*>(mat)->GetMTFace();
+ self->m_imgTexture = (Image*)tface->tpage;
+ self->m_useMatTexture = false;
+ }
+ }
+ // check if texture is available, if not, initialization failed
+ if (self->m_imgTexture == NULL && self->m_matTexture == NULL)
+ // throw exception if initialization failed
+ THRWEXCP(MaterialNotAvail, S_OK);
+
+ // if texture object is provided
+ if (texObj != NULL)
+ {
+ // copy texture code
+ self->m_actTex = texObj->m_actTex;
+ self->m_mipmap = texObj->m_mipmap;
+ if (texObj->m_source != NULL)
+ Texture_setSource(self, reinterpret_cast<PyObject*>(texObj->m_source), NULL);
+ }
+ else
+ // otherwise generate texture code
+ glGenTextures(1, (GLuint*)&self->m_actTex);
+ }
+ catch (Exception & exp)
+ {
+ exp.report();
+ return -1;
+ }
+ }
+ // initialization succeded
+ return 0;
+}
+
+
+// close added texture
+PyObject * Texture_close(Texture * self)
+{
+ // restore texture
+ if (self->m_orgSaved)
+ {
+ self->m_orgSaved = false;
+ // restore original texture code
+ if (self->m_useMatTexture)
+ self->m_matTexture->swapTexture(self->m_orgTex);
+ else
+ self->m_imgTexture->bindcode = self->m_orgTex;
+ // drop actual texture
+ if (self->m_actTex != 0)
+ {
+ glDeleteTextures(1, (GLuint *)&self->m_actTex);
+ self->m_actTex = 0;
+ }
+ }
+ Py_RETURN_NONE;
+}
+
+
+// refresh texture
+PyObject * Texture_refresh (Texture * self, PyObject * args)
+{
+ // get parameter - refresh source
+ PyObject * param;
+ if (!PyArg_ParseTuple(args, "O", &param) || !PyBool_Check(param))
+ {
+ // report error
+ PyErr_SetString(PyExc_TypeError, "The value must be a bool");
+ return NULL;
+ }
+ // some trick here: we are in the business of loading a texture,
+ // no use to do it if we are still in the same rendering frame.
+ // We find this out by looking at the engine current clock time
+ KX_KetsjiEngine* engine = KX_GetActiveEngine();
+ if (engine->GetClockTime() != self->m_lastClock)
+ {
+ self->m_lastClock = engine->GetClockTime();
+ // set source refresh
+ bool refreshSource = (param == Py_True);
+ // try to proces texture from source
+ try
+ {
+ // if source is available
+ if (self->m_source != NULL)
+ {
+ // check texture code
+ if (!self->m_orgSaved)
+ {
+ self->m_orgSaved = true;
+ // save original image code
+ if (self->m_useMatTexture)
+ self->m_orgTex = self->m_matTexture->swapTexture(self->m_actTex);
+ else
+ {
+ self->m_orgTex = self->m_imgTexture->bindcode;
+ self->m_imgTexture->bindcode = self->m_actTex;
+ }
+ }
+
+ // get texture
+ unsigned int * texture = self->m_source->m_image->getImage(self->m_actTex);
+ // if texture is available
+ if (texture != NULL)
+ {
+ // get texture size
+ short * orgSize = self->m_source->m_image->getSize();
+ // calc scaled sizes
+ short size[] = {ImageBase::calcSize(orgSize[0]), ImageBase::calcSize(orgSize[1])};
+ // scale texture if needed
+ if (size[0] != orgSize[0] || size[1] != orgSize[1])
+ {
+ // if scaled image buffer is smaller than needed
+ if (self->m_scaledImgSize < (unsigned int)(size[0] * size[1]))
+ {
+ // new size
+ self->m_scaledImgSize = size[0] * size[1];
+ // allocate scaling image
+ delete [] self->m_scaledImg;
+ self->m_scaledImg = new unsigned int[self->m_scaledImgSize];
+ }
+ // scale texture
+ gluScaleImage(GL_RGBA, orgSize[0], orgSize[1], GL_UNSIGNED_BYTE, texture,
+ size[0], size[1], GL_UNSIGNED_BYTE, self->m_scaledImg);
+ // use scaled image instead original
+ texture = self->m_scaledImg;
+ }
+ // load texture for rendering
+ loadTexture (self->m_actTex, texture, size, self->m_mipmap);
+
+ // refresh texture source, if required
+ if (refreshSource) self->m_source->m_image->refresh();
+ }
+ }
+ }
+ CATCH_EXCP;
+ }
+ Py_RETURN_NONE;
+}
+
+
+// get mipmap value
+PyObject * Texture_getMipmap (Texture * self, void * closure)
+{
+ // return true if flag is set, otherwise false
+ if (self->m_mipmap) Py_RETURN_TRUE;
+ else Py_RETURN_FALSE;
+}
+
+// set mipmap value
+int Texture_setMipmap (Texture * self, PyObject * value, void * closure)
+{
+ // check parameter, report failure
+ if (value == NULL || !PyBool_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a bool");
+ return -1;
+ }
+ // set mipmap
+ self->m_mipmap = value == Py_True;
+ // success
+ return 0;
+}
+
+
+// get source object
+PyObject * Texture_getSource (Texture * self, PyObject * value, void * closure)
+{
+ // if source exists
+ if (self->m_source != NULL)
+ {
+ Py_INCREF(self->m_source);
+ return reinterpret_cast<PyObject*>(self->m_source);
+ }
+ // otherwise return None
+ Py_RETURN_NONE;
+}
+
+
+// set source object
+int Texture_setSource (Texture * self, PyObject * value, void * closure)
+{
+ // check new value
+ if (value == NULL || !pyImageTypes.in(value->ob_type))
+ {
+ // report value error
+ PyErr_SetString(PyExc_TypeError, "Invalid type of value");
+ return -1;
+ }
+ // increase ref count for new value
+ Py_INCREF(value);
+ // release previous
+ Py_XDECREF(self->m_source);
+ // set new value
+ self->m_source = reinterpret_cast<PyImage*>(value);
+ // return success
+ return 0;
+}
+
+
+// class Texture methods
+static PyMethodDef textureMethods[] =
+{
+ { "close", (PyCFunction)Texture_close, METH_NOARGS, "Close dynamic texture and restore original"},
+ { "refresh", (PyCFunction)Texture_refresh, METH_VARARGS, "Refresh texture from source"},
+ {NULL} /* Sentinel */
+};
+
+// class Texture attributes
+static PyGetSetDef textureGetSets[] =
+{
+ {(char*)"source", (getter)Texture_getSource, (setter)Texture_setSource, (char*)"source of texture", NULL},
+ {(char*)"mipmap", (getter)Texture_getMipmap, (setter)Texture_setMipmap, (char*)"mipmap texture", NULL},
+ {NULL}
+};
+
+
+// class Texture declaration
+PyTypeObject TextureType =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.Texture", /*tp_name*/
+ sizeof(Texture), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Texture_dealloc,/*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "Texture objects", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ textureMethods, /* tp_methods */
+ 0, /* tp_members */
+ textureGetSets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Texture_init, /* tp_init */
+ 0, /* tp_alloc */
+ Texture_new, /* tp_new */
+};
diff --git a/source/gameengine/VideoTexture/Texture.h b/source/gameengine/VideoTexture/Texture.h
new file mode 100644
index 00000000000..3c371e51537
--- /dev/null
+++ b/source/gameengine/VideoTexture/Texture.h
@@ -0,0 +1,86 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2006 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined TEXTURE_H
+#define TEXTURE_H
+
+#include <PyObjectPlus.h>
+#include <structmember.h>
+
+#include <DNA_image_types.h>
+#include <BL_Texture.h>
+#include <KX_BlenderMaterial.h>
+
+#include "ImageBase.h"
+#include "BlendType.h"
+
+
+// type Texture declaration
+struct Texture
+{
+ PyObject_HEAD
+
+ // texture is using blender material
+ bool m_useMatTexture;
+
+ // video texture bind code
+ unsigned int m_actTex;
+ // original texture bind code
+ unsigned int m_orgTex;
+ // original texture saved
+ bool m_orgSaved;
+
+ // texture image for game materials
+ Image * m_imgTexture;
+ // texture for blender materials
+ BL_Texture * m_matTexture;
+
+ // use mipmapping
+ bool m_mipmap;
+
+ // scaled image buffer
+ unsigned int * m_scaledImg;
+ // scaled image buffer size
+ unsigned int m_scaledImgSize;
+ // last refresh
+ double m_lastClock;
+
+ // image source
+ PyImage * m_source;
+};
+
+
+// Texture type description
+extern PyTypeObject TextureType;
+
+// load texture
+void loadTexture (unsigned int texId, unsigned int * texture, short * size,
+ bool mipmap = false);
+
+// get material
+RAS_IPolyMaterial * getMaterial (PyObject *obj, short matID);
+
+// get material ID
+short getMaterialID (PyObject * obj, char * name);
+
+
+#endif
diff --git a/source/gameengine/VideoTexture/VideoBase.cpp b/source/gameengine/VideoTexture/VideoBase.cpp
new file mode 100644
index 00000000000..10117c3af9e
--- /dev/null
+++ b/source/gameengine/VideoTexture/VideoBase.cpp
@@ -0,0 +1,195 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if defined WIN32
+#define WINDOWS_LEAN_AND_MEAN
+#include <Windows.h>
+#endif
+
+#include "VideoBase.h"
+
+#include "FilterSource.h"
+
+// VideoBase implementation
+
+
+// initialize image data
+void VideoBase::init(short width, short height)
+{
+ // save original sizes
+ m_orgSize[0] = width;
+ m_orgSize[1] = height;
+ // call base class initialization
+ ImageBase::init(width, height);
+}
+
+
+// process video frame
+void VideoBase::process (BYTE * sample)
+{
+ // if scale was changed
+ if (m_scaleChange)
+ // reset image
+ init(m_orgSize[0], m_orgSize[1]);
+ // if image is allocated and is able to store new image
+ if (m_image != NULL && !m_avail)
+ {
+ // filters used
+ // convert video format to image
+ switch (m_format)
+ {
+ case RGBA32:
+ {
+ FilterRGBA32 filtRGBA;
+ // use filter object for format to convert image
+ filterImage(filtRGBA, sample, m_orgSize);
+ // finish
+ break;
+ }
+ case RGB24:
+ {
+ FilterRGB24 filtRGB;
+ // use filter object for format to convert image
+ filterImage(filtRGB, sample, m_orgSize);
+ // finish
+ break;
+ }
+ case YV12:
+ {
+ // use filter object for format to convert image
+ FilterYV12 filtYUV;
+ filtYUV.setBuffs(sample, m_orgSize);
+ filterImage(filtYUV, sample, m_orgSize);
+ // finish
+ break;
+ }
+ }
+ }
+}
+
+
+// python functions
+
+
+// exceptions for video source initialization
+ExceptionID SourceVideoEmpty, SourceVideoCreation;
+ExpDesc SourceVideoEmptyDesc (SourceVideoEmpty, "Source Video is empty");
+ExpDesc SourceVideoCreationDesc (SourceVideoCreation, "SourceVideo object was not created");
+
+// open video source
+void Video_open (VideoBase * self, char * file, short captureID)
+{
+ // if file is empty, throw exception
+ if (file == NULL) THRWEXCP(SourceVideoEmpty, S_OK);
+
+ // open video file or capture device
+ if (captureID >= 0)
+ self->openCam(file, captureID);
+ else
+ self->openFile(file);
+}
+
+
+// play video
+PyObject * Video_play (PyImage * self)
+{ if (getVideo(self)->play()) Py_RETURN_TRUE; else Py_RETURN_FALSE; }
+
+// stop video
+PyObject * Video_stop (PyImage * self)
+{ if (getVideo(self)->stop()) Py_RETURN_TRUE; else Py_RETURN_FALSE; }
+
+// get status
+PyObject * Video_getStatus (PyImage * self, void * closure)
+{
+ return Py_BuildValue("h", getVideo(self)->getStatus());
+}
+
+// refresh video
+PyObject * Video_refresh (PyImage * self)
+{
+ getVideo(self)->refresh();
+ return Video_getStatus(self, NULL);
+}
+
+
+// get range
+PyObject * Video_getRange (PyImage * self, void * closure)
+{
+ return Py_BuildValue("[ff]", getVideo(self)->getRange()[0],
+ getVideo(self)->getRange()[1]);
+}
+
+// set range
+int Video_setRange (PyImage * self, PyObject * value, void * closure)
+{
+ // check validity of parameter
+ if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2
+ || !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 0))
+ || !PyFloat_Check(PySequence_Fast_GET_ITEM(value, 1)))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 longs");
+ return -1;
+ }
+ // set range
+ getVideo(self)->setRange(PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 0)),
+ PyFloat_AsDouble(PySequence_Fast_GET_ITEM(value, 1)));
+ // success
+ return 0;
+}
+
+// get repeat
+PyObject * Video_getRepeat (PyImage * self, void * closure)
+{ return Py_BuildValue("h", getVideo(self)->getRepeat()); }
+
+// set repeat
+int Video_setRepeat (PyImage * self, PyObject * value, void * closure)
+{
+ // check validity of parameter
+ if (value == NULL || !PyInt_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be an int");
+ return -1;
+ }
+ // set repeat
+ getVideo(self)->setRepeat(int(PyInt_AsLong(value)));
+ // success
+ return 0;
+}
+
+// get frame rate
+PyObject * Video_getFrameRate (PyImage * self, void * closure)
+{ return Py_BuildValue("f", double(getVideo(self)->getFrameRate())); }
+
+// set frame rate
+int Video_setFrameRate (PyImage * self, PyObject * value, void * closure)
+{
+ // check validity of parameter
+ if (value == NULL || !PyFloat_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a float");
+ return -1;
+ }
+ // set repeat
+ getVideo(self)->setFrameRate(float(PyFloat_AsDouble(value)));
+ // success
+ return 0;
+}
diff --git a/source/gameengine/VideoTexture/VideoBase.h b/source/gameengine/VideoTexture/VideoBase.h
new file mode 100644
index 00000000000..15ecb7a78f4
--- /dev/null
+++ b/source/gameengine/VideoTexture/VideoBase.h
@@ -0,0 +1,185 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#if !defined VIDEOBASE_H
+#define VIDEOBASE_H
+
+
+#include <PyObjectPlus.h>
+
+#include "ImageBase.h"
+
+#include "Exception.h"
+
+// source states
+const int SourceError = -1;
+const int SourceEmpty = 0;
+const int SourceReady = 1;
+const int SourcePlaying = 2;
+const int SourceStopped = 3;
+
+
+// video source formats
+enum VideoFormat { None, RGB24, YV12, RGBA32 };
+
+
+/// base class for video source
+class VideoBase : public ImageBase
+{
+public:
+ /// constructor
+ VideoBase (void) : ImageBase(true), m_format(None), m_status(SourceEmpty),
+ m_repeat(0), m_frameRate(1.0)
+ {
+ m_orgSize[0] = m_orgSize[1] = 0;
+ m_range[0] = m_range[1] = 0.0;
+ }
+
+ /// destructor
+ virtual ~VideoBase (void) {}
+
+ /// open video file
+ virtual void openFile (char * file)
+ {
+ m_isFile = true;
+ m_status = SourceReady;
+ }
+ /// open video capture device
+ virtual void openCam (char * file, short camIdx)
+ {
+ m_isFile = false;
+ m_status = SourceReady;
+ }
+
+ /// play video
+ virtual bool play (void)
+ {
+ if (m_status == SourceReady || m_status == SourceStopped)
+ {
+ m_status = SourcePlaying;
+ return true;
+ }
+ return false;
+ }
+ /// stop/pause video
+ virtual bool stop (void)
+ {
+ if (m_status == SourcePlaying)
+ {
+ m_status = SourceStopped;
+ return true;
+ }
+ return false;
+ }
+
+ // get video status
+ int getStatus (void) { return m_status; }
+
+ /// get play range
+ const double * getRange (void) { return m_range; }
+ /// set play range
+ virtual void setRange (double start, double stop)
+ {
+ if (m_isFile)
+ {
+ m_range[0] = start;
+ m_range[1] = stop;
+ }
+ }
+
+ // get video repeat
+ int getRepeat (void) { return m_repeat; }
+ /// set video repeat
+ virtual void setRepeat (int rep)
+ { if (m_isFile) m_repeat = rep; }
+
+ /// get frame rate
+ float getFrameRate (void) { return m_frameRate; }
+ /// set frame rate
+ virtual void setFrameRate (float rate)
+ { if (m_isFile) m_frameRate = rate > 0.0 ? rate : 1.0f; }
+
+protected:
+ /// video format
+ VideoFormat m_format;
+ /// original video size
+ short m_orgSize[2];
+
+ /// video status
+ int m_status;
+
+ /// is source file
+ bool m_isFile;
+
+ /// replay range
+ double m_range[2];
+ /// repeat count
+ int m_repeat;
+ /// frame rate
+ float m_frameRate;
+
+ /// initialize image data
+ void init (short width, short height);
+
+ /// process source data
+ void process (BYTE * sample);
+};
+
+
+
+// python fuctions
+
+
+// cast Image pointer to Video
+inline VideoBase * getVideo (PyImage * self)
+{ return static_cast<VideoBase*>(self->m_image); }
+
+
+extern ExceptionID SourceVideoCreation;
+
+// object initialization
+template <class T> void Video_init (PyImage * self)
+{
+ // create source video object
+ if (self->m_image != NULL) delete self->m_image;
+ HRESULT hRslt = S_OK;
+ self->m_image = new T(&hRslt);
+ CHCKHRSLT(hRslt, SourceVideoCreation);
+}
+
+
+// video functions
+void Video_open (VideoBase * self, char * file, short captureID);
+PyObject * Video_play (PyImage * self);
+PyObject * Video_stop (PyImage * self);
+PyObject * Video_refresh (PyImage * self);
+PyObject * Video_getStatus (PyImage * self, void * closure);
+PyObject * Video_getRange (PyImage * self, void * closure);
+int Video_setRange (PyImage * self, PyObject * value, void * closure);
+PyObject * Video_getRepeat (PyImage * self, void * closure);
+int Video_setRepeat (PyImage * self, PyObject * value, void * closure);
+PyObject * Video_getFrameRate (PyImage * self, void * closure);
+int Video_setFrameRate (PyImage * self, PyObject * value, void * closure);
+
+
+#endif
+
diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.cpp b/source/gameengine/VideoTexture/VideoFFmpeg.cpp
new file mode 100644
index 00000000000..02798c7e596
--- /dev/null
+++ b/source/gameengine/VideoTexture/VideoFFmpeg.cpp
@@ -0,0 +1,927 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#ifdef WITH_FFMPEG
+
+// INT64_C fix for some linux machines (C99ism)
+#define __STDC_CONSTANT_MACROS
+#include <stdint.h>
+
+
+#include "MEM_guardedalloc.h"
+#include "PIL_time.h"
+
+#include <string>
+
+#include "Exception.h"
+#include "VideoFFmpeg.h"
+
+
+// default framerate
+const double defFrameRate = 25.0;
+// time scale constant
+const long timeScale = 1000;
+
+// macro for exception handling and logging
+#define CATCH_EXCP catch (Exception & exp) \
+{ exp.report(); m_status = SourceError; }
+
+extern "C" void do_init_ffmpeg();
+
+// class RenderVideo
+
+// constructor
+VideoFFmpeg::VideoFFmpeg (HRESULT * hRslt) : VideoBase(),
+m_codec(NULL), m_formatCtx(NULL), m_codecCtx(NULL),
+m_frame(NULL), m_frameDeinterlaced(NULL), m_frameRGB(NULL), m_imgConvertCtx(NULL),
+m_deinterlace(false), m_preseek(0), m_videoStream(-1), m_baseFrameRate(25.0),
+m_lastFrame(-1), m_eof(false), m_curPosition(-1), m_startTime(0),
+m_captWidth(0), m_captHeight(0), m_captRate(0.f), m_isImage(false)
+{
+ // set video format
+ m_format = RGB24;
+ // force flip because ffmpeg always return the image in the wrong orientation for texture
+ setFlip(true);
+ // construction is OK
+ *hRslt = S_OK;
+}
+
+// destructor
+VideoFFmpeg::~VideoFFmpeg ()
+{
+}
+
+
+// release components
+bool VideoFFmpeg::release()
+{
+ // release
+ if (m_codecCtx)
+ {
+ avcodec_close(m_codecCtx);
+ m_codecCtx = NULL;
+ }
+ if (m_formatCtx)
+ {
+ av_close_input_file(m_formatCtx);
+ m_formatCtx = NULL;
+ }
+ if (m_frame)
+ {
+ av_free(m_frame);
+ m_frame = NULL;
+ }
+ if (m_frameDeinterlaced)
+ {
+ MEM_freeN(m_frameDeinterlaced->data[0]);
+ av_free(m_frameDeinterlaced);
+ m_frameDeinterlaced = NULL;
+ }
+ if (m_frameRGB)
+ {
+ MEM_freeN(m_frameRGB->data[0]);
+ av_free(m_frameRGB);
+ m_frameRGB = NULL;
+ }
+ if (m_imgConvertCtx)
+ {
+ sws_freeContext(m_imgConvertCtx);
+ m_imgConvertCtx = NULL;
+ }
+ m_codec = NULL;
+ m_status = SourceStopped;
+ return true;
+}
+
+
+// set initial parameters
+void VideoFFmpeg::initParams (short width, short height, float rate, bool image)
+{
+ m_captWidth = width;
+ m_captHeight = height;
+ m_captRate = rate;
+ m_isImage = image;
+}
+
+int VideoFFmpeg::openStream(const char *filename, AVInputFormat *inputFormat, AVFormatParameters *formatParams)
+{
+ AVFormatContext *formatCtx;
+ int i, videoStream;
+ AVCodec *codec;
+ AVCodecContext *codecCtx;
+
+ if(av_open_input_file(&formatCtx, filename, inputFormat, 0, formatParams)!=0)
+ return -1;
+
+ if(av_find_stream_info(formatCtx)<0)
+ {
+ av_close_input_file(formatCtx);
+ return -1;
+ }
+
+ /* Find the first video stream */
+ videoStream=-1;
+ for(i=0; i<formatCtx->nb_streams; i++)
+ {
+ if(formatCtx->streams[i] &&
+ get_codec_from_stream(formatCtx->streams[i]) &&
+ (get_codec_from_stream(formatCtx->streams[i])->codec_type==CODEC_TYPE_VIDEO))
+ {
+ videoStream=i;
+ break;
+ }
+ }
+
+ if(videoStream==-1)
+ {
+ av_close_input_file(formatCtx);
+ return -1;
+ }
+
+ codecCtx = get_codec_from_stream(formatCtx->streams[videoStream]);
+
+ /* Find the decoder for the video stream */
+ codec=avcodec_find_decoder(codecCtx->codec_id);
+ if(codec==NULL)
+ {
+ av_close_input_file(formatCtx);
+ return -1;
+ }
+ codecCtx->workaround_bugs = 1;
+ if(avcodec_open(codecCtx, codec)<0)
+ {
+ av_close_input_file(formatCtx);
+ return -1;
+ }
+
+#ifdef FFMPEG_OLD_FRAME_RATE
+ if(codecCtx->frame_rate>1000 && codecCtx->frame_rate_base==1)
+ codecCtx->frame_rate_base=1000;
+ m_baseFrameRate = (double)codecCtx->frame_rate / (double)codecCtx->frame_rate_base;
+#else
+ m_baseFrameRate = av_q2d(formatCtx->streams[videoStream]->r_frame_rate);
+#endif
+ if (m_baseFrameRate <= 0.0)
+ m_baseFrameRate = defFrameRate;
+
+ m_codec = codec;
+ m_codecCtx = codecCtx;
+ m_formatCtx = formatCtx;
+ m_videoStream = videoStream;
+ m_frame = avcodec_alloc_frame();
+ m_frameDeinterlaced = avcodec_alloc_frame();
+ m_frameRGB = avcodec_alloc_frame();
+
+ // allocate buffer if deinterlacing is required
+ avpicture_fill((AVPicture*)m_frameDeinterlaced,
+ (uint8_t*)MEM_callocN(avpicture_get_size(
+ m_codecCtx->pix_fmt,
+ m_codecCtx->width, m_codecCtx->height),
+ "ffmpeg deinterlace"),
+ m_codecCtx->pix_fmt, m_codecCtx->width, m_codecCtx->height);
+
+ // check if the pixel format supports Alpha
+ if (m_codecCtx->pix_fmt == PIX_FMT_RGB32 ||
+ m_codecCtx->pix_fmt == PIX_FMT_BGR32 ||
+ m_codecCtx->pix_fmt == PIX_FMT_RGB32_1 ||
+ m_codecCtx->pix_fmt == PIX_FMT_BGR32_1)
+ {
+ // allocate buffer to store final decoded frame
+ m_format = RGBA32;
+ avpicture_fill((AVPicture*)m_frameRGB,
+ (uint8_t*)MEM_callocN(avpicture_get_size(
+ PIX_FMT_RGBA,
+ m_codecCtx->width, m_codecCtx->height),
+ "ffmpeg rgba"),
+ PIX_FMT_RGBA, m_codecCtx->width, m_codecCtx->height);
+ // allocate sws context
+ m_imgConvertCtx = sws_getContext(
+ m_codecCtx->width,
+ m_codecCtx->height,
+ m_codecCtx->pix_fmt,
+ m_codecCtx->width,
+ m_codecCtx->height,
+ PIX_FMT_RGBA,
+ SWS_FAST_BILINEAR,
+ NULL, NULL, NULL);
+ } else
+ {
+ // allocate buffer to store final decoded frame
+ m_format = RGB24;
+ avpicture_fill((AVPicture*)m_frameRGB,
+ (uint8_t*)MEM_callocN(avpicture_get_size(
+ PIX_FMT_RGB24,
+ m_codecCtx->width, m_codecCtx->height),
+ "ffmpeg rgb"),
+ PIX_FMT_RGB24, m_codecCtx->width, m_codecCtx->height);
+ // allocate sws context
+ m_imgConvertCtx = sws_getContext(
+ m_codecCtx->width,
+ m_codecCtx->height,
+ m_codecCtx->pix_fmt,
+ m_codecCtx->width,
+ m_codecCtx->height,
+ PIX_FMT_RGB24,
+ SWS_FAST_BILINEAR,
+ NULL, NULL, NULL);
+ }
+ if (!m_imgConvertCtx) {
+ avcodec_close(m_codecCtx);
+ av_close_input_file(m_formatCtx);
+ av_free(m_frame);
+ MEM_freeN(m_frameDeinterlaced->data[0]);
+ av_free(m_frameDeinterlaced);
+ MEM_freeN(m_frameRGB->data[0]);
+ av_free(m_frameRGB);
+ return -1;
+ }
+ return 0;
+}
+
+// open video file
+void VideoFFmpeg::openFile (char * filename)
+{
+ do_init_ffmpeg();
+
+ if (openStream(filename, NULL, NULL) != 0)
+ return;
+
+ if (m_codecCtx->gop_size)
+ m_preseek = (m_codecCtx->gop_size < 25) ? m_codecCtx->gop_size+1 : 25;
+ else if (m_codecCtx->has_b_frames)
+ m_preseek = 25; // should determine gopsize
+ else
+ m_preseek = 0;
+
+ // get video time range
+ m_range[0] = 0.0;
+ m_range[1] = (double)m_formatCtx->duration / AV_TIME_BASE;
+
+ // open base class
+ VideoBase::openFile(filename);
+
+ if (
+#ifdef FFMPEG_PB_IS_POINTER
+ m_formatCtx->pb && m_formatCtx->pb->is_streamed
+#else
+ m_formatCtx->pb.is_streamed
+#endif
+ )
+ {
+ // the file is in fact a streaming source, prevent seeking
+ m_isFile = false;
+ // for streaming it is important to do non blocking read
+ m_formatCtx->flags |= AVFMT_FLAG_NONBLOCK;
+ }
+
+ if (m_isImage)
+ {
+ // the file is to be treated as an image, i.e. load the first frame only
+ m_isFile = false;
+ // in case of reload, the filename is taken from m_imageName, no need to change it
+ if (m_imageName.Ptr() != filename)
+ m_imageName = filename;
+ m_preseek = 0;
+ m_avail = false;
+ play();
+ }
+
+}
+
+
+// open video capture device
+void VideoFFmpeg::openCam (char * file, short camIdx)
+{
+ // open camera source
+ AVInputFormat *inputFormat;
+ AVFormatParameters formatParams;
+ AVRational frameRate;
+ char *p, filename[28], rateStr[20];
+
+ do_init_ffmpeg();
+
+ memset(&formatParams, 0, sizeof(formatParams));
+#ifdef WIN32
+ // video capture on windows only through Video For Windows driver
+ inputFormat = av_find_input_format("vfwcap");
+ if (!inputFormat)
+ // Video For Windows not supported??
+ return;
+ sprintf(filename, "%d", camIdx);
+#else
+ // In Linux we support two types of devices: VideoForLinux and DV1394.
+ // the user specify it with the filename:
+ // [<device_type>][:<standard>]
+ // <device_type> : 'v4l' for VideoForLinux, 'dv1394' for DV1394. By default 'v4l'
+ // <standard> : 'pal', 'secam' or 'ntsc'. By default 'ntsc'
+ // The driver name is constructed automatically from the device type:
+ // v4l : /dev/video<camIdx>
+ // dv1394: /dev/dv1394/<camIdx>
+ // If you have different driver name, you can specify the driver name explicitely
+ // instead of device type. Examples of valid filename:
+ // /dev/v4l/video0:pal
+ // /dev/ieee1394/1:ntsc
+ // dv1394:secam
+ // v4l:pal
+ if (file && strstr(file, "1394") != NULL)
+ {
+ // the user specifies a driver, check if it is v4l or d41394
+ inputFormat = av_find_input_format("dv1394");
+ sprintf(filename, "/dev/dv1394/%d", camIdx);
+ } else
+ {
+ inputFormat = av_find_input_format("video4linux");
+ sprintf(filename, "/dev/video%d", camIdx);
+ }
+ if (!inputFormat)
+ // these format should be supported, check ffmpeg compilation
+ return;
+ if (file && strncmp(file, "/dev", 4) == 0)
+ {
+ // user does not specify a driver
+ strncpy(filename, file, sizeof(filename));
+ filename[sizeof(filename)-1] = 0;
+ if ((p = strchr(filename, ':')) != 0)
+ *p = 0;
+ }
+ if (file && (p = strchr(file, ':')) != NULL)
+ formatParams.standard = p+1;
+#endif
+ //frame rate
+ if (m_captRate <= 0.f)
+ m_captRate = defFrameRate;
+ sprintf(rateStr, "%f", m_captRate);
+ av_parse_video_frame_rate(&frameRate, rateStr);
+ // populate format parameters
+ // need to specify the time base = inverse of rate
+ formatParams.time_base.num = frameRate.den;
+ formatParams.time_base.den = frameRate.num;
+ formatParams.width = m_captWidth;
+ formatParams.height = m_captHeight;
+
+ if (openStream(filename, inputFormat, &formatParams) != 0)
+ return;
+
+ // for video capture it is important to do non blocking read
+ m_formatCtx->flags |= AVFMT_FLAG_NONBLOCK;
+ // open base class
+ VideoBase::openCam(file, camIdx);
+}
+
+// play video
+bool VideoFFmpeg::play (void)
+{
+ try
+ {
+ // if object is able to play
+ if (VideoBase::play())
+ {
+ // set video position
+ setPositions();
+ // return success
+ return true;
+ }
+ }
+ CATCH_EXCP;
+ return false;
+}
+
+
+// stop video
+bool VideoFFmpeg::stop (void)
+{
+ try
+ {
+ if (VideoBase::stop())
+ {
+ return true;
+ }
+ }
+ CATCH_EXCP;
+ return false;
+}
+
+
+// set video range
+void VideoFFmpeg::setRange (double start, double stop)
+{
+ try
+ {
+ // set range
+ VideoBase::setRange(start, stop);
+ // set range for video
+ setPositions();
+ }
+ CATCH_EXCP;
+}
+
+// set framerate
+void VideoFFmpeg::setFrameRate (float rate)
+{
+ VideoBase::setFrameRate(rate);
+}
+
+
+// image calculation
+void VideoFFmpeg::calcImage (unsigned int texId)
+{
+ loadFrame();
+}
+
+
+// load frame from video
+void VideoFFmpeg::loadFrame (void)
+{
+ // get actual time
+ double actTime = PIL_check_seconds_timer() - m_startTime;
+ // if video has ended
+ if (m_isFile && actTime * m_frameRate >= m_range[1])
+ {
+ // if repeats are set, decrease them
+ if (m_repeat > 0)
+ --m_repeat;
+ // if video has to be replayed
+ if (m_repeat != 0)
+ {
+ // reset its position
+ actTime -= (m_range[1] - m_range[0]) / m_frameRate;
+ m_startTime += (m_range[1] - m_range[0]) / m_frameRate;
+ }
+ // if video has to be stopped, stop it
+ else
+ m_status = SourceStopped;
+ }
+ // if video is playing
+ if (m_status == SourcePlaying)
+ {
+ // actual frame
+ long actFrame = m_isFile ? long(actTime * actFrameRate()) : m_lastFrame + 1;
+ // if actual frame differs from last frame
+ if (actFrame != m_lastFrame)
+ {
+ // get image
+ if(grabFrame(actFrame))
+ {
+ AVFrame* frame = getFrame();
+ // save actual frame
+ m_lastFrame = actFrame;
+ // init image, if needed
+ init(short(m_codecCtx->width), short(m_codecCtx->height));
+ // process image
+ process((BYTE*)(frame->data[0]));
+ // in case it is an image, automatically stop reading it
+ if (m_isImage)
+ {
+ m_status = SourceStopped;
+ // close the file as we don't need it anymore
+ release();
+ }
+ }
+ }
+ }
+}
+
+
+// set actual position
+void VideoFFmpeg::setPositions (void)
+{
+ // set video start time
+ m_startTime = PIL_check_seconds_timer();
+ // if file is played and actual position is before end position
+ if (m_isFile && !m_eof && m_lastFrame >= 0 && m_lastFrame < m_range[1] * actFrameRate())
+ // continue from actual position
+ m_startTime -= double(m_lastFrame) / actFrameRate();
+ else
+ m_startTime -= m_range[0];
+}
+
+// position pointer in file, position in second
+bool VideoFFmpeg::grabFrame(long position)
+{
+ AVPacket packet;
+ int frameFinished;
+ int posFound = 1;
+ bool frameLoaded = false;
+ long long targetTs = 0;
+
+ // first check if the position that we are looking for is in the preseek range
+ // if so, just read the frame until we get there
+ if (position > m_curPosition + 1
+ && m_preseek
+ && position - (m_curPosition + 1) < m_preseek)
+ {
+ while(av_read_frame(m_formatCtx, &packet)>=0)
+ {
+ if (packet.stream_index == m_videoStream)
+ {
+ avcodec_decode_video(
+ m_codecCtx,
+ m_frame, &frameFinished,
+ packet.data, packet.size);
+ if (frameFinished)
+ m_curPosition++;
+ }
+ av_free_packet(&packet);
+ if (position == m_curPosition+1)
+ break;
+ }
+ }
+ // if the position is not in preseek, do a direct jump
+ if (position != m_curPosition + 1)
+ {
+ double timeBase = av_q2d(m_formatCtx->streams[m_videoStream]->time_base);
+ long long pos = (long long)
+ ((long long) (position - m_preseek) * AV_TIME_BASE / m_baseFrameRate);
+ long long startTs = m_formatCtx->streams[m_videoStream]->start_time;
+
+ if (pos < 0)
+ pos = 0;
+
+ if (startTs != AV_NOPTS_VALUE)
+ pos += (long long)(startTs * AV_TIME_BASE * timeBase);
+
+ if (position <= m_curPosition || !m_eof)
+ {
+ // no need to seek past the end of the file
+ if (av_seek_frame(m_formatCtx, -1, pos, AVSEEK_FLAG_BACKWARD) >= 0)
+ {
+ // current position is now lost, guess a value.
+ // It's not important because it will be set at this end of this function
+ m_curPosition = position - m_preseek - 1;
+ }
+ }
+ // this is the timestamp of the frame we're looking for
+ targetTs = (long long)(((double) position) / m_baseFrameRate / timeBase);
+ if (startTs != AV_NOPTS_VALUE)
+ targetTs += startTs;
+
+ posFound = 0;
+ avcodec_flush_buffers(m_codecCtx);
+ }
+
+ while(av_read_frame(m_formatCtx, &packet)>=0)
+ {
+ if(packet.stream_index == m_videoStream)
+ {
+ avcodec_decode_video(m_codecCtx,
+ m_frame, &frameFinished,
+ packet.data, packet.size);
+
+ if (frameFinished && !posFound)
+ {
+ if (packet.dts >= targetTs)
+ posFound = 1;
+ }
+
+ if(frameFinished && posFound == 1)
+ {
+ AVFrame * input = m_frame;
+
+ /* This means the data wasnt read properly,
+ this check stops crashing */
+ if ( input->data[0]==0 && input->data[1]==0
+ && input->data[2]==0 && input->data[3]==0)
+ {
+ av_free_packet(&packet);
+ break;
+ }
+
+ if (m_deinterlace)
+ {
+ if (avpicture_deinterlace(
+ (AVPicture*) m_frameDeinterlaced,
+ (const AVPicture*) m_frame,
+ m_codecCtx->pix_fmt,
+ m_codecCtx->width,
+ m_codecCtx->height) >= 0)
+ {
+ input = m_frameDeinterlaced;
+ }
+ }
+ // convert to RGB24
+ sws_scale(m_imgConvertCtx,
+ input->data,
+ input->linesize,
+ 0,
+ m_codecCtx->height,
+ m_frameRGB->data,
+ m_frameRGB->linesize);
+ av_free_packet(&packet);
+ frameLoaded = true;
+ break;
+ }
+ }
+ av_free_packet(&packet);
+ }
+ m_eof = !frameLoaded;
+ if (frameLoaded)
+ m_curPosition = position;
+ return frameLoaded;
+}
+
+
+// python methods
+
+
+// cast Image pointer to VideoFFmpeg
+inline VideoFFmpeg * getVideoFFmpeg (PyImage * self)
+{ return static_cast<VideoFFmpeg*>(self->m_image); }
+
+
+// object initialization
+static int VideoFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds)
+{
+ PyImage * self = reinterpret_cast<PyImage*>(pySelf);
+ // parameters - video source
+ // file name or format type for capture (only for Linux: video4linux or dv1394)
+ char * file = NULL;
+ // capture device number
+ short capt = -1;
+ // capture width, only if capt is >= 0
+ short width = 0;
+ // capture height, only if capt is >= 0
+ short height = 0;
+ // capture rate, only if capt is >= 0
+ float rate = 25.f;
+
+ static char *kwlist[] = {"file", "capture", "rate", "width", "height", NULL};
+
+ // get parameters
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|hfhh", kwlist, &file, &capt,
+ &rate, &width, &height))
+ return -1;
+
+ try
+ {
+ // create video object
+ Video_init<VideoFFmpeg>(self);
+
+ // set thread usage
+ getVideoFFmpeg(self)->initParams(width, height, rate);
+
+ // open video source
+ Video_open(getVideo(self), file, capt);
+ }
+ catch (Exception & exp)
+ {
+ exp.report();
+ return -1;
+ }
+ // initialization succeded
+ return 0;
+}
+
+PyObject * VideoFFmpeg_getPreseek (PyImage *self, void * closure)
+{
+ return Py_BuildValue("h", getFFmpeg(self)->getPreseek());
+}
+
+// set range
+int VideoFFmpeg_setPreseek (PyImage * self, PyObject * value, void * closure)
+{
+ // check validity of parameter
+ if (value == NULL || !PyInt_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be an integer");
+ return -1;
+ }
+ // set preseek
+ getFFmpeg(self)->setPreseek(PyInt_AsLong(value));
+ // success
+ return 0;
+}
+
+// get deinterlace
+PyObject * VideoFFmpeg_getDeinterlace (PyImage * self, void * closure)
+{
+ if (getFFmpeg(self)->getDeinterlace())
+ Py_RETURN_TRUE;
+ else
+ Py_RETURN_FALSE;
+}
+
+// set flip
+int VideoFFmpeg_setDeinterlace (PyImage * self, PyObject * value, void * closure)
+{
+ // check parameter, report failure
+ if (value == NULL || !PyBool_Check(value))
+ {
+ PyErr_SetString(PyExc_TypeError, "The value must be a bool");
+ return -1;
+ }
+ // set deinterlace
+ getFFmpeg(self)->setDeinterlace(value == Py_True);
+ // success
+ return 0;
+}
+
+// methods structure
+static PyMethodDef videoMethods[] =
+{ // methods from VideoBase class
+ {"play", (PyCFunction)Video_play, METH_NOARGS, "Play video"},
+ {"stop", (PyCFunction)Video_stop, METH_NOARGS, "Stop (pause) video"},
+ {"refresh", (PyCFunction)Video_refresh, METH_NOARGS, "Refresh video - get its status"},
+ {NULL}
+};
+// attributes structure
+static PyGetSetDef videoGetSets[] =
+{ // methods from VideoBase class
+ {(char*)"status", (getter)Video_getStatus, NULL, (char*)"video status", NULL},
+ {(char*)"range", (getter)Video_getRange, (setter)Video_setRange, (char*)"replay range", NULL},
+ {(char*)"repeat", (getter)Video_getRepeat, (setter)Video_setRepeat, (char*)"repeat count, -1 for infinite repeat", NULL},
+ {(char*)"framerate", (getter)Video_getFrameRate, (setter)Video_setFrameRate, (char*)"frame rate", NULL},
+ // attributes from ImageBase class
+ {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
+ {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
+ {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL},
+ {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
+ {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
+ {(char*)"preseek", (getter)VideoFFmpeg_getPreseek, (setter)VideoFFmpeg_setPreseek, (char*)"nb of frames of preseek", NULL},
+ {(char*)"deinterlace", (getter)VideoFFmpeg_getDeinterlace, (setter)VideoFFmpeg_setDeinterlace, (char*)"deinterlace image", NULL},
+ {NULL}
+};
+
+// python type declaration
+PyTypeObject VideoFFmpegType =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.VideoFFmpeg", /*tp_name*/
+ sizeof(PyImage), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Image_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "FFmpeg video source", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ videoMethods, /* tp_methods */
+ 0, /* tp_members */
+ videoGetSets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)VideoFFmpeg_init, /* tp_init */
+ 0, /* tp_alloc */
+ Image_allocNew, /* tp_new */
+};
+
+// object initialization
+static int ImageFFmpeg_init (PyObject * pySelf, PyObject * args, PyObject * kwds)
+{
+ PyImage * self = reinterpret_cast<PyImage*>(pySelf);
+ // parameters - video source
+ // file name or format type for capture (only for Linux: video4linux or dv1394)
+ char * file = NULL;
+
+ // get parameters
+ if (!PyArg_ParseTuple(args, "s", &file))
+ return -1;
+
+ try
+ {
+ // create video object
+ Video_init<VideoFFmpeg>(self);
+
+ getVideoFFmpeg(self)->initParams(0, 0, 1.0, true);
+
+ // open video source
+ Video_open(getVideo(self), file, -1);
+ }
+ catch (Exception & exp)
+ {
+ exp.report();
+ return -1;
+ }
+ // initialization succeded
+ return 0;
+}
+
+PyObject * Image_reload (PyImage * self, PyObject *args)
+{
+ char * newname = NULL;
+
+ if (self->m_image != NULL && PyArg_ParseTuple(args, "|s", &newname))
+ {
+ VideoFFmpeg* video = getFFmpeg(self);
+ // check type of object
+ if (!newname)
+ newname = video->getImageName();
+ if (!newname) {
+ // if not set, retport error
+ PyErr_SetString(PyExc_RuntimeError, "No image file name given");
+ return NULL;
+ }
+ // make sure the previous file is cleared
+ video->release();
+ // open the new file
+ video->openFile(newname);
+ }
+ Py_RETURN_NONE;
+}
+
+// methods structure
+static PyMethodDef imageMethods[] =
+{ // methods from VideoBase class
+ {"refresh", (PyCFunction)Video_refresh, METH_NOARGS, "Refresh image, i.e. load it"},
+ {"reload", (PyCFunction)Image_reload, METH_VARARGS, "Reload image, i.e. reopen it"},
+ {NULL}
+};
+// attributes structure
+static PyGetSetDef imageGetSets[] =
+{ // methods from VideoBase class
+ {(char*)"status", (getter)Video_getStatus, NULL, (char*)"video status", NULL},
+ // attributes from ImageBase class
+ {(char*)"image", (getter)Image_getImage, NULL, (char*)"image data", NULL},
+ {(char*)"size", (getter)Image_getSize, NULL, (char*)"image size", NULL},
+ {(char*)"scale", (getter)Image_getScale, (setter)Image_setScale, (char*)"fast scale of image (near neighbour)", NULL},
+ {(char*)"flip", (getter)Image_getFlip, (setter)Image_setFlip, (char*)"flip image vertically", NULL},
+ {(char*)"filter", (getter)Image_getFilter, (setter)Image_setFilter, (char*)"pixel filter", NULL},
+ {NULL}
+};
+
+// python type declaration
+PyTypeObject ImageFFmpegType =
+{
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "VideoTexture.ImageFFmpeg", /*tp_name*/
+ sizeof(PyImage), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor)Image_dealloc, /*tp_dealloc*/
+ 0, /*tp_print*/
+ 0, /*tp_getattr*/
+ 0, /*tp_setattr*/
+ 0, /*tp_compare*/
+ 0, /*tp_repr*/
+ 0, /*tp_as_number*/
+ 0, /*tp_as_sequence*/
+ 0, /*tp_as_mapping*/
+ 0, /*tp_hash */
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /*tp_as_buffer*/
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ "FFmpeg image source", /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ imageMethods, /* tp_methods */
+ 0, /* tp_members */
+ imageGetSets, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)ImageFFmpeg_init, /* tp_init */
+ 0, /* tp_alloc */
+ Image_allocNew, /* tp_new */
+};
+
+#endif //WITH_FFMPEG
+
+
diff --git a/source/gameengine/VideoTexture/VideoFFmpeg.h b/source/gameengine/VideoTexture/VideoFFmpeg.h
new file mode 100644
index 00000000000..e60f1727aab
--- /dev/null
+++ b/source/gameengine/VideoTexture/VideoFFmpeg.h
@@ -0,0 +1,173 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexture library
+
+Copyright (c) 2007 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+#if !defined VIDEOFFMPEG_H
+#define VIDEOFFMPEG_H
+
+#ifdef WITH_FFMPEG
+extern "C" {
+#include <ffmpeg/avformat.h>
+#include <ffmpeg/avcodec.h>
+#include <ffmpeg/rational.h>
+#include <ffmpeg/swscale.h>
+}
+
+#if LIBAVFORMAT_VERSION_INT < (49 << 16)
+#define FFMPEG_OLD_FRAME_RATE 1
+#else
+#define FFMPEG_CODEC_IS_POINTER 1
+#endif
+
+#if LIBAVFORMAT_VERSION_INT >= (52 << 16)
+#define FFMPEG_PB_IS_POINTER 1
+#endif
+
+#ifdef FFMPEG_CODEC_IS_POINTER
+static inline AVCodecContext* get_codec_from_stream(AVStream* stream)
+{
+ return stream->codec;
+}
+#else
+static inline AVCodecContext* get_codec_from_stream(AVStream* stream)
+{
+ return &stream->codec;
+}
+#endif
+
+#include "VideoBase.h"
+
+
+// type VideoFFmpeg declaration
+class VideoFFmpeg : public VideoBase
+{
+public:
+ /// constructor
+ VideoFFmpeg (HRESULT * hRslt);
+ /// destructor
+ virtual ~VideoFFmpeg ();
+
+ /// set initial parameters
+ void initParams (short width, short height, float rate, bool image=false);
+ /// open video/image file
+ virtual void openFile (char * file);
+ /// open video capture device
+ virtual void openCam (char * driver, short camIdx);
+
+ /// release video source
+ virtual bool release (void);
+
+ /// play video
+ virtual bool play (void);
+ /// stop/pause video
+ virtual bool stop (void);
+
+ /// set play range
+ virtual void setRange (double start, double stop);
+ /// set frame rate
+ virtual void setFrameRate (float rate);
+ // some specific getters and setters
+ int getPreseek(void) { return m_preseek; }
+ void setPreseek(int preseek) { if (preseek >= 0) m_preseek = preseek; }
+ bool getDeinterlace(void) { return m_deinterlace; }
+ void setDeinterlace(bool deinterlace) { m_deinterlace = deinterlace; }
+ char *getImageName(void) { return (m_isImage) ? m_imageName.Ptr() : NULL; }
+
+protected:
+
+ // format and codec information
+ AVCodec *m_codec;
+ AVFormatContext *m_formatCtx;
+ AVCodecContext *m_codecCtx;
+ // raw frame extracted from video file
+ AVFrame *m_frame;
+ // deinterlaced frame if codec requires it
+ AVFrame *m_frameDeinterlaced;
+ // decoded RGB24 frame if codec requires it
+ AVFrame *m_frameRGB;
+ // conversion from raw to RGB is done with sws_scale
+ struct SwsContext *m_imgConvertCtx;
+ // should the codec be deinterlaced?
+ bool m_deinterlace;
+ // number of frame of preseek
+ int m_preseek;
+ // order number of stream holding the video in format context
+ int m_videoStream;
+
+ // the actual frame rate
+ double m_baseFrameRate;
+
+ /// last displayed frame
+ long m_lastFrame;
+
+ /// end of file reached
+ bool m_eof;
+
+ /// current file pointer position in file expressed in frame number
+ long m_curPosition;
+
+ /// time of video play start
+ double m_startTime;
+
+ /// width of capture in pixel
+ short m_captWidth;
+
+ /// height of capture in pixel
+ short m_captHeight;
+
+ /// frame rate of capture in frames per seconds
+ float m_captRate;
+
+ /// is file an image?
+ bool m_isImage;
+
+ /// keep last image name
+ STR_String m_imageName;
+
+ /// image calculation
+ virtual void calcImage (unsigned int texId);
+
+ /// load frame from video
+ void loadFrame (void);
+
+ /// set actual position
+ void setPositions (void);
+
+ /// get actual framerate
+ double actFrameRate (void) { return m_frameRate * m_baseFrameRate; }
+
+ /// common function to video file and capture
+ int openStream(const char *filename, AVInputFormat *inputFormat, AVFormatParameters *formatParams);
+
+ /// check if a frame is available and load it in pFrame, return true if a frame could be retrieved
+ bool grabFrame(long frame);
+
+ /// return the frame in RGB24 format, the image data is found in AVFrame.data[0]
+ AVFrame* getFrame(void) { return m_frameRGB; }
+};
+
+inline VideoFFmpeg * getFFmpeg (PyImage * self)
+{
+ return static_cast<VideoFFmpeg*>(self->m_image);
+}
+
+#endif //WITH_FFMPEG
+
+#endif
diff --git a/source/gameengine/VideoTexture/blendVideoTex.cpp b/source/gameengine/VideoTexture/blendVideoTex.cpp
new file mode 100644
index 00000000000..b38882f8164
--- /dev/null
+++ b/source/gameengine/VideoTexture/blendVideoTex.cpp
@@ -0,0 +1,194 @@
+/* $Id$
+-----------------------------------------------------------------------------
+This source file is part of VideoTexure library
+
+Copyright (c) 2006 The Zdeno Ash Miklas
+
+This program is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free Software
+Foundation; either version 2 of the License, or (at your option) any later
+version.
+
+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 Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public License along with
+this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+Place - Suite 330, Boston, MA 02111-1307, USA, or go to
+http://www.gnu.org/copyleft/lesser.txt.
+-----------------------------------------------------------------------------
+*/
+
+#include <PyObjectPlus.h>
+
+#include <RAS_GLExtensionManager.h>
+
+#include <RAS_IPolygonMaterial.h>
+
+//Old API
+//#include "TexPlayer.h"
+//#include "TexImage.h"
+//#include "TexFrameBuff.h"
+
+//#include "TexPlayerGL.h"
+
+#include "ImageBase.h"
+#include "FilterBase.h"
+#include "Texture.h"
+
+#include "Exception.h"
+
+
+// get material id
+static PyObject * getMaterialID (PyObject *self, PyObject *args)
+{
+ // parameters - game object with video texture
+ PyObject * obj = NULL;
+ // material name
+ char * matName;
+
+ // get parameters
+ if (!PyArg_ParseTuple(args, "Os", &obj, &matName))
+ return NULL;
+ // get material id
+ short matID = getMaterialID(obj, matName);
+ // if material was not found, report errot
+ if (matID < 0)
+ {
+ PyErr_SetString(PyExc_RuntimeError, "object doesn't have material with given name");
+ return NULL;
+ }
+ // return material ID
+ return Py_BuildValue("h", matID);
+}
+
+
+// get last error description
+static PyObject * getLastError (PyObject *self, PyObject *args)
+{
+ return Py_BuildValue("s", Exception::m_lastError.c_str());
+}
+
+// set log file
+static PyObject * setLogFile (PyObject *self, PyObject *args)
+{
+ // get parameters
+ if (!PyArg_ParseTuple(args, "s", &Exception::m_logFile))
+ return Py_BuildValue("i", -1);
+ // log file was loaded
+ return Py_BuildValue("i", 0);
+}
+
+
+// image to numpy array
+static PyObject * imageToArray (PyObject * self, PyObject *args)
+{
+ // parameter is Image object
+ PyObject * pyImg;
+ if (!PyArg_ParseTuple(args, "O", &pyImg) || !pyImageTypes.in(pyImg->ob_type))
+ {
+ // if object is incorect, report error
+ PyErr_SetString(PyExc_TypeError, "The value must be a image source object");
+ return NULL;
+ }
+ // get image structure
+ PyImage * img = reinterpret_cast<PyImage*>(pyImg);
+ // create array object
+ unsigned int * imgBuff = img->m_image->getImage();
+ // if image is available, convert it to array
+ if (imgBuff != NULL)
+ // Nasty problem here: the image buffer is an array of integers
+ // in the processor endian format. The user must take care of that in the script.
+ // Need to find an elegant solution to this problem
+ return Py_BuildValue("s#", imgBuff, img->m_image->getBuffSize());
+ // otherwise return None
+ Py_RETURN_NONE;
+}
+
+
+// metody modulu
+static PyMethodDef moduleMethods[] =
+{
+ {"materialID", getMaterialID, METH_VARARGS, "Gets object's Blender Material ID"},
+ {"getLastError", getLastError, METH_NOARGS, "Gets last error description"},
+ {"setLogFile", setLogFile, METH_VARARGS, "Sets log file name"},
+ {"imageToArray", imageToArray, METH_VARARGS, "get array from image source"},
+ {NULL} /* Sentinel */
+};
+
+#if WITH_FFMPEG
+extern PyTypeObject VideoFFmpegType;
+extern PyTypeObject ImageFFmpegType;
+#endif
+extern PyTypeObject FilterBlueScreenType;
+extern PyTypeObject FilterGrayType;
+extern PyTypeObject FilterColorType;
+extern PyTypeObject FilterLevelType;
+extern PyTypeObject FilterNormalType;
+extern PyTypeObject FilterRGB24Type;
+extern PyTypeObject FilterRGBA32Type;
+extern PyTypeObject FilterBGR24Type;
+extern PyTypeObject ImageBuffType;
+extern PyTypeObject ImageMixType;
+extern PyTypeObject ImageRenderType;
+extern PyTypeObject ImageViewportType;
+extern PyTypeObject ImageViewportType;
+
+
+static void registerAllTypes(void)
+{
+#if WITH_FFMPEG
+ pyImageTypes.add(&VideoFFmpegType, "VideoFFmpeg");
+ pyImageTypes.add(&ImageFFmpegType, "ImageFFmpeg");
+#endif
+ pyImageTypes.add(&ImageBuffType, "ImageBuff");
+ pyImageTypes.add(&ImageMixType, "ImageMix");
+ //pyImageTypes.add(&ImageRenderType, "ImageRender");
+ pyImageTypes.add(&ImageViewportType, "ImageViewport");
+
+ pyFilterTypes.add(&FilterBlueScreenType, "FilterBlueScreen");
+ pyFilterTypes.add(&FilterGrayType, "FilterGray");
+ pyFilterTypes.add(&FilterColorType, "FilterColor");
+ pyFilterTypes.add(&FilterLevelType, "FilterLevel");
+ pyFilterTypes.add(&FilterNormalType, "FilterNormal");
+ pyFilterTypes.add(&FilterRGB24Type, "FilterRGB24");
+ pyFilterTypes.add(&FilterRGBA32Type, "FilterRGBA32");
+ pyFilterTypes.add(&FilterBGR24Type, "FilterBGR24");
+}
+
+PyObject* initVideoTexture(void)
+{
+ // initialize GL extensions
+ //bgl::InitExtensions(0);
+
+ // prepare classes
+ registerAllTypes();
+ registerAllExceptions();
+
+ if (!pyImageTypes.ready())
+ return NULL;
+ if (!pyFilterTypes.ready())
+ return NULL;
+ if (PyType_Ready(&TextureType) < 0)
+ return NULL;
+
+ PyObject * m = Py_InitModule4("VideoTexture", moduleMethods,
+ "Module that allows to play video files on textures in GameBlender.",
+ (PyObject*)NULL,PYTHON_API_VERSION);
+ if (m == NULL)
+ return NULL;
+
+ // initialize classes
+ pyImageTypes.reg(m);
+ pyFilterTypes.reg(m);
+
+ Py_INCREF(&TextureType);
+ PyModule_AddObject(m, (char*)"Texture", (PyObject*)&TextureType);
+
+ // init last error description
+ Exception::m_lastError[0] = '\0';
+ return m;
+}
+
+// registration to Image types, put here because of silly linker bug