Commit Graph

642 Commits

Author SHA1 Message Date
Benoit Bolsee
572f1d88d2 BGE bug fix (good for 2.47): automatic detection that target object of AddObject actuator is being deleted to avoid crash (bad game design anyway) 2008-07-12 12:10:27 +00:00
Hamed Zaghaghi
a49c9c458a improvement of 2d-filter custom shader,
some bugfixes,
now you can use depth buffer and luminance buffer without any settings,
also you can use object's properties in a shader
2008-07-12 10:21:37 +00:00
Campbell Barton
310a37c29c Adding an option for action actuator - "Continue" this means animations always play from where they left off. Continue was the 2.46 operation too, so new functionality is the option to disable.
When using states, an action like kick or throw can often switch out before finishing playing the action, and there was no way to play from the start frame the second time round. (even setting the actions current frame through python doesn't work work)
2008-07-10 14:23:19 +00:00
Brecht Van Lommel
99fdf27af9 Sync with Apricot Game Engine
=============================

* Clean up and optimizations in skinned/deformed mesh code.
* Compatibility fixes and clean up in the rasterizer.
* Changes related to GLSL shadow buffers which should have no
  effect, to keep the code in sync with apricot.
2008-07-10 12:47:20 +00:00
Campbell Barton
732d886e0a bugfix, vector was not checked for zero length before normalizing, closing blender instantly with an assert. 2008-07-09 15:30:15 +00:00
Campbell Barton
60d099648c added a factor argument for aligning to vector, this isn't correct since it does linear interpolation of the vector and renormalizes.
(can be improved to rotate correctly but for our  use ist ok for now, would also be useful to have an argument to clamp the maximum rotation angle to get a constant rotation speed),

This will used to make franky upright when falling from an angle, to track to a surface when hanging onto a ledge and setting the glide pitch.
Without this rotation is instant and jerky.

currently this is done with Mathutils which isnt available in Blender Player.

def do_rotate_up(own):
	own.alignAxisToVect([0,0,1], 2, 0.1)

replaces...

def do_rotate_up(own):
	up_nor = Vector(0,0,1)
	own_mat = Matrix(*own.getOrientation()).transpose()
	own_up = up_nor * own_mat
	ang = AngleBetweenVecs(own_up, up_nor)
	if ang > 0.005:
		# Set orientation
		cross = CrossVecs(own_up, up_nor)
		new_mat = own_mat * RotationMatrix(ang*0.1, 3, 'r', cross)
		own.setOrientation(new_mat.transpose())


M    source/gameengine/Ketsji/KX_GameObject.cpp
M    source/gameengine/Ketsji/KX_GameObject.h
2008-07-09 09:21:52 +00:00
Campbell Barton
e279fc4a81 fix for crasher with touch sensor, ben you may want to look at this, should be ok since the ray sensor does NULL checks in for getNewClientInfo in a similar area. 2008-07-08 22:43:44 +00:00
Campbell Barton
bbf1ce2762 bugfix - GameEngine PyObject methods did not all return when using dir(), because inherited methods were ignored, This made it incredibly annoying, not only having to search a C++ file to see what functions were available. but looking up methods inherited from other C++ classes.
There is still no __members__ attribute so dir() wont work at all for attributes.
2008-07-08 17:57:31 +00:00
Benoit Bolsee
d1fd99b070 BGE logic patch: new "Add" mode for Ipo actuator, several corrections in state system.
New Add mode for Ipo actuator
=============================
A new Add button, mutually exclusive with Force button, is available in
the Ipo actuator. When selected, it activates the Add mode that consists
in adding the Ipo curve to the current object situation in world
coordinates, or parent coordinates if the object has a parent. Scale Ipo
curves are multiplied instead of added to the object current scale.
If the local flag is selected, the Ipo curve is added (multiplied) in 
the object's local coordinates. 
Delta Ipo curves are handled identically to normal Ipo curve and there 
is no need to work with Delta Ipo curves provided that you make sure 
that the Ipo curve starts from origin. Origin means location 0 for 
Location Ipo curve, rotation 0 for Rotation Ipo curve and scale 1 for 
Scale Ipo curve.

The "current object situation" means the object's location, rotation 
and scale at the start of the Ipo curve. For Loop Stop and Loop End Ipo 
actuators, this means at the start of each loop. This initial state is
used as a base during the execution of the Ipo Curve but when the Ipo 
curve is restarted (later or immediately in case of Loop mode), the  
object current situation at that time is used as the new base.

For reference, here is the exact operation of the Add mode for each
type of Ipo curve (oLoc, oRot, oScale, oMat: object's loc/rot/scale
and orientation matrix at the start of the curve; iLoc, iRot, iScale,
iMat: Ipo curve loc/rot/scale and orientation matrix resulting from
the rotation).

Location
  Local=false: newLoc = oLoc+iLoc
  Local=true : newLoc = oLoc+oScale*(oMat*iLoc)
Rotation
  Local=false: newMat = iMat*oMat
  Local=true : newMat = oMat*iMat
Scale
  Local=false: newScale = oScale*iScale
  Local=true : newScale = oScale*iScale

Add+Local mode is very useful to have dynamic object executing complex
movement relative to their current location/orientation. Of cource, 
dynamics should be disabled during the execution of the curve.

Several corrections in state system
===================================
- Object initial state is taken into account when adding object
  dynamically
- Fix bug with link count when adding object dynamically
- Fix false on-off detection for Actuator sensor when actuator is
  trigged on negative event.
- Fix Parent actuator false activation on negative event
- Loop Ipo curve not restarting at correct frame when start frame is
  different from one.
2008-07-08 12:18:43 +00:00
Campbell Barton
8a729824f4 GameObject rayCast and rayCastTo were not setting exception strings (causes return without exception set error)
Also made game state buttons only have a dot in states that have controllers in them.
2008-07-06 14:11:30 +00:00
Andrea Weikert
0bdfc6a953 == BUGFIX ==
- fix crash when exiting game engine (with ESC-key).
- reason for crash: std::vector iterator is invalid after vector::erase
2008-07-04 20:24:15 +00:00
Campbell Barton
107b78a3d2 Made some python game engine funcs use NOARGS, getAxisVec was using wrong multiplication order.
Use BUT_TOGDUAL for controllers init states so you can see what the init state is for any controller without using the button to check.
2008-07-04 19:00:56 +00:00
Benoit Bolsee
70d239ef7d BGE logic update: new servo control motion actuator, new distance constraint actuator, new orientation constraint actuator, new actuator sensor.
General
=======
- Removal of Damp option in motion actuator (replaced by
  Servo control motion).
- No PyDoc at present, will be added soon.

Generalization of the Lvl option
================================
A sensor with the Lvl option selected will always produce an 
event at the start of the game or when entering a state or at 
object creation. The event will be positive or negative 
depending of the sensor condition. A negative pulse makes
sense when used with a NAND controller: it will be converted
into an actuator activation.

Servo control motion
====================
A new variant of the motion actuator allows to control speed 
with force. The control if of type "PID" (Propotional, Integral, 
Derivate): the force is automatically adapted to achieve the 
target speed. All the parameters of the servo controller are
configurable. The result is a great variety of motion style: 
anysotropic friction, flying, sliding, pseudo Dloc...
This actuator should be used in preference to Dloc and LinV
as it produces more fluid movements and avoids the collision 
problem with Dloc.
LinV : target speed as (X,Y,Z) vector in local or world 
       coordinates (mostly useful in local coordinates).
Limit: the force can be limited along each axis (in the same
       coordinates of LinV). No limitation means that the force
       will grow as large as necessary to achieve the target 
       speed along that axis. Set a max value to limit the 
       accelaration along an axis (slow start) and set a min
       value (negative) to limit the brake force.
P:     Proportional coefficient of servo controller, don't set
       directly unless you know what you're doing.
I:     Integral coefficient of servo controller. Use low value
       (<0.1) for slow reaction (sliding), high values (>0.5)
       for hard control. The P coefficient will be automatically
       set to 60 times the I coefficient (a reasonable value).
D:     Derivate coefficient. Leave to 0 unless you know what
       you're doing. High values create instability. 

Notes: - This actuator works perfectly in zero friction 
         environment: the PID controller will simulate friction
         by applying force as needed.
       - This actuator is compatible with simple Drot motion
         actuator but not with LinV and Dloc motion.
       - (0,0,0) is a valid target speed.
       - All parameters are accessible through Python.

Distance constraint actuator
============================
A new variant of the constraint actuator allows to set the
distance and orientation relative to a surface. The controller
uses a ray to detect the surface (or any object) and adapt the
distance and orientation parallel to the surface.
Damp:  Time constant (in nb of frames) of distance and 
       orientation control.
Dist:  Select to enable distance control and set target 
       distance. The object will be position at the given
       distance of surface along the ray direction.
Direction: chose a local axis as the ray direction.
Range: length of ray. Objecgt within this distance will be 
       detected.
N    : Select to enable orientation control. The actuator will
       change the orientation and the location of the object 
       so that it is parallel to the surface at the vertical
       of the point of contact of the ray.  
M/P  : Select to enable material detection. Default is property
       detection.
Property/Material: name of property/material that the target of
       ray must have to be detected. If not set, property/
       material filter is disabled and any collisioning object
       within range will be detected.
PER  : Select to enable persistent operation. Normally the 
       actuator disables itself automatically if the ray does
       not reach a valid target. 
time : Maximum activation time of actuator. 
       0 : unlimited.
       >0: number of frames before automatic deactivation.  
rotDamp: Time constant (in nb of frame) of orientation control.
       0 : use Damp parameter.
       >0: use a different time constant for orientation.

Notes: - If neither N nor Dist options are set, the actuator
         does not change the position and orientation of the
         object; it works as a ray sensor.
       - The ray has no "X-ray" capability: if the first object
         hit does not have the required property/material, it
         returns no hit and the actuator disables itself unless
         PER option is enabled.
       - This actuator changes the position and orientation but
         not the speed of the object. This has an important 
         implication in a gravity environment: the gravity will
         cause the speed to increase although the object seems
         to stay still (it is repositioned at each frame).
         The gravity must be compensated in one way or another.
         the new servo control motion actuator is the simplest 
         way: set the target speed along the ray axis to 0
         and the servo control will automatically compensate 
         the gravity.
       - This actuator changes the orientation of the object 
         and will conflict with Drot motion unless it is 
         placed BEFORE the Drot motion actuator (the order of 
         actuator is important)
       - All parameters are accessible through Python.

Orientation constraint 
======================
A new variant of the constraint actuator allows to align an
object axis along a global direction.
Damp : Time constant (in nb of frames) of orientation control.
X,Y,Z: Global coordinates of reference direction. 
time : Maximum activation time of actuator. 
       0 : unlimited.
       >0: number of frames before automatic deactivation.  

Notes: - (X,Y,Z) = (0,0,0) is not a valid direction
       - This actuator changes the orientation of the object
         and will conflict with Drot motion unless it is placed
         BEFORE the Drot motion actuator (the order of 
         actuator is important).
       - This actuator doesn't change the location and speed. 
         It is compatible with gravity.
       - All parameters are accessible through Python.

Actuator sensor 
===============
This sensor detects the activation and deactivation of actuators 
of the same object. The sensor generates a positive pulse when 
the corresponding sensor is activated and a negative pulse when 
it is deactivated (the contrary if the Inv option is selected). 
This is mostly useful to chain actions and to detect the loss of 
contact of the distance motion actuator.

Notes: - Actuators are disabled at the start of the game; if you
         want to detect the On-Off transition of an actuator 
         after it has been activated at least once, unselect the
         Lvl and Inv options and use a NAND controller.
       - Some actuators deactivates themselves immediately after 
         being activated. The sensor detects this situation as 
         an On-Off transition.
       - The actuator name can be set through Python.
2008-07-04 08:14:50 +00:00
Campbell Barton
bd74679a39 small changes to py funcs that can run 100s of times a second, so python wont generate empty args tuple when they are not needed. 2008-07-04 00:30:44 +00:00
Campbell Barton
5c93e75682 non user visible changes and small optimizations to the game engine pyapi as well as fixing some bugs.
* 2 returning errors without exception set another return None instead of NULL.
* a missing check for parent relation
* BPY matrix length was incorrect in matrix.c, this change could break some scripts, however when a script expects a list of lists for a matrix, the len() function is incorrect and will give an error. This was the only thing stopping apricot game logic running in trunk.

Also added a function for GameObjects  -  getAxisVect(vec), multiplies the vector be the objects worldspace rotation matrix. Very useful if you want to know what the forward direction is for an object and dont want to use Blender.Mathutils which is tedious and not available in BlenderPlayer yet.
2008-07-04 00:05:50 +00:00
Campbell Barton
31aa43da97 Adding GameObject setLinearVelocity(), without this interacting with objects requires them to have logic bricks to apply force which doesn't work well when the character is in a seperate blend file to the levels. (its also messy to have a script & multiple motion actuators on each object you can pickup and throw).
This is also needed for removing any force that existed before suspending dynamics - In the case of franky hanging, resuming dynamics when he fell would apply the velocity he had when grabbing making dropping to the ground work unpredictably. 

Also note in pydocs that enable/disable rigidbody physics doesn't work with bullet yet.
2008-07-03 01:34:50 +00:00
Campbell Barton
b0958b6646 Checked all cases where PyArg_ParseTuple is used in blenders game engine and made sure all will raise errors when called with invalid args. 2008-07-01 16:43:46 +00:00
Campbell Barton
bc8364fef0 bugfix, ActionActuator was missing many checks for PyArg_ParseTuple failing.
This meant an error in a script could be reported in a different line or script file which makes it quite hard to trace the problem. There were also places where invalid pointers could be used because of this.
The whole game engine pyapi probably needs to have these checks added.
2008-07-01 13:21:37 +00:00
Campbell Barton
96152f8409 track to would crash (with a C++ assert) if the source and target are in the same location, which I have had happen a few times while testing. 2008-07-01 05:16:08 +00:00
Campbell Barton
6a3e8e7fff BGE python api addition, GameObject get/setState and Controller.getState()
Also added a note in the tooltip for action priority when using more then 1 action at a time.
2008-06-29 21:52:23 +00:00
Brecht Van Lommel
ab7794392e Fix for bug #7753: after game engine drawing with vertex arrays,
nurbs/curves/text dissappears.

This also removes the "vertex arrays" option and enables it always
for OpenGL version >= 1.1 - there's no need to have an option to
make things render faster disabled by default, also it should work
stable now.
2008-06-29 21:51:27 +00:00
Jean-Luc Peurière
7056d63f41 adding explicit cast to get things compiling 2008-06-29 12:25:15 +00:00
Hamed Zaghaghi
b98e53b8ac BGE , fix an compile error 2008-06-28 14:19:25 +00:00
Hamed Zaghaghi
1231a2171a BGE 2d-filter, custom shaders now can have depth texture and luminance texture 2008-06-28 03:18:11 +00:00
Campbell Barton
f0a3cbcdac patch [#15865] BGE API call to delete objects
from Dalai Felinto (dfelinto) 
renamed deleteObject to endObject() to match the user interface.
2008-06-27 11:35:55 +00:00
Campbell Barton
11cdc2a002 Python API/Game engine fixes, dosn't affect 2.47
* Action FrameProp was checking if the string was true, not that it contained any text.
* Added GameObject.getVisible() since there is already a getVisible
* Added GameObject.getPropertyNames() Needed in apricot so Franky can collect and throw items in the level without having the names defined elsewhere or modifying his game logic which is stored in a separate blend file.
2008-06-26 12:39:06 +00:00
Campbell Barton
84c4e89eba Commented out face transp changing when switching images, this is more annoying then helpful.
Edited Game engine docs to note that the matrix will need to be transposed if used with Mathutils.Matrix()
Edited "Collision" button since ray-sensor also uses collision.
2008-06-25 16:09:29 +00:00
Benoit Bolsee
c353af4d3a BGE patch 15044 approved: Edit Object Dynamics Actuator.
Add enable/disable dynamics actuator under the "Edit Object" category.
The Enable/disable rigid body option is also availale but not implemented.
2008-06-25 14:09:15 +00:00
Benoit Bolsee
820c2df12c BGE patch: Add automatic support for armature driven shape keys.
To take advantage of this feature, you must have a mesh with 
relative shape keys and shape Ipo curves with drivers referring
to bones of the mesh's parent armature. 
The BGE will automatically detect the dependency between the 
shape keys and the armature and execute the Ipo drivers during
the rendering of the armature actions.
This technique is used to make the armature action more natural: 
the shape keys compensate in places where the armature deformation 
is uggly and the drivers make sure that the shape correction
is synchronized with the bone position.

Note: This is not compatible with shape actions; BLender does 
not allow to have Shape Ipo Curves and Shape actions at the same
time.
2008-06-24 22:19:00 +00:00
Benoit Bolsee
4d478cbe86 BGE patch: remove Shape key driver code from previous commit 2008-06-24 21:39:45 +00:00
Benoit Bolsee
15c105c157 BGE patch: Add damping and clamping option to motion actuator.
This patch introduces two options for the motion actuator:

damping: number of frames to reach the target velocity. It takes
into account the startup velocityin the target velocity direction
and add 1/damping fraction of target velocity until the full 
velocity is reached. Works only with linear and angular velocity.
It will be extended to delta and force motion method in a future
release.

clamping: apply the force and torque as long as the target velocity
is not reached. If this option is set, the velocity specified 
in linV or angV are not applied to the object but used as target
velocity. You should also specify a force in force or torque field: 
the force will be applied as long as the velocity along the axis of
the vector set in linV or angV is not reached. Works best in low
friction environment.
2008-06-24 19:37:43 +00:00
Benoit Bolsee
02132de7aa BGE patch: Add NAND, NOR, XOR, XNOR controllers.
NAND controller is an inverted AND controller: the output is 
     1 if any of the input is 0.
NOR  controller is an inverted OR controller: the output is 0
     if any of the input is 1.
XOR  controller is an exclusive OR: the output is 1 if and only
     if one input is 1 and all the other inputs are 0.
XNOR controller is an inverted XOR: the output is 0 if and only
     if one input is 0 and all the other inputs are 0.
The NAND, NORT and XNOR controllers are very usefull to create
complementary outputs to start and stop actuators synchronously.
MSCV project files updated.
2008-06-23 20:41:18 +00:00
Benoit Bolsee
67c0b32375 BGE patch: Add level option on sensor and fix sensor reset.
Level option is now available on all sensors but is only implemented on 
mouse and keyboard sensors. The purpose of that option is to make
the sensor react on level rather than edge by default. It's only
applicable to state engine system when there is a state transition:
the sensor will generate a pulse if the condition is met from the
start of the state. Normally, the keyboard sensor generate a pulse
only when the key is pressed and not when the key is already pressed.
This patch allows to select this behavior.
The second part of the patch corrects the reset method for sensors
with inverted output.
2008-06-23 20:26:48 +00:00
Benoit Bolsee
75e22a1917 BGE patch #14386: Action Actuator Current Frame Prop. This patch is very usefull for action feedback logic: a sensor on the property can be used to detect a certain moment in the action and trigger more stuff. The property must be on float type for best results 2008-06-23 15:32:44 +00:00
Benoit Bolsee
5372def2b0 BGE patch: add state engine support in the logic bricks.
This patch introduces a simple state engine system with the logic bricks. This system features full
backward compatibility, multiple active states, multiple state transitions, automatic disabling of 
sensor and actuators, full GUI support and selective display of sensors and actuators. 
Note: Python API is available but not documented yet. It will be added asap.

State internals
===============
The state system is object based. The current state mask is stored in the object as a 32 bit value; 
each bit set in the mask is an active state. The controllers have a state mask too but only one bit
can be set: a controller belongs to a single state. The game engine will only execute controllers 
that belong to active states. Sensors and actuators don't have a state mask but are effectively 
attached to states via their links to the controllers. Sensors and actuators can be connected to more
than one state. When a controller becomes inactive because of a state change, its links to sensors 
and actuators are temporarily broken (until the state becomes active again). If an actuator gets isolated, 
i.e all the links to controllers are broken, it is automatically disabled. If a sensor gets isolated, 
the game engine will stop calling it to save CPU. It will also reset the sensor internal state so that
it can react as if the game just started when it gets reconnected to an active controller. For example,
an Always sensor in no pulse mode that is connected to a single state (i.e connected to one or more 
controllers of a single state) will generate a pulse each time the state becomes active. This feature is 
not available on all sensors, see the notes below.

GUI
===
This system system is fully configurable through the GUI: the object state mask is visible under the
object bar in the controller's colum as an array of buttons just like the 3D view layer mask.
Click on a state bit to only display the controllers of that state. You can select more than one state
with SHIFT-click. The All button sets all the bits so that you can see all the controllers of the object. 
The Ini button sets the state mask back to the object default state. You can change the default state 
of object by first selecting the desired state mask and storing using the menu under the State button. 
If you define a default state mask, it will be loaded into the object state make when you load the blend
file or when you run the game under the blenderplayer. However, when you run the game under Blender, 
the current selected state mask will be used as the startup state for the object. This allows you to test
specific state during the game design.

The controller display the state they belong to with a new button in the controller header. When you add
a new controller, it is added by default in the lowest enabled state. You can change the controller state 
by clicking on the button and selecting another state. If more than one state is enabled in the object
state mask, controllers are grouped by state for more readibility. 

The new Sta button in the sensor and actuator column header allows you to display only the sensors and 
actuators that are linked to visible controllers.

A new state actuator is available to modify the state during the game. It defines a bit mask and 
the operation to apply on the current object state mask:

Cpy: the bit mask is copied to the object state mask.
Add: the bits that set in the bit mask will be turned on in the object state mask.
Sub: the bits that set in the bit mask will be turned off in the object state mask.
Inv: the bits that set in the bit mask will be inverted in the objecyy state mask.

Notes
=====
- Although states have no name, a simply convention consists in using the name of the first controller 
  of the state as the state name. The GUI will support that convention by displaying as a hint the name
  of the first controller of the state when you move the mouse over a state bit of the object state mask
  or of the state actuator bit mask.
- Each object has a state mask and each object can have a state engine but if several objects are 
  part of a logical group, it is recommended to put the state engine only in the main object and to
  link the controllers of that object to the sensors and actuators of the different objects.
- When loading an old blend file, the state mask of all objects and controllers are initialized to 1 
  so that all the controllers belong to this single state. This ensures backward compatibility with 
  existing game.
- When the state actuator is activated at the same time as other actuators, these actuators are 
  guaranteed to execute before being eventually disabled due to the state change. This is useful for
  example to send a message or update a property at the time of changing the state.
- Sensors that depend on underlying resource won't reset fully when they are isolated. By the time they
  are acticated again, they will behave as follow:
  * keyboard sensor: keys already pressed won't be detected. The keyboard sensor is only sensitive 
    to new key press.
  * collision sensor: objects already colliding won't be detected. Only new collisions are 
    detected.
  * near and radar sensor: same as collision sensor.
2008-06-22 14:23:57 +00:00
Campbell Barton
a1e78a0cca * Documented that get/setOrientation use an inverted rotation matrix
* OB prefix is needed when specifying the object for the Message Actuator, this is very bad since other object fields in the BGE dont need this prefix - a real fix would need do_versions to keep old files running.
* RotationMatrix was all nans if the rotation vector axis was 0,0,0, Changed so in this case just return a matrix that doesn't rotate anything,

spent some angry hours to find these issues, maybe this will save others the hassle ;)
2008-06-20 20:54:29 +00:00
Benoit Bolsee
de7619991c BGE bug fix for new shape action: mesh with multiple materials did not deform properly 2008-06-19 14:40:46 +00:00
Benoit Bolsee
df8a3882c6 BGE patch #13625: getLinearVelocity() rewrite to use only vector and matrix operations 2008-06-18 21:22:17 +00:00
Brecht Van Lommel
3f488f4d70 * Fix for a crash in game engine vertex array drawing with texfaces.
* For 2D filters, don't require opengl 2.0 but just the extensions,
  so it works on computers without full 2.0 support too.
* In debug mode, don't print memory statistics for preview render.
2008-06-18 10:30:14 +00:00
Jiri Hnidek
5cd4b6ac90 Small fix to be able to compile Blender. 2008-06-18 09:52:31 +00:00
Campbell Barton
d39154bb50 bugfix, BGE, use vec.safe_normalized() rather then vec.normalized() because in some cases the ray_cast sensor could crash blender. 2008-06-18 09:06:51 +00:00
Benoit Bolsee
48c7c9d957 Forgot to set Id property on new shape action files 2008-06-18 07:03:47 +00:00
Benoit Bolsee
2bece8dcb5 BGE Patch: Add Shape Action support and update MSCV_7 project file for glew.
Shape Action are now supported in the BGE. A new type of actuator "Shape Action" is available on mesh objects. It can be combined with Action actuator on parent armature. Only relative keys are supported. All the usual action options are available: type, blending, priority, Python API. Only actions with shape channels should be specified of course, otherwise the actuator has no effect. Shape action will still work after a mesh replacement provided that the new mesh has compatible shape keys.
2008-06-18 06:46:49 +00:00
Brecht Van Lommel
272a91f754 Merge of apricot branch game engine changes into trunk, excluding GLSL.
GLEW
====

Added the GLEW opengl extension library into extern/, always compiled
into Blender now. This is much nicer than doing this kind of extension
management manually, and will be used in the game engine, for GLSL, and
other opengl extensions.

* According to the GLEW website it works on Windows, Linux, Mac OS X,
  FreeBSD, Irix, and Solaris. There might still be platform specific
  issues due to this commit, so let me know and I'll look into it.
* This means also that all extensions will now always be compiled in,
  regardless of the glext.h on the platform where compilation happens.

Game Engine
===========

Refactoring of the use of opengl extensions and other drawing code
in the game engine, and cleaning up some hacks related to GLSL
integration. These changes will be merged into trunk too after this.

The game engine graphics demos & apricot level survived my tests,
but this could use some good testing of course.

For users: please test with the options "Generate Display Lists" and
"Vertex Arrays" enabled, these should be the fastest and are supposed
to be "unreliable", but if that's the case that's probably due to bugs
that can be fixed.

* The game engine now also uses GLEW for extensions, replacing the
  custom opengl extensions code that was there. Removes a lot of
  #ifdef's, but the runtime checks stay of course.
* Removed the WITHOUT_GLEXT environment variable. This was added to
  work around a specific bug and only disabled multitexturing anyway.
  It might also have caused a slowdown since it was retrieving the
  environment variable for every vertex in immediate mode (bug #13680).

* Refactored the code to allow drawing skinned meshes with vertex
  arrays too, removing some specific immediate mode drawing functions
  for this that only did extra normal calculation. Now it always splits
  vertices of flat faces instead.
* Refactored normal recalculation with some minor optimizations,
  required for the above change.
* Removed some outdated code behind the __NLA_OLDDEFORM #ifdef.
* Fixed various bugs in setting of multitexture coordinates and vertex
  attributes for vertex arrays. These were not being enabled/disabled
  correct according to the opengl spec, leading to crashes. Also tangent
  attributes used an immediate mode call for vertex arrays, which can't
  work.
* Fixed use of uninitialized variable in RAS_TexVert.
* Exporting skinned meshes was doing O(n^2) lookups for vertices and
  deform weights, now uses same trick as regular meshes.
2008-06-17 10:27:34 +00:00
Campbell Barton
c9d1924ea5 Use the scenes framerate for ipo and action framerate in the game engine, was hard coded to 25. 2008-06-17 10:06:38 +00:00
Campbell Barton
9b69c56917 Material color was always overriding OBCOL for blender text. 2008-06-16 09:16:04 +00:00
Campbell Barton
f63b70635c bugfix, clip alpha wasn't working in the GE, not happy with these functions, they probably need bigger changes not to assume all alpha requires face sorting with a disabled depth buffer, 2008-06-15 09:43:24 +00:00
Benoit Bolsee
89c1875bc9 BGE patch: support Set Scene in BGE. Linked Set Scene should have no name conflict in Object, Object data and Action of the main scene to avoid confusion in Python scripting. Nested Set Scene are supported. You will need Python scripting to create cross references between objects in the main scene and the Set (e.g TrackTo actuator) 2008-06-14 20:42:15 +00:00
Campbell Barton
fc7a83b458 Added access for adjusting timeOffset value at runtime, used for apricot (Franky climbing walls) 2008-06-14 17:12:49 +00:00
Campbell Barton
8bd82d4e36 Some pose action ipo corruptions when using BGE, added some debug printf's when copying to/from the same pose since it should never happen. 2008-06-13 02:20:09 +00:00
Campbell Barton
192037960d error in variable name, not sure how this even compiled 2008-06-09 22:54:56 +00:00
Campbell Barton
f39758cddc adding clip alpha (binary alpha) to the 3D view and game engine. 2008-06-09 15:45:46 +00:00
Joshua Leung
71573cbd55 Bugfix #13666:
Missing #include <stdio.h> in source/gameengine/Ketsji/KX_RayCast.cpp
2008-06-08 10:48:37 +00:00
Hamed Zaghaghi
6ffadbfb10 fix 2dfilter problem on AMD64, Patches item #13626 2008-06-06 01:28:51 +00:00
Kent Mein
fbb56ee997 Issue jms was having with # else on msvc. Seems odd but easy to fix.
Kent
2008-06-04 18:11:48 +00:00
Hamed Zaghaghi
d565e8a02f bugfix #13618 - 2d filters + GLSL python scripts 2008-06-04 02:54:42 +00:00
Benoit Bolsee
772d241582 Fix BGE bug #13605: GameEngine corrupts Pose data 2008-06-03 22:54:24 +00:00
Benoit Bolsee
1cc61f633f Patch #11000 approved: [new function] KX_GameObject::alignAxisToVect() Align an object's axis to a given vector 2008-06-02 17:31:05 +00:00
Benoit Bolsee
da1f38f99d Apply BGE patch 11137: Render objects with negative scaling correctly (as in Blender) 2008-05-25 14:37:39 +00:00
Benoit Bolsee
e2a9590a15 BGE patch: rename rayCastToEx() to rayCast() - better name 2008-05-24 22:50:31 +00:00
Benoit Bolsee
cc6dac8c42 BGE patch: add rayCastToEx(), an extended version of rayCastTo() for use in game script 2008-05-24 18:06:58 +00:00
Benoit Bolsee
7f10f5f66f fix BGE bug #8646: unusable anaglyph settings
The best rules for stereo rendering are now applied to Blender. Here is the new situation:
1) The focal distance is now settable through the GUI: select the camera (each camera can have a different setting) and go to the camera data (F9): the "Dof Dist" and "Dof Ob" can be used to set the focal distance for that camera. The "Dof Ob" is interesting because it sets the focal distance so that the center this object will appear at the surface of the screen when running the game.
2) The eye separation is automatically set to focal_distance/30, which is considered to be a reasonable value. If you need a different value, you can always use Python scripting. 

Notes: 
- If you switch camera during the game, the focal distance will also change unless you have set the focal distance by scripting, in which case it overwrites the focal distance setting of all cameras.
- If you don't set the focal distance in the camera data or by scripting, the default value will be used. The default value corresponds more of less to the near clipping plane which means that all the objects will be very far with little 3D effect.
- If you don't set the eye separation by scripting, it is automatically computed as focal_distance/30, regardless on how the focal distance was set.
2008-05-24 08:34:04 +00:00
Campbell Barton
92c9ae280c replacing epydoc generation script with one copied from bpy docs 2008-05-20 05:55:12 +00:00
Benoit Bolsee
a6a4b78417 Fix BGE bug #7532: TrackTo Actuator does not work correctly if it has a Vertex Parent. This is only a partial fix: the user must put the parent vertex at the center of the parent object and disable the physics on the tracking object (use empty or collision free object). 2008-05-14 20:22:57 +00:00
Campbell Barton
ac71783e8d last commit had a typo, also adjusted teh and colour instances 2008-05-12 21:12:10 +00:00
Benoit Bolsee
96486b356f fix BGE bug #8668: Behavior of os.getcwd() is not consistent between operating systems
Add a function GameLogic.expandPath() that works like Blender.sys.expandpath() and is also available in the BlenderPlayer.
Fix the game actuator in the BlenderPlayer to work like in Blender: 
- try first to load the .blend from the current working directory
- if not found, try to load from the startup .blend or runtime base directory
2008-05-11 18:45:30 +00:00
Kent Mein
106974a9d2 Fixing up the webplugin defines for the Makefiles.
Now you can do one of the following to disable it:
export NAN_NO_PLUGIN=true
export WITH_BF_WEBPLUGIN=false

or
export WITH_BF_WEBPLUGIN=true to enable building it.
(Its set to false by default)

Kent
2008-05-08 18:38:21 +00:00
Benoit Bolsee
44cdc480de Fix BGE bug #6054: Camera actuator crashes Blender. The crash occurs when min,max << height (bad practice anyway). 2008-05-07 22:32:45 +00:00
Benoit Bolsee
881802d8a3 BGE patch #10492 approved: getLinearVelocity() now can provide local velocity as well. This patch is harmless and backward compatible; it can go safely into 2.46 release 2008-05-06 20:55:55 +00:00
Kent Mein
3ba9069c04 Fixes Makefiles for mac_compat_glext.h by updating some include paths.
Kent
2008-05-06 09:43:28 +00:00
Kent Mein
b36fe51c7d Fixed some indentation, I stumbled across (spaces vs tabs)
and also removed return 0 from a void stub.

Kent
2008-05-05 17:29:11 +00:00
Benoit Bolsee
cf654b44b6 Fix BGE bug in patch #8724 (memory optimization): serious problem with alpha texture when Use Blender Material is active and several objects have same texture. This bug messes up greatly with OpenGL texture. The GE is not usable without this fix. 2008-05-04 21:14:38 +00:00
Campbell Barton
6c05a92fe1 missed out on some BLI_convertstringcode's, also found that playing relative quicktime paths from the python api never worked, was using the 'Scene' type cast to a char. 2008-05-04 15:02:48 +00:00
Ken Hughes
7aa6833499 More compiler fixes for BLI_convertstringcode calls 2008-05-04 14:14:09 +00:00
Joshua Leung
e6be454787 More compiler fixes for BLI_convertstringcode calls 2008-05-04 11:09:30 +00:00
Benoit Bolsee
e7a106625c BGE bug fix: set parent actuator change the orientation of object 2008-05-02 17:22:28 +00:00
Benoit Bolsee
f0a41d9d97 Partially revert BGE bug fix #8863: don't send keyboard sensor positive pulse on level, this would badly interfere with keyboard sensors controlling set scene/restart scene actuators. Only send negative pulse on level to stop actuators after scene suspend 2008-05-02 15:47:08 +00:00
Benoit Bolsee
d99ddc5cf8 Fix BGE bug #8863: Keyboard Sensor does not send negative pulse if key released while scene suspended. The fix covers keyboard and mouse sensor 2008-05-01 20:43:18 +00:00
Benoit Bolsee
31adad5b4d Fix BGE bug: dynamic-but-not-rigid objects are added as rigid body during the game. 2008-05-01 16:00:59 +00:00
Benoit Bolsee
eef2b7e125 Complement to bug fix #8869: crash with alpha mesh 2008-05-01 12:35:21 +00:00
Benoit Bolsee
3a430c33d2 fix BGE bug #8869: Added objects are not lit correctly
The current layer information is now stored in KX_GameObject and inherited from the parent object when dynamically added. This information is used during the rendering the select the lamps. As the selected lamps are always coming from active layers, their position and orientation are correct.
2008-04-30 19:58:44 +00:00
Jean-Luc Peurière
b6a6507ddf getting ARB shaders working again in GE.
This is is a kludge, and only to get a release
working. later solution is to use glew
2008-04-29 16:22:13 +00:00
Benoit Bolsee
2740bbc89c Update MSVC project files to support ffmpeg. Make sure you do svn update in lib/windows to link with latest ffmpeg libraries 2008-04-27 15:02:37 +00:00
Benoit Bolsee
bc059cb8b2 BGE bug: crash when an object being tracked-to is deleted (bad practice anyway). Fix by creating a generic cross reference between actuators (only TrackTo uses it at the moment) and objects so that the actuator is informed when the target object is deleted 2008-04-26 20:41:25 +00:00
Benoit Bolsee
9b9359120f BGE bug: fix a crash at game exit caused by inconsistent controller map after object deletion. The bug became apparent since the memory leaks have been fixed. 2008-04-24 21:26:39 +00:00
Benoit Bolsee
f4cc03b0f1 Better fix for BGE bug #7892: dRot is reversed on dynamic objects. Make sure that graphic, Bullet and Sumo(deprecated) objects rotate the same way. This fix reverses the rotation of non-dynamic objects compared to 2.45: you will need to change the sign of dRot in 2.45 games for them to work correctly in 2.46 2008-04-23 21:48:17 +00:00
Benoit Bolsee
9098de4479 second attempt to fix compilation problem with 2D shaders on systems without GLExt or without shader support: use GL_ARB_shader_objects to conditionally compile the 2D shader code 2008-04-20 21:01:13 +00:00
Benoit Bolsee
bdf5c0689b BGE bug fix: crash at exit when object with Radar/Near sensor has debug properties 2008-04-19 21:15:37 +00:00
Benoit Bolsee
b0049e6088 fix BGE bug #8094: Collision sensor on child object makes the object rotate or move very fast. Collision sensor can now be set on child object without side effect. 2008-04-19 21:09:40 +00:00
Benoit Bolsee
1fc1fb117e BGE: fix compilation error with 2D filters on System without GL extenstion: add conditional compile statements 2008-04-18 22:22:50 +00:00
Chris Want
5d0a207ecb Patch from GSR that a) fixes a whole bunch of GPL/BL license
blocks that were previously missed; and b) greatly increase my
ohloh stats!
2008-04-16 22:40:48 +00:00
Benoit Bolsee
35e655cd5a BGE: Fix restitution: object will now bounce according to material restitution setting 2008-04-16 18:47:36 +00:00
Kent Mein
867e12836b This patch spawns from this game engine issue:
[#7113] GE crash pressing as soon as P on 64 bit


Note:         glext.h has been removed from the source
        If you get errors compiling with it you have 2 options
                download/install 	glext.h        (preferred method)
                or set WITH_BF_GLEXT=false
        If your a user and having problems with game engine try
                setting the env var: WITHOUT_GLEXT 1

Kent
2008-04-16 17:40:59 +00:00
Campbell Barton
83c5401896 replace magic numbers with constants for (G.vd->persp), view naming was also using persp as a flag which worked but isnt correct. 2008-04-16 08:48:49 +00:00
Benoit Bolsee
6bb327badc BGE fix: keep reference count consist on source object when replicating property copy actuator 2008-04-14 22:45:28 +00:00
Benoit Bolsee
566053319a fix BGE bug #8309: After Parent Object added to the visual layer, Child Camera won't follow.
This bug fix is made of two parts:
1) It's now possible to dynamically add a camera.
2) Empty camera name on a SetCamera actuator now points to the actuator's parent object if this object is a camera. 
This trick is useful to make current a dynamically created camera: just add a SetCamera actuator on the camera itself and leave the name empty. Later, when the camera is added in the scene with an AddObject actuator, either directly or via a parent object, you just need to activate the actuator to make the newly created camera current. If you set a name on a SetCamera actuator, it will always point to the original camera, even after replication.
2008-04-14 20:54:20 +00:00
Benoit Bolsee
dfd7387641 fix BGE bug #8880: blenderplayer closing when esc is pressed
ESC now quits the game by default in all modes unless a keyboard sensor is set on ESC. 
In this case, the game designer must arrange for an alternative way to quit the game.
2008-04-12 21:18:58 +00:00
Benoit Bolsee
4bab327c1b fix BGE patch #7892: dRot motion is reversed on non-dynamic objects
Positive dRot motion actuator will now make the dynamic and non-dynamic objects rotate counter-clock wise.
2008-04-11 21:19:00 +00:00
Benoit Bolsee
539ff57015 fix BGE bug #8813: new rayCastTo() function hits near sensor collision box 2008-04-10 20:17:12 +00:00
Benoit Bolsee
34771ef405 add KX_GameObject::rayCastTo() PyDoc 2008-04-06 20:02:41 +00:00