1 """
2 Documentation for the GameTypes Module.
3 =======================================
4
5 @group Base: PyObjectPlus, CValue, CPropValue, SCA_ILogicBrick, SCA_IObject, SCA_ISensor, SCA_IController, SCA_IActuator
6
7 @group Object: KX_GameObject, KX_LightObject, KX_Camera
8
9 @group Mesh: KX_MeshProxy, KX_PolyProxy, KX_VertexProxy
10
11 @group Shading: KX_PolygonMaterial, KX_BlenderMaterial, BL_Shader
12
13 @group Sensors: SCA_ActuatorSensor, SCA_AlwaysSensor, SCA_DelaySensor, SCA_JoystickSensor, SCA_KeyboardSensor, KX_MouseFocusSensor, SCA_MouseSensor, KX_NearSensor, KX_NetworkMessageSensor, SCA_PropertySensor, KX_RadarSensor, SCA_RandomSensor, KX_RaySensor, KX_TouchSensor
14
15 @group Actuators: SCA_2DFilterActuator, BL_ActionActuator, KX_SCA_AddObjectActuator, KX_CameraActuator, KX_CDActuator, KX_ConstraintActuator, KX_SCA_DynamicActuator, KX_SCA_EndObjectActuator, KX_GameActuator, KX_IpoActuator, KX_NetworkMessageActuator, KX_ObjectActuator, KX_ParentActuator, SCA_PropertyActuator, SCA_RandomActuator, KX_SCA_ReplaceMeshActuator, KX_SceneActuator, BL_ShapeActionActuator, KX_SoundActuator, KX_StateActuator, KX_TrackToActuator, KX_VisibilityActuator
16
17 @group Controllers: SCA_ANDController, SCA_NANDController, SCA_NORController, SCA_ORController, SCA_PythonController, SCA_XNORController, SCA_XORController
18 """
19 import GameLogic
20
22 """
23 PyObjectPlus base class of most other types in the Game Engine.
24
25 @ivar invalid: Test if the object has been freed by the game engine and is no longer valid.
26
27 Normally this is not a problem but when storing game engine data in the GameLogic module,
28 KX_Scenes or other KX_GameObjects its possible to hold a reference to invalid data.
29 Calling an attribute or method on an invalid object will raise a SystemError.
30
31 The invalid attribute allows testing for this case without exception handling.
32 @type invalid: bool
33 """
34
36 """
37 Check if this is a type or a subtype game_type.
38
39 @param game_type: the name of the type or the type its self from the L{GameTypes} module.
40 @type game_type: string or type
41 @return: True if this object is a type or a subtype of game_type.
42 @rtype: bool
43 """
44
46 """
47 This class is a basis for other classes.
48 @ivar name: The name of this CValue derived object (read-only).
49 @type name: string
50 @group Deprecated: getName
51 """
53 """
54 Returns the name of the CValue.
55
56 @deprecated: Use the L{name} attribute instead.
57 @note: in most cases the CValue's subclasses will override this function.
58 @rtype: string
59 """
60
62 """
63 This class has no python functions
64 """
65 pass
66
68 """
69 Base class for all logic bricks.
70
71 @ivar executePriority: This determines the order controllers are evaluated, and actuators are activated (lower priority is executed first).
72 @type executePriority: int
73 @ivar owner: The game object this logic brick is attached to (read-only).
74 @type owner: L{KX_GameObject} or None in exceptional cases.
75 @ivar name: The name of this logic brick (read-only).
76 @type name: string
77 """
78
79
81 """
82 Gets the game object associated with this logic brick.
83
84 @deprecated: Use the L{owner} attribute instead.
85 @rtype: L{KX_GameObject}
86 """
87
89 """
90 Sets the priority of this logic brick.
91
92 This determines the order controllers are evaluated, and actuators are activated.
93 Bricks with lower priority will be executed first.
94
95 @deprecated: Use the L{executePriority} attribute instead.
96 @type priority: integer
97 @param priority: the priority of this logic brick.
98 """
100 """
101 Gets the execution priority of this logic brick.
102
103 @deprecated: Use the L{executePriority} attribute instead.
104 @rtype: integer
105 @return: this logic bricks current priority.
106 """
107
108
110 """
111 This class has no python functions
112 """
113 pass
114
116 """
117 Base class for all sensor logic bricks.
118
119 @ivar usePosPulseMode: Flag to turn positive pulse mode on and off.
120 @type usePosPulseMode: boolean
121 @ivar useNegPulseMode: Flag to turn negative pulse mode on and off.
122 @type useNegPulseMode: boolean
123 @ivar frequency: The frequency for pulse mode sensors.
124 @type frequency: int
125 @ivar level: Option whether to detect level or edge transition when entering a state.
126 It makes a difference only in case of logic state transition (state actuator).
127 A level detector will immediately generate a pulse, negative or positive
128 depending on the sensor condition, as soon as the state is activated.
129 A edge detector will wait for a state change before generating a pulse.
130 note: mutually exclusive with L{tap}, enabling will disable L{tap}.
131 @type level: boolean
132 @ivar tap: When enabled only sensors that are just activated will send a positive event,
133 after this they will be detected as negative by the controllers.
134 This will make a key thats held act as if its only tapped for an instant.
135 note: mutually exclusive with L{level}, enabling will disable L{level}.
136 @type tap: boolean
137 @ivar invert: Flag to set if this sensor activates on positive or negative events.
138 @type invert: boolean
139 @ivar triggered: True if this sensor brick is in a positive state. (read-only)
140 @type triggered: boolean
141 @ivar positive: True if this sensor brick is in a positive state. (read-only)
142 @type positive: boolean
143 """
144
146 """
147 Reset sensor internal state, effect depends on the type of sensor and settings.
148
149 The sensor is put in its initial state as if it was just activated.
150 """
151
153 """
154 True if this sensor brick is in a positive state.
155
156 @deprecated: use L{positive}
157 """
158
160 """
161 True if this sensor brick has triggered the current controller.
162
163 @deprecated: use L{triggered}
164 """
165
167 """
168 True if the sensor is in positive pulse mode.
169
170 @deprecated: use L{usePosPulseMode}
171 """
173 """
174 Sets positive pulse mode.
175
176 @type pulse: boolean
177 @param pulse: If True, will activate positive pulse mode for this sensor.
178 @deprecated: use L{usePosPulseMode}
179 """
181 """
182 The frequency for pulse mode sensors.
183
184 @rtype: integer
185 @return: the pulse frequency in 1/50 sec.
186 @deprecated: use L{frequency}
187 """
189 """
190 Sets the frequency for pulse mode sensors.
191
192 @type freq: integer
193 @return: the pulse frequency in 1/50 sec.
194 @deprecated: use L{frequency}
195 """
197 """
198 True if the sensor is in negative pulse mode.
199
200 @deprecated: use L{useNegPulseMode}
201 """
203 """
204 Sets negative pulse mode.
205
206 @type pulse: boolean
207 @param pulse: If True, will activate negative pulse mode for this sensor.
208 @deprecated: use L{useNegPulseMode}
209 """
211 """
212 True if this sensor activates on negative events.
213
214 @deprecated: use L{invert}
215 """
217 """
218 Sets if this sensor activates on positive or negative events.
219
220 @type invert: boolean
221 @param invert: true if activates on negative events; false if activates on positive events.
222 @deprecated: use L{invert}
223 """
225 """
226 Returns whether this sensor is a level detector or a edge detector.
227 It makes a difference only in case of logic state transition (state actuator).
228 A level detector will immediately generate a pulse, negative or positive
229 depending on the sensor condition, as soon as the state is activated.
230 A edge detector will wait for a state change before generating a pulse.
231
232 @rtype: boolean
233 @return: true if sensor is level sensitive, false if it is edge sensitive
234 @deprecated: use L{level}
235 """
237 """
238 Set whether to detect level or edge transition when entering a state.
239
240 @param level: Detect level instead of edge? (KX_TRUE, KX_FALSE)
241 @type level: boolean
242 @deprecated: use L{level}
243 """
244
245
247 """
248 Base class for all controller logic bricks.
249
250 @ivar state: the controllers state bitmask.
251 This can be used with the GameObject's state to test if the controller is active.
252 @type state: int bitmask
253 @ivar sensors: a list of sensors linked to this controller
254 - note: the sensors are not necessarily owned by the same object.
255 - note: when objects are instanced in dupligroups links may be lost from objects outside the dupligroup.
256 @type sensors: sequence supporting index/string lookups and iteration.
257 @ivar actuators: a list of actuators linked to this controller.
258 - note: the sensors are not necessarily owned by the same object.
259 - note: when objects are instanced in dupligroups links may be lost from objects outside the dupligroup.
260 @type actuators: sequence supporting index/string lookups and iteration.
261 @ivar useHighPriority: When set the controller executes always before all other controllers that dont have this set.
262 note: Order of execution between high priority controllers is not guaranteed.
263 @type useHighPriority: bool
264 """
265
267 """
268 Get the controllers state bitmask, this can be used with the GameObject's state to test if the the controller is active.
269 This for instance will always be true however you could compare with a previous state to see when the state was activated.
270 GameLogic.getCurrentController().state & GameLogic.getCurrentController().owner.state
271 @deprecated: Use the L{state} property
272 @rtype: int
273 """
275 """
276 Gets a list of all sensors attached to this controller.
277 @deprecated: use the L{sensors} property
278 @rtype: list [L{SCA_ISensor}]
279 """
281 """
282 Gets the named linked sensor.
283 @deprecated: use the L{sensors}[name] property
284 @type name: string
285 @rtype: L{SCA_ISensor}
286 """
288 """
289 Gets a list of all actuators linked to this controller.
290 @deprecated: Use the L{actuators} property
291 @rtype: list [L{SCA_IActuator}]
292 """
294 """
295 Gets the named linked actuator.
296 @deprecated: use the L{actuators}[name] property
297 @type name: string
298 @rtype: L{SCA_IActuator}
299 """
300
301
303 """
304 Base class for all actuator logic bricks.
305 """
306
308 """
309 Action Actuators apply an action to an actor.
310
311 @ivar action: The name of the action to set as the current action.
312 @type action: string
313 @ivar channelNames: A list of channel names that may be used with L{setChannel} and L{getChannel}
314 @type channelNames: list of strings
315 @ivar frameStart: Specifies the starting frame of the animation.
316 @type frameStart: float
317 @ivar frameEnd: Specifies the ending frame of the animation.
318 @type frameEnd: float
319 @ivar blendIn: Specifies the number of frames of animation to generate when making transitions between actions.
320 @type blendIn: float
321 @ivar priority: Sets the priority of this actuator. Actuators will lower
322 priority numbers will override actuators with higher
323 numbers.
324 @type priority: integer
325 @ivar frame: Sets the current frame for the animation.
326 @type frame: float
327 @ivar propName: Sets the property to be used in FromProp playback mode.
328 @type propName: string
329 @ivar blendTime: Sets the internal frame timer. This property must be in
330 the range from 0.0 to blendIn.
331 @type blendTime: float
332 @ivar mode: The operation mode of the actuator. KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
333 @type mode: integer
334 @ivar useContinue: The actions continue option, True or False.
335 When True, the action will always play from where last left off,
336 otherwise negative events to this actuator will reset it to its start frame.
337 @type useContinue: boolean
338 @ivar framePropName: The name of the property that is set to the current frame number.
339 @type framePropName: string
340 """
342 """
343 Alternative to the 2 arguments, 4 arguments (channel, matrix, loc, size, quat) are also supported.
344
345 @note: These values are relative to the bones rest position, currently the api has no way to get this info (which is annoying), but can be worked around by using bones with a rest pose that has no translation.
346 @param channel: A string specifying the name of the bone channel, error raised if not in L{channelNames}.
347 @type channel: string
348 @param matrix: A 4x4 matrix specifying the overriding transformation
349 as an offset from the bone's rest position.
350 @type matrix: list [[float]]
351 """
352
354 """
355 @param channel: A string specifying the name of the bone channel. error raised if not in L{channelNames}.
356 @type channel: string
357 @rtype: tuple
358 @return: (loc, size, quat)
359 """
360
361
363 """
364 Sets the current action.
365 @deprecated: use the L{action} property
366 @param action: The name of the action to set as the current action.
367 @type action: string
368 @param reset: Optional parameter indicating whether to reset the
369 blend timer or not. A value of 1 indicates that the
370 timer should be reset. A value of 0 will leave it
371 unchanged. If reset is not specified, the timer will
372 be reset.
373 """
374
376 """
377 Specifies the starting frame of the animation.
378 @deprecated: Use the L{frameStart} property
379 @param start: the starting frame of the animation
380 @type start: float
381 """
382
384 """
385 Specifies the ending frame of the animation.
386 @deprecated: use the L{frameEnd} property
387 @param end: the ending frame of the animation
388 @type end: float
389 """
391 """
392 Specifies the number of frames of animation to generate
393 when making transitions between actions.
394 @deprecated: use the L{blendIn} property
395 @param blendin: the number of frames in transition.
396 @type blendin: float
397 """
398
400 """
401 Sets the priority of this actuator.
402
403 @deprecated: Use use the L{priority} property
404 @param priority: Specifies the new priority. Actuators will lower
405 priority numbers will override actuators with higher
406 numbers.
407 @type priority: integer
408 """
410 """
411 Sets the current frame for the animation.
412
413 @deprecated: use the L{frame} property
414 @param frame: Specifies the new current frame for the animation
415 @type frame: float
416 """
417
419 """
420 Sets the property to be used in FromProp playback mode.
421
422 @deprecated: use the L{property} property
423 @param prop: the name of the property to use.
424 @type prop: string.
425 """
426
428 """
429 Sets the internal frame timer.
430
431 Allows the script to directly modify the internal timer
432 used when generating transitions between actions.
433
434 @deprecated: use the L{blendTime} property
435 @param blendtime: The new time. This parameter must be in the range from 0.0 to 1.0.
436 @type blendtime: float
437 """
438
440 """
441 Sets the operation mode of the actuator
442
443 @deprecated: use the L{type} property
444 @param mode: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
445 @type mode: integer
446 """
447
449 """
450 Set the actions continue option True or False. see getContinue.
451
452 @deprecated: use the L{useContinue} property
453 @param cont: The continue option.
454 @type cont: bool
455 """
456
458 """
459 Returns the operation mode of the actuator
460
461 @deprecated: use the L{type} property
462 @rtype: integer
463 @return: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
464 """
465
467 """
468 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.
469
470 @deprecated: use the L{useContinue} property
471 @rtype: bool
472 """
473
475 """
476 getAction() returns the name of the action associated with this actuator.
477
478 @deprecated: use the L{action} property
479 @rtype: string
480 """
481
483 """
484 Returns the starting frame of the action.
485
486 @deprecated: use the L{frameStart} property
487 @rtype: float
488 """
490 """
491 Returns the last frame of the action.
492
493 @deprecated: use the L{frameEnd} property
494 @rtype: float
495 """
497 """
498 Returns the number of interpolation animation frames to be generated when this actuator is triggered.
499
500 @deprecated: use the L{blendIn} property
501 @rtype: float
502 """
504 """
505 Returns the priority for this actuator. Actuators with lower Priority numbers will
506 override actuators with higher numbers.
507
508 @deprecated: use the L{priority} property
509 @rtype: integer
510 """
512 """
513 Returns the current frame number.
514
515 @deprecated: use the L{frame} property
516 @rtype: float
517 """
519 """
520 Returns the name of the property to be used in FromProp mode.
521
522 @deprecated: use the L{property} property
523 @rtype: string
524 """
526 """
527 @deprecated: use the L{framePropName} property
528 @param prop: A string specifying the property of the object that will be updated with the action frame number.
529 @type prop: string
530 """
532 """
533 Returns the name of the property that is set to the current frame number.
534
535 @deprecated: use the L{framePropName} property
536 @rtype: string
537 """
538
539
541 """
542 BL_Shader GLSL shaders.
543
544 TODO - Description
545 """
546
557
559 """
560 Clear the shader. Use this method before the source is changed with L{setSource}.
561 """
563 """
564 Returns the fragment program.
565
566 @rtype: string
567 @return: The fragment program.
568 """
570 """
571 Get the vertex program.
572
573 @rtype: string
574 @return: The vertex program.
575 """
577 """
578 Check if the shader is valid.
579
580 @rtype: bool
581 @return: True if the shader is valid
582 """
584 """
585 Set attribute location. (The parameter is ignored a.t.m. and the value of "tangent" is always used.)
586
587 @param enum: attribute location value
588 @type enum: integer
589 """
591 """
592 Set the maximum number of passes. Not used a.t.m.
593
594 @param max_pass: the maximum number of passes
595 @type max_pass: integer
596 """
598 """
599 Set uniform texture sample index.
600
601 @param name: Uniform name
602 @type name: string
603
604 @param index: Texture sample index.
605 @type index: integer
606 """
607 - def setSource(vertexProgram, fragmentProgram):
608 """
609 Set the vertex and fragment programs
610
611 @param vertexProgram: Vertex program
612 @type vertexProgram: string
613
614 @param fragmentProgram: Fragment program
615 @type fragmentProgram: string
616 """
780 """
781 Validate the shader object.
782
783 """
784
786 """
787 ShapeAction Actuators apply an shape action to an mesh object.\
788
789 @ivar action: The name of the action to set as the current shape action.
790 @type action: string
791 @ivar frameStart: Specifies the starting frame of the shape animation.
792 @type frameStart: float
793 @ivar frameEnd: Specifies the ending frame of the shape animation.
794 @type frameEnd: float
795 @ivar blendIn: Specifies the number of frames of animation to generate when making transitions between actions.
796 @type blendIn: float
797 @ivar priority: Sets the priority of this actuator. Actuators will lower
798 priority numbers will override actuators with higher
799 numbers.
800 @type priority: integer
801 @ivar frame: Sets the current frame for the animation.
802 @type frame: float
803 @ivar propName: Sets the property to be used in FromProp playback mode.
804 @type propName: string
805 @ivar blendTime: Sets the internal frame timer. This property must be in
806 the range from 0.0 to blendin.
807 @type blendTime: float
808 @ivar mode: The operation mode of the actuator.
809 KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER,
810 KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
811 @type mode: integer
812 @ivar framePropName: The name of the property that is set to the current frame number.
813 @type framePropName: string
814
815 """
816
818 """
819 Sets the current action.
820
821 @deprecated: use the L{action} property
822 @param action: The name of the action to set as the current action.
823 @type action: string
824 @param reset: Optional parameter indicating whether to reset the
825 blend timer or not. A value of 1 indicates that the
826 timer should be reset. A value of 0 will leave it
827 unchanged. If reset is not specified, the timer will
828 be reset.
829 """
830
832 """
833 Specifies the starting frame of the animation.
834
835 @deprecated: use the L{frameStart} property
836 @param start: the starting frame of the animation
837 @type start: float
838 """
839
841 """
842 Specifies the ending frame of the animation.
843
844 @deprecated: use the L{frameEnd} property
845 @param end: the ending frame of the animation
846 @type end: float
847 """
849 """
850 Specifies the number of frames of animation to generate
851 when making transitions between actions.
852
853 @deprecated: use the L{blendIn} property
854 @param blendin: the number of frames in transition.
855 @type blendin: float
856 """
857
859 """
860 Sets the priority of this actuator.
861
862 @deprecated: use the L{priority} property
863 @param priority: Specifies the new priority. Actuators will lower
864 priority numbers will override actuators with higher
865 numbers.
866 @type priority: integer
867 """
869 """
870 Sets the current frame for the animation.
871
872 @deprecated: use the L{frame} property
873 @param frame: Specifies the new current frame for the animation
874 @type frame: float
875 """
876
878 """
879 Sets the property to be used in FromProp playback mode.
880
881 @deprecated: use the L{property} property
882 @param prop: the name of the property to use.
883 @type prop: string.
884 """
885
887 """
888 Sets the internal frame timer.
889
890 Allows the script to directly modify the internal timer
891 used when generating transitions between actions.
892
893 @deprecated: use the L{blendTime} property
894 @param blendtime: The new time. This parameter must be in the range from 0.0 to 1.0.
895 @type blendtime: float
896 """
897
899 """
900 Sets the operation mode of the actuator
901
902 @deprecated: use the L{type} property
903 @param mode: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
904 @type mode: integer
905 """
906
908 """
909 Returns the operation mode of the actuator
910
911 @deprecated: use the L{type} property
912 @rtype: integer
913 @return: KX_ACTIONACT_PLAY, KX_ACTIONACT_PROPERTY, KX_ACTIONACT_FLIPPER, KX_ACTIONACT_LOOPSTOP, KX_ACTIONACT_LOOPEND
914 """
915
917 """
918 getAction() returns the name of the action associated with this actuator.
919
920 @deprecated: use the L{action} property
921 @rtype: string
922 """
923
925 """
926 Returns the starting frame of the action.
927
928 @deprecated: use the L{frameStart} property
929 @rtype: float
930 """
932 """
933 Returns the last frame of the action.
934
935 @deprecated: use the L{frameEnd} property
936 @rtype: float
937 """
939 """
940 Returns the number of interpolation animation frames to be generated when this actuator is triggered.
941
942 @deprecated: use the L{blendIn} property
943 @rtype: float
944 """
946 """
947 Returns the priority for this actuator. Actuators with lower Priority numbers will
948 override actuators with higher numbers.
949
950 @deprecated: use the L{priority} property
951 @rtype: integer
952 """
954 """
955 Returns the current frame number.
956
957 @deprecated: use the L{frame} property
958 @rtype: float
959 """
961 """
962 Returns the name of the property to be used in FromProp mode.
963
964 @deprecated: use the L{property} property
965 @rtype: string
966 """
968 """
969 @deprecated: use the L{framePropName} property
970 @param prop: A string specifying the property of the object that will be updated with the action frame number.
971 @type prop: string
972 """
974 """
975 Returns the name of the property that is set to the current frame number.
976
977 @deprecated: use the L{framePropName} property
978 @rtype: string
979 """
980
981
983 """
984 CListValue
985
986 This is a list like object used in the game engine internally that behaves similar to a python list in most ways.
987
988 As well as the normal index lookup.
989 C{val= clist[i]}
990
991 CListValue supports string lookups.
992 C{val= scene.objects["OBCube"]}
993
994 Other operations such as C{len(clist), list(clist), clist[0:10]} are also supported.
995 """
997 """
998 Add an item to the list (like pythons append)
999
1000 Warning: Appending values to the list can cause crashes when the list is used internally by the game engine.
1001 """
1002
1004 """
1005 Count the number of instances of a value in the list.
1006
1007 @rtype: integer
1008 @return: number of instances
1009 """
1011 """
1012 Return the index of a value in the list.
1013
1014 @rtype: integer
1015 @return: The index of the value in the list.
1016 """
1018 """
1019 Reverse the order of the list.
1020 """
1021 - def get(key, default=None):
1022 """
1023 Return the value matching key, or the default value if its not found.
1024 @return: The key value or a default.
1025 """
1027 """
1028 Return True if the key is found.
1029 @rtype: boolean
1030 @return: The key value or a default.
1031 """
1033 """
1034 This is a funtion especially for the game engine to return a value with a spesific id.
1035
1036 Since object names are not always unique, the id of an object can be used to get an object from the CValueList.
1037
1038 Example.
1039
1040 C{myObID = id(gameObject)}
1041
1042 C{...}
1043
1044 C{ob= scene.objects.from_id(myObID)}
1045
1046 Where myObID is an int or long from the id function.
1047
1048 This has the advantage that you can store the id in places you could not store a gameObject.
1049
1050 Warning: the id is derived from a memory location and will be different each time the game engine starts.
1051 """
1052
1054 """
1055 KX_BlenderMaterial
1056
1057 """
1058
1060 """
1061 Returns the material's shader.
1062
1063 @rtype: L{BL_Shader}
1064 @return: the material's shader
1065 """
1066
1068 """
1069 Set the pixel color arithmetic functions.
1070
1071 @param src: Specifies how the red, green, blue,
1072 and alpha source blending factors are computed.
1073 @type src: GL_ZERO,
1074 GL_ONE,
1075 GL_SRC_COLOR,
1076 GL_ONE_MINUS_SRC_COLOR,
1077 GL_DST_COLOR,
1078 GL_ONE_MINUS_DST_COLOR,
1079 GL_SRC_ALPHA,
1080 GL_ONE_MINUS_SRC_ALPHA,
1081 GL_DST_ALPHA,
1082 GL_ONE_MINUS_DST_ALPHA,
1083 GL_SRC_ALPHA_SATURATE
1084
1085
1086 @param dest: Specifies how the red, green, blue,
1087 and alpha destination blending factors are computed.
1088 @type dest: GL_ZERO,
1089 GL_ONE,
1090 GL_SRC_COLOR,
1091 GL_ONE_MINUS_SRC_COLOR,
1092 GL_DST_COLOR,
1093 GL_ONE_MINUS_DST_COLOR,
1094 GL_SRC_ALPHA,
1095 GL_ONE_MINUS_SRC_ALPHA,
1096 GL_DST_ALPHA,
1097 GL_ONE_MINUS_DST_ALPHA,
1098 GL_SRC_ALPHA_SATURATE
1099
1100 """
1102 """
1103 Returns the material's index.
1104
1105 @rtype: integer
1106 @return: the material's index
1107 """
1108
1110 """
1111 CD Controller actuator.
1112 @ivar volume: controls the volume to set the CD to. 0.0 = silent, 1.0 = max volume.
1113 @type volume: float
1114 @ivar track: the track selected to be played
1115 @type track: integer
1116 @ivar gain: the gain (volume) of the CD between 0.0 and 1.0.
1117 @type gain: float
1118 """
1120 """
1121 Starts the CD playing.
1122 """
1124 """
1125 Stops the CD playing.
1126 """
1128 """
1129 Pauses the CD.
1130 """
1132 """
1133 Resumes the CD after a pause.
1134 """
1136 """
1137 Plays the CD from the beginning.
1138 """
1140 """
1141 Plays the track selected.
1142 """
1143
1145 """
1146 Sets the gain (volume) of the CD.
1147
1148 @deprecated: Use the L{volume} property.
1149 @type gain: float
1150 @param gain: the gain to set the CD to. 0.0 = silent, 1.0 = max volume.
1151 """
1153 """
1154 Gets the current gain (volume) of the CD.
1155
1156 @deprecated: Use the L{volume} property.
1157 @rtype: float
1158 @return: Between 0.0 (silent) and 1.0 (max volume)
1159 """
1160
1161
1163 """
1164 Applies changes to a camera.
1165
1166 @ivar min: minimum distance to the target object maintained by the actuator
1167 @type min: float
1168 @ivar max: maximum distance to stay from the target object
1169 @type max: float
1170 @ivar height: height to stay above the target object
1171 @type height: float
1172 @ivar useXY: axis this actuator is tracking, true=X, false=Y
1173 @type useXY: boolean
1174 @ivar object: the object this actuator tracks.
1175 @type object: KX_GameObject or None
1176 @author: snail
1177 """
1178
1180 """
1181 Returns the name of the object this actuator tracks.
1182
1183 @deprecated: Use the L{object} attribute instead.
1184 @type name_only: bool
1185 @param name_only: optional argument, when 0 return a KX_GameObject
1186 @rtype: string, KX_GameObject or None if no object is set
1187 """
1188
1190 """
1191 Sets the object this actuator tracks.
1192
1193 @deprecated: Use the L{object} attribute instead.
1194 @param target: the object to track.
1195 @type target: L{KX_GameObject}, string or None
1196 """
1197
1199 """
1200 Returns the minimum distance to target maintained by the actuator.
1201
1202 @deprecated: Use the L{min} attribute instead.
1203 @rtype: float
1204 """
1205
1207 """
1208 Sets the minimum distance to the target object maintained by the
1209 actuator.
1210
1211 @deprecated: Use the L{min} attribute instead.
1212 @param distance: The minimum distance to maintain.
1213 @type distance: float
1214 """
1215
1217 """
1218 Gets the maximum distance to stay from the target object.
1219
1220 @deprecated: Use the L{max} attribute instead.
1221 @rtype: float
1222 """
1223
1225 """
1226 Sets the maximum distance to stay from the target object.
1227
1228 @deprecated: Use the L{max} attribute instead.
1229 @param distance: The maximum distance to maintain.
1230 @type distance: float
1231 """
1232
1234 """
1235 Returns the height to stay above the target object.
1236
1237 @deprecated: Use the L{height} attribute instead.
1238 @rtype: float
1239 """
1240
1242 """
1243 Sets the height to stay above the target object.
1244
1245 @deprecated: Use the L{height} attribute instead.
1246 @type height: float
1247 @param height: The height to stay above the target object.
1248 """
1249
1251 """
1252 Sets the axis to get behind.
1253
1254 @deprecated: Use the L{useXY} attribute instead.
1255 @param xaxis: False to track Y axis, True to track X axis.
1256 @type xaxis: boolean
1257 """
1258
1260 """
1261 Returns the axis this actuator is tracking.
1262
1263 @deprecated: Use the L{useXY} attribute instead.
1264 @return: True if tracking X axis, False if tracking Y axis.
1265 @rtype: boolean
1266 """
1267
1268
1270 """
1271 A constraint actuator limits the position, rotation, distance or orientation of an object.
1272
1273 Properties:
1274
1275 @ivar damp: time constant of the constraint expressed in frame (not use by Force field constraint)
1276 @type damp: integer
1277
1278 @ivar rotDamp: time constant for the rotation expressed in frame (only for the distance constraint)
1279 0 = use damp for rotation as well
1280 @type rotDamp: integer
1281
1282 @ivar direction: the reference direction in world coordinate for the orientation constraint
1283 @type direction: 3-tuple of float: [x,y,z]
1284
1285 @ivar option: Binary combination of the following values:
1286 Applicable to Distance constraint:
1287 - KX_ACT_CONSTRAINT_NORMAL ( 64) : Activate alignment to surface
1288 - KX_ACT_CONSTRAINT_DISTANCE ( 512) : Activate distance control
1289 - KX_ACT_CONSTRAINT_LOCAL (1024) : direction of the ray is along the local axis
1290 Applicable to Force field constraint:
1291 - KX_ACT_CONSTRAINT_DOROTFH (2048) : Force field act on rotation as well
1292 Applicable to both:
1293 - KX_ACT_CONSTRAINT_MATERIAL ( 128) : Detect material rather than property
1294 - KX_ACT_CONSTRAINT_PERMANENT ( 256) : No deactivation if ray does not hit target
1295 @type option: integer
1296
1297 @ivar time: activation time of the actuator. The actuator disables itself after this many frame.
1298 If set to 0, the actuator is not limited in time.
1299 @type time: integer
1300
1301 @ivar propName: the name of the property or material for the ray detection of the distance constraint.
1302 @type propName: string
1303
1304 @ivar min: The lower bound of the constraint
1305 For the rotation and orientation constraint, it represents radiant
1306 @type min: float
1307
1308 @ivar distance: the target distance of the distance constraint
1309 @type distance: float
1310
1311 @ivar max: the upper bound of the constraint.
1312 For rotation and orientation constraints, it represents radiant.
1313 @type max: float
1314
1315 @ivar rayLength: the length of the ray of the distance constraint.
1316 @type rayLength: float
1317
1318 @ivar limit: type of constraint, use one of the following constant:
1319 KX_ACT_CONSTRAINT_LOCX ( 1) : limit X coord
1320 KX_ACT_CONSTRAINT_LOCY ( 2) : limit Y coord
1321 KX_ACT_CONSTRAINT_LOCZ ( 3) : limit Z coord
1322 KX_ACT_CONSTRAINT_ROTX ( 4) : limit X rotation
1323 KX_ACT_CONSTRAINT_ROTY ( 5) : limit Y rotation
1324 KX_ACT_CONSTRAINT_ROTZ ( 6) : limit Z rotation
1325 KX_ACT_CONSTRAINT_DIRPX ( 7) : set distance along positive X axis
1326 KX_ACT_CONSTRAINT_DIRPY ( 8) : set distance along positive Y axis
1327 KX_ACT_CONSTRAINT_DIRPZ ( 9) : set distance along positive Z axis
1328 KX_ACT_CONSTRAINT_DIRNX (10) : set distance along negative X axis
1329 KX_ACT_CONSTRAINT_DIRNY (11) : set distance along negative Y axis
1330 KX_ACT_CONSTRAINT_DIRNZ (12) : set distance along negative Z axis
1331 KX_ACT_CONSTRAINT_ORIX (13) : set orientation of X axis
1332 KX_ACT_CONSTRAINT_ORIY (14) : set orientation of Y axis
1333 KX_ACT_CONSTRAINT_ORIZ (15) : set orientation of Z axis
1334 KX_ACT_CONSTRAINT_FHPX (16) : set force field along positive X axis
1335 KX_ACT_CONSTRAINT_FHPY (17) : set force field along positive Y axis
1336 KX_ACT_CONSTRAINT_FHPZ (18) : set force field along positive Z axis
1337 KX_ACT_CONSTRAINT_FHNX (19) : set force field along negative X axis
1338 KX_ACT_CONSTRAINT_FHNY (20) : set force field along negative Y axis
1339 KX_ACT_CONSTRAINT_FHNZ (21) : set force field along negative Z axis
1340 @type limit: integer
1341 """
1342
1344 """
1345 Sets the time this constraint is delayed.
1346
1347 @param time: The number of frames to delay.
1348 Negative values are ignored.
1349 @type time: integer
1350 """
1352 """
1353 Returns the damping time of the constraint.
1354
1355 @rtype: integer
1356 """
1358 """
1359 Sets the lower bound of the constraint.
1360
1361 For rotational and orientation constraints, lower is specified in degrees.
1362
1363 @type lower: float
1364 """
1366 """
1367 Gets the lower bound of the constraint.
1368
1369 For rotational and orientation constraints, the lower bound is returned in radians.
1370
1371 @rtype: float
1372 """
1374 """
1375 Sets the upper bound of the constraint.
1376
1377 For rotational and orientation constraints, upper is specified in degrees.
1378
1379 @type upper: float
1380 """
1382 """
1383 Gets the upper bound of the constraint.
1384
1385 For rotational and orientation constraints, the upper bound is returned in radians.
1386
1387 @rtype: float
1388 """
1390 """
1391 Sets the type of constraint.
1392
1393 See module L{GameLogic} for valid constraint types.
1394
1395 @param limit:
1396 Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ
1397 Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY or KX_CONSTRAINTACT_ROTZ
1398 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
1399 Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ
1400 """
1402 """
1403 Gets the type of constraint.
1404
1405 See module L{GameLogic} for valid constraints.
1406
1407 @return:
1408 Position constraints: KX_CONSTRAINTACT_LOCX, KX_CONSTRAINTACT_LOCY, KX_CONSTRAINTACT_LOCZ,
1409 Rotation constraints: KX_CONSTRAINTACT_ROTX, KX_CONSTRAINTACT_ROTY, KX_CONSTRAINTACT_ROTZ,
1410 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,
1411 Orientation constraints: KX_ACT_CONSTRAINT_ORIX, KX_ACT_CONSTRAINT_ORIY, KX_ACT_CONSTRAINT_ORIZ
1412 """
1414 """
1415 Sets the time constant of the orientation constraint.
1416
1417 @param duration: If the duration is negative, it is set to 0.
1418 @type duration: integer
1419 """
1421 """
1422 Returns the damping time for application of the constraint.
1423
1424 @rtype: integer
1425 """
1427 """
1428 Sets the reference direction in world coordinate for the orientation constraint
1429
1430 @type vector: 3-tuple
1431 """
1433 """
1434 Returns the reference direction of the orientation constraint in world coordinate.
1435
1436 @rtype: 3-tuple
1437 """
1439 """
1440 Sets several options of the distance constraint.
1441
1442 @type option: integer
1443 @param option: Binary combination of the following values:
1444 64 : Activate alignment to surface
1445 128 : Detect material rather than property
1446 256 : No deactivation if ray does not hit target
1447 512 : Activate distance control
1448 """
1450 """
1451 Returns the option parameter.
1452
1453 @rtype: integer
1454 """
1456 """
1457 Sets the activation time of the actuator.
1458
1459 @type duration: integer
1460 @param duration: The actuator disables itself after this many frame.
1461 If set to 0 or negative, the actuator is not limited in time.
1462 """
1464 """
1465 Returns the time parameter.
1466
1467 @rtype: integer
1468 """
1470 """
1471 Sets the name of the property or material for the ray detection of the distance constraint.
1472
1473 @type property: string
1474 @param property: If empty, the ray will detect any collisioning object.
1475 """
1477 """
1478 Returns the property parameter.
1479
1480 @rtype: string
1481 """
1483 """
1484 Sets the target distance in distance constraint.
1485
1486 @type distance: float
1487 """
1489 """
1490 Returns the distance parameter.
1491
1492 @rtype: float
1493 """
1495 """
1496 Sets the maximum ray length of the distance constraint.
1497
1498 @type length: float
1499 """
1501 """
1502 Returns the length of the ray
1503
1504 @rtype: float
1505 """
1506
1507
1509 """
1510 KX_ConstraintWrapper
1511
1512 """
1514 """
1515 Returns the contraint's ID
1516
1517 @rtype: integer
1518 @return: the constraint's ID
1519 """
1520
1522 """
1523 The game actuator loads a new .blend file, restarts the current .blend file or quits the game.
1524
1525 Properties:
1526
1527 @ivar fileName: the new .blend file to load
1528 @type fileName: string.
1529 @ivar mode: The mode of this actuator
1530 @type mode: Constant in...
1531 - L{GameLogic.KX_GAME_LOAD}
1532 - L{GameLogic.KX_GAME_START}
1533 - L{GameLogic.KX_GAME_RESTART}
1534 - L{GameLogic.KX_GAME_QUIT}
1535 - L{GameLogic.KX_GAME_SAVECFG}
1536 - L{GameLogic.KX_GAME_LOADCFG}
1537 """
1538
1540 """
1541 Returns the filename of the new .blend file to load.
1542
1543 @deprecated: use the L{fileName} property
1544 @rtype: string
1545 """
1547 """
1548 Sets the new .blend file to load.
1549
1550 @deprecated: use the L{fileName} property
1551 @param filename: The file name this actuator will load.
1552 @type filename: string
1553 """
1554
1555
1557 """
1558 All game objects are derived from this class.
1559
1560 Properties assigned to game objects are accessible as attributes of this class.
1561 - note: Calling ANY method or attribute on an object that has been removed from a scene will raise a SystemError, if an object may have been removed since last accessing it use the L{invalid} attribute to check.
1562
1563 @ivar name: The object's name. (read-only)
1564 - note: Currently (Blender 2.49) the prefix "OB" is added to all objects name. This may change in blender 2.5.
1565 @type name: string.
1566 @ivar mass: The object's mass
1567 - note: The object must have a physics controller for the mass to be applied, otherwise the mass value will be returned as 0.0
1568 @type mass: float
1569 @ivar linVelocityMin: Enforces the object keeps moving at a minimum velocity.
1570 - note: Applies to dynamic and rigid body objects only.
1571 - note: A value of 0.0 disables this option.
1572 - note: While objects are stationary the minimum velocity will not be applied.
1573 @type linVelocityMin: float
1574 @ivar linVelocityMax: Clamp the maximum linear velocity to prevent objects moving beyond a set speed.
1575 - note: Applies to dynamic and rigid body objects only.
1576 - note: A value of 0.0 disables this option (rather then setting it stationary).
1577 @type linVelocityMax: float
1578 @ivar localInertia: the object's inertia vector in local coordinates. Read only.
1579 @type localInertia: list [ix, iy, iz]
1580 @ivar parent: The object's parent object. (read-only)
1581 @type parent: L{KX_GameObject} or None
1582 @ivar visible: visibility flag.
1583 - note: Game logic will still run for invisible objects.
1584 @type visible: boolean
1585 @ivar occlusion: occlusion capability flag.
1586 @type occlusion: boolean
1587 @ivar position: The object's position.
1588
1589 deprecated: use L{localPosition} and L{worldPosition}
1590 @type position: list [x, y, z] On write: local position, on read: world position
1591 @ivar orientation: The object's orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
1592
1593 deprecated: use L{localOrientation} and L{worldOrientation}
1594 @type orientation: 3x3 Matrix [[float]] On write: local orientation, on read: world orientation
1595 @ivar scaling: The object's scaling factor. list [sx, sy, sz]
1596
1597 deprecated: use L{localScale} and L{worldScale}
1598 @type scaling: list [sx, sy, sz] On write: local scaling, on read: world scaling
1599 @ivar localOrientation: The object's local orientation. 3x3 Matrix. You can also write a Quaternion or Euler vector.
1600 @type localOrientation: 3x3 Matrix [[float]]
1601 @ivar worldOrientation: The object's world orientation.
1602 @type worldOrientation: 3x3 Matrix [[float]]
1603 @ivar localScale: The object's local scaling factor.
1604 @type localScale: list [sx, sy, sz]
1605 @ivar worldScale: The object's world scaling factor. Read-only
1606 @type worldScale: list [sx, sy, sz]
1607 @ivar localPosition: The object's local position.
1608 @type localPosition: list [x, y, z]
1609 @ivar worldPosition: The object's world position.
1610 @type worldPosition: list [x, y, z]
1611 @ivar timeOffset: adjust the slowparent delay at runtime.
1612 @type timeOffset: float
1613 @ivar state: the game object's state bitmask, using the first 30 bits, one bit must always be set.
1614 @type state: int
1615 @ivar meshes: a list meshes for this object.
1616 - note: Most objects use only 1 mesh.
1617 - note: Changes to this list will not update the KX_GameObject.
1618 @type meshes: list of L{KX_MeshProxy}
1619 @ivar sensors: a sequence of L{SCA_ISensor} objects with string/index lookups and iterator support.
1620 - note: This attribute is experemental and may be removed (but probably wont be).
1621 - note: Changes to this list will not update the KX_GameObject.
1622 @type sensors: list
1623 @ivar controllers: a sequence of L{SCA_IController} objects with string/index lookups and iterator support.
1624 - note: This attribute is experemental and may be removed (but probably wont be).
1625 - note: Changes to this list will not update the KX_GameObject.
1626 @type controllers: list of L{SCA_ISensor}.
1627 @ivar actuators: a list of L{SCA_IActuator} with string/index lookups and iterator support.
1628 - note: This attribute is experemental and may be removed (but probably wont be).
1629 - note: Changes to this list will not update the KX_GameObject.
1630 @type actuators: list
1631 @ivar attrDict: get the objects internal python attribute dictionary for direct (faster) access.
1632 @type attrDict: dict
1633 @ivar children: direct children of this object, (read-only).
1634 @type children: L{CListValue} of L{KX_GameObject}'s
1635 @ivar childrenRecursive: all children of this object including childrens children, (read-only).
1636 @type childrenRecursive: L{CListValue} of L{KX_GameObject}'s
1637 @group Deprecated: getPosition, setPosition, setWorldPosition, getOrientation, setOrientation, getState, setState, getParent, getVisible, getMass, getMesh, getChildren, getChildrenRecursive
1638 @group Property Access: get, has_key, attrDict, getPropertyNames
1639 """
1641 """
1642 Delete this object, can be used inpace of the EndObject Actuator.
1643 The actual removal of the object from the scene is delayed.
1644 """
1645 - def replaceMesh(mesh, useDisplayMesh=True, usePhysicsMesh=False):
1646 """
1647 Replace the mesh of this object with a new mesh. This works the same was as the actuator.
1648 @type mesh: L{KX_MeshProxy} or mesh name
1649 @type useDisplayMesh: bool
1650 @param useDisplayMesh: when enabled the display mesh will be replaced (optional argument).
1651 @type usePhysicsMesh: bool
1652 @param usePhysicsMesh: when enabled the physics mesh will be replaced (optional argument).
1653 """
1655 """
1656 Gets the game object's visible flag.
1657
1658 @deprecated: use L{visible}
1659 @rtype: boolean
1660 """
1662 """
1663 Sets the game object's visible flag.
1664
1665 @type visible: boolean
1666 @type recursive: boolean
1667 @param recursive: optional argument to set all childrens visibility flag too.
1668 """
1670 """
1671 Sets the game object's occlusion capability.
1672
1673 @type occlusion: boolean
1674 @type recursive: boolean
1675 @param recursive: optional argument to set all childrens occlusion flag too.
1676 """
1678 """
1679 Gets the game object's state bitmask.
1680
1681 @deprecated: use L{state}
1682 @rtype: int
1683 @return: the objects state.
1684 """
1686 """
1687 Sets the game object's state flag.
1688 The bitmasks for states from 1 to 30 can be set with (1<<0, 1<<1, 1<<2 ... 1<<29)
1689 @deprecated: use L{state}
1690 @type state: integer
1691 """
1693 """
1694 Sets the game object's position.
1695 Global coordinates for root object, local for child objects.
1696
1697 @deprecated: use L{localPosition}
1698 @type pos: [x, y, z]
1699 @param pos: the new position, in local coordinates.
1700 """
1702 """
1703 Sets the game object's position in world coordinates regardless if the object is root or child.
1704
1705 @deprecated: use L{worldPosition}
1706 @type pos: [x, y, z]
1707 @param pos: the new position, in world coordinates.
1708 """
1710 """
1711 Gets the game object's position.
1712
1713 @deprecated: use L{worldPosition}
1714 @rtype: list [x, y, z]
1715 @return: the object's position in world coordinates.
1716 """
1718 """
1719 Sets the game object's orientation.
1720
1721 @deprecated: use L{localOrientation}
1722 @type orn: 3x3 rotation matrix, or Quaternion.
1723 @param orn: a rotation matrix specifying the new rotation.
1724 @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
1725 """
1727 """
1728 Aligns any of the game object's axis along the given vector.
1729
1730 @type vect: 3d vector.
1731 @param vect: a vector to align the axis.
1732 @type axis: integer.
1733 @param axis:The axis you want to align
1734 - 0: X axis
1735 - 1: Y axis
1736 - 2: Z axis (default)
1737 @type factor: float
1738 @param factor: Only rotate a feaction of the distance to the target vector (0.0 - 1.0)
1739 """
1741 """
1742 Returns the axis vector rotates by the objects worldspace orientation.
1743 This is the equivalent if multiplying the vector by the orientation matrix.
1744
1745 @type vect: 3d vector.
1746 @param vect: a vector to align the axis.
1747 @rtype: 3d vector.
1748 @return: The vector in relation to the objects rotation.
1749
1750 """
1752 """
1753 Gets the game object's orientation.
1754
1755 @deprecated: use L{worldOrientation}
1756 @rtype: 3x3 rotation matrix
1757 @return: The game object's rotation matrix
1758 @note: When using this matrix with Blender.Mathutils.Matrix() types, it will need to be transposed.
1759 """
1761 """
1762 Sets the game object's movement.
1763
1764 @type movement: 3d vector.
1765 @param movement: movement vector.
1766 @type local: boolean
1767 @param local: - False: you get the "global" movement ie: relative to world orientation (default).
1768 - True: you get the "local" movement ie: relative to object orientation.
1769 """
1771 """
1772 Sets the game object's rotation.
1773
1774 @type rotation: 3d vector.
1775 @param rotation: rotation vector.
1776 @type local: boolean
1777 @param local: - False: you get the "global" rotation ie: relative to world orientation (default).
1778 - True: you get the "local" rotation ie: relative to object orientation.
1779 """
1781 """
1782 Sets the game object's force.
1783
1784 This requires a dynamic object.
1785
1786 @type force: 3d vector.
1787 @param force: force vector.
1788 @type local: boolean
1789 @param local: - False: you get the "global" force ie: relative to world orientation (default).
1790 - True: you get the "local" force ie: relative to object orientation.
1791 """
1793 """
1794 Sets the game object's torque.
1795
1796 This requires a dynamic object.
1797
1798 @type torque: 3d vector.
1799 @param torque: torque vector.
1800 @type local: boolean
1801 @param local: - False: you get the "global" torque ie: relative to world orientation (default).
1802 - True: you get the "local" torque ie: relative to object orientation.
1803 """
1805 """
1806 Gets the game object's linear velocity.
1807
1808 This method returns the game object's velocity through it's centre of mass,
1809 ie no angular velocity component.
1810
1811 @type local: boolean
1812 @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
1813 - True: you get the "local" velocity ie: relative to object orientation.
1814 @rtype: list [vx, vy, vz]
1815 @return: the object's linear velocity.
1816 """
1818 """
1819 Sets the game object's linear velocity.
1820
1821 This method sets game object's velocity through it's centre of mass,
1822 ie no angular velocity component.
1823
1824 This requires a dynamic object.
1825
1826 @type velocity: 3d vector.
1827 @param velocity: linear velocity vector.
1828 @type local: boolean
1829 @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
1830 - True: you get the "local" velocity ie: relative to object orientation.
1831 """
1833 """
1834 Gets the game object's angular velocity.
1835
1836 @type local: boolean
1837 @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
1838 - True: you get the "local" velocity ie: relative to object orientation.
1839 @rtype: list [vx, vy, vz]
1840 @return: the object's angular velocity.
1841 """
1843 """
1844 Sets the game object's angular velocity.
1845
1846 This requires a dynamic object.
1847
1848 @type velocity: 3d vector.
1849 @param velocity: angular velocity vector.
1850 @type local: boolean
1851 @param local: - False: you get the "global" velocity ie: relative to world orientation (default).
1852 - True: you get the "local" velocity ie: relative to object orientation.
1853 """
1855 """
1856 Gets the game object's velocity at the specified point.
1857
1858 Gets the game object's velocity at the specified point, including angular
1859 components.
1860
1861 @type point: list [x, y, z]
1862 @param point: the point to return the velocity for, in local coordinates. (optional: default = [0, 0, 0])
1863 @rtype: list [vx, vy, vz]
1864 @return: the velocity at the specified point.
1865 """
1867 """
1868 Gets the game object's mass.
1869
1870 @deprecated: use L{mass}
1871 @rtype: float
1872 @return: the object's mass.
1873 """
1875 """
1876 Gets the game object's reaction force.
1877
1878 The reaction force is the force applied to this object over the last simulation timestep.
1879 This also includes impulses, eg from collisions.
1880
1881 (B{This is not implimented for bullet physics at the moment})
1882
1883 @rtype: list [fx, fy, fz]
1884 @return: the reaction force of this object.
1885 """
1887 """
1888 Applies an impulse to the game object.
1889
1890 This will apply the specified impulse to the game object at the specified point.
1891 If point != getPosition(), applyImpulse will also change the object's angular momentum.
1892 Otherwise, only linear momentum will change.
1893
1894 @type point: list [x, y, z]
1895 @param point: the point to apply the impulse to (in world coordinates)
1896 """
1898 """
1899 Suspends physics for this object.
1900 """
1902 """
1903 Resumes physics for this object.
1904 @Note: The objects linear velocity will be applied from when the dynamics were suspended.
1905 """
1907 """
1908 Enables rigid body physics for this object.
1909
1910 Rigid body physics allows the object to roll on collisions.
1911 @Note: This is not working with bullet physics yet.
1912 """
1914 """
1915 Disables rigid body physics for this object.
1916 @Note: This is not working with bullet physics yet. The angular is removed but rigid body physics can still rotate it later.
1917 """
1919 """
1920 Gets this object's parent.
1921
1922 @deprecated: use L{parent}
1923 @rtype: L{KX_GameObject}
1924 @return: this object's parent object, or None if this object has no parent.
1925 """
1927 """
1928 Sets this object's parent.
1929 Control the shape status with the optional compound and ghost parameters:
1930 compound=1: the object shape should be added to the parent compound shape (default)
1931 compound=0: the object should keep its individual shape.
1932 In that case you can control if it should be ghost or not:
1933 ghost=1 if the object should be made ghost while parented (default)
1934 ghost=0 if the object should be solid while parented
1935 Note: if the object type is sensor, it stays ghost regardless of ghost parameter
1936
1937 @type parent: L{KX_GameObject}
1938 @param parent: new parent object.
1939 @type compound: int
1940 @param compound: whether the shape should be added to the parent compound shape
1941 @type ghost: int
1942 @param ghost: whether the object should be ghost while parented
1943 """
1945 """
1946 Removes this objects parent.
1947 """
1949 """
1950 Return a list of immediate children of this object.
1951 @rtype: L{CListValue} of L{KX_GameObject}
1952 @return: a list of all this objects children.
1953 """
1955 """
1956 Return a list of children of this object, including all their childrens children.
1957 @rtype: L{CListValue} of L{KX_GameObject}
1958 @return: a list of all this objects children recursivly.
1959 """
1961 """
1962 Gets the mesh object for this object.
1963
1964 @type mesh: integer
1965 @param mesh: the mesh object to return (optional: default mesh = 0)
1966 @rtype: L{KX_MeshProxy}
1967 @return: the first mesh object associated with this game object, or None if this object has no meshs.
1968 """
1970 """
1971 Returns the user data object associated with this game object's physics controller.
1972 """
1974 """
1975 Gets a list of all property names.
1976 @rtype: list
1977 @return: All property names for this object.
1978 """
1980 """
1981 Returns the distance to another object or point.
1982
1983 @param other: a point or another L{KX_GameObject} to measure the distance to.
1984 @type other: L{KX_GameObject} or list [x, y, z]
1985 @rtype: float
1986 """
1988 """
1989 Returns the vector and the distance to another object or point.
1990 The vector is normalized unless the distance is 0, in which a NULL vector is returned.
1991
1992 @param other: a point or another L{KX_GameObject} to get the vector and distance to.
1993 @type other: L{KX_GameObject} or list [x, y, z]
1994 @rtype: 3-tuple (float, 3-tuple (x,y,z), 3-tuple (x,y,z))
1995 @return: (distance, globalVector(3), localVector(3))
1996 """
1998 """
1999 Look towards another point/object and find first object hit within dist that matches prop.
2000
2001 The ray is always casted from the center of the object, ignoring the object itself.
2002 The ray is casted towards the center of another object or an explicit [x,y,z] point.
2003 Use rayCast() if you need to retrieve the hit point
2004
2005 @param other: [x,y,z] or object towards which the ray is casted
2006 @type other: L{KX_GameObject} or 3-tuple
2007 @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
2008 @type dist: float
2009 @param prop: property name that object must have; can be omitted => detect any object
2010 @type prop: string
2011 @rtype: L{KX_GameObject}
2012 @return: the first object hit or None if no object or object does not match prop
2013 """
2014 - def rayCast(objto,objfrom,dist,prop,face,xray,poly):
2015 """
2016 Look from a point/object to another point/object and find first object hit within dist that matches prop.
2017 if poly is 0, returns a 3-tuple with object reference, hit point and hit normal or (None,None,None) if no hit.
2018 if poly is 1, returns a 4-tuple with in addition a L{KX_PolyProxy} as 4th element.
2019
2020 Ex::
2021 # shoot along the axis gun-gunAim (gunAim should be collision-free)
2022 ob,point,normal = gun.rayCast(gunAim,None,50)
2023 if ob:
2024 # hit something
2025
2026 Notes:
2027 The ray ignores the object on which the method is called.
2028 It is casted from/to object center or explicit [x,y,z] points.
2029
2030 The face paremeter determines the orientation of the normal::
2031 0 => hit normal is always oriented towards the ray origin (as if you casted the ray from outside)
2032 1 => hit normal is the real face normal (only for mesh object, otherwise face has no effect)
2033
2034 The ray has X-Ray capability if xray parameter is 1, otherwise the first object hit (other than self object) stops the ray.
2035 The prop and xray parameters interact as follow::
2036 prop off, xray off: return closest hit or no hit if there is no object on the full extend of the ray.
2037 prop off, xray on : idem.
2038 prop on, xray off: return closest hit if it matches prop, no hit otherwise.
2039 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.
2040 The L{KX_PolyProxy} 4th element of the return tuple when poly=1 allows to retrieve information on the polygon hit by the ray.
2041 If there is no hit or the hit object is not a static mesh, None is returned as 4th element.
2042
2043 The ray ignores collision-free objects and faces that dont have the collision flag enabled, you can however use ghost objects.
2044
2045 @param objto: [x,y,z] or object to which the ray is casted
2046 @type objto: L{KX_GameObject} or 3-tuple
2047 @param objfrom: [x,y,z] or object from which the ray is casted; None or omitted => use self object center
2048 @type objfrom: L{KX_GameObject} or 3-tuple or None
2049 @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to to
2050 @type dist: float
2051 @param prop: property name that object must have; can be omitted or "" => detect any object
2052 @type prop: string
2053 @param face: normal option: 1=>return face normal; 0 or omitted => normal is oriented towards origin
2054 @type face: int
2055 @param xray: X-ray option: 1=>skip objects that don't match prop; 0 or omitted => stop on first object
2056 @type xray: int
2057 @param poly: polygon option: 1=>return value is a 4-tuple and the 4th element is a L{KX_PolyProxy}
2058 @type poly: int
2059 @rtype: 3-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz))
2060 or 4-tuple (L{KX_GameObject}, 3-tuple (x,y,z), 3-tuple (nx,ny,nz), L{KX_PolyProxy})
2061 @return: (object,hitpoint,hitnormal) or (object,hitpoint,hitnormal,polygon)
2062 If no hit, returns (None,None,None) or (None,None,None,None)
2063 If the object hit is not a static mesh, polygon is None
2064 """
2066 """
2067 Set the objects collision margin.
2068
2069 note: If this object has no physics controller (a physics ID of zero), this function will raise RuntimeError.
2070
2071 @type margin: float
2072 @param margin: the collision margin distance in blender units.
2073 """
2075 """
2076 Sends a message.
2077
2078 @param subject: The subject of the message
2079 @type subject: string
2080 @param body: The body of the message (optional)
2081 @type body: string
2082 @param to: The name of the object to send the message to (optional)
2083 @type to: string
2084 """
2086 """
2087 Updates the physics system with the changed mesh.
2088
2089 If no arguments are given the physics mesh will be re-created from the first mesh assigned to the game object.
2090
2091 @param gameObject: optional argument, set the physics shape from this gameObjets mesh.
2092 @type gameObject: string, L{KX_GameObject} or None
2093 @param meshObject: optional argument, set the physics shape from this mesh.
2094 @type meshObject: string, L{KX_MeshProxy} or None
2095
2096 @note: if this object has instances the other instances will be updated too.
2097 @note: the gameObject argument has an advantage that it can convert from a mesh with modifiers applied (such as subsurf).
2098 @warning: only triangle mesh type objects are supported currently (not convex hull)
2099 @warning: if the object is a part of a combound object it will fail (parent or child)
2100 @warning: rebuilding the physics mesh can be slow, running many times per second will give a performance hit.
2101 @rtype: boolean
2102 @return: True if reinstance succeeded, False if it failed.
2103 """
2104
2105 - def get(key, default=None):
2106 """
2107 Return the value matching key, or the default value if its not found.
2108 @return: The key value or a default.
2109 """
2111 """
2112 Return True if the key is found.
2113 @rtype: boolean
2114 @return: The key value or a default.
2115 """
2116
2117
2119 """
2120 IPO actuator activates an animation.
2121
2122 @ivar frameStart: Start frame.
2123 @type frameStart: float
2124 @ivar frameEnd: End frame.
2125 @type frameEnd: float
2126 @ivar propName: Use this property to define the Ipo position
2127 @type propName: string
2128 @ivar framePropName: Assign this property this action current frame number
2129 @type framePropName: string
2130 @ivar mode: Play mode for the ipo. (In GameLogic.KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND, KX_IPOACT_FROM_PROP)
2131 @type mode: int
2132 @ivar useIpoAsForce: Apply Ipo as a global or local force depending on the local option (dynamic objects only)
2133 @type useIpoAsForce: bool
2134 @ivar useIpoAdd: Ipo is added to the current loc/rot/scale in global or local coordinate according to Local flag
2135 @type useIpoAdd: bool
2136 @ivar useIpoLocal: Let the ipo acts in local coordinates, used in Force and Add mode.
2137 @type useIpoLocal: bool
2138 @ivar useChildren: Update IPO on all children Objects as well
2139 @type useChildren: bool
2140 """
2141
2142 - def set(mode, startframe, endframe, force):
2143 """
2144 Sets the properties of the actuator.
2145
2146 @deprecated: use other attributes.
2147 @param mode: "Play", "PingPong", "Flipper", "LoopStop", "LoopEnd" or "FromProp"
2148 @type mode: string
2149 @param startframe: first frame to use
2150 @type startframe: integer
2151 @param endframe: last frame to use
2152 @type endframe: integer
2153 @param force: special mode
2154 @type force: integer (0=normal, 1=interpret location as force, 2=additive)
2155 """
2157 """
2158 Sets the name of the property to be used in FromProp mode.
2159
2160 @deprecated: use L{propName}
2161 @type property: string
2162 """
2164 """
2165 Sets the frame from which the IPO starts playing.
2166
2167 @deprecated: use L{frameStart}
2168 @type startframe: integer
2169 """
2171 """
2172 Returns the frame from which the IPO starts playing.
2173
2174 @deprecated: use L{frameStart}
2175 @rtype: integer
2176 """
2178 """
2179 Sets the frame at which the IPO stops playing.
2180
2181 @deprecated: use L{frameEnd}
2182 @type endframe: integer
2183 """
2185 """
2186 Returns the frame at which the IPO stops playing.
2187
2188 @deprecated: use L{frameEnd}
2189 @rtype: integer
2190 """
2192 """
2193 Set whether to interpret the ipo as a force rather than a displacement.
2194
2195 @deprecated: use L{useIpoAsForce}
2196 @type force: boolean
2197 @param force: KX_TRUE or KX_FALSE
2198 """
2200 """
2201 Returns whether to interpret the ipo as a force rather than a displacement.
2202
2203 @deprecated: use L{useIpoAsForce}
2204 @rtype: boolean
2205 """
2207 """
2208 Set whether to interpret the ipo as additive rather than absolute.
2209
2210 @deprecated: use L{useIpoAdd}
2211 @type add: boolean
2212 @param add: KX_TRUE or KX_FALSE
2213 """
2215 """
2216 Returns whether to interpret the ipo as additive rather than absolute.
2217
2218 @deprecated: use L{useIpoAdd}
2219 @rtype: boolean
2220 """
2222 """
2223 Sets the operation mode of the actuator.
2224
2225 @deprecated: use L{type}
2226 @param mode: KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND
2227 @type mode: string
2228 """
2230 """
2231 Returns the operation mode of the actuator.
2232
2233 @deprecated: use L{type}
2234 @rtype: integer
2235 @return: KX_IPOACT_PLAY, KX_IPOACT_PINGPONG, KX_IPOACT_FLIPPER, KX_IPOACT_LOOPSTOP, KX_IPOACT_LOOPEND
2236 """
2238 """
2239 Set whether to apply the force in the object's local
2240 coordinates rather than the world global coordinates.
2241
2242 @deprecated: use L{useIpoLocal}
2243 @param local: Apply the ipo-as-force in the object's local
2244 coordinates? (KX_TRUE, KX_FALSE)
2245 @type local: boolean
2246 """
2248 """
2249 Return whether to apply the force in the object's local
2250 coordinates rather than the world global coordinates.
2251
2252 @deprecated: use L{useIpoLocal}
2253 """
2254
2255
2257 """
2258 A Light object.
2259
2260 Example:
2261
2262 # Turn on a red alert light.
2263 import GameLogic
2264
2265 co = GameLogic.getCurrentController()
2266 light = co.owner
2267
2268 light.energy = 1.0
2269 light.colour = [1.0, 0.0, 0.0]
2270
2271 @group Constants: NORMAL, SPOT, SUN
2272 @ivar SPOT: A spot light source. See attribute 'type'
2273 @ivar SUN: A point light source with no attenuation. See attribute 'type'
2274 @ivar NORMAL: A point light source. See attribute 'type'
2275
2276 @ivar type: The type of light - must be SPOT, SUN or NORMAL
2277 @ivar layer: The layer mask that this light affects object on.
2278 @type layer: bitfield
2279 @ivar energy: The brightness of this light.
2280 @type energy: float
2281 @ivar distance: The maximum distance this light can illuminate. (SPOT and NORMAL lights only)
2282 @type distance: float
2283 @ivar colour: The colour of this light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0]
2284 @type colour: list [r, g, b]
2285 @ivar color: Synonym for colour.
2286 @ivar lin_attenuation: The linear component of this light's attenuation. (SPOT and NORMAL lights only)
2287 @type lin_attenuation: float
2288 @ivar quad_attenuation: The quadratic component of this light's attenuation (SPOT and NORMAL lights only)
2289 @type quad_attenuation: float
2290 @ivar spotsize: The cone angle of the spot light, in degrees. (float) (SPOT lights only)
2291 0.0 <= spotsize <= 180.0. Spotsize = 360.0 is also accepted.
2292 @ivar spotblend: Specifies the intensity distribution of the spot light. (float) (SPOT lights only)
2293 Higher values result in a more focused light source.
2294 0.0 <= spotblend <= 1.0.
2295
2296 """
2297
2299 """
2300 A mesh object.
2301
2302 You can only change the vertex properties of a mesh object, not the mesh topology.
2303
2304 To use mesh objects effectively, you should know a bit about how the game engine handles them.
2305 1. Mesh Objects are converted from Blender at scene load.
2306 2. The Converter groups polygons by Material. This means they can be sent to the
2307 renderer efficiently. A material holds:
2308 1. The texture.
2309 2. The Blender material.
2310 3. The Tile properties
2311 4. The face properties - (From the "Texture Face" panel)
2312 5. Transparency & z sorting
2313 6. Light layer
2314 7. Polygon shape (triangle/quad)
2315 8. Game Object
2316 3. Verticies will be split by face if necessary. Verticies can only be shared between
2317 faces if:
2318 1. They are at the same position
2319 2. UV coordinates are the same
2320 3. Their normals are the same (both polygons are "Set Smooth")
2321 4. They are the same colour
2322 For example: a cube has 24 verticies: 6 faces with 4 verticies per face.
2323
2324 The correct method of iterating over every L{KX_VertexProxy} in a game object::
2325 import GameLogic
2326
2327 co = GameLogic.getCurrentController()
2328 obj = co.owner
2329
2330 m_i = 0
2331 mesh = obj.getMesh(m_i) # There can be more than one mesh...
2332 while mesh != None:
2333 for mat in range(mesh.getNumMaterials()):
2334 for v_index in range(mesh.getVertexArrayLength(mat)):
2335 vertex = mesh.getVertex(mat, v_index)
2336 # Do something with vertex here...
2337 # ... eg: colour the vertex red.
2338 vertex.colour = [1.0, 0.0, 0.0, 1.0]
2339 m_i += 1
2340 mesh = obj.getMesh(m_i)
2341
2342 @ivar materials:
2343 @type materials: list of L{KX_BlenderMaterial} or L{KX_PolygonMaterial} types
2344
2345 @ivar numPolygons:
2346 @type numPolygons: integer
2347
2348 @ivar numMaterials:
2349 @type numMaterials: integer
2350 """
2351
2353 """
2354 Gets the number of materials associated with this object.
2355
2356 @rtype: integer
2357 """
2358
2360 """
2361 Gets the name of the specified material.
2362
2363 @type matid: integer
2364 @param matid: the specified material.
2365 @rtype: string
2366 @return: the attached material name.
2367 """
2368 - def getTextureName(matid):
2369 """
2370 Gets the name of the specified material's texture.
2371
2372 @type matid: integer
2373 @param matid: the specified material
2374 @rtype: string
2375 @return: the attached material's texture name.
2376 """
2378 """
2379 Gets the length of the vertex array associated with the specified material.
2380
2381 There is one vertex array for each material.
2382
2383 @type matid: integer
2384 @param matid: the specified material
2385 @rtype: integer
2386 @return: the number of verticies in the vertex array.
2387 """
2389 """
2390 Gets the specified vertex from the mesh object.
2391
2392 @type matid: integer
2393 @param matid: the specified material
2394 @type index: integer
2395 @param index: the index into the vertex array.
2396 @rtype: L{KX_VertexProxy}
2397 @return: a vertex object.
2398 """
2400 """
2401 Returns the number of polygon in the mesh.
2402
2403 @rtype: integer
2404 """
2406 """
2407 Gets the specified polygon from the mesh.
2408
2409 @type index: integer
2410 @param index: polygon number
2411 @rtype: L{KX_PolyProxy}
2412 @return: a polygon object.
2413 """
2414
2416 """
2417 Mouse Sensor logic brick.
2418
2419 Properties:
2420
2421 @ivar position: current [x,y] coordinates of the mouse, in frame coordinates (pixels)
2422 @type position: [integer,interger]
2423 @ivar mode: sensor mode: 1=KX_MOUSESENSORMODE_LEFTBUTTON 2=KX_MOUSESENSORMODE_MIDDLEBUTTON
2424 3=KX_MOUSESENSORMODE_RIGHTBUTTON 4=KX_MOUSESENSORMODE_WHEELUP
2425 5=KX_MOUSESENSORMODE_WHEELDOWN 9=KX_MOUSESENSORMODE_MOVEMENT
2426 @type mode: integer
2427 """
2428
2430 """
2431 Gets the x coordinate of the mouse.
2432
2433 @deprecated: use the L{position} property
2434 @rtype: integer
2435 @return: the current x coordinate of the mouse, in frame coordinates (pixels)
2436 """
2438 """
2439 Gets the y coordinate of the mouse.
2440
2441 @deprecated: use the L{position} property
2442 @rtype: integer
2443 @return: the current y coordinate of the mouse, in frame coordinates (pixels).
2444 """
2455
2457 """
2458 The mouse focus sensor detects when the mouse is over the current game object.
2459
2460 The mouse focus sensor works by transforming the mouse coordinates from 2d device
2461 space to 3d space then raycasting away from the camera.
2462
2463 @ivar raySource: The worldspace source of the ray (the view position)
2464 @type raySource: list (vector of 3 floats)
2465 @ivar rayTarget: The worldspace target of the ray.
2466 @type rayTarget: list (vector of 3 floats)
2467 @ivar rayDirection: The L{rayTarget} - L{raySource} normalized.
2468 @type rayDirection: list (normalized vector of 3 floats)
2469 @ivar hitObject: the last object the mouse was over.
2470 @type hitObject: L{KX_GameObject} or None
2471 @ivar hitPosition: The worldspace position of the ray intersecton.
2472 @type hitPosition: list (vector of 3 floats)
2473 @ivar hitNormal: the worldspace normal from the face at point of intersection.
2474 @type hitNormal: list (normalized vector of 3 floats)
2475 @ivar usePulseFocus: When enabled, moving the mouse over a different object generates a pulse. (only used when the 'Mouse Over Any' sensor option is set)
2476 @type usePulseFocus: bool
2477 """
2478
2480 """
2481 Returns the normal (in worldcoordinates) at the point of collision where the object was hit by this ray.
2482
2483 @deprecated: use the L{hitNormal} property
2484 @rtype: list [x, y, z]
2485 @return: the ray collision normal.
2486 """
2488 """
2489 Returns the object that was hit by this ray or None.
2490
2491 @deprecated: use the L{hitObject} property
2492 @rtype: L{KX_GameObject} or None
2493 @return: the collision object.
2494 """
2496 """
2497 Returns the position (in worldcoordinates) at the point of collision where the object was hit by this ray.
2498
2499 @deprecated: use the L{hitPosition} property
2500 @rtype: list [x, y, z]
2501 @return: the ray collision position.
2502 """
2504 """
2505 Returns the normalized direction (in worldcoordinates) of the ray cast by the mouse.
2506
2507 @deprecated: use the L{rayDirection} property
2508 @rtype: list [x, y, z]
2509 @return: the ray direction.
2510 """
2512 """
2513 Returns the position (in worldcoordinates) the ray was cast from by the mouse.
2514
2515 @deprecated: use the L{raySource} property
2516 @rtype: list [x, y, z]
2517 @return: the ray source.
2518 """
2520 """
2521 Returns the target of the ray (in worldcoordinates) that seeks the focus object.
2522
2523 @deprecated: use the L{rayTarget} property
2524 @rtype: list [x, y, z]
2525 @return: the ray target.
2526 """
2527
2528
2530 """
2531 Touch sensor detects collisions between objects.
2532
2533 @ivar propName: The property or material to collide with.
2534 @type propName: string
2535 @ivar useMaterial: Determines if the sensor is looking for a property or material.
2536 KX_True = Find material; KX_False = Find property
2537 @type useMaterial: boolean
2538 @ivar usePulseCollision: When enabled, changes to the set of colliding objects generate a pulse.
2539 @type usePulseCollision: bool
2540 @ivar hitObject: The last collided object. (read-only)
2541 @type hitObject: L{KX_GameObject} or None
2542 @ivar hitObjectList: A list of colliding objects. (read-only)
2543 @type hitObjectList: L{CListValue} of L{KX_GameObject}
2544 """
2545
2547 """
2548 Set the property or material to collide with. Use
2549 setTouchMaterial() to switch between properties and
2550 materials.
2551
2552 @deprecated: use the L{property} property
2553 @type name: string
2554 """
2555
2557 """
2558 Returns the property or material to collide with. Use
2559 getTouchMaterial() to find out whether this sensor
2560 looks for properties or materials.
2561
2562 @deprecated: use the L{property} property
2563 @rtype: string
2564 """
2566 """
2567 Returns the last object hit by this touch sensor.
2568
2569 @deprecated: use the L{hitObject} property
2570 @rtype: L{KX_GameObject}
2571 """
2573 """
2574 Returns a list of all objects hit in the last frame. (B{deprecated})
2575
2576 Only objects that have the requisite material/property are listed.
2577
2578 @deprecated: use the L{hitObjectList} property
2579 @rtype: L{CListValue} of L{hitObjectList}
2580 """
2582 """
2583 Returns KX_TRUE if this sensor looks for a specific material,
2584 KX_FALSE if it looks for a specific property. (B{deprecated})
2585
2586 @deprecated: use the L{useMaterial} property
2587 """
2588
2589
2591 """
2592 A near sensor is a specialised form of touch sensor.
2593
2594 @ivar distance: The near sensor activates when an object is within this distance.
2595 @type distance: float
2596 @ivar resetDistance: The near sensor deactivates when the object exceeds this distance.
2597 @type resetDistance: float
2598 """
2599
2601 """
2602 Message Actuator
2603
2604 @ivar propName: Messages will only be sent to objects with the given property name.
2605 @type propName: string
2606 @ivar subject: The subject field of the message.
2607 @type subject: string
2608 @ivar body: The body of the message.
2609 @type body: string
2610 @ivar usePropBody: Send a property instead of a regular body message.
2611 @type usePropBody: boolean
2612 """
2613
2615 """
2616 Messages will only be sent to objects with the given property name.
2617
2618 @deprecated: Use the L{propName} attribute instead.
2619 @type name: string
2620 """
2622 """
2623 Sets the subject field of the message.
2624
2625 @deprecated: Use the L{subject} attribute instead.
2626 @type subject: string
2627 """
2628 - def setBodyType(bodytype):
2629 """
2630 Sets the type of body to send.
2631
2632 @deprecated: Use the L{usePropBody} attribute instead.
2633 @type bodytype: boolean
2634 @param bodytype: True to send the value of a property, False to send the body text.
2635 """
2636 - def setBody(body):
2637 """
2638 Sets the message body.
2639
2640 @deprecated: Use the L{body} attribute instead.
2641 @type body: string
2642 @param body: if the body type is True, this is the name of the property to send.
2643 if the body type is False, this is the text to send.
2644 """
2645
2646
2648 """
2649 The Message Sensor logic brick.
2650
2651 Currently only loopback (local) networks are supported.
2652
2653 @ivar subject: The subject the sensor is looking for.
2654 @type subject: string
2655 @ivar frameMessageCount: The number of messages received since the last frame.
2656 (Read-only)
2657 @type frameMessageCount: int
2658 @ivar subjects: The list of message subjects received. (Read-only)
2659 @type subjects: list of strings
2660 @ivar bodies: The list of message bodies received. (Read-only)
2661 @type bodies: list of strings
2662 """
2663
2665 """
2666 Change the message subject text that this sensor is listening to.
2667
2668 @deprecated: Use the L{subject} attribute instead.
2669 @type subject: string
2670 @param subject: the new message subject to listen for.
2671 """
2672
2674 """
2675 Get the number of messages received since the last frame.
2676
2677 @deprecated: Use the L{frameMessageCount} attribute instead.
2678 @rtype: integer
2679 """
2681 """
2682 Gets the list of message bodies.
2683
2684 @deprecated: Use the L{bodies} attribute instead.
2685 @rtype: list
2686 """
2688 """
2689 Gets the message subject this sensor is listening for from the Subject: field.
2690
2691 @deprecated: Use the L{subject} attribute instead.
2692 @rtype: string
2693 """
2695 """
2696 Gets the list of message subjects received.
2697
2698 @deprecated: Use the L{subjects} attribute instead.
2699 @rtype: list
2700 """
2701
2702
2704 """
2705 The object actuator ("Motion Actuator") applies force, torque, displacement, angular displacement,
2706 velocity, or angular velocity to an object.
2707 Servo control allows to regulate force to achieve a certain speed target.
2708
2709 @ivar force: The force applied by the actuator
2710 @type force: list [x, y, z]
2711 @ivar useLocalForce: A flag specifying if the force is local
2712 @type useLocalForce: bool
2713 @ivar torque: The torque applied by the actuator
2714 @type torque: list [x, y, z]
2715 @ivar useLocalTorque: A flag specifying if the torque is local
2716 @type useLocalTorque: bool
2717 @ivar dLoc: The displacement vector applied by the actuator
2718 @type dLoc: list [x, y, z]
2719 @ivar useLocalDLoc: A flag specifying if the dLoc is local
2720 @type useLocalDLoc: bool
2721 @ivar dRot: The angular displacement vector applied by the actuator
2722 - note: Since the displacement is applied every frame, you must adjust the displacement
2723 based on the frame rate, or you game experience will depend on the player's computer
2724 speed.
2725 @type dRot: list [x, y, z]
2726 @ivar useLocalDRot: A flag specifying if the dRot is local
2727 @type useLocalDRot: bool
2728 @ivar linV: The linear velocity applied by the actuator
2729 @type linV: list [x, y, z]
2730 @ivar useLocalLinV: A flag specifying if the linear velocity is local
2731 - note: This is the target speed for servo controllers
2732 @type useLocalLinV: bool
2733 @ivar angV: The angular velocity applied by the actuator
2734 @type angV: list [x, y, z]
2735 @ivar useLocalAngV: A flag specifying if the angular velocity is local
2736 @type useLocalAngV: bool
2737
2738 @ivar damping: The damping parameter of the servo controller
2739 @type damping: short
2740
2741 @ivar forceLimitX: The min/max force limit along the X axis and activates or deactivates the limits in the servo controller
2742 @type forceLimitX: list [min(float), max(float), bool]
2743 @ivar forceLimitY: The min/max force limit along the Y axis and activates or deactivates the limits in the servo controller
2744 @type forceLimitY: list [min(float), max(float), bool]
2745 @ivar forceLimitZ: The min/max force limit along the Z axis and activates or deactivates the limits in the servo controller
2746 @type forceLimitZ: list [min(float), max(float), bool]
2747
2748 @ivar pid: The PID coefficients of the servo controller
2749 @type pid: list of floats [proportional, integral, derivate]
2750 @ivar reference: The object that is used as reference to compute the velocity for the servo controller.
2751 @type reference: KX_GameObject or None
2752
2753 @group Deprecated: getForce, setForce, getTorque, setTorque, getDLoc, setDLoc, getDRot, setDRot, getLinearVelocity, setLinearVelocity, getAngularVelocity,
2754 setAngularVelocity, getDamping, setDamping, getForceLimitX, setForceLimitX, getForceLimitY, setForceLimitY, getForceLimitZ, setForceLimitZ,
2755 getPID, setPID
2756 """
2758 """
2759 Returns the force applied by the actuator.
2760
2761 @deprecated: Use L{force} and L{useLocalForce} instead.
2762 @rtype: list [fx, fy, fz, local]
2763 @return: A four item list, containing the vector force, and a flag specifying whether the force is local.
2764 """
2766 """
2767 Sets the force applied by the actuator.
2768
2769 @deprecated: Use L{force} and L{useLocalForce} instead.
2770 @type fx: float
2771 @param fx: the x component of the force.
2772 @type fy: float
2773 @param fy: the z component of the force.
2774 @type fz: float
2775 @param fz: the z component of the force.
2776 @type local: boolean
2777 @param local: - False: the force is applied in world coordinates.
2778 - True: the force is applied in local coordinates.
2779 """
2781 """
2782 Returns the torque applied by the actuator.
2783
2784 @deprecated: Use L{torque} and L{useLocalTorque} instead.
2785 @rtype: list [S{Tau}x, S{Tau}y, S{Tau}z, local]
2786 @return: A four item list, containing the vector torque, and a flag specifying whether
2787 the torque is applied in local coordinates (True) or world coordinates (False)
2788 """
2790 """
2791 Sets the torque applied by the actuator.
2792
2793 @deprecated: Use L{torque} and L{useLocalTorque} instead.
2794 @type tx: float
2795 @param tx: the x component of the torque.
2796 @type ty: float
2797 @param ty: the z component of the torque.
2798 @type tz: float
2799 @param tz: the z component of the torque.
2800 @type local: boolean
2801 @param local: - False: the torque is applied in world coordinates.
2802 - True: the torque is applied in local coordinates.
2803 """
2805 """
2806 Returns the displacement vector applied by the actuator.
2807
2808 @deprecated: Use L{dLoc} and L{useLocalDLoc} instead.
2809 @rtype: list [dx, dy, dz, local]
2810 @return: A four item list, containing the vector displacement, and whether
2811 the displacement is applied in local coordinates (True) or world
2812 coordinates (False)
2813 """
2815 """
2816 Sets the displacement vector applied by the actuator.
2817
2818 Since the displacement is applied every frame, you must adjust the displacement
2819 based on the frame rate, or you game experience will depend on the player's computer
2820 speed.
2821
2822 @deprecated: Use L{dLoc} and L{useLocalDLoc} instead.
2823 @type dx: float
2824 @param dx: the x component of the displacement vector.
2825 @type dy: float
2826 @param dy: the z component of the displacement vector.
2827 @type dz: float
2828 @param dz: the z component of the displacement vector.
2829 @type local: boolean
2830 @param local: - False: the displacement vector is applied in world coordinates.
2831 - True: the displacement vector is applied in local coordinates.
2832 """
2834 """
2835 Returns the angular displacement vector applied by the actuator.
2836
2837 @deprecated: Use L{dRot} and L{useLocalDRot} instead.
2838 @rtype: list [dx, dy, dz, local]
2839 @return: A four item list, containing the angular displacement vector, and whether
2840 the displacement is applied in local coordinates (True) or world coordinates (False)
2841 """
2843 """
2844 Sets the angular displacement vector applied by the actuator.
2845
2846 Since the displacement is applied every frame, you must adjust the displacement
2847 based on the frame rate, or you game experience will depend on the player's computer
2848 speed.
2849
2850 @deprecated: Use L{dRot} and L{useLocalDRot} instead.
2851 @type dx: float
2852 @param dx: the x component of the angular displacement vector.
2853 @type dy: float
2854 @param dy: the z component of the angular displacement vector.
2855 @type dz: float
2856 @param dz: the z component of the angular displacement vector.
2857 @type local: boolean
2858 @param local: - False: the angular displacement vector is applied in world coordinates.
2859 - True: the angular displacement vector is applied in local coordinates.
2860 """
2862 """
2863 Returns the linear velocity applied by the actuator.
2864 For the servo control actuator, this is the target speed.
2865
2866 @deprecated: Use L{linV} and L{useLocalLinV} instead.
2867 @rtype: list [vx, vy, vz, local]
2868 @return: A four item list, containing the vector velocity, and whether the velocity is applied in local coordinates (True) or world coordinates (False)
2869 """
2871 """
2872 Sets the linear velocity applied by the actuator.
2873 For the servo control actuator, sets the target speed.
2874
2875 @deprecated: Use L{linV} and L{useLocalLinV} instead.
2876 @type vx: float
2877 @param vx: the x component of the velocity vector.
2878 @type vy: float
2879 @param vy: the z component of the velocity vector.
2880 @type vz: float
2881 @param vz: the z component of the velocity vector.
2882 @type local: boolean
2883 @param local: - False: the velocity vector is in world coordinates.
2884 - True: the velocity vector is in local coordinates.
2885 """
2887 """
2888 Returns the angular velocity applied by the actuator.
2889
2890 @deprecated: Use L{angV} and L{useLocalAngV} instead.
2891 @rtype: list [S{omega}x, S{omega}y, S{omega}z, local]
2892 @return: A four item list, containing the vector velocity, and whether
2893 the velocity is applied in local coordinates (True) or world
2894 coordinates (False)
2895 """
2897 """
2898 Sets the angular velocity applied by the actuator.
2899
2900 @deprecated: Use L{angV} and L{useLocalAngV} instead.
2901 @type wx: float
2902 @param wx: the x component of the velocity vector.
2903 @type wy: float
2904 @param wy: the z component of the velocity vector.
2905 @type wz: float
2906 @param wz: the z component of the velocity vector.
2907 @type local: boolean
2908 @param local: - False: the velocity vector is applied in world coordinates.
2909 - True: the velocity vector is applied in local coordinates.
2910 """
2912 """
2913 Returns the damping parameter of the servo controller.
2914
2915 @deprecated: Use L{damping} instead.
2916 @rtype: integer
2917 @return: the time constant of the servo controller in frame unit.
2918 """
2920 """
2921 Sets the damping parameter of the servo controller.
2922
2923 @deprecated: Use L{damping} instead.
2924 @type damp: integer
2925 @param damp: the damping parameter in frame unit.
2926 """
2928 """
2929 Returns the min/max force limit along the X axis used by the servo controller.
2930
2931 @deprecated: Use L{forceLimitX} instead.
2932 @rtype: list [min, max, enabled]
2933 @return: A three item list, containing the min and max limits of the force as float
2934 and whether the limits are active(true) or inactive(true)
2935 """
2937 """
2938 Sets the min/max force limit along the X axis and activates or deactivates the limits in the servo controller.
2939
2940 @deprecated: Use L{forceLimitX} instead.
2941 @type min: float
2942 @param min: the minimum value of the force along the X axis.
2943 @type max: float
2944 @param max: the maximum value of the force along the X axis.
2945 @type enable: boolean
2946 @param enable: - True: the force will be limited to the min/max
2947 - False: the force will not be limited
2948 """
2950 """
2951 Returns the min/max force limit along the Y axis used by the servo controller.
2952
2953 @deprecated: Use L{forceLimitY} instead.
2954 @rtype: list [min, max, enabled]
2955 @return: A three item list, containing the min and max limits of the force as float
2956 and whether the limits are active(true) or inactive(true)
2957 """
2959 """
2960 Sets the min/max force limit along the Y axis and activates or deactivates the limits in the servo controller.
2961
2962 @deprecated: Use L{forceLimitY} instead.
2963 @type min: float
2964 @param min: the minimum value of the force along the Y axis.
2965 @type max: float
2966 @param max: the maximum value of the force along the Y axis.
2967 @type enable: boolean
2968 @param enable: - True: the force will be limited to the min/max
2969 - False: the force will not be limited
2970 """
2972 """
2973 Returns the min/max force limit along the Z axis used by the servo controller.
2974
2975 @deprecated: Use L{forceLimitZ} instead.
2976 @rtype: list [min, max, enabled]
2977 @return: A three item list, containing the min and max limits of the force as float
2978 and whether the limits are active(true) or inactive(true)
2979 """
2981 """
2982 Sets the min/max force limit along the Z axis and activates or deactivates the limits in the servo controller.
2983
2984 @deprecated: Use L{forceLimitZ} instead.
2985 @type min: float
2986 @param min: the minimum value of the force along the Z axis.
2987 @type max: float
2988 @param max: the maximum value of the force along the Z axis.
2989 @type enable: boolean
2990 @param enable: - True: the force will be limited to the min/max
2991 - False: the force will not be limited
2992 """
2994 """
2995 Returns the PID coefficient of the servo controller.
2996
2997 @deprecated: Use L{pid} instead.
2998 @rtype: list [P, I, D]
2999 @return: A three item list, containing the PID coefficient as floats:
3000 P : proportional coefficient
3001 I : Integral coefficient
3002 D : Derivate coefficient
3003 """
3005 """
3006 Sets the PID coefficients of the servo controller.
3007
3008 @deprecated: Use L{pid} instead.
3009 @type P: flat
3010 @param P: proportional coefficient
3011 @type I: float
3012 @param I: Integral coefficient
3013 @type D: float
3014 @param D: Derivate coefficient
3015 """
3016
3018 """
3019 The parent actuator can set or remove an objects parent object.
3020 @ivar object: the object this actuator sets the parent too.
3021 @type object: KX_GameObject or None
3022 @ivar mode: The mode of this actuator
3023 @type mode: int from 0 to 1 L{GameLogic.Parent Actuator}
3024 @ivar compound: Whether the object shape should be added to the parent compound shape when parenting
3025 Effective only if the parent is already a compound shape
3026 @type compound: bool
3027 @ivar ghost: whether the object should be made ghost when parenting
3028 Effective only if the shape is not added to the parent compound shape
3029 @type ghost: bool
3030
3031 """
3033 """
3034 Sets the object to set as parent.
3035
3036 Object can be either a L{KX_GameObject} or the name of the object.
3037
3038 @deprecated: Use the L{object} property.
3039 @type object: L{KX_GameObject}, string or None
3040 """
3042 """
3043 Returns the name of the object to change to.
3044
3045 @deprecated: Use the L{object} property.
3046 @type name_only: bool
3047 @param name_only: optional argument, when 0 return a KX_GameObject
3048 @rtype: string, KX_GameObject or None if no object is set
3049 """
3050
3052 """
3053 KX_PhysicsObjectWrapper
3054
3055 """
3057 """
3058 Set the object to be active.
3059
3060 @param active: set to True to be active
3061 @type active: bool
3062 """
3063
3065 """
3066 Set the angular velocity of the object.
3067
3068 @param x: angular velocity for the x-axis
3069 @type x: float
3070
3071 @param y: angular velocity for the y-axis
3072 @type y: float
3073
3074 @param z: angular velocity for the z-axis
3075 @type z: float
3076
3077 @param local: set to True for local axis
3078 @type local: bool
3079 """
3081 """
3082 Set the linear velocity of the object.
3083
3084 @param x: linear velocity for the x-axis
3085 @type x: float
3086
3087 @param y: linear velocity for the y-axis
3088 @type y: float
3089
3090 @param z: linear velocity for the z-axis
3091 @type z: float
3092
3093 @param local: set to True for local axis
3094 @type local: bool
3095 """
3097 """
3098 Set the position of the object
3099
3100 @param x: x coordinate
3101 @type x: float
3102
3103 @param y: y coordinate
3104 @type y: float
3105
3106 @param z: z coordinate
3107 @type z: float
3108 """
3109
3111 """
3112 A polygon holds the index of the vertex forming the poylgon.
3113
3114 Note:
3115 The polygon attributes are read-only, you need to retrieve the vertex proxy if you want
3116 to change the vertex settings.
3117
3118 @ivar matname: The name of polygon material, empty if no material.
3119 @type matname: string
3120 @ivar material: The material of the polygon
3121 @type material: L{KX_PolygonMaterial} or L{KX_BlenderMaterial}
3122 @ivar texture: The texture name of the polygon.
3123 @type texture: string
3124 @ivar matid: The material index of the polygon, use this to retrieve vertex proxy from mesh proxy
3125 @type matid: integer
3126 @ivar v1: vertex index of the first vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
3127 @type v1: integer
3128 @ivar v2: vertex index of the second vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
3129 @type v2: integer
3130 @ivar v3: vertex index of the third vertex of the polygon, use this to retrieve vertex proxy from mesh proxy
3131 @type v3: integer
3132 @ivar v4: vertex index of the fourth vertex of the polygon, 0 if polygon has only 3 vertex
3133 use this to retrieve vertex proxy from mesh proxy
3134 @type v4: integer
3135 @ivar visible: visible state of the polygon: 1=visible, 0=invisible
3136 @type visible: integer
3137 @ivar collide: collide state of the polygon: 1=receives collision, 0=collision free.
3138 @type collide: integer
3139 """
3140
3142 """
3143 Returns the polygon material name with MA prefix
3144
3145 @rtype: string
3146 @return: material name
3147 """
3149 """
3150 Returns the polygon material
3151
3152 @rtype: L{KX_PolygonMaterial} or L{KX_BlenderMaterial}
3153 """
3155 """
3156 Returns the polygon texture name
3157
3158 @rtype: string
3159 @return: texture name
3160 """
3162 """
3163 Returns the material bucket index of the polygon.
3164 This index and the ones returned by getVertexIndex() are needed to retrieve the vertex proxy from L{KX_MeshProxy}.
3165
3166 @rtype: integer
3167 @return: the material index in the mesh
3168 """
3170 """
3171 Returns the number of vertex of the polygon.
3172
3173 @rtype: integer
3174 @return: number of vertex, 3 or 4.
3175 """
3177 """
3178 Returns whether the polygon is visible or not
3179
3180 @rtype: integer
3181 @return: 0=invisible, 1=visible
3182 """
3184 """
3185 Returns whether the polygon is receives collision or not
3186
3187 @rtype: integer
3188 @return: 0=collision free, 1=receives collision
3189 """
3191 """
3192 Returns the mesh vertex index of a polygon vertex
3193 This index and the one returned by getMaterialIndex() are needed to retrieve the vertex proxy from L{KX_MeshProxy}.
3194
3195 @type vertex: integer
3196 @param vertex: index of the vertex in the polygon: 0->3
3197 @rtype: integer
3198 @return: mesh vertex index
3199 """
3201 """
3202 Returns a mesh proxy
3203
3204 @rtype: L{KX_MeshProxy}
3205 @return: mesh proxy
3206 """
3207
3209 """
3210 This is the interface to materials in the game engine.
3211
3212 Materials define the render state to be applied to mesh objects.
3213
3214 Warning: Some of the methods/variables are CObjects. If you mix these up,
3215 you will crash blender.
3216
3217 This example requires:
3218 - PyOpenGL http://pyopengl.sourceforge.net/
3219 - GLEWPy http://glewpy.sourceforge.net/
3220 Example::
3221
3222 import GameLogic
3223 import OpenGL
3224 from OpenGL.GL import *
3225 from OpenGL.GLU import *
3226 import glew
3227 from glew import *
3228
3229 glewInit()
3230
3231 vertex_shader = \"\"\"
3232
3233 void main(void)
3234 {
3235 gl_Position = ftransform();
3236 }
3237 \"\"\"
3238
3239 fragment_shader =\"\"\"
3240
3241 void main(void)
3242 {
3243 gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);
3244 }
3245 \"\"\"
3246
3247 class MyMaterial:
3248 def __init__(self):
3249 self.pass_no = 0
3250 # Create a shader
3251 self.m_program = glCreateProgramObjectARB()
3252 # Compile the vertex shader
3253 self.shader(GL_VERTEX_SHADER_ARB, (vertex_shader))
3254 # Compile the fragment shader
3255 self.shader(GL_FRAGMENT_SHADER_ARB, (fragment_shader))
3256 # Link the shaders together
3257 self.link()
3258
3259 def PrintInfoLog(self, tag, object):
3260 \"\"\"
3261 PrintInfoLog prints the GLSL compiler log
3262 \"\"\"
3263 print "Tag: def PrintGLError(self, tag = ""):
3264
3265 def PrintGLError(self, tag = ""):
3266 \"\"\"
3267 Prints the current GL error status
3268 \"\"\"
3269 if len(tag):
3270 print tag
3271 err = glGetError()
3272 if err != GL_NO_ERROR:
3273 print "GL Error: %s\\n"%(gluErrorString(err))
3274
3275 def shader(self, type, shaders):
3276 \"\"\"
3277 shader compiles a GLSL shader and attaches it to the current
3278 program.
3279
3280 type should be either GL_VERTEX_SHADER_ARB or GL_FRAGMENT_SHADER_ARB
3281 shaders should be a sequence of shader source to compile.
3282 \"\"\"
3283 # Create a shader object
3284 shader_object = glCreateShaderObjectARB(type)
3285
3286 # Add the source code
3287 glShaderSourceARB(shader_object, len(shaders), shaders)
3288
3289 # Compile the shader
3290 glCompileShaderARB(shader_object)
3291
3292 # Print the compiler log
3293 self.PrintInfoLog("vertex shader", shader_object)
3294
3295 # Check if compiled, and attach if it did
3296 compiled = glGetObjectParameterivARB(shader_object, GL_OBJECT_COMPILE_STATUS_ARB)
3297 if compiled:
3298 glAttachObjectARB(self.m_program, shader_object)
3299
3300 # Delete the object (glAttachObjectARB makes a copy)
3301 glDeleteObjectARB(shader_object)
3302
3303 # print the gl error log
3304 self.PrintGLError()
3305
3306 def link(self):
3307 \"\"\"
3308 Links the shaders together.
3309 \"\"\"
3310 # clear error indicator
3311 glGetError()
3312
3313 glLinkProgramARB(self.m_program)
3314
3315 self.PrintInfoLog("link", self.m_program)
3316
3317 linked = glGetObjectParameterivARB(self.m_program, GL_OBJECT_LINK_STATUS_ARB)
3318 if not linked:
3319 print "Shader failed to link"
3320 return
3321
3322 glValidateProgramARB(self.m_program)
3323 valid = glGetObjectParameterivARB(self.m_program, GL_OBJECT_VALIDATE_STATUS_ARB)
3324 if not valid:
3325 print "Shader failed to validate"
3326 return
3327
3328 def activate(self, rasty, cachingInfo, mat):
3329 self.pass_no+=1
3330 if (self.pass_no == 1):
3331 glDisable(GL_COLOR_MATERIAL)
3332 glUseProgramObjectARB(self.m_program)
3333 return True
3334
3335 glEnable(GL_COLOR_MATERIAL)
3336 glUseProgramObjectARB(0)
3337 self.pass_no = 0
3338 return False
3339
3340 obj = GameLogic.getCurrentController().owner
3341
3342 mesh = obj.meshes[0]
3343
3344 for mat in mesh.materials:
3345 mat.setCustomMaterial(MyMaterial())
3346 print mat.texture
3347
3348 @ivar texture: Texture name
3349 @type texture: string (read-only)
3350
3351 @ivar gl_texture: OpenGL texture handle (eg for glBindTexture(GL_TEXTURE_2D, gl_texture)
3352 @type gl_texture: integer (read-only)
3353
3354 @ivar material: Material name
3355 @type material: string (read-only)
3356
3357 @ivar tface: Texture face properties
3358 @type tface: CObject (read-only)
3359
3360 @ivar tile: Texture is tiling
3361 @type tile: boolean
3362 @ivar tilexrep: Number of tile repetitions in x direction.
3363 @type tilexrep: integer
3364 @ivar tileyrep: Number of tile repetitions in y direction.
3365 @type tileyrep: integer
3366
3367 @ivar drawingmode: Drawing mode for the material.
3368 - 2 (drawingmode & 4) Textured
3369 - 4 (drawingmode & 16) Light
3370 - 14 (drawingmode & 16384) 3d Polygon Text
3371 @type drawingmode: bitfield
3372
3373 @ivar transparent: This material is transparent. All meshes with this
3374 material will be rendered after non transparent meshes from back
3375 to front.
3376 @type transparent: boolean
3377
3378 @ivar zsort: Transparent polygons in meshes with this material will be sorted back to
3379 front before rendering.
3380 Non-Transparent polygons will be sorted front to back before rendering.
3381 @type zsort: boolean
3382
3383 @ivar lightlayer: Light layers this material affects.
3384 @type lightlayer: bitfield.
3385
3386 @ivar triangle: Mesh data with this material is triangles. It's probably not safe to change this.
3387 @type triangle: boolean
3388
3389 @ivar diffuse: The diffuse colour of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0]
3390 @type diffuse: list [r, g, b]
3391 @ivar specular: The specular colour of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0]
3392 @type specular: list [r, g, b]
3393 @ivar shininess: The shininess (specular exponent) of the material. 0.0 <= shininess <= 128.0
3394 @type shininess: float
3395 @ivar specularity: The amount of specular of the material. 0.0 <= specularity <= 1.0
3396 @type specularity: float
3397 """
3398 - def updateTexture(tface, rasty):
3399 """
3400 Updates a realtime animation.
3401
3402 @param tface: Texture face (eg mat.tface)
3403 @type tface: CObject
3404 @param rasty: Rasterizer
3405 @type rasty: CObject
3406 """
3407 - def setTexture(tface):
3408 """
3409 Sets texture render state.
3410
3411 Example::
3412 mat.setTexture(mat.tface)
3413
3414 @param tface: Texture face
3415 @type tface: CObject
3416 """
3418 """
3419 Sets material parameters for this object for rendering.
3420
3421 Material Parameters set:
3422 1. Texture
3423 2. Backface culling
3424 3. Line drawing
3425 4. Specular Colour
3426 5. Shininess
3427 6. Diffuse Colour
3428 7. Polygon Offset.
3429
3430 @param rasty: Rasterizer instance.
3431 @type rasty: CObject
3432 @param cachingInfo: Material cache instance.
3433 @type cachingInfo: CObject
3434 """
3436 """
3437 Sets the material state setup object.
3438
3439 Using this method, you can extend or completely replace the gameengine material
3440 to do your own advanced multipass effects.
3441
3442 Use this method to register your material class. Instead of the normal material,
3443 your class's activate method will be called just before rendering the mesh.
3444 This should setup the texture, material, and any other state you would like.
3445 It should return True to render the mesh, or False if you are finished. You should
3446 clean up any state Blender does not set before returning False.
3447
3448 Activate Method Definition::
3449 def activate(self, rasty, cachingInfo, material):
3450
3451 Example::
3452 class PyMaterial:
3453 def __init__(self):
3454 self.pass_no = -1
3455
3456 def activate(self, rasty, cachingInfo, material):
3457 # Activate the material here.
3458 #
3459 # The activate method will be called until it returns False.
3460 # Every time the activate method returns True the mesh will
3461 # be rendered.
3462 #
3463 # rasty is a CObject for passing to material.updateTexture()
3464 # and material.activate()
3465 # cachingInfo is a CObject for passing to material.activate()
3466 # material is the KX_PolygonMaterial instance this material
3467 # was added to
3468
3469 # default material properties:
3470 self.pass_no += 1
3471 if self.pass_no == 0:
3472 material.activate(rasty, cachingInfo)
3473 # Return True to do this pass
3474 return True
3475
3476 # clean up and return False to finish.
3477 self.pass_no = -1
3478 return False
3479
3480 # Create a new Python Material and pass it to the renderer.
3481 mat.setCustomMaterial(PyMaterial())
3482
3483 @param material: The material object.
3484 @type material: instance
3485 """
3486
3488 """
3489 Radar sensor is a near sensor with a conical sensor object.
3490
3491 @ivar coneOrigin: The origin of the cone with which to test. The origin
3492 is in the middle of the cone.
3493 (read-only)
3494 @type coneOrigin: list of floats [x, y, z]
3495 @ivar coneTarget: The center of the bottom face of the cone with which to test.
3496 (read-only)
3497 @type coneTarget: list of floats [x, y, z]
3498 @ivar distance: The height of the cone with which to test.
3499 @type distance: float
3500 @ivar angle: The angle of the cone (in degrees) with which to test.
3501 @type angle: float from 0 to 360
3502 @ivar axis: The axis on which the radar cone is cast
3503 @type axis: int from 0 to 5
3504 KX_RADAR_AXIS_POS_X, KX_RADAR_AXIS_POS_Y, KX_RADAR_AXIS_POS_Z,
3505 KX_RADAR_AXIS_NEG_X, KX_RADAR_AXIS_NEG_Y, KX_RADAR_AXIS_NEG_Z
3506 """
3507
3508
3510 """
3511 Returns the origin of the cone with which to test. The origin
3512 is in the middle of the cone.
3513
3514 @deprecated: Use the L{coneOrigin} property.
3515 @rtype: list [x, y, z]
3516 """
3517
3519 """
3520 Returns the center of the bottom face of the cone with which to test.
3521
3522 @deprecated: Use the L{coneTarget} property.
3523 @rtype: list [x, y, z]
3524 """
3525
3526
3528 """
3529 Returns the height of the cone with which to test.
3530
3531 @rtype: float
3532 """
3533
3535 """
3536 A ray sensor detects the first object in a given direction.
3537
3538 @ivar propName: The property the ray is looking for.
3539 @type propName: string
3540 @ivar range: The distance of the ray.
3541 @type range: float
3542 @ivar useMaterial: Whether or not to look for a material (false = property)
3543 @type useMaterial: boolean
3544 @ivar useXRay: Whether or not to use XRay.
3545 @type useXRay: boolean
3546 @ivar hitObject: The game object that was hit by the ray. (Read-only)
3547 @type hitObject: KX_GameObject
3548 @ivar hitPosition: The position (in worldcoordinates) where the object was hit by the ray. (Read-only)
3549 @type hitPosition: list [x, y, z]
3550 @ivar hitNormal: The normal (in worldcoordinates) of the object at the location where the object was hit by the ray. (Read-only)
3551 @type hitNormal: list [x, y, z]
3552 @ivar rayDirection: The direction from the ray (in worldcoordinates). (Read-only)
3553 @type rayDirection: list [x, y, z]
3554 @ivar axis: The axis the ray is pointing on.
3555 @type axis: int from 0 to 5
3556 KX_RAY_AXIS_POS_X, KX_RAY_AXIS_POS_Y, KX_RAY_AXIS_POS_Z,
3557 KX_RAY_AXIS_NEG_X, KX_RAY_AXIS_NEG_Y, KX_RAY_AXIS_NEG_Z
3558 """
3559
3561 """
3562 Returns the game object that was hit by this ray.
3563
3564 @deprecated: Use the L{hitObject} attribute instead.
3565 @rtype: KX_GameObject
3566 """
3568 """
3569 Returns the position (in worldcoordinates) where the object was hit by this ray.
3570
3571 @deprecated: Use the L{hitPosition} attribute instead.
3572 @rtype: list [x, y, z]
3573 """
3575 """
3576 Returns the normal (in worldcoordinates) of the object at the location where the object was hit by this ray.
3577
3578 @deprecated: Use the L{hitNormal} attribute instead.
3579 @rtype: list [nx, ny, nz]
3580 """
3582 """
3583 Returns the direction from the ray (in worldcoordinates)
3584
3585 @deprecated: Use the L{rayDirection} attribute instead.
3586 @rtype: list [dx, dy, dz]
3587 """
3588
3589
3591 """
3592 Edit Object Actuator (in Add Object Mode)
3593 @ivar object: the object this actuator adds.
3594 @type object: KX_GameObject or None
3595 @ivar objectLastCreated: the last added object from this actuator (read-only).
3596 @type objectLastCreated: KX_GameObject or None
3597 @ivar time: the lifetime of added objects, in frames. Set to 0 to disable automatic deletion.
3598 @type time: integer
3599 @ivar linearVelocity: the initial linear velocity of added objects.
3600 @type linearVelocity: list [vx, vy, vz]
3601 @ivar angularVelocity: the initial angular velocity of added objects.
3602 @type angularVelocity: list [vx, vy, vz]
3603
3604 @warning: An Add Object actuator will be ignored if at game start, the linked object doesn't exist
3605 (or is empty) or the linked object is in an active layer.
3606
3607 This will genereate a warning in the console:
3608
3609 C{ERROR: GameObject I{OBName} has a AddObjectActuator I{ActuatorName} without object (in 'nonactive' layer)}
3610 """
3611
3613 """
3614 Sets the game object to add.
3615
3616 A copy of the object will be added to the scene when the actuator is activated.
3617
3618 If the object does not exist, this function is ignored.
3619
3620 object can either be a L{KX_GameObject} or the name of an object or None.
3621
3622 @deprecated: use the L{object} property
3623 @type object: L{KX_GameObject}, string or None
3624 """
3626 """
3627 Returns the name of the game object to be added.
3628
3629 Returns None if no game object has been assigned to be added.
3630
3631 @deprecated: use the L{object} property
3632 @type name_only: bool
3633 @param name_only: optional argument, when 0 return a KX_GameObject
3634 @rtype: string, KX_GameObject or None if no object is set
3635 """
3637 """
3638 Sets the lifetime of added objects, in frames.
3639
3640 If time == 0, the object will last forever.
3641
3642 @deprecated: use the L{time} property
3643 @type time: integer
3644 @param time: The minimum value for time is 0.
3645 """
3647 """
3648 Returns the lifetime of the added object, in frames.
3649
3650 @deprecated: use the L{time} property
3651 @rtype: integer
3652 """
3654 """
3655 Sets the initial linear velocity of added objects.
3656
3657 @deprecated: use the L{linearVelocity} property
3658 @type vx: float
3659 @param vx: the x component of the initial linear velocity.
3660 @type vy: float
3661 @param vy: the y component of the initial linear velocity.
3662 @type vz: float
3663 @param vz: the z component of the initial linear velocity.
3664 """
3666 """
3667 Returns the initial linear velocity of added objects.
3668
3669 @deprecated: use the L{linearVelocity} property
3670 @rtype: list [vx, vy, vz]
3671 """
3673 """
3674 Sets the initial angular velocity of added objects.
3675
3676 @deprecated: use the L{angularVelocity} property
3677 @type vx: float
3678 @param vx: the x component of the initial angular velocity.
3679 @type vy: float
3680 @param vy: the y component of the initial angular velocity.
3681 @type vz: float
3682 @param vz: the z component of the initial angular velocity.
3683 """
3685 """
3686 Returns the initial angular velocity of added objects.
3687
3688 @deprecated: use the L{angularVelocity} property
3689 @rtype: list [vx, vy, vz]
3690 """
3692 """
3693 Returns the last object created by this actuator.
3694
3695 @deprecated: use the L{objectLastCreated} property
3696 @rtype: L{KX_GameObject}
3697 @return: A L{KX_GameObject} or None if no object has been created.
3698 """
3699
3701 """
3702 Returns the last object created by this actuator. The object can then be accessed from L{objectLastCreated}.
3703
3704 @rtype: None
3705 """
3706
3708 """
3709 Dynamic Actuator.
3710 @ivar mode: the type of operation of the actuator, 0-4
3711 KX_DYN_RESTORE_DYNAMICS, KX_DYN_DISABLE_DYNAMICS,
3712 KX_DYN_ENABLE_RIGID_BODY, KX_DYN_DISABLE_RIGID_BODY, KX_DYN_SET_MASS
3713 @type mode: integer
3714 @ivar mass: the mass value for the KX_DYN_SET_MASS operation
3715 @type mass: float
3716 """
3717
3719 """
3720 Set the type of operation when the actuator is activated:
3721 - 0 = restore dynamics
3722 - 1 = disable dynamics
3723 - 2 = enable rigid body
3724 - 3 = disable rigid body
3725 - 4 = set mass
3726
3727 @deprecated: Use the L{mode} attribute instead.
3728 """
3730 """
3731 return the type of operation
3732 @deprecated: Use the L{mode} attribute instead.
3733 """
3734
3735
3737 """
3738 Edit Object Actuator (in End Object mode)
3739
3740 This actuator has no python methods.
3741 """
3742
3744 """
3745 Edit Object actuator, in Replace Mesh mode.
3746
3747 Example::
3748 # Level-of-detail
3749 # Switch a game object's mesh based on its depth in the camera view.
3750 # +----------+ +-----------+ +-------------------------------------+
3751 # | Always +-----+ Python +-----+ Edit Object (Replace Mesh) LOD.Mesh |
3752 # +----------+ +-----------+ +-------------------------------------+
3753 import GameLogic
3754
3755 # List detail meshes here
3756 # Mesh (name, near, far)
3757 # Meshes overlap so that they don't 'pop' when on the edge of the distance.
3758 meshes = ((".Hi", 0.0, -20.0),
3759 (".Med", -15.0, -50.0),
3760 (".Lo", -40.0, -100.0)
3761 )
3762
3763 co = GameLogic.getCurrentController()
3764 obj = co.owner
3765 act = co.actuators["LOD." + obj.name]
3766 cam = GameLogic.getCurrentScene().active_camera
3767
3768 def Depth(pos, plane):
3769 return pos[0]*plane[0] + pos[1]*plane[1] + pos[2]*plane[2] + plane[3]
3770
3771 # Depth is negative and decreasing further from the camera
3772 depth = Depth(obj.position, cam.world_to_camera[2])
3773
3774 newmesh = None
3775 curmesh = None
3776 # Find the lowest detail mesh for depth
3777 for mesh in meshes:
3778 if depth < mesh[1] and depth > mesh[2]:
3779 newmesh = mesh
3780 if "ME" + obj.name + mesh[0] == act.getMesh():
3781 curmesh = mesh
3782
3783 if newmesh != None and "ME" + obj.name + newmesh[0] != act.getMesh():
3784 # The mesh is a different mesh - switch it.
3785 # Check the current mesh is not a better fit.
3786 if curmesh == None or curmesh[1] < depth or curmesh[2] > depth:
3787 act.mesh = obj.getName() + newmesh[0]
3788 GameLogic.addActiveActuator(act, True)
3789
3790 @warning: Replace mesh actuators will be ignored if at game start, the
3791 named mesh doesn't exist.
3792
3793 This will generate a warning in the console:
3794
3795 C{ERROR: GameObject I{OBName} ReplaceMeshActuator I{ActuatorName} without object}
3796
3797 @ivar mesh: L{KX_MeshProxy} or the name of the mesh that will replace the current one
3798 Set to None to disable actuator
3799 @type mesh: L{KX_MeshProxy} or None if no mesh is set
3800
3801 @ivar useDisplayMesh: when true the displayed mesh is replaced.
3802 @type useDisplayMesh: boolean
3803 @ivar usePhysicsMesh: when true the physics mesh is replaced.
3804 @type usePhysicsMesh: boolean
3805 """
3807 """
3808 Sets the name of the mesh that will replace the current one.
3809 When the name is None it will unset the mesh value so no action is taken.
3810
3811 @deprecated: Use the L{mesh} attribute instead.
3812 @type name: string or None
3813 """
3815 """
3816 Returns the name of the mesh that will replace the current one.
3817
3818 Returns None if no mesh has been scheduled to be added.
3819
3820 @deprecated: Use the L{mesh} attribute instead.
3821 @rtype: string or None
3822 """
3824 """
3825 Immediately replace mesh without delay.
3826 @rtype: None
3827 """
3828
3830 """
3831 An active scene that gives access to objects, cameras, lights and scene attributes.
3832
3833 The activity culling stuff is supposed to disable logic bricks when their owner gets too far
3834 from the active camera. It was taken from some code lurking at the back of KX_Scene - who knows
3835 what it does!
3836
3837 Example::
3838 import GameLogic
3839
3840 # get the scene
3841 scene = GameLogic.getCurrentScene()
3842
3843 # print all the objects in the scene
3844 for obj in scene.objects:
3845 print obj.name
3846
3847 # get an object named 'Cube'
3848 obj = scene.objects["OBCube"]
3849
3850 # get the first object in the scene.
3851 obj = scene.objects[0]
3852
3853 Example::
3854 # Get the depth of an object in the camera view.
3855 import GameLogic
3856
3857 obj = GameLogic.getCurrentController().owner
3858 cam = GameLogic.getCurrentScene().active_camera
3859
3860 # Depth is negative and decreasing further from the camera
3861 depth = obj.position[0]*cam.world_to_camera[2][0] + obj.position[1]*cam.world_to_camera[2][1] + obj.position[2]*cam.world_to_camera[2][2] + cam.world_to_camera[2][3]
3862
3863 @bug: All attributes are read only at the moment.
3864
3865 @ivar name: The scene's name, (read-only).
3866 @type name: string
3867 @ivar objects: A list of objects in the scene, (read-only).
3868 @type objects: L{CListValue} of L{KX_GameObject}
3869 @ivar objectsInactive: A list of objects on background layers (used for the addObject actuator), (read-only).
3870 @type objectsInactive: L{CListValue} of L{KX_GameObject}
3871 @ivar lights: A list of lights in the scene, (read-only).
3872 @type lights: L{CListValue} of L{KX_LightObject}
3873 @ivar cameras: A list of cameras in the scene, (read-only).
3874 @type cameras: L{CListValue} of L{KX_Camera}
3875 @ivar active_camera: The current active camera.
3876 note: this can be set directly from python to avoid using the L{KX_SceneActuator}.
3877 @type active_camera: L{KX_Camera}
3878 @ivar suspended: True if the scene is suspended, (read-only).
3879 @type suspended: boolean
3880 @ivar activity_culling: True if the scene is activity culling
3881 @type activity_culling: boolean
3882 @ivar activity_culling_radius: The distance outside which to do activity culling. Measured in manhattan distance.
3883 @type activity_culling_radius: float
3884 @ivar dbvt_culling: True when Dynamic Bounding box Volume Tree is set (read-only).
3885 @type dbvt_culling: bool
3886 @group Deprecated: getLightList, getObjectList, getName
3887 """
3888
3890 """
3891 Returns the list of lights in the scene.
3892
3893 @deprecated: Use the L{lights} attribute instead.
3894 @rtype: list [L{KX_LightObject}]
3895 """
3897 """
3898 Returns the list of objects in the scene.
3899
3900 @deprecated: Use the L{objects} attribute instead.
3901 @rtype: list [L{KX_GameObject}]
3902 """
3904 """
3905 Returns the name of the scene.
3906
3907 @deprecated: Use the L{name} attribute instead.
3908 @rtype: string
3909 """
3910
3912 """
3913 Adds an object to the scene like the Add Object Actuator would, and returns the created object.
3914
3915 @param object: The object to add
3916 @type object: L{KX_GameObject} or string
3917 @param other: The object's center to use when adding the object
3918 @type other: L{KX_GameObject} or string
3919 @param time: The lifetime of the added object, in frames. A time of 0 means the object will last forever.
3920 @type time: int
3921
3922 @rtype: L{KX_GameObject}
3923 """
3924
3926 """
3927 Scene Actuator logic brick.
3928
3929 @warning: Scene actuators that use a scene name will be ignored if at game start, the
3930 named scene doesn't exist or is empty
3931
3932 This will generate a warning in the console:
3933
3934 C{ERROR: GameObject I{OBName} has a SceneActuator I{ActuatorName} (SetScene) without scene}
3935
3936 @ivar scene: the name of the scene to change to/overlay/underlay/remove/suspend/resume
3937 @type scene: string.
3938 @ivar camera: the camera to change to.
3939 When setting the attribute, you can use either a L{KX_Camera} or the name of the camera.
3940 @type camera: L{KX_Camera} on read, string or L{KX_Camera} on write
3941 @ivar useRestart: Set flag to True to restart the sene
3942 @type useRestart: bool
3943 @ivar mode: The mode of the actuator
3944 @type mode: int from 0 to 5 L{GameLogic.Scene Actuator}
3945 """
3946
3948 """
3949 Set flag to True to restart the scene.
3950
3951 @deprecated: Use the L{useRestart} attribute instead.
3952 @type flag: boolean
3953 """
3955 """
3956 Sets the name of the scene to change to/overlay/underlay/remove/suspend/resume.
3957
3958 @deprecated: use the L{scene} attribute instead.
3959 @type scene: string
3960 """
3962 """
3963 Sets the camera to change to.
3964
3965 Camera can be either a L{KX_Camera} or the name of the camera.
3966
3967 @deprecated: use the L{camera} attribute instead.
3968 @type camera: L{KX_Camera} or string
3969 """
3971 """
3972 Returns True if the scene will be restarted.
3973
3974 @deprecated: use the L{useRestart} attribute instead.
3975 @rtype: boolean
3976 """
3978 """
3979 Returns the name of the scene to change to/overlay/underlay/remove/suspend/resume.
3980
3981 Returns an empty string ("") if no scene has been set.
3982
3983 @deprecated: use the L{scene} attribute instead.
3984 @rtype: string
3985 """
3987 """
3988 Returns the name of the camera to change to.
3989
3990 @deprecated: use the L{camera} attribute instead.
3991 @rtype: string
3992 """
3993
3994
3996 """
3997 Sound Actuator.
3998
3999 The L{startSound()}, L{pauseSound()} and L{stopSound()} do not require
4000 the actuator to be activated - they act instantly provided that the actuator has
4001 been activated once at least.
4002
4003 @ivar fileName: The filename of the sound this actuator plays.
4004 @type fileName: string
4005
4006 @ivar volume: The volume (gain) of the sound.
4007 @type volume: float
4008
4009 @ivar pitch: The pitch of the sound.
4010 @type pitch: float
4011
4012 @ivar rollOffFactor: The roll off factor. Rolloff defines the rate of attenuation as the sound gets further away.
4013 @type rollOffFactor: float
4014
4015 @ivar looping: The loop mode of the actuator.
4016 @type looping: integer
4017
4018 @ivar position: The position of the sound as a list: [x, y, z].
4019 @type position: float array
4020
4021 @ivar velocity: The velocity of the emitter as a list: [x, y, z]. The relative velocity to the observer determines the pitch. List of 3 floats: [x, y, z].
4022 @type velocity: float array
4023
4024 @ivar orientation: The orientation of the sound. When setting the orientation you can also use quaternion [float,float,float,float] or euler angles [float,float,float]
4025 @type orientation: 3x3 matrix [[float]]
4026
4027 @ivar mode: The operation mode of the actuator. You can use one of the following constants:
4028 - KX_SOUNDACT_PLAYSTOP (1)
4029 - KX_SOUNDACT_PLAYEND (2)
4030 - KX_SOUNDACT_LOOPSTOP (3)
4031 - KX_SOUNDACT_LOOPEND (4)
4032 - KX_SOUNDACT_LOOPBIDIRECTIONAL (5)
4033 - KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP (6)
4034 @type mode: integer
4035 """
4036
4037
4039 """
4040 Starts the sound.
4041 """
4043 """
4044 Pauses the sound.
4045 """
4047 """
4048 Stops the sound.
4049 """
4050
4051
4052
4054 """
4055 Sets the filename of the sound this actuator plays.
4056
4057 @deprecated: Use the L{fileName} attribute instead.
4058 @type filename: string
4059 """
4061 """
4062 Returns the filename of the sound this actuator plays.
4063
4064 @deprecated: Use the L{fileName} attribute instead.
4065 @rtype: string
4066 """
4068 """
4069 Sets the gain (volume) of the sound
4070
4071 @deprecated: Use the L{volume} attribute instead.
4072 @type gain: float
4073 @param gain: 0.0 (quiet) <= gain <= 1.0 (loud)
4074 """
4076 """
4077 Gets the gain (volume) of the sound.
4078
4079 @deprecated: Use the L{volume} attribute instead.
4080 @rtype: float
4081 """
4083 """
4084 Sets the pitch of the sound.
4085
4086 @deprecated: Use the L{pitch} attribute instead.
4087 @type pitch: float
4088 """
4090 """
4091 Returns the pitch of the sound.
4092
4093 @deprecated: Use the L{pitch} attribute instead.
4094 @rtype: float
4095 """
4097 """
4098 Sets the rolloff factor for the sounds.
4099
4100 Rolloff defines the rate of attenuation as the sound gets further away.
4101 Higher rolloff factors shorten the distance at which the sound can be heard.
4102
4103 @deprecated: Use the L{rollOffFactor} attribute instead.
4104 @type rolloff: float
4105 """
4107 """
4108 Returns the rolloff factor for the sound.
4109
4110 @deprecated: Use the L{rollOffFactor} attribute instead.
4111 @rtype: float
4112 """
4114 """
4115 Sets the loop mode of the actuator.
4116
4117 @bug: There are no constants defined for this method!
4118 @param loop: - Play Stop 1
4119 - Play End 2
4120 - Loop Stop 3
4121 - Loop End 4
4122 - Bidirection Stop 5
4123 - Bidirection End 6
4124
4125 @deprecated: Use the L{looping} attribute instead.
4126 @type loop: integer
4127 """
4129 """
4130 Returns the current loop mode of the actuator.
4131
4132 @deprecated: Use the L{looping} attribute instead.
4133 @rtype: integer
4134 """
4136 """
4137 Sets the position this sound will come from.
4138
4139 @deprecated: Use the L{position} attribute instead.
4140 @type x: float
4141 @param x: The x coordinate of the sound.
4142 @type y: float
4143 @param y: The y coordinate of the sound.
4144 @type z: float
4145 @param z: The z coordinate of the sound.
4146 """
4148 """
4149 Sets the velocity this sound is moving at.
4150
4151 The sound's pitch is determined from the velocity.
4152
4153 @deprecated: Use the L{velocity} attribute instead.
4154 @type vx: float
4155 @param vx: The vx coordinate of the sound.
4156 @type vy: float
4157 @param vy: The vy coordinate of the sound.
4158 @type vz: float
4159 @param vz: The vz coordinate of the sound.
4160 """
4162 """
4163 Sets the orientation of the sound.
4164
4165 The nine parameters specify a rotation matrix::
4166 | o11, o12, o13 |
4167 | o21, o22, o23 |
4168 | o31, o32, o33 |
4169 @deprecated: Use the L{orientation} attribute instead.
4170 """
4171
4173 """
4174 Sets the operation mode of the actuator.
4175
4176 @deprecated: Use the L{type} attribute instead.
4177 @param mode: KX_SOUNDACT_PLAYSTOP, KX_SOUNDACT_PLAYEND, KX_SOUNDACT_LOOPSTOP, KX_SOUNDACT_LOOPEND, KX_SOUNDACT_LOOPBIDIRECTIONAL, KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP
4178 @type mode: integer
4179 """
4180
4182 """
4183 Returns the operation mode of the actuator.
4184
4185 @deprecated: Use the L{type} attribute instead.
4186 @rtype: integer
4187 @return: KX_SOUNDACT_PLAYSTOP, KX_SOUNDACT_PLAYEND, KX_SOUNDACT_LOOPSTOP, KX_SOUNDACT_LOOPEND, KX_SOUNDACT_LOOPBIDIRECTIONAL, KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP
4188 """
4189
4190
4192 """
4193 State actuator changes the state mask of parent object.
4194
4195 Property:
4196
4197 @ivar operation: type of bit operation to be applied on object state mask.
4198 You can use one of the following constant:
4199 - KX_STATE_OP_CPY (0) : Copy state mask
4200 - KX_STATE_OP_SET (1) : Add bits to state mask
4201 - KX_STATE_OP_CLR (2) : Substract bits to state mask
4202 - KX_STATE_OP_NEG (3) : Invert bits to state mask
4203 @type operation: integer
4204
4205 @ivar mask: value that defines the bits that will be modified by the operation.
4206 The bits that are 1 in the mask will be updated in the object state,
4207 the bits that are 0 are will be left unmodified expect for the Copy operation
4208 which copies the mask to the object state
4209 @type mask: integer
4210 """
4212 """
4213 Set the type of bit operation to be applied on object state mask.
4214 Use setMask() to specify the bits that will be modified.
4215
4216 @deprecated: Use the L{operation} attribute instead.
4217 @param op: bit operation (0=Copy, 1=Add, 2=Substract, 3=Invert)
4218 @type op: integer
4219 """
4221 """
4222 Set the value that defines the bits that will be modified by the operation.
4223 The bits that are 1 in the value will be updated in the object state,
4224 the bits that are 0 are will be left unmodified expect for the Copy operation
4225 which copies the value to the object state.
4226
4227 @deprecated: Use the L{mask} attribute instead.
4228 @param mask: bits that will be modified
4229 @type mask: integer
4230 """
4231
4233 """
4234 Edit Object actuator in Track To mode.
4235
4236 @warning: Track To Actuators will be ignored if at game start, the
4237 object to track to is invalid.
4238
4239 This will generate a warning in the console:
4240
4241 C{ERROR: GameObject I{OBName} no object in EditObjectActuator I{ActuatorName}}
4242
4243 @ivar object: the object this actuator tracks.
4244 @type object: KX_GameObject or None
4245 @ivar time: the time in frames with which to delay the tracking motion
4246 @type time: integer
4247 @ivar use3D: the tracking motion to use 3D
4248 @type use3D: boolean
4249
4250 """
4251
4253 """
4254 Sets the object to track.
4255
4256 @deprecated: Use the L{object} attribute instead.
4257 @type object: L{KX_GameObject}, string or None
4258 @param object: Either a reference to a game object or the name of the object to track.
4259 """
4261 """
4262 Returns the name of the object to track.
4263
4264 @deprecated: Use the L{object} attribute instead.
4265 @type name_only: bool
4266 @param name_only: optional argument, when 0 return a KX_GameObject
4267 @rtype: string, KX_GameObject or None if no object is set
4268 """
4270 """
4271 Sets the time in frames with which to delay the tracking motion.
4272
4273 @deprecated: Use the L{time} attribute instead.
4274 @type time: integer
4275 """
4277 """
4278 Returns the time in frames with which the tracking motion is delayed.
4279
4280 @deprecated: Use the L{time} attribute instead.
4281 @rtype: integer
4282 """
4284 """
4285 DEPRECATED: Use the property.
4286 Sets the tracking motion to use 3D.
4287
4288 @deprecated: Use the L{use3D} attribute instead.
4289 @type use3d: boolean
4290 @param use3d: - True: allow the tracking motion to extend in the z-direction.
4291 - False: lock the tracking motion to the x-y plane.
4292 """
4294 """
4295 Returns True if the tracking motion will track in the z direction.
4296
4297 @deprecated: Use the L{use3D} attribute instead.
4298 @rtype: boolean
4299 """
4300
4301
4303 """
4304 KX_VehicleWrapper
4305
4306 TODO - description
4307 """
4308
4309 - def addWheel(wheel, attachPos, attachDir, axleDir, suspensionRestLength, wheelRadius, hasSteering):
4310
4311 """
4312 Add a wheel to the vehicle
4313
4314 @param wheel: The object to use as a wheel.
4315 @type wheel: L{KX_GameObject} or a KX_GameObject name
4316 @param attachPos: The position that this wheel will attach to.
4317 @type attachPos: vector of 3 floats
4318 @param attachDir: The direction this wheel points.
4319 @type attachDir: vector of 3 floats
4320 @param axleDir: The direction of this wheels axle.
4321 @type axleDir: vector of 3 floats
4322 @param suspensionRestLength: TODO - Description
4323 @type suspensionRestLength: float
4324 @param wheelRadius: The size of the wheel.
4325 @type wheelRadius: float
4326 """
4327
4329 """
4330 Apply a braking force to the specified wheel
4331
4332 @param force: the brake force
4333 @type force: float
4334
4335 @param wheelIndex: index of the wheel where the force needs to be applied
4336 @type wheelIndex: integer
4337 """
4339 """
4340 Apply an engine force to the specified wheel
4341
4342 @param force: the engine force
4343 @type force: float
4344
4345 @param wheelIndex: index of the wheel where the force needs to be applied
4346 @type wheelIndex: integer
4347 """
4349 """
4350 Get the constraint ID
4351
4352 @rtype: integer
4353 @return: the constraint id
4354 """
4356 """
4357 Returns the constraint type.
4358
4359 @rtype: integer
4360 @return: constraint type
4361 """
4363 """
4364 Returns the number of wheels.
4365
4366 @rtype: integer
4367 @return: the number of wheels for this vehicle
4368 """
4370 """
4371 Returns the wheel orientation as a quaternion.
4372
4373 @param wheelIndex: the wheel index
4374 @type wheelIndex: integer
4375
4376 @rtype: TODO - type should be quat as per method name but from the code it looks like a matrix
4377 @return: TODO Description
4378 """
4380 """
4381 Returns the position of the specified wheel
4382
4383 @param wheelIndex: the wheel index
4384 @type wheelIndex: integer
4385
4386 @rtype: list[x, y, z]
4387 @return: position vector
4388 """
4390 """
4391 Returns the rotation of the specified wheel
4392
4393 @param wheelIndex: the wheel index
4394 @type wheelIndex: integer
4395
4396 @rtype: float
4397 @return: the wheel rotation
4398 """
4400 """
4401 Set the specified wheel's roll influence.
4402 The higher the roll influence the more the vehicle will tend to roll over in corners.
4403
4404 @param rollInfluece: the wheel roll influence
4405 @type rollInfluece: float
4406
4407 @param wheelIndex: the wheel index
4408 @type wheelIndex: integer
4409 """
4411 """
4412 Set the specified wheel's steering
4413
4414 @param steering: the wheel steering
4415 @type steering: float
4416
4417 @param wheelIndex: the wheel index
4418 @type wheelIndex: integer
4419 """
4421 """
4422 Set the specified wheel's compression
4423
4424 @param compression: the wheel compression
4425 @type compression: float
4426
4427 @param wheelIndex: the wheel index
4428 @type wheelIndex: integer
4429 """
4431 """
4432 Set the specified wheel's damping
4433
4434 @param damping: the wheel damping
4435 @type damping: float
4436
4437 @param wheelIndex: the wheel index
4438 @type wheelIndex: integer
4439 """
4441 """
4442 Set the specified wheel's stiffness
4443
4444 @param stiffness: the wheel stiffness
4445 @type stiffness: float
4446
4447 @param wheelIndex: the wheel index
4448 @type wheelIndex: integer
4449 """
4451 """
4452 Set the specified wheel's tyre friction
4453
4454 @param friction: the tyre friction
4455 @type friction: float
4456
4457 @param wheelIndex: the wheel index
4458 @type wheelIndex: integer
4459 """
4460
4462 """
4463 A vertex holds position, UV, colour and normal information.
4464
4465 Note:
4466 The physics simulation is NOT currently updated - physics will not respond
4467 to changes in the vertex position.
4468
4469 @ivar XYZ: The position of the vertex.
4470 @type XYZ: list [x, y, z]
4471 @ivar UV: The texture coordinates of the vertex.
4472 @type UV: list [u, v]
4473 @ivar normal: The normal of the vertex
4474 @type normal: list [nx, ny, nz]
4475 @ivar colour: The colour of the vertex.
4476 Black = [0.0, 0.0, 0.0, 1.0], White = [1.0, 1.0, 1.0, 1.0]
4477 @type colour: list [r, g, b, a]
4478 @ivar color: Synonym for colour.
4479
4480 @group Position: x, y, z
4481 @ivar x: The x coordinate of the vertex.
4482 @type x: float
4483 @ivar y: The y coordinate of the vertex.
4484 @type y: float
4485 @ivar z: The z coordinate of the vertex.
4486 @type z: float
4487
4488 @group Texture Coordinates: u, v
4489 @ivar u: The u texture coordinate of the vertex.
4490 @type u: float
4491 @ivar v: The v texture coordinate of the vertex.
4492 @type v: float
4493
4494 @ivar u2: The second u texture coordinate of the vertex.
4495 @type u2: float
4496 @ivar v2: The second v texture coordinate of the vertex.
4497 @type v2: float
4498
4499 @group Colour: r, g, b, a
4500 @ivar r: The red component of the vertex colour. 0.0 <= r <= 1.0
4501 @type r: float
4502 @ivar g: The green component of the vertex colour. 0.0 <= g <= 1.0
4503 @type g: float
4504 @ivar b: The blue component of the vertex colour. 0.0 <= b <= 1.0
4505 @type b: float
4506 @ivar a: The alpha component of the vertex colour. 0.0 <= a <= 1.0
4507 @type a: float
4508 """
4509
4511 """
4512 Gets the position of this vertex.
4513
4514 @rtype: list [x, y, z]
4515 @return: this vertexes position in local coordinates.
4516 """
4518 """
4519 Sets the position of this vertex.
4520
4521 @type pos: list [x, y, z]
4522 @param pos: the new position for this vertex in local coordinates.
4523 """
4525 """
4526 Gets the UV (texture) coordinates of this vertex.
4527
4528 @rtype: list [u, v]
4529 @return: this vertexes UV (texture) coordinates.
4530 """
4532 """
4533 Sets the UV (texture) coordinates of this vertex.
4534
4535 @type uv: list [u, v]
4536 """
4538 """
4539 Gets the 2nd UV (texture) coordinates of this vertex.
4540
4541 @rtype: list [u, v]
4542 @return: this vertexes UV (texture) coordinates.
4543 """
4545 """
4546 Sets the 2nd UV (texture) coordinates of this vertex.
4547
4548 @type uv: list [u, v]
4549 @param unit: optional argument, FLAT==1, SECOND_UV==2, defaults to SECOND_UV
4550 @param unit: int
4551 """
4553 """
4554 Gets the colour of this vertex.
4555
4556 The colour is represented as four bytes packed into an integer value. The colour is
4557 packed as RGBA.
4558
4559 Since Python offers no way to get each byte without shifting, you must use the struct module to
4560 access colour in an machine independent way.
4561
4562 Because of this, it is suggested you use the r, g, b and a attributes or the colour attribute instead.
4563
4564 Example::
4565 import struct;
4566 col = struct.unpack('4B', struct.pack('I', v.getRGBA()))
4567 # col = (r, g, b, a)
4568 # black = ( 0, 0, 0, 255)
4569 # white = (255, 255, 255, 255)
4570
4571 @rtype: integer
4572 @return: packed colour. 4 byte integer with one byte per colour channel in RGBA format.
4573 """
4575 """
4576 Sets the colour of this vertex.
4577
4578 See getRGBA() for the format of col, and its relevant problems. Use the r, g, b and a attributes
4579 or the colour attribute instead.
4580
4581 setRGBA() also accepts a four component list as argument col. The list represents the colour as [r, g, b, a]
4582 with black = [0.0, 0.0, 0.0, 1.0] and white = [1.0, 1.0, 1.0, 1.0]
4583
4584 Example::
4585 v.setRGBA(0xff0000ff) # Red
4586 v.setRGBA(0xff00ff00) # Green on little endian, transparent purple on big endian
4587 v.setRGBA([1.0, 0.0, 0.0, 1.0]) # Red
4588 v.setRGBA([0.0, 1.0, 0.0, 1.0]) # Green on all platforms.
4589
4590 @type col: integer or list [r, g, b, a]
4591 @param col: the new colour of this vertex in packed RGBA format.
4592 """
4594 """
4595 Gets the normal vector of this vertex.
4596
4597 @rtype: list [nx, ny, nz]
4598 @return: normalised normal vector.
4599 """
4601 """
4602 Sets the normal vector of this vertex.
4603
4604 @type normal: sequence of floats [r, g, b]
4605 @param normal: the new normal of this vertex.
4606 """
4607
4609 """
4610 Visibility Actuator.
4611 @ivar visibility: whether the actuator makes its parent object visible or invisible
4612 @type visibility: boolean
4613 @ivar useOcclusion: whether the actuator makes its parent object an occluder or not
4614 @type useOcclusion: boolean
4615 @ivar useRecursion: whether the visibility/occlusion should be propagated to all children of the object
4616 @type useRecursion: boolean
4617 """
4618
4620 """
4621 Sets whether the actuator makes its parent object visible or invisible.
4622
4623 @deprecated: Use the L{visibility} attribute instead.
4624 @param visible: - True: Makes its parent visible.
4625 - False: Makes its parent invisible.
4626 """
4627
4628
4630 """
4631 Create, enable and disable 2D filters
4632
4633 Properties:
4634
4635 The following properties don't have an immediate effect.
4636 You must active the actuator to get the result.
4637 The actuator is not persistent: it automatically stops itself after setting up the filter
4638 but the filter remains active. To stop a filter you must activate the actuator with 'type'
4639 set to RAS_2DFILTER_DISABLED or RAS_2DFILTER_NOFILTER.
4640
4641 @ivar shaderText: shader source code for custom shader
4642 @type shaderText: string
4643 @ivar disableMotionBlur: action on motion blur: 0=enable, 1=disable
4644 @type disableMotionBlur: integer
4645 @ivar mode: type of 2D filter, use one of the following constants:
4646 RAS_2DFILTER_ENABLED (-2) : enable the filter that was previously disabled
4647 RAS_2DFILTER_DISABLED (-1) : disable the filter that is currently active
4648 RAS_2DFILTER_NOFILTER (0) : disable and destroy the filter that is currently active
4649 RAS_2DFILTER_MOTIONBLUR (1) : create and enable preset filters
4650 RAS_2DFILTER_BLUR (2)
4651 RAS_2DFILTER_SHARPEN (3)
4652 RAS_2DFILTER_DILATION (4)
4653 RAS_2DFILTER_EROSION (5)
4654 RAS_2DFILTER_LAPLACIAN (6)
4655 RAS_2DFILTER_SOBEL (7)
4656 RAS_2DFILTER_PREWITT (8)
4657 RAS_2DFILTER_GRAYSCALE (9)
4658 RAS_2DFILTER_SEPIA (10)
4659 RAS_2DFILTER_INVERT (11)
4660 RAS_2DFILTER_CUSTOMFILTER (12) : customer filter, the code code is set via shaderText property
4661 @type mode: integer
4662 @ivar passNumber: order number of filter in the stack of 2D filters. Filters are executed in increasing order of passNb.
4663 Only be one filter can be defined per passNb.
4664 @type passNumber: integer (0-100)
4665 @ivar value: argument for motion blur filter
4666 @type value: float (0.0-100.0)
4667 """
4668
4670 """
4671 An AND controller activates only when all linked sensors are activated.
4672
4673 There are no special python methods for this controller.
4674 """
4675
4677 """
4678 Actuator sensor detect change in actuator state of the parent object.
4679 It generates a positive pulse if the corresponding actuator is activated
4680 and a negative pulse if the actuator is deactivated.
4681
4682 Properties:
4683
4684 @ivar actuator: the name of the actuator that the sensor is monitoring.
4685 @type actuator: string
4686 """
4687
4689 """
4690 Return the Actuator with which the sensor operates.
4691
4692 @deprecated: Use the L{actuator} attribute instead.
4693 @rtype: string
4694 """
4696 """
4697 Sets the Actuator with which to operate. If there is no Actuator
4698 of this name, the function has no effect.
4699
4700 @deprecated: Use the L{actuator} attribute instead.
4701 @param name: actuator name
4702 @type name: string
4703 """
4704
4705
4707 """
4708 This sensor is always activated.
4709 """
4710
4712 """
4713 The Delay sensor generates positive and negative triggers at precise time,
4714 expressed in number of frames. The delay parameter defines the length
4715 of the initial OFF period. A positive trigger is generated at the end of this period.
4716 The duration parameter defines the length of the ON period following the OFF period.
4717 There is a negative trigger at the end of the ON period. If duration is 0, the sensor
4718 stays ON and there is no negative trigger.
4719 The sensor runs the OFF-ON cycle once unless the repeat option is set: the
4720 OFF-ON cycle repeats indefinately (or the OFF cycle if duration is 0).
4721 Use SCA_ISensor::reset() at any time to restart sensor.
4722
4723 Properties:
4724
4725 @ivar delay: length of the initial OFF period as number of frame, 0 for immediate trigger.
4726 @type delay: integer.
4727 @ivar duration: length of the ON period in number of frame after the initial OFF period.
4728 If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
4729 @type duration: integer
4730 @ivar repeat: 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
4731 @type repeat: integer
4732 """
4733
4735 """
4736 Set the initial delay before the positive trigger.
4737
4738 @deprecated: Use the L{delay} attribute instead.
4739 @param delay: length of the initial OFF period as number of frame, 0 for immediate trigger
4740 @type delay: integer
4741 """
4743 """
4744 Set the duration of the ON pulse after initial delay and the generation of the positive trigger.
4745 If duration is greater than 0, a negative trigger is sent at the end of the ON pulse.
4746
4747 @deprecated: Use the L{duration} attribute instead.
4748 @param duration: length of the ON period in number of frame after the initial OFF period
4749 @type duration: integer
4750 """
4752 """
4753 Set if the sensor repeat mode.
4754
4755 @deprecated: Use the L{repeat} attribute instead.
4756 @param repeat: 1 if the OFF-ON cycle should be repeated indefinately, 0 if it should run once.
4757 @type repeat: integer
4758 """
4760 """
4761 Return the delay parameter value.
4762
4763 @deprecated: Use the L{delay} attribute instead.
4764 @rtype: integer
4765 """
4767 """
4768 Return the duration parameter value
4769
4770 @deprecated: Use the L{duration} attribute instead.
4771 @rtype: integer
4772 """
4774 """
4775 Return the repeat parameter value
4776
4777 @deprecated: Use the L{repeat} attribute instead.
4778 @rtype: KX_TRUE or KX_FALSE
4779 """
4780
4781
4783 """
4784 This sensor detects player joystick events.
4785
4786 Properties:
4787
4788 @ivar axisValues: (read-only) The state of the joysticks axis as a list of values L{numAxis} long.
4789 each spesifying the value of an axis between -32767 and 32767 depending on how far the axis is pushed, 0 for nothing.
4790 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.
4791 left:[-32767, 0, ...], right:[32767, 0, ...], up:[0, -32767, ...], down:[0, 32767, ...]
4792 @type axisValues: list of ints
4793
4794 @ivar axisSingle: (read-only) like L{axisValues} but returns a single axis value that is set by the sensor.
4795 Only use this for "Single Axis" type sensors otherwise it will raise an error.
4796 @type axisSingle: int
4797
4798 @ivar hatValues: (read-only) The state of the joysticks hats as a list of values L{numHats} long.
4799 each spesifying the direction of the hat from 1 to 12, 0 when inactive.
4800 Hat directions are as follows...
4801 - 0:None
4802 - 1:Up
4803 - 2:Right
4804 - 4:Down
4805 - 8:Left
4806 - 3:Up - Right
4807 - 6:Down - Right
4808 - 12:Down - Left
4809 - 9:Up - Left
4810
4811 @type hatValues: list of ints
4812
4813 @ivar hatSingle: (read-only) like L{hatValues} but returns a single hat direction value that is set by the sensor.
4814 @type hatSingle: int
4815
4816 @ivar numAxis: (read-only) The number of axes for the joystick at this index.
4817 @type numAxis: integer
4818 @ivar numButtons: (read-only) The number of buttons for the joystick at this index.
4819 @type numButtons: integer
4820 @ivar numHats: (read-only) The number of hats for the joystick at this index.
4821 @type numHats: integer
4822 @ivar connected: (read-only) True if a joystick is connected at this joysticks index.
4823 @type connected: boolean
4824 @ivar index: The joystick index to use (from 0 to 7). The first joystick is always 0.
4825 @type index: integer
4826 @ivar threshold: Axis threshold. Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
4827 @type threshold: integer
4828 @ivar button: The button index the sensor reacts to (first button = 0). When the "All Events" toggle is set, this option has no effect.
4829 @type button: integer
4830 @ivar axis: The axis this sensor reacts to, as a list of two values [axisIndex, axisDirection]
4831 axisIndex: the axis index to use when detecting axis movement, 1=primary directional control, 2=secondary directional control.
4832 axisDirection: 0=right, 1=up, 2=left, 3=down
4833 @type axis: [integer, integer]
4834 @ivar hat: The hat the sensor reacts to, as a list of two values: [hatIndex, hatDirection]
4835 hatIndex: the hat index to use when detecting hat movement, 1=primary hat, 2=secondary hat (4 max).
4836 hatDirection: 1-12
4837 @type hat: [integer, integer]
4838 """
4839
4852
4854 """
4855 Returns the joystick index to use (from 1 to 8).
4856
4857 @deprecated: Use the L{index} attribute instead.
4858 @rtype: integer
4859 """
4861 """
4862 Sets the joystick index to use.
4863
4864 @deprecated: Use the L{index} attribute instead.
4865 @param index: The index of this joystick sensor, Clamped between 1 and 8.
4866 @type index: integer
4867 @note: This is only useful when you have more then 1 joystick connected to your computer - multiplayer games.
4868 """
4870 """
4871 Returns the current axis this sensor reacts to. See L{getAxisValue()<SCA_JoystickSensor.getAxisValue>} for the current axis state.
4872
4873 @deprecated: Use the L{axis} attribute instead.
4874 @rtype: list
4875 @return: 2 values returned are [axisIndex, axisDirection] - see L{setAxis()<SCA_JoystickSensor.setAxis>} for their purpose.
4876 @note: When the "All Events" toggle is set, this option has no effect.
4877 """
4878 - def setAxis(axisIndex, axisDirection):
4879 """
4880 @deprecated: Use the L{axis} attribute instead.
4881 @param axisIndex: Set the axis index to use when detecting axis movement.
4882 @type axisIndex: integer from 1 to 2
4883 @param axisDirection: Set the axis direction used for detecting motion. 0:right, 1:up, 2:left, 3:down.
4884 @type axisDirection: integer from 0 to 3
4885 @note: When the "All Events" toggle is set, this option has no effect.
4886 """
4888 """
4889 Returns the state of the joysticks axis. See differs to L{getAxis()<SCA_JoystickSensor.getAxis>} returning the current state of the joystick.
4890
4891 @deprecated: Use the L{axisValues} attribute instead.
4892 @rtype: list
4893 @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.
4894
4895 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.
4896
4897 left:[-32767, 0, ...], right:[32767, 0, ...], up:[0, -32767, ...], down:[0, 32767, ...]
4898 @note: Some gamepads only set the axis on and off like a button.
4899 """
4901 """
4902 Get the axis threshold. See L{setThreshold()<SCA_JoystickSensor.setThreshold>} for details.
4903
4904 @deprecated: Use the L{threshold} attribute instead.
4905 @rtype: integer
4906 """
4908 """
4909 Set the axis threshold.
4910
4911 @deprecated: Use the L{threshold} attribute instead.
4912 @param threshold: Joystick axis motion below this threshold wont trigger an event. Use values between (0 and 32767), lower values are more sensitive.
4913 @type threshold: integer
4914 """
4938 """
4939 Returns the current hat direction this sensor is set to.
4940 [hatNumber, hatDirection].
4941
4942 @deprecated: Use the L{hat} attribute instead.
4943 @rtype: list
4944 @note: When the "All Events" toggle is set, this option has no effect.
4945 """
4946 - def setHat(index,direction):
4947 """
4948 Sets the hat index the sensor reacts to when the "All Events" option is not set.
4949
4950 @deprecated: Use the L{hat} attribute instead.
4951 @type index: integer
4952 """
4954 """
4955 Returns the number of axes for the joystick at this index.
4956
4957 @deprecated: Use the L{numAxis} attribute instead.
4958 @rtype: integer
4959 """
4968 """
4969 Returns the number of hats for the joystick at this index.
4970
4971 @deprecated: Use the L{numHats} attribute instead.
4972 @rtype: integer
4973 """
4975 """
4976 Returns True if a joystick is detected at this joysticks index.
4977
4978 @deprecated: Use the L{connected} attribute instead.
4979 @rtype: bool
4980 """
4981
4982
4984 """
4985 A keyboard sensor detects player key presses.
4986
4987 See module L{GameKeys} for keycode values.
4988
4989 @ivar key: The key code this sensor is looking for.
4990 @type key: keycode from L{GameKeys} module
4991 @ivar hold1: The key code for the first modifier this sensor is looking for.
4992 @type hold1: keycode from L{GameKeys} module
4993 @ivar hold2: The key code for the second modifier this sensor is looking for.
4994 @type hold2: keycode from L{GameKeys} module
4995 @ivar toggleProperty: The name of the property that indicates whether or not to log keystrokes as a string.
4996 @type toggleProperty: string
4997 @ivar targetProperty: The name of the property that receives keystrokes in case in case a string is logged.
4998 @type targetProperty: string
4999 @ivar useAllKeys: Flag to determine whether or not to accept all keys.
5000 @type useAllKeys: boolean
5001 @ivar events: a list of pressed keys that have either been pressed, or just released, or are active this frame. (read-only).
5002
5003 - 'keycode' matches the values in L{GameKeys}.
5004 - 'status' uses...
5005 - L{GameLogic.KX_INPUT_NONE}
5006 - L{GameLogic.KX_INPUT_JUST_ACTIVATED}
5007 - L{GameLogic.KX_INPUT_ACTIVE}
5008 - L{GameLogic.KX_INPUT_JUST_RELEASED}
5009
5010 @type events: list [[keycode, status], ...]
5011 """
5012
5014 """
5015 Get the status of a key.
5016
5017 @rtype: key state L{GameLogic} members (KX_INPUT_NONE, KX_INPUT_JUST_ACTIVATED, KX_INPUT_ACTIVE, KX_INPUT_JUST_RELEASED)
5018 @return: The state of the given key
5019 @type keycode: integer
5020 @param keycode: The code that represents the key you want to get the state of
5021 """
5022
5023
5025 """
5026 Returns the key code this sensor is looking for.
5027
5028 @deprecated: Use the L{key} attribute instead.
5029 @rtype: keycode from L{GameKeys} module
5030 """
5031
5033 """
5034 Set the key this sensor should listen for.
5035
5036 @deprecated: Use the L{key} attribute instead.
5037 @type keycode: keycode from L{GameKeys} module
5038 """
5039
5041 """
5042 Returns the key code for the first modifier this sensor is looking for.
5043
5044 @deprecated: Use the L{hold1} attribute instead.
5045 @rtype: keycode from L{GameKeys} module
5046 """
5047
5049 """
5050 Sets the key code for the first modifier this sensor should look for.
5051
5052 @deprecated: Use the L{hold1} attribute instead.
5053 @type keycode: keycode from L{GameKeys} module
5054 """
5055
5057 """
5058 Returns the key code for the second modifier this sensor is looking for.
5059
5060 @deprecated: Use the L{hold2} attribute instead.
5061 @rtype: keycode from L{GameKeys} module
5062 """
5063
5065 """
5066 Sets the key code for the second modifier this sensor should look for.
5067
5068 @deprecated: Use the L{hold2} attribute instead.
5069 @type keycode: keycode from L{GameKeys} module
5070 """
5071
5073 """
5074 Get a list of keys that have either been pressed, or just released this frame.
5075
5076 @deprecated: Use the L{events} attribute instead.
5077 @rtype: list of key status. [[keycode, status]]
5078 """
5079
5081 """
5082 Get a list of currently pressed keys that have either been pressed, or just released
5083
5084 @deprecated: Use the L{events} attribute instead.
5085 @rtype: list of key status. [[keycode, status]]
5086 """
5087
5088
5090 """
5091 An NAND controller activates when all linked sensors are not active.
5092
5093 There are no special python methods for this controller.
5094 """
5095
5097 """
5098 An NOR controller activates only when all linked sensors are de-activated.
5099
5100 There are no special python methods for this controller.
5101 """
5102
5104 """
5105 An OR controller activates when any connected sensor activates.
5106
5107 There are no special python methods for this controller.
5108 """
5109
5111 """
5112 Property Actuator
5113
5114 Properties:
5115
5116 @ivar propName: the property on which to operate.
5117 @type propName: string
5118 @ivar value: the value with which the actuator operates.
5119 @type value: string
5120 @ivar mode: TODO - add constants to game logic dict!.
5121 @type mode: int
5122 """
5123
5125 """
5126 Set the property on which to operate.
5127
5128 If there is no property of this name, the call is ignored.
5129
5130 @deprecated: Use the L{propName} attribute instead.
5131 @type prop: string
5132 @param prop: The name of the property to set.
5133 """
5135 """
5136 Returns the name of the property on which to operate.
5137
5138 @deprecated: Use the L{propName} attribute instead.
5139 @rtype: string
5140 """
5142 """
5143 Set the value with which the actuator operates.
5144
5145 If the value is not compatible with the type of the
5146 property, the subsequent action is ignored.
5147
5148 @deprecated: Use the L{value} attribute instead.
5149 @type value: string
5150 """
5152 """
5153 Gets the value with which this actuator operates.
5154
5155 @deprecated: Use the L{value} attribute instead.
5156 @rtype: string
5157 """
5158
5159
5161 """
5162 Activates when the game object property matches.
5163
5164 Properties:
5165
5166 @ivar mode: type of check on the property:
5167 KX_PROPSENSOR_EQUAL(1), KX_PROPSENSOR_NOTEQUAL(2), KX_PROPSENSOR_INTERVAL(3),
5168 KX_PROPSENSOR_CHANGED(4), KX_PROPSENSOR_EXPRESSION(5)
5169 @type mode: integer
5170 @ivar propName: the property the sensor operates.
5171 @type propName: string
5172 @ivar value: the value with which the sensor compares to the value of the property.
5173 @type value: string
5174 """
5175
5177 """
5178 Gets when to activate this sensor.
5179
5180 @deprecated: Use the L{mode} attribute instead.
5181 @return: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
5182 KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED,
5183 or KX_PROPSENSOR_EXPRESSION.
5184 """
5185
5187 """
5188 Set the type of check to perform.
5189
5190 @deprecated: Use the L{mode} attribute instead.
5191 @type checktype: KX_PROPSENSOR_EQUAL, KX_PROPSENSOR_NOTEQUAL,
5192 KX_PROPSENSOR_INTERVAL, KX_PROPSENSOR_CHANGED,
5193 or KX_PROPSENSOR_EXPRESSION.
5194 """
5195
5197 """
5198 Return the property with which the sensor operates.
5199
5200 @deprecated: Use the L{propName} attribute instead.
5201 @rtype: string
5202 @return: the name of the property this sensor is watching.
5203 """
5205 """
5206 Sets the property with which to operate. If there is no property
5207 of that name, this call is ignored.
5208
5209 @deprecated: Use the L{propName} attribute instead.
5210 @type name: string.
5211 """
5213 """
5214 Return the value with which the sensor compares to the value of the property.
5215
5216 @deprecated: Use the L{value} attribute instead.
5217 @rtype: string
5218 @return: the value of the property this sensor is watching.
5219 """
5221 """
5222 Set the value with which the sensor operates. If the value
5223 is not compatible with the type of the property, the subsequent
5224 action is ignored.
5225
5226 @deprecated: Use the L{value} attribute instead.
5227 @type value: string
5228 """
5229
5230
5232 """
5233 A Python controller uses a Python script to activate it's actuators,
5234 based on it's sensors.
5235
5236 Properties:
5237
5238 @ivar script: The value of this variable depends on the execution methid.
5239 - When 'Script' execution mode is set this value contains the entire python script as a single string (not the script name as you might expect) which can be modified to run different scripts.
5240 - When 'Module' execution mode is set this value will contain a single line string - module name and function "module.func" or "package.modile.func" where the module names are python textblocks or external scripts.
5241 note: once this is set the script name given for warnings will remain unchanged.
5242 @type script: string
5243 @ivar mode: the execution mode for this controller (read-only).
5244 - Script: 0, Execite the L{script} as a python code.
5245 - Module: 1, Execite the L{script} as a module and function.
5246 @type mode: int
5247
5248 @group Deprecated: getScript, setScript
5249 """
5251 """
5252 Activates an actuator attached to this controller.
5253 @type actuator: actuator or the actuator name as a string
5254 """
5256 """
5257 Deactivates an actuator attached to this controller.
5258 @type actuator: actuator or the actuator name as a string
5259 """
5261 """
5262 Gets the Python script body this controller executes.
5263
5264 @deprecated: Use the L{script} attribute instead.
5265 @rtype: string
5266 """
5268 """
5269 Sets the Python script string this controller executes.
5270
5271 @deprecated: Use the L{script} attribute instead.
5272 @type script_body: string.
5273 """
5274
5276 """
5277 Random Actuator
5278
5279 Properties:
5280
5281 @ivar seed: Seed of the random number generator.
5282 Equal seeds produce equal series. If the seed is 0,
5283 the generator will produce the same value on every call.
5284 @type seed: integer
5285 @ivar para1: the first parameter of the active distribution.
5286 Refer to the documentation of the generator types for the meaning
5287 of this value.
5288 @type para1: float, read-only
5289 @ivar para2: the second parameter of the active distribution.
5290 Refer to the documentation of the generator types for the meaning
5291 of this value.
5292 @type para2: float, read-only
5293 @ivar distribution: distribution type:
5294 KX_RANDOMACT_BOOL_CONST, KX_RANDOMACT_BOOL_UNIFORM, KX_RANDOMACT_BOOL_BERNOUILLI,
5295 KX_RANDOMACT_INT_CONST, KX_RANDOMACT_INT_UNIFORM, KX_RANDOMACT_INT_POISSON,
5296 KX_RANDOMACT_FLOAT_CONST, KX_RANDOMACT_FLOAT_UNIFORM, KX_RANDOMACT_FLOAT_NORMAL,
5297 KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
5298 @type distribution: integer, read-only
5299 @ivar propName: the name of the property to set with the random value.
5300 If the generator and property types do not match, the assignment is ignored.
5301 @type propName: string
5302
5303 """
5305 """
5306 Sets this generator to produce a constant boolean value.
5307
5308 @param value: The value to return.
5309 @type value: boolean
5310 """
5318 """
5319 Sets this generator to produce a Bernouilli distribution.
5320
5321 @param value: Specifies the proportion of False values to produce.
5322 - 0.0: Always generate True
5323 - 1.0: Always generate False
5324 @type value: float
5325 """
5327 """
5328 Sets this generator to always produce the given value.
5329
5330 @param value: the value this generator produces.
5331 @type value: integer
5332 """
5342 """
5343 Generate a Poisson-distributed number.
5344
5345 This performs a series of Bernouilli tests with parameter value.
5346 It returns the number of tries needed to achieve succes.
5347
5348 @type value: float
5349 """
5351 """
5352 Always generate the given value.
5353
5354 @type value: float
5355 """
5365 """
5366 Generates a random float from the given normal distribution.
5367
5368 @type mean: float
5369 @param mean: The mean (average) value of the generated numbers
5370 @type standard_deviation: float
5371 @param standard_deviation: The standard deviation of the generated numbers.
5372 """
5374 """
5375 Generate negative-exponentially distributed numbers.
5376
5377 The half-life 'time' is characterized by half_life.
5378
5379 @type half_life: float
5380 """
5381
5383 """
5384 Sets the seed of the random number generator.
5385
5386 Equal seeds produce equal series. If the seed is 0,
5387 the generator will produce the same value on every call.
5388
5389 @deprecated: Use the L{seed} attribute instead.
5390 @type seed: integer
5391 """
5393 """
5394 Returns the initial seed of the generator.
5395
5396 @deprecated: Use the L{seed} attribute instead.
5397 @rtype: integer
5398 """
5400 """
5401 Returns the first parameter of the active distribution.
5402
5403 Refer to the documentation of the generator types for the meaning
5404 of this value.
5405
5406 @deprecated: Use the L{para1} attribute instead.
5407 @rtype: float
5408 """
5410 """
5411 Returns the second parameter of the active distribution.
5412
5413 Refer to the documentation of the generator types for the meaning
5414 of this value.
5415
5416 @deprecated: Use the L{para2} attribute instead.
5417 @rtype: float
5418 """
5420 """
5421 Returns the type of random distribution.
5422
5423 @deprecated: Use the L{distribution} attribute instead.
5424 @rtype: distribution type
5425 @return: KX_RANDOMACT_BOOL_CONST, KX_RANDOMACT_BOOL_UNIFORM, KX_RANDOMACT_BOOL_BERNOUILLI,
5426 KX_RANDOMACT_INT_CONST, KX_RANDOMACT_INT_UNIFORM, KX_RANDOMACT_INT_POISSON,
5427 KX_RANDOMACT_FLOAT_CONST, KX_RANDOMACT_FLOAT_UNIFORM, KX_RANDOMACT_FLOAT_NORMAL,
5428 KX_RANDOMACT_FLOAT_NEGATIVE_EXPONENTIAL
5429 """
5431 """
5432 Set the property to which the random value is assigned.
5433
5434 If the generator and property types do not match, the assignment is ignored.
5435
5436 @deprecated: Use the L{propName} attribute instead.
5437 @type property: string
5438 @param property: The name of the property to set.
5439 """
5441 """
5442 Returns the name of the property to set.
5443
5444 @deprecated: Use the L{propName} attribute instead.
5445 @rtype: string
5446 """
5447
5448
5449
5451 """
5452 This sensor activates randomly.
5453
5454 @ivar lastDraw: The seed of the random number generator.
5455 @type lastDraw: int
5456 @ivar seed: The seed of the random number generator.
5457 @type seed: int
5458 """
5459
5461 """
5462 Sets the seed of the random number generator.
5463
5464 If the seed is 0, the generator will produce the same value on every call.
5465
5466 @type seed: integer.
5467 """
5469 """
5470 Returns the initial seed of the generator. Equal seeds produce equal random
5471 series.
5472
5473 @rtype: integer
5474 """
5476 """
5477 Returns the last random number generated.
5478
5479 @rtype: integer
5480 """
5481
5483 """
5484 An XNOR controller activates when all linked sensors are the same (activated or inative).
5485
5486 There are no special python methods for this controller.
5487 """
5488
5490 """
5491 An XOR controller activates when there is the input is mixed, but not when all are on or off.
5492
5493 There are no special python methods for this controller.
5494 """
5495
5497 """
5498 A Camera object.
5499
5500 @group Constants: INSIDE, INTERSECT, OUTSIDE
5501 @ivar INSIDE: see sphereInsideFrustum() and boxInsideFrustum()
5502 @ivar INTERSECT: see sphereInsideFrustum() and boxInsideFrustum()
5503 @ivar OUTSIDE: see sphereInsideFrustum() and boxInsideFrustum()
5504
5505 @ivar lens: The camera's lens value.
5506 @type lens: float
5507 @ivar near: The camera's near clip distance.
5508 @type near: float
5509 @ivar far: The camera's far clip distance.
5510 @type far: float
5511 @ivar perspective: True if this camera has a perspective transform, False for an orthographic projection.
5512 @type perspective: boolean
5513 @ivar frustum_culling: True if this camera is frustum culling.
5514 @type frustum_culling: boolean
5515 @ivar projection_matrix: This camera's 4x4 projection matrix.
5516 @type projection_matrix: 4x4 Matrix [[float]]
5517 @ivar modelview_matrix: This camera's 4x4 model view matrix. (read-only)
5518 Regenerated every frame from the camera's position and orientation.
5519 @type modelview_matrix: 4x4 Matrix [[float]]
5520 @ivar camera_to_world: This camera's camera to world transform. (read-only)
5521 Regenerated every frame from the camera's position and orientation.
5522 @type camera_to_world: 4x4 Matrix [[float]]
5523 @ivar world_to_camera: This camera's world to camera transform. (read-only)
5524 Regenerated every frame from the camera's position and orientation.
5525 This is camera_to_world inverted.
5526 @type world_to_camera: 4x4 Matrix [[float]]
5527 @ivar useViewport: True when the camera is used as a viewport, set True to enable a viewport for this camera.
5528 @type useViewport: bool
5529
5530 @group Deprecated: enableViewport, getProjectionMatrix, setProjectionMatrix
5531 """
5532
5534 """
5535 Tests the given sphere against the view frustum.
5536
5537 @note: when the camera is first initialized the result will be invalid because the projection matrix has not been set.
5538 @param centre: The centre of the sphere (in world coordinates.)
5539 @type centre: list [x, y, z]
5540 @param radius: the radius of the sphere
5541 @type radius: float
5542 @return: INSIDE, OUTSIDE or INTERSECT
5543
5544 Example::
5545 import GameLogic
5546 co = GameLogic.getCurrentController()
5547 cam = co.owner
5548
5549 # A sphere of radius 4.0 located at [x, y, z] = [1.0, 1.0, 1.0]
5550 if (cam.sphereInsideFrustum([1.0, 1.0, 1.0], 4) != cam.OUTSIDE):
5551 # Sphere is inside frustum !
5552 # Do something useful !
5553 else:
5554 # Sphere is outside frustum
5555 """
5557 """
5558 Tests the given box against the view frustum.
5559
5560 Example::
5561 import GameLogic
5562 co = GameLogic.getCurrentController()
5563 cam = co.owner
5564
5565 # Box to test...
5566 box = []
5567 box.append([-1.0, -1.0, -1.0])
5568 box.append([-1.0, -1.0, 1.0])
5569 box.append([-1.0, 1.0, -1.0])
5570 box.append([-1.0, 1.0, 1.0])
5571 box.append([ 1.0, -1.0, -1.0])
5572 box.append([ 1.0, -1.0, 1.0])
5573 box.append([ 1.0, 1.0, -1.0])
5574 box.append([ 1.0, 1.0, 1.0])
5575
5576 if (cam.boxInsideFrustum(box) != cam.OUTSIDE):
5577 # Box is inside/intersects frustum !
5578 # Do something useful !
5579 else:
5580 # Box is outside the frustum !
5581
5582 @note: when the camera is first initialized the result will be invalid because the projection matrix has not been set.
5583 @return: INSIDE, OUTSIDE or INTERSECT
5584 @type box: list
5585 @param box: Eight (8) corner points of the box (in world coordinates.)
5586 """
5588 """
5589 Tests the given point against the view frustum.
5590
5591 Example::
5592 import GameLogic
5593 co = GameLogic.getCurrentController()
5594 cam = co.owner
5595
5596 # Test point [0.0, 0.0, 0.0]
5597 if (cam.pointInsideFrustum([0.0, 0.0, 0.0])):
5598 # Point is inside frustum !
5599 # Do something useful !
5600 else:
5601 # Box is outside the frustum !
5602
5603 @note: when the camera is first initialized the result will be invalid because the projection matrix has not been set.
5604 @rtype: boolean
5605 @return: True if the given point is inside this camera's viewing frustum.
5606 @type point: [x, y, z]
5607 @param point: The point to test (in world coordinates.)
5608 """
5610 """
5611 Returns the camera-to-world transform.
5612
5613 @rtype: matrix (4x4 list)
5614 @return: the camera-to-world transform matrix.
5615 """
5617 """
5618 Returns the world-to-camera transform.
5619
5620 This returns the inverse matrix of getCameraToWorld().
5621
5622 @rtype: matrix (4x4 list)
5623 @return: the world-to-camera transform matrix.
5624 """
5626 """
5627 Returns the camera's projection matrix.
5628
5629 @deprecated: Use the L{projection_matrix} attribute instead.
5630 @rtype: matrix (4x4 list)
5631 @return: the camera's projection matrix.
5632 """
5634 """
5635 Sets the camera's projection matrix.
5636
5637 You should use normalised device coordinates for the clipping planes:
5638 left = -1.0, right = 1.0, top = 1.0, bottom = -1.0, near = cam.near, far = cam.far
5639
5640 Example::
5641 import GameLogic
5642
5643 def Scale(matrix, size):
5644 for y in range(4):
5645 for x in range(4):
5646 matrix[y][x] = matrix[y][x] * size[y]
5647 return matrix
5648
5649 # Generate a perspective projection matrix
5650 def Perspective(cam):
5651 return [[cam.near, 0.0 , 0.0 , 0.0 ],
5652 [0.0 , cam.near, 0.0 , 0.0 ],
5653 [0.0 , 0.0 , -(cam.far+cam.near)/(cam.far-cam.near), -2.0*cam.far*cam.near/(cam.far - cam.near)],
5654 [0.0 , 0.0 , -1.0 , 0.0 ]]
5655
5656 # Generate an orthographic projection matrix
5657 # You will need to scale the camera
5658 def Orthographic(cam):
5659 return [[1.0/cam.scaling[0], 0.0 , 0.0 , 0.0 ],
5660 [0.0 , 1.0/cam.scaling[1], 0.0 , 0.0 ],
5661 [0.0 , 0.0 , -2.0/(cam.far-cam.near), -(cam.far+cam.near)/(cam.far-cam.near)],
5662 [0.0 , 0.0 , 0.0 , 1.0 ]]
5663
5664 # Generate an isometric projection matrix
5665 def Isometric(cam):
5666 return Scale([[0.707, 0.0 , 0.707, 0.0],
5667 [0.408, 0.816,-0.408, 0.0],
5668 [0.0 , 0.0 , 0.0 , 0.0],
5669 [0.0 , 0.0 , 0.0 , 1.0]],
5670 [1.0/cam.scaling[0], 1.0/cam.scaling[1], 1.0/cam.scaling[2], 1.0])
5671
5672 co = GameLogic.getCurrentController()
5673 cam = co.owner
5674 cam.setProjectionMatrix(Perspective(cam)))
5675
5676 @deprecated: Use the L{projection_matrix} attribute instead.
5677 @type matrix: 4x4 matrix.
5678 @param matrix: The new projection matrix for this camera.
5679 """
5680
5682 """
5683 Use this camera to draw a viewport on the screen (for split screen games or overlay scenes). The viewport region is defined with L{setViewport}.
5684
5685 @deprecated: Use the L{useViewport} attribute instead.
5686 @type viewport: bool
5687 @param viewport: the new viewport status
5688 """
5690 """
5691 Set this cameras viewport ontop of all other viewport.
5692 """
5694 """
5695 Sets the region of this viewport on the screen in pixels.
5696
5697 Use L{Rasterizer.getWindowHeight} L{Rasterizer.getWindowWidth} to calculate values relative to the entire display.
5698
5699 @type left: int
5700 @type bottom: int
5701 @type right: int
5702 @type top: int
5703 """
5705 """
5706 Gets the position of an object projected on screen space.
5707
5708 Example:
5709 # For an object in the middle of the screen, coord = [0.5,0.5]
5710 coord = camera.getScreenPosition(object)
5711
5712 @param arg: L{KX_GameObject}, object name or list [x, y, z]
5713 @rtype: list [x, y]
5714 @return: the object's position in screen coordinates.
5715 """
5717 """
5718 Gets the vector from the camera position in the screen coordinate direction.
5719
5720 Example:
5721 # Gets the vector of the camera front direction:
5722 m_vect = camera.getScreenVect(0.5,0.5)
5723
5724 @type x: float
5725 @type y: float
5726 @rtype: 3d vector
5727 @return: the vector from a screen coordinate.
5728 """
5730 """
5731 Look towards a screen coordinate (x,y) and find first object hit within dist that matches prop.
5732 The ray is similar to KX_GameObject->rayCastTo.
5733
5734 Example:
5735 # Gets an object with a property "wall" in front of the camera within a distance of 100:
5736 target = camera.getScreenRay(0.5,0.5,100,"wall")
5737
5738 @type x: float
5739 @type y: float
5740 @param dist: max distance to look (can be negative => look behind); 0 or omitted => detect up to other
5741 @type dist: float
5742 @param property: property name that object must have; can be omitted => detect any object
5743 @type property: string
5744 @rtype: L{KX_GameObject}
5745 @return: the first object hit or None if no object or object does not match prop
5746 """
5747
5748
5749 """
5750 import types
5751 attrs = []
5752 for name, val in locals().items():
5753 if name.startswith('__'):
5754 continue
5755 if type(val) == types.ClassType:
5756 for line in val.__doc__.split('\n'):
5757 if '@ivar' in line:
5758 attrs.append(name + '::' + line.split()[1].replace(':', ''))
5759
5760 for a in attrs:
5761 print a
5762 """
5763
5764
5765
5766 """
5767 import types
5768 import re
5769 import pprint
5770 depAttrs = {}
5771 for name, val in locals().items():
5772 if name.startswith('__'):
5773 continue
5774 if type(val) == types.ClassType:
5775 print "\t# %s" % name
5776
5777 # Inspect each attribute.
5778 for attrName in dir(val):
5779 if attrName.startswith('__'):
5780 continue
5781 attr = getattr(val, attrName)
5782
5783 # Check whether this attribute is deprecated by searching each line.
5784 newAttrName = None
5785 for line in attr.__doc__.split('\n'):
5786 match = re.search(r'@deprecated.*L{(\w+)}', line)
5787 if match:
5788 newAttrName = match.group(1)
5789 break
5790 if not newAttrName:
5791 continue
5792
5793 # Store the mappings to new attributes in a list (because there
5794 # could be collisions).
5795 if not depAttrs.has_key(attrName):
5796 depAttrs[attrName] = {}
5797 mapping = depAttrs[attrName]
5798
5799 for line in val.__doc__.split('\n'):
5800 if ("@type %s:" % newAttrName) in line:
5801 # The attribute is being replaced in this class (i.e. the
5802 # deprecated attribute wasn't inherited from a parent). We
5803 # have a winner!
5804 funcType = None
5805 if 'sequence' in line:
5806 funcType = 'Keyed'
5807 else:
5808 funcType = 'Simple'
5809
5810 if attrName.startswith('get') or attrName.startswith('is'):
5811 func = "replace%sGetter" % funcType
5812 elif attrName.startswith('set') or attrName.startswith('enable'):
5813 func = "replace%sSetter" % funcType
5814 else:
5815 func = 'UNKNOWN'
5816
5817 # Another mapping, from a conversion tuple to lists of class
5818 # names.
5819 conversion = (func, newAttrName)
5820 if not mapping.has_key(conversion):
5821 mapping[conversion] = []
5822 mapping[conversion].append(name)
5823 break
5824
5825 pprint.pprint(depAttrs, width = 100)
5826 """
5827