2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2010-04-29 07:01:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
2011-02-27 20:29:51 +00:00
|
|
|
|
|
|
|
|
/** \file blender/editors/space_logic/logic_ops.c
|
|
|
|
|
* \ingroup splogic
|
|
|
|
|
*/
|
|
|
|
|
|
2010-04-29 07:01:48 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
|
#include "DNA_sensor_types.h"
|
2010-05-04 00:06:13 +00:00
|
|
|
#include "DNA_controller_types.h"
|
|
|
|
|
#include "DNA_actuator_types.h"
|
2010-04-29 07:01:48 +00:00
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2010-04-29 07:01:48 +00:00
|
|
|
|
|
|
|
|
#include "BKE_context.h"
|
|
|
|
|
#include "BKE_main.h"
|
|
|
|
|
#include "BKE_sca.h"
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
#include "BKE_material.h" //for texface convert
|
2010-04-29 07:01:48 +00:00
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
#include "ED_logic.h"
|
2010-04-29 07:01:48 +00:00
|
|
|
#include "ED_object.h"
|
|
|
|
|
#include "ED_screen.h"
|
|
|
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
#include "RNA_define.h"
|
|
|
|
|
#include "RNA_enum_types.h"
|
|
|
|
|
|
|
|
|
|
#include "WM_api.h"
|
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
|
|
|
|
|
#include "logic_intern.h"
|
|
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
// temporary new includes for texface functions
|
|
|
|
|
#include "DNA_mesh_types.h"
|
|
|
|
|
#include "DNA_material_types.h"
|
|
|
|
|
#include "DNA_meshdata_types.h"
|
|
|
|
|
|
2010-04-29 07:01:48 +00:00
|
|
|
/* ************* Generic Operator Helpers ************* */
|
|
|
|
|
static int edit_sensor_poll(bContext *C)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr= CTX_data_pointer_get_type(C, "sensor", &RNA_Sensor);
|
|
|
|
|
|
|
|
|
|
if (ptr.data && ((ID*)ptr.id.data)->lib) return 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-04 00:06:13 +00:00
|
|
|
static int edit_controller_poll(bContext *C)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr= CTX_data_pointer_get_type(C, "controller", &RNA_Controller);
|
|
|
|
|
|
|
|
|
|
if (ptr.data && ((ID*)ptr.id.data)->lib) return 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int edit_actuator_poll(bContext *C)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr= CTX_data_pointer_get_type(C, "actuator", &RNA_Actuator);
|
|
|
|
|
|
|
|
|
|
if (ptr.data && ((ID*)ptr.id.data)->lib) return 0;
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-04-29 07:01:48 +00:00
|
|
|
static void edit_sensor_properties(wmOperatorType *ot)
|
|
|
|
|
{
|
2012-01-11 08:51:06 +00:00
|
|
|
RNA_def_string(ot->srna, "sensor", "", MAX_NAME, "Sensor", "Name of the sensor to edit");
|
|
|
|
|
RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the object the sensor belongs to");
|
2010-04-29 07:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int edit_sensor_invoke_properties(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr= CTX_data_pointer_get_type(C, "sensor", &RNA_Sensor);
|
|
|
|
|
|
2012-01-11 16:32:12 +00:00
|
|
|
if (RNA_struct_property_is_set(op->ptr, "sensor") && RNA_struct_property_is_set(op->ptr, "object") )
|
2010-04-29 07:01:48 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
if (ptr.data) {
|
|
|
|
|
bSensor *sens = ptr.data;
|
|
|
|
|
Object *ob = ptr.id.data;
|
|
|
|
|
|
|
|
|
|
RNA_string_set(op->ptr, "sensor", sens->name);
|
|
|
|
|
RNA_string_set(op->ptr, "object", ob->id.name+2);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
static Object *edit_object_property_get(bContext *C, wmOperator *op)
|
2010-04-29 07:01:48 +00:00
|
|
|
{
|
2012-01-11 08:51:06 +00:00
|
|
|
char ob_name[MAX_NAME];
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
Object *ob;
|
|
|
|
|
|
2010-04-29 07:01:48 +00:00
|
|
|
RNA_string_get(op->ptr, "object", ob_name);
|
2010-06-17 07:33:57 +00:00
|
|
|
|
|
|
|
|
/* if ob_name is valid try to find the object with this name
|
2012-03-03 16:31:46 +00:00
|
|
|
* otherwise gets the active object */
|
2012-01-11 08:51:06 +00:00
|
|
|
if (BLI_strnlen(ob_name, MAX_NAME) > 0)
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
ob = BLI_findstring(&(CTX_data_main(C)->object), ob_name, offsetof(ID, name) + 2);
|
2010-06-17 07:33:57 +00:00
|
|
|
else
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
ob= ED_object_active_context(C);
|
|
|
|
|
|
|
|
|
|
return ob;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bSensor *edit_sensor_property_get(bContext *C, wmOperator *op, Object **ob)
|
|
|
|
|
{
|
2012-01-11 08:51:06 +00:00
|
|
|
char sensor_name[MAX_NAME];
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
bSensor *sens;
|
|
|
|
|
|
|
|
|
|
RNA_string_get(op->ptr, "sensor", sensor_name);
|
2010-06-17 07:33:57 +00:00
|
|
|
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
*ob= edit_object_property_get(C, op);
|
|
|
|
|
if (!*ob) return NULL;
|
2010-04-29 07:01:48 +00:00
|
|
|
|
2010-06-17 06:34:11 +00:00
|
|
|
sens = BLI_findstring(&((*ob)->sensors), sensor_name, offsetof(bSensor, name));
|
2010-04-29 07:01:48 +00:00
|
|
|
return sens;
|
|
|
|
|
}
|
2010-06-17 06:34:11 +00:00
|
|
|
|
2010-05-04 00:06:13 +00:00
|
|
|
static void edit_controller_properties(wmOperatorType *ot)
|
|
|
|
|
{
|
2012-01-11 08:51:06 +00:00
|
|
|
RNA_def_string(ot->srna, "controller", "", MAX_NAME, "Controller", "Name of the controller to edit");
|
|
|
|
|
RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the object the controller belongs to");
|
2010-05-04 00:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int edit_controller_invoke_properties(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr= CTX_data_pointer_get_type(C, "controller", &RNA_Controller);
|
|
|
|
|
|
2012-01-11 16:32:12 +00:00
|
|
|
if (RNA_struct_property_is_set(op->ptr, "controller") && RNA_struct_property_is_set(op->ptr, "object") )
|
2010-05-04 00:06:13 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
if (ptr.data) {
|
|
|
|
|
bController *cont = ptr.data;
|
|
|
|
|
Object *ob = ptr.id.data;
|
|
|
|
|
|
|
|
|
|
RNA_string_set(op->ptr, "controller", cont->name);
|
|
|
|
|
RNA_string_set(op->ptr, "object", ob->id.name+2);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-17 06:34:11 +00:00
|
|
|
static bController *edit_controller_property_get(bContext *C, wmOperator *op, Object **ob)
|
2010-05-04 00:06:13 +00:00
|
|
|
{
|
2012-01-11 08:51:06 +00:00
|
|
|
char controller_name[MAX_NAME];
|
2010-05-04 00:06:13 +00:00
|
|
|
bController *cont;
|
|
|
|
|
|
|
|
|
|
RNA_string_get(op->ptr, "controller", controller_name);
|
2010-06-17 07:33:57 +00:00
|
|
|
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
*ob= edit_object_property_get(C, op);
|
|
|
|
|
if (!*ob) return NULL;
|
2010-05-04 00:06:13 +00:00
|
|
|
|
2010-06-17 06:34:11 +00:00
|
|
|
cont = BLI_findstring(&((*ob)->controllers), controller_name, offsetof(bController, name));
|
2010-05-04 00:06:13 +00:00
|
|
|
return cont;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void edit_actuator_properties(wmOperatorType *ot)
|
|
|
|
|
{
|
2012-01-11 08:51:06 +00:00
|
|
|
RNA_def_string(ot->srna, "actuator", "", MAX_NAME, "Actuator", "Name of the actuator to edit");
|
|
|
|
|
RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the object the actuator belongs to");
|
2010-05-04 00:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int edit_actuator_invoke_properties(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
PointerRNA ptr= CTX_data_pointer_get_type(C, "actuator", &RNA_Actuator);
|
|
|
|
|
|
2012-01-11 16:32:12 +00:00
|
|
|
if (RNA_struct_property_is_set(op->ptr, "actuator") && RNA_struct_property_is_set(op->ptr, "object") )
|
2010-05-04 00:06:13 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
if (ptr.data) {
|
|
|
|
|
bActuator *act = ptr.data;
|
|
|
|
|
Object *ob = ptr.id.data;
|
|
|
|
|
|
|
|
|
|
RNA_string_set(op->ptr, "actuator",act->name);
|
|
|
|
|
RNA_string_set(op->ptr, "object", ob->id.name+2);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
static bActuator *edit_actuator_property_get(bContext *C, wmOperator *op, Object **ob)
|
2010-05-04 00:06:13 +00:00
|
|
|
{
|
2012-01-11 08:51:06 +00:00
|
|
|
char actuator_name[MAX_NAME];
|
2010-05-04 00:06:13 +00:00
|
|
|
bActuator *act;
|
|
|
|
|
|
|
|
|
|
RNA_string_get(op->ptr, "actuator", actuator_name);
|
2010-06-17 07:33:57 +00:00
|
|
|
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
*ob= edit_object_property_get(C, op);
|
|
|
|
|
if (!*ob) return NULL;
|
2010-05-04 00:06:13 +00:00
|
|
|
|
2010-06-17 06:34:11 +00:00
|
|
|
act = BLI_findstring(&((*ob)->actuators), actuator_name, offsetof(bActuator, name));
|
2010-05-04 00:06:13 +00:00
|
|
|
return act;
|
|
|
|
|
}
|
2010-04-29 07:01:48 +00:00
|
|
|
|
2010-07-09 00:14:46 +00:00
|
|
|
static int logicbricks_move_property_get(wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
int type = RNA_enum_get(op->ptr, "direction");
|
|
|
|
|
|
|
|
|
|
if (type == 1)
|
|
|
|
|
return TRUE;
|
|
|
|
|
else
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-04 00:06:13 +00:00
|
|
|
/* ************* Add/Remove Sensor Operator ************* */
|
2010-04-29 07:01:48 +00:00
|
|
|
|
|
|
|
|
static int sensor_remove_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2010-06-17 06:34:11 +00:00
|
|
|
Object *ob=NULL;
|
|
|
|
|
bSensor *sens = edit_sensor_property_get(C, op, &ob);
|
2010-04-29 07:01:48 +00:00
|
|
|
|
|
|
|
|
if (!sens)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
BLI_remlink(&(ob->sensors), sens);
|
|
|
|
|
free_sensor(sens);
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_LOGIC, NULL);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int sensor_remove_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
2010-04-29 07:01:48 +00:00
|
|
|
{
|
|
|
|
|
if (edit_sensor_invoke_properties(C, op))
|
|
|
|
|
return sensor_remove_exec(C, op);
|
|
|
|
|
else
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void LOGIC_OT_sensor_remove(wmOperatorType *ot)
|
2010-04-29 07:01:48 +00:00
|
|
|
{
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Remove Sensor";
|
|
|
|
|
ot->description = "Remove a sensor from the active object";
|
|
|
|
|
ot->idname = "LOGIC_OT_sensor_remove";
|
2010-04-29 07:01:48 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = sensor_remove_invoke;
|
|
|
|
|
ot->exec = sensor_remove_exec;
|
|
|
|
|
ot->poll = edit_sensor_poll;
|
2010-04-29 07:01:48 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2010-06-17 06:34:11 +00:00
|
|
|
edit_sensor_properties(ot);
|
2010-04-29 07:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int sensor_add_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
Object *ob;
|
2010-04-29 07:01:48 +00:00
|
|
|
bSensor *sens;
|
2010-05-10 05:46:01 +00:00
|
|
|
PointerRNA sens_ptr;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
const char *sens_name;
|
2012-01-11 08:51:06 +00:00
|
|
|
char name[MAX_NAME];
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
int type= RNA_enum_get(op->ptr, "type");
|
|
|
|
|
|
|
|
|
|
ob= edit_object_property_get(C, op);
|
|
|
|
|
if (!ob)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
2010-04-29 07:01:48 +00:00
|
|
|
|
|
|
|
|
sens= new_sensor(type);
|
|
|
|
|
BLI_addtail(&(ob->sensors), sens);
|
2010-05-10 05:46:01 +00:00
|
|
|
|
|
|
|
|
/* set the sensor name based on rna type enum */
|
|
|
|
|
RNA_pointer_create((ID *)ob, &RNA_Sensor, sens, &sens_ptr);
|
|
|
|
|
prop = RNA_struct_find_property(&sens_ptr, "type");
|
2010-05-14 10:45:50 +00:00
|
|
|
|
|
|
|
|
RNA_string_get(op->ptr, "name", name);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (BLI_strnlen(name, MAX_NAME) < 1) {
|
2010-05-14 10:45:50 +00:00
|
|
|
RNA_property_enum_name(C, &sens_ptr, prop, RNA_property_enum_get(&sens_ptr, prop), &sens_name);
|
|
|
|
|
BLI_strncpy(sens->name, sens_name, sizeof(sens->name));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
BLI_strncpy(sens->name, name, sizeof(sens->name));
|
|
|
|
|
|
2010-04-29 07:01:48 +00:00
|
|
|
make_unique_prop_names(C, sens->name);
|
|
|
|
|
ob->scaflag |= OB_SHOWSENS;
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_LOGIC, NULL);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void LOGIC_OT_sensor_add(wmOperatorType *ot)
|
2010-04-29 07:01:48 +00:00
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Sensor";
|
2010-04-29 07:01:48 +00:00
|
|
|
ot->description = "Add a sensor to the active object";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "LOGIC_OT_sensor_add";
|
2010-04-29 07:01:48 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
|
ot->exec = sensor_add_exec;
|
|
|
|
|
ot->poll = ED_operator_object_active_editable;
|
2010-04-29 07:01:48 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2010-04-29 07:01:48 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, SENS_ALWAYS, "Type", "Type of sensor to add");
|
2010-05-07 02:01:50 +00:00
|
|
|
RNA_def_enum_funcs(prop, rna_Sensor_type_itemf);
|
2012-01-11 08:51:06 +00:00
|
|
|
RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the Sensor to add");
|
|
|
|
|
RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the Object to add the Sensor to");
|
2010-04-29 07:01:48 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-04 00:06:13 +00:00
|
|
|
/* ************* Add/Remove Controller Operator ************* */
|
|
|
|
|
|
|
|
|
|
static int controller_remove_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2010-06-17 06:34:11 +00:00
|
|
|
Object *ob = NULL;
|
|
|
|
|
bController *cont = edit_controller_property_get(C, op, &ob);
|
2010-05-04 00:06:13 +00:00
|
|
|
|
|
|
|
|
if (!cont)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
BLI_remlink(&(ob->controllers), cont);
|
2010-05-05 00:12:31 +00:00
|
|
|
unlink_controller(cont);
|
2010-05-04 00:06:13 +00:00
|
|
|
free_controller(cont);
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_LOGIC, NULL);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int controller_remove_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
2010-05-04 00:06:13 +00:00
|
|
|
{
|
|
|
|
|
if (edit_controller_invoke_properties(C, op))
|
|
|
|
|
return controller_remove_exec(C, op);
|
|
|
|
|
else
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void LOGIC_OT_controller_remove(wmOperatorType *ot)
|
2010-05-04 00:06:13 +00:00
|
|
|
{
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Remove Controller";
|
|
|
|
|
ot->description = "Remove a controller from the active object";
|
|
|
|
|
ot->idname = "LOGIC_OT_controller_remove";
|
2010-05-04 00:06:13 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = controller_remove_invoke;
|
|
|
|
|
ot->exec = controller_remove_exec;
|
|
|
|
|
ot->poll = edit_controller_poll;
|
2010-05-04 00:06:13 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2010-06-17 06:34:11 +00:00
|
|
|
edit_controller_properties(ot);
|
2010-05-04 00:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int controller_add_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
Object *ob;
|
2010-05-04 00:06:13 +00:00
|
|
|
bController *cont;
|
2010-05-10 05:46:01 +00:00
|
|
|
PointerRNA cont_ptr;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
const char *cont_name;
|
2010-05-05 00:12:31 +00:00
|
|
|
int bit;
|
2012-01-11 08:51:06 +00:00
|
|
|
char name[MAX_NAME];
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
int type= RNA_enum_get(op->ptr, "type");
|
|
|
|
|
|
|
|
|
|
ob= edit_object_property_get(C, op);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ob)
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2010-05-05 00:12:31 +00:00
|
|
|
|
2010-05-04 00:06:13 +00:00
|
|
|
cont= new_controller(type);
|
|
|
|
|
BLI_addtail(&(ob->controllers), cont);
|
2010-05-10 05:46:01 +00:00
|
|
|
|
|
|
|
|
/* set the controller name based on rna type enum */
|
|
|
|
|
RNA_pointer_create((ID *)ob, &RNA_Controller, cont, &cont_ptr);
|
|
|
|
|
prop = RNA_struct_find_property(&cont_ptr, "type");
|
2010-05-14 10:45:50 +00:00
|
|
|
|
|
|
|
|
RNA_string_get(op->ptr, "name", name);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (BLI_strnlen(name, MAX_NAME) < 1) {
|
2010-05-14 10:45:50 +00:00
|
|
|
RNA_property_enum_name(C, &cont_ptr, prop, RNA_property_enum_get(&cont_ptr, prop), &cont_name);
|
|
|
|
|
BLI_strncpy(cont->name, cont_name, sizeof(cont->name));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
BLI_strncpy(cont->name, name, sizeof(cont->name));
|
|
|
|
|
|
2010-05-04 00:06:13 +00:00
|
|
|
make_unique_prop_names(C, cont->name);
|
2010-05-05 00:12:31 +00:00
|
|
|
/* set the controller state mask from the current object state.
|
2012-03-03 16:31:46 +00:00
|
|
|
* A controller is always in a single state, so select the lowest bit set
|
|
|
|
|
* from the object state */
|
2010-05-05 00:12:31 +00:00
|
|
|
for (bit=0; bit<OB_MAX_STATES; bit++) {
|
|
|
|
|
if (ob->state & (1<<bit))
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
cont->state_mask = (1<<bit);
|
|
|
|
|
if (cont->state_mask == 0) {
|
|
|
|
|
/* shouldn't happen, object state is never 0 */
|
|
|
|
|
cont->state_mask = 1;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-04 00:06:13 +00:00
|
|
|
ob->scaflag |= OB_SHOWCONT;
|
2010-05-05 00:12:31 +00:00
|
|
|
|
2010-05-04 00:06:13 +00:00
|
|
|
WM_event_add_notifier(C, NC_LOGIC, NULL);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void LOGIC_OT_controller_add(wmOperatorType *ot)
|
2010-05-04 00:06:13 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Controller";
|
2010-05-04 00:06:13 +00:00
|
|
|
ot->description = "Add a controller to the active object";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "LOGIC_OT_controller_add";
|
2010-05-04 00:06:13 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
|
ot->exec = controller_add_exec;
|
|
|
|
|
ot->poll = ED_operator_object_active_editable;
|
2010-05-04 00:06:13 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2010-05-04 00:06:13 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = RNA_def_enum(ot->srna, "type", controller_type_items, CONT_LOGIC_AND, "Type", "Type of controller to add");
|
2012-01-11 08:51:06 +00:00
|
|
|
RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the Controller to add");
|
|
|
|
|
RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the Object to add the Controller to");
|
2010-05-04 00:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ************* Add/Remove Actuator Operator ************* */
|
|
|
|
|
|
|
|
|
|
static int actuator_remove_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
2010-06-17 06:34:11 +00:00
|
|
|
Object *ob=NULL;
|
|
|
|
|
bActuator *act = edit_actuator_property_get(C, op, &ob);
|
2010-05-04 00:06:13 +00:00
|
|
|
|
|
|
|
|
if (!act)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
BLI_remlink(&(ob->actuators), act);
|
2010-05-05 00:12:31 +00:00
|
|
|
unlink_actuator(act);
|
2010-05-04 00:06:13 +00:00
|
|
|
free_actuator(act);
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_LOGIC, NULL);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int actuator_remove_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
2010-05-04 00:06:13 +00:00
|
|
|
{
|
|
|
|
|
if (edit_actuator_invoke_properties(C, op))
|
|
|
|
|
return actuator_remove_exec(C, op);
|
|
|
|
|
else
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void LOGIC_OT_actuator_remove(wmOperatorType *ot)
|
2010-05-04 00:06:13 +00:00
|
|
|
{
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Remove Actuator";
|
|
|
|
|
ot->description = "Remove an actuator from the active object";
|
|
|
|
|
ot->idname = "LOGIC_OT_actuator_remove";
|
2010-05-04 00:06:13 +00:00
|
|
|
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = actuator_remove_invoke;
|
|
|
|
|
ot->exec = actuator_remove_exec;
|
|
|
|
|
ot->poll = edit_actuator_poll;
|
2010-05-04 00:06:13 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2010-06-17 06:34:11 +00:00
|
|
|
edit_actuator_properties(ot);
|
2010-05-04 00:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int actuator_add_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
Object *ob;
|
2010-05-04 00:06:13 +00:00
|
|
|
bActuator *act;
|
2010-05-10 05:46:01 +00:00
|
|
|
PointerRNA act_ptr;
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
const char *act_name;
|
2012-01-11 08:51:06 +00:00
|
|
|
char name[MAX_NAME];
|
2010-05-04 00:06:13 +00:00
|
|
|
int type= RNA_enum_get(op->ptr, "type");
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
|
|
|
|
|
ob= edit_object_property_get(C, op);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ob)
|
Logics ops: add s/c/a can now be called with an object parameter (e.g. bpy.ops.logic.controller_add_exec(name="name", object="non_active_object")
If no parameter is passed it uses the active object.
To do: make logic_window set "active object" in context before calling add s/c/a operator
So far I tried this before uiItemMenuEnumO(row, "LOGIC_OT_controller_add", "type", "Add Controller", 0); :
+RNA_pointer_create((ID *)ob, &RNA_Object, ob, &ob_ptr);
+uiLayoutSetContextPointer(row, "object", &ob_ptr);
Not working though :) (not committed either). to be investigated.
2010-06-17 08:42:15 +00:00
|
|
|
return OPERATOR_CANCELLED;
|
2010-05-04 00:06:13 +00:00
|
|
|
|
|
|
|
|
act= new_actuator(type);
|
|
|
|
|
BLI_addtail(&(ob->actuators), act);
|
2010-05-10 05:46:01 +00:00
|
|
|
|
|
|
|
|
/* set the actuator name based on rna type enum */
|
|
|
|
|
RNA_pointer_create((ID *)ob, &RNA_Actuator, act, &act_ptr);
|
|
|
|
|
prop = RNA_struct_find_property(&act_ptr, "type");
|
2010-05-14 10:45:50 +00:00
|
|
|
|
|
|
|
|
RNA_string_get(op->ptr, "name", name);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (BLI_strnlen(name, MAX_NAME) < 1) {
|
2010-05-14 10:45:50 +00:00
|
|
|
RNA_property_enum_name(C, &act_ptr, prop, RNA_property_enum_get(&act_ptr, prop), &act_name);
|
|
|
|
|
BLI_strncpy(act->name, act_name, sizeof(act->name));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
BLI_strncpy(act->name, name, sizeof(act->name));
|
|
|
|
|
|
2010-05-04 00:06:13 +00:00
|
|
|
make_unique_prop_names(C, act->name);
|
2010-05-05 00:12:31 +00:00
|
|
|
ob->scaflag |= OB_SHOWACT;
|
2010-05-10 05:46:01 +00:00
|
|
|
|
2010-05-04 00:06:13 +00:00
|
|
|
WM_event_add_notifier(C, NC_LOGIC, NULL);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void LOGIC_OT_actuator_add(wmOperatorType *ot)
|
2010-05-04 00:06:13 +00:00
|
|
|
{
|
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Add Actuator";
|
2011-10-20 07:56:04 +00:00
|
|
|
ot->description = "Add an actuator to the active object";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "LOGIC_OT_actuator_add";
|
2010-05-04 00:06:13 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = WM_menu_invoke;
|
|
|
|
|
ot->exec = actuator_add_exec;
|
|
|
|
|
ot->poll = ED_operator_object_active_editable;
|
2010-05-04 00:06:13 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2010-05-04 00:06:13 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->prop = prop= RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, CONT_LOGIC_AND, "Type", "Type of actuator to add");
|
2010-05-07 02:01:50 +00:00
|
|
|
RNA_def_enum_funcs(prop, rna_Actuator_type_itemf);
|
2012-01-11 08:51:06 +00:00
|
|
|
RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Name of the Actuator to add");
|
|
|
|
|
RNA_def_string(ot->srna, "object", "", MAX_NAME, "Object", "Name of the Object to add the Actuator to");
|
2010-05-04 00:06:13 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-09 00:14:46 +00:00
|
|
|
/* ************* Move Logic Bricks Operator ************* */
|
|
|
|
|
static EnumPropertyItem logicbricks_move_direction[] ={
|
|
|
|
|
{1, "UP", 0, "Move Up", ""},
|
|
|
|
|
{2, "DOWN", 0, "Move Down", ""},
|
|
|
|
|
{0, NULL, 0, NULL, NULL}};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int sensor_move_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Object *ob=NULL;
|
|
|
|
|
bSensor *sens= edit_sensor_property_get(C, op, &ob);
|
|
|
|
|
int move_up= logicbricks_move_property_get(op);
|
|
|
|
|
|
|
|
|
|
if (!sens)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
sca_move_sensor(sens, ob, move_up);
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_LOGIC, NULL);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int sensor_move_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
2010-07-09 00:14:46 +00:00
|
|
|
{
|
|
|
|
|
if (edit_sensor_invoke_properties(C, op)) {
|
|
|
|
|
return sensor_move_exec(C, op);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void LOGIC_OT_sensor_move(wmOperatorType *ot)
|
2010-07-09 00:14:46 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Move Sensor";
|
2011-04-19 10:35:24 +00:00
|
|
|
ot->description = "Move Sensor";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "LOGIC_OT_sensor_move";
|
2010-07-09 00:14:46 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = sensor_move_invoke;
|
|
|
|
|
ot->exec = sensor_move_exec;
|
|
|
|
|
ot->poll = edit_sensor_poll;
|
2010-07-09 00:14:46 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2010-07-09 00:14:46 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
edit_sensor_properties(ot);
|
|
|
|
|
RNA_def_enum(ot->srna, "direction", logicbricks_move_direction, 1, "Direction", "Move Up or Down");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int controller_move_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Object *ob=NULL;
|
|
|
|
|
bController *cont= edit_controller_property_get(C, op, &ob);
|
|
|
|
|
int move_up= logicbricks_move_property_get(op);
|
|
|
|
|
|
|
|
|
|
if (!cont)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
sca_move_controller(cont, ob, move_up);
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_LOGIC, NULL);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int controller_move_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
2010-07-09 00:14:46 +00:00
|
|
|
{
|
|
|
|
|
if (edit_controller_invoke_properties(C, op)) {
|
|
|
|
|
return controller_move_exec(C, op);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void LOGIC_OT_controller_move(wmOperatorType *ot)
|
2010-07-09 00:14:46 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Move Controller";
|
2010-07-09 00:14:46 +00:00
|
|
|
ot->description = "Move Controller";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "LOGIC_OT_controller_move";
|
2010-07-09 00:14:46 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = controller_move_invoke;
|
|
|
|
|
ot->exec = controller_move_exec;
|
|
|
|
|
ot->poll = edit_controller_poll;
|
2010-07-09 00:14:46 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2010-07-09 00:14:46 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
edit_controller_properties(ot);
|
|
|
|
|
RNA_def_enum(ot->srna, "direction", logicbricks_move_direction, 1, "Direction", "Move Up or Down");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int actuator_move_exec(bContext *C, wmOperator *op)
|
|
|
|
|
{
|
|
|
|
|
Object *ob=NULL;
|
|
|
|
|
bActuator *act = edit_actuator_property_get(C, op, &ob);
|
|
|
|
|
int move_up= logicbricks_move_property_get(op);
|
|
|
|
|
|
|
|
|
|
if (!act)
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
|
|
|
|
|
sca_move_actuator(act, ob, move_up);
|
|
|
|
|
|
|
|
|
|
WM_event_add_notifier(C, NC_LOGIC, NULL);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-15 01:36:14 +00:00
|
|
|
static int actuator_move_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
2010-07-09 00:14:46 +00:00
|
|
|
{
|
|
|
|
|
if (edit_actuator_invoke_properties(C, op)) {
|
|
|
|
|
return actuator_move_exec(C, op);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return OPERATOR_CANCELLED;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-14 17:55:27 +00:00
|
|
|
static void LOGIC_OT_actuator_move(wmOperatorType *ot)
|
2010-07-09 00:14:46 +00:00
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "Move Actuator";
|
2010-07-09 00:14:46 +00:00
|
|
|
ot->description = "Move Actuator";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "LOGIC_OT_actuator_move";
|
2010-07-09 00:14:46 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = actuator_move_invoke;
|
|
|
|
|
ot->exec = actuator_move_exec;
|
|
|
|
|
ot->poll = edit_actuator_poll;
|
2010-07-09 00:14:46 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
2010-07-09 00:14:46 +00:00
|
|
|
|
|
|
|
|
/* properties */
|
|
|
|
|
edit_actuator_properties(ot);
|
|
|
|
|
RNA_def_enum(ot->srna, "direction", logicbricks_move_direction, 1, "Direction", "Move Up or Down");
|
|
|
|
|
}
|
|
|
|
|
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
/* ************* TexFace Converter Operator ************* */
|
|
|
|
|
static int texface_convert_exec(bContext *C, wmOperator *UNUSED(op))
|
|
|
|
|
{
|
|
|
|
|
Main *bmain= CTX_data_main(C);
|
|
|
|
|
do_version_tface(bmain, 0);
|
|
|
|
|
|
|
|
|
|
return OPERATOR_FINISHED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int texface_convert_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
|
|
|
|
|
{
|
|
|
|
|
return texface_convert_exec(C, op);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void LOGIC_OT_texface_convert(wmOperatorType *ot)
|
|
|
|
|
{
|
|
|
|
|
/* identifiers */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->name = "TexFace to Material Converter";
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
ot->description = "Convert old texface settings into material. It may create new materials if needed";
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->idname = "LOGIC_OT_texface_convert";
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
|
|
|
|
|
/* api callbacks */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->invoke = texface_convert_invoke;
|
|
|
|
|
ot->exec = texface_convert_exec;
|
|
|
|
|
// ot->poll = texface_convert_poll;
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
|
|
|
|
|
/* flags */
|
2012-03-22 07:26:09 +00:00
|
|
|
ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-09 00:14:46 +00:00
|
|
|
|
2010-04-29 07:01:48 +00:00
|
|
|
void ED_operatortypes_logic(void)
|
|
|
|
|
{
|
|
|
|
|
WM_operatortype_append(LOGIC_OT_sensor_remove);
|
|
|
|
|
WM_operatortype_append(LOGIC_OT_sensor_add);
|
2010-07-09 00:14:46 +00:00
|
|
|
WM_operatortype_append(LOGIC_OT_sensor_move);
|
2010-05-04 00:06:13 +00:00
|
|
|
WM_operatortype_append(LOGIC_OT_controller_remove);
|
|
|
|
|
WM_operatortype_append(LOGIC_OT_controller_add);
|
2010-07-09 00:14:46 +00:00
|
|
|
WM_operatortype_append(LOGIC_OT_controller_move);
|
2010-05-04 00:06:13 +00:00
|
|
|
WM_operatortype_append(LOGIC_OT_actuator_remove);
|
|
|
|
|
WM_operatortype_append(LOGIC_OT_actuator_add);
|
2010-07-09 00:14:46 +00:00
|
|
|
WM_operatortype_append(LOGIC_OT_actuator_move);
|
TexFace to Material Settings big patch
Summary:
========
The idea here is to move the texface options into the material panel.
For images with the change please visit:
http://code.blender.org/index.php/2011/09/bge-material-texface-changes
1 - Some of the legacy problems 2.49 and 2.5x has with the texface system:
==========================================================================
1.1) Shadow, Bilboard and Halo are mutual exclusive (in the code), yet you can
select a face to be more than one mode.
1.2) Sort only works for blend Alpha yet it's an option regardless of the
Transparency Blend you pick.
1.3) Shared doesn't affect anything in BGE.
1.4) ObColor only works for Text objects (old bitmap texts) when using Texture
Face Materials. (not address yet, I so far ignored obcolor)
2 - Notes:
============
2.1) Now "Use Face Textures" in material Option panel will work in Multitexture
even if there is no texture channel.
2.2) In FaceTexture mode it will use TexFace all the time, even if you don't
check the "Use Texture Face" option in the UI. It's a matter of decision, since
the code for either way is there. I decided by the solution that makes the
creation of a material fast - in this mode the user doesn't need to mess with
textures or this "Use Texture Face" option at all. I'm not strong in my opinion
here. But I think if we don't have this then what is the point of the Texture
Face mode?
2.3) I kept references for tface only when we need the image, UV or the tiling
setting. It should help later when/if we split the Image and UV layers from the
tface struct (Campbell and Brecht proposal).
3 - Changes in a Nutshell:
==========================
3.1) "Texture Face" panel (in the Mesh/Object Data panel) no longer exists. Those settings are all part of the material properties, visible when Game Render is set.
3.2) "Texture Face" Shading mode (in the Render panel) is now called “Single Texture”, it needs a material for special settings (e.g. Billboard, Alpha Sort, …).
3.3) New options in the Material Panel
* Shadeless option in the Material panel is now supported for all three Shading modes.
* Physics is now toggleable, this is the old Collision option.
* Two Side (on) is now called Back Culling (off).
* Alpha Sort is one of the Alpha options, together (and mutually exclusive) to Alpha Blend, Alpha Clip, Add and Opaque (i.e. solid).
* Shadow, Billboard and Halo are grouped in the “Face Orientation” property.
* "Face Textures" and "Face Textures Alpha" (under Options) can be used for all but GLSL shading mode (to be supported in GLSL eventually).
* The backend in the game engine is still the same as before. The only changes are in the interface and in the way you need to think your materials. The bottomline is: It’s no longer possible to share materials between faces that do not share the same game properties.
4 - Acknowledgment:
==================
Mike Pan for the design discussions, and testing along the whole development process.
Vitor Balbio for the first hands-on code with the interface changes. That helped me a lot to push me into work on that.
Benoit Bolsee and Brecht van Lommel for patch review (* no one reviewed the whole patch, or the latest iteractions, so I still hold liability for any problems).
Blender artists that gave feedback and helped testing the patch.
Patch review and original documentation can be found here:
http://wiki.blender.org/index.php/User:Dfelinto/TexFace
http://codereview.appspot.com/4289041/
2011-09-19 19:55:59 +00:00
|
|
|
WM_operatortype_append(LOGIC_OT_texface_convert);
|
2010-04-29 07:01:48 +00:00
|
|
|
}
|