forked from bartvdbraak/blender
Py API (GSoC): Second merging commit
Rough summary of fixes/changes: - Blender Py API: GameLogic -> bge.logic - Blender Py API: Implemented missing KX_PYATTRIBUTE_TODOs and -DUMMYs. - Fix for [#22924] KX_PolygonMaterial.diffuse does not return expected list[r,g,b] - Py API: Renaming _owner attribute of mathutils classes to owner. - Fix some minor errors in mathutils and blf. - Enabling game engine autoplay again based on a patch by Dalai: * The biggest 3D view in the open scene is used, if there is none, blender opens the file normally and raises an error. * The 3D view are is made fullscreen. * Quad view, header, properties and toolbox panel are all hidden to get the maximum view. * If the game engine full screen setting is set, the game starts in fullscreen. - Fix for ipo conversion on file transition in the game engine.
This commit is contained in:
parent
25fec1592e
commit
0be08725ad
@ -2529,7 +2529,7 @@ static short draw_actuatorbuttons(Main *bmain, Object *ob, bActuator *act, uiBlo
|
||||
}
|
||||
|
||||
//str = "Scene %t|Load game%x0|Start loaded game%x1|Restart this game%x2|Quit this game %x3";
|
||||
str = "Scene %t|Start new game%x0|Restart this game%x2|Quit this game %x3|Save GameLogic.globalDict %x4|Load GameLogic.globalDict %x5";
|
||||
str = "Scene %t|Start new game%x0|Restart this game%x2|Quit this game %x3|Save bge.logic.globalDict %x4|Load bge.logic.globalDict %x5";
|
||||
uiDefButS(block, MENU, B_REDR, str, xco+40, yco-24, (width-80), 19, &gma->type, 0.0, 0.0, 0, 0, "");
|
||||
|
||||
yco -= ysize;
|
||||
|
@ -1557,8 +1557,8 @@ static void rna_def_game_actuator(BlenderRNA *brna)
|
||||
{ACT_GAME_LOAD, "START", 0, "Start new game", ""},
|
||||
{ACT_GAME_RESTART, "RESTART", 0, "Restart this game", ""},
|
||||
{ACT_GAME_QUIT, "QUIT", 0, "Quit this game", ""},
|
||||
{ACT_GAME_SAVECFG, "SAVECFG", 0, "Save GameLogic.globalDict", ""},
|
||||
{ACT_GAME_LOADCFG, "LOADCFG", 0, "Load GameLogic.globalDict", ""},
|
||||
{ACT_GAME_SAVECFG, "SAVECFG", 0, "Save bge.logic.globalDict", ""},
|
||||
{ACT_GAME_LOADCFG, "LOADCFG", 0, "Load bge.logic.globalDict", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
srna= RNA_def_struct(brna, "GameActuator", "Actuator");
|
||||
|
@ -39,7 +39,7 @@ static char py_blf_position_doc[] =
|
||||
" :arg y: Y axis position to draw the text.\n"
|
||||
" :type y: float\n"
|
||||
" :arg z: Z axis position to draw the text.\n"
|
||||
" :type x: float\n";
|
||||
" :type z: float\n";
|
||||
|
||||
static PyObject *py_blf_position(PyObject *self, PyObject *args)
|
||||
{
|
||||
@ -261,7 +261,7 @@ static char py_blf_rotation_doc[] =
|
||||
" :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default font use 0.\n"
|
||||
" :type fontid: int\n"
|
||||
" :arg angle: The angle for text drawing to use.\n"
|
||||
" :type aspect: float\n";
|
||||
" :type angle: float\n";
|
||||
|
||||
static PyObject *py_blf_rotation(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
@ -445,7 +445,7 @@ static PyGetSetDef Color_getseters[] = {
|
||||
{"hsv", (getter)Color_getHSV, (setter)Color_setHSV, "HSV Values in [0, 1].\n\n:type: float triplet", (void *)0},
|
||||
|
||||
{"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL},
|
||||
{"_owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
|
||||
{"owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
|
||||
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
@ -621,7 +621,7 @@ static PyGetSetDef Euler_getseters[] = {
|
||||
{"order", (getter)Euler_getOrder, (setter)Euler_setOrder, "Euler rotation order.\n\n:type: string in ['XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX']", (void *)NULL},
|
||||
|
||||
{"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL},
|
||||
{"_owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
|
||||
{"owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
|
||||
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
@ -1737,7 +1737,7 @@ static PyGetSetDef Matrix_getseters[] = {
|
||||
{"median_scale", (getter)Matrix_getMedianScale, (setter)NULL, "The average scale applied to each axis (readonly).\n\n:type: float", NULL},
|
||||
{"is_negative", (getter)Matrix_getIsNegative, (setter)NULL, "True if this matrix results in a negative scale, 3x3 and 4x4 only, (readonly).\n\n:type: bool", NULL},
|
||||
{"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL},
|
||||
{"_owner",(getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
|
||||
{"owner",(getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
|
||||
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
@ -109,7 +109,7 @@ static PyObject *Quaternion_ToEuler(QuaternionObject * self, PyObject *args)
|
||||
}
|
||||
//----------------------------Quaternion.toMatrix()------------------
|
||||
static char Quaternion_ToMatrix_doc[] =
|
||||
".. method:: to_matrix(other)\n"
|
||||
".. method:: to_matrix()\n"
|
||||
"\n"
|
||||
" Return a matrix representation of the quaternion.\n"
|
||||
"\n"
|
||||
@ -930,7 +930,7 @@ static PyGetSetDef Quaternion_getseters[] = {
|
||||
{"angle", (getter)Quaternion_getAngle, (setter)Quaternion_setAngle, "angle of the quaternion.\n\n:type: float", NULL},
|
||||
{"axis",(getter)Quaternion_getAxisVec, (setter)Quaternion_setAxisVec, "quaternion axis as a vector.\n\n:type: :class:`Vector`", NULL},
|
||||
{"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL},
|
||||
{"_owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
|
||||
{"owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
|
||||
{NULL,NULL,NULL,NULL,NULL} /* Sentinel */
|
||||
};
|
||||
|
||||
|
@ -508,7 +508,8 @@ static char Vector_angle_doc[] =
|
||||
" :arg other: another vector to compare the angle with\n"
|
||||
" :type other: :class:`Vector`\n"
|
||||
" :arg fallback: return this value when the angle cant be calculated (zero length vector)\n"
|
||||
" :return angle: angle in radians or fallback when given\n"
|
||||
" :type fallback: any\n"
|
||||
" :return: angle in radians or fallback when given\n"
|
||||
" :rtype: float\n"
|
||||
"\n"
|
||||
" .. note:: Zero length vectors raise an :exc:`AttributeError`.\n";
|
||||
@ -607,8 +608,9 @@ static char Vector_Project_doc[] =
|
||||
"\n"
|
||||
" Return the projection of this vector onto the *other*.\n"
|
||||
"\n"
|
||||
" :arg other: second vector.\n"
|
||||
" :type other: :class:`Vector`\n"
|
||||
" :return projection: the parallel projection vector\n"
|
||||
" :return: the parallel projection vector\n"
|
||||
" :rtype: :class:`Vector`\n";
|
||||
|
||||
static PyObject *Vector_Project(VectorObject *self, VectorObject *value)
|
||||
@ -1601,7 +1603,7 @@ static PyGetSetDef Vector_getseters[] = {
|
||||
{"length", (getter)Vector_getLength, (setter)Vector_setLength, "Vector Length.\n\n:type: float", NULL},
|
||||
{"magnitude", (getter)Vector_getLength, (setter)Vector_setLength, "Vector Length.\n\n:type: float", NULL},
|
||||
{"is_wrapped", (getter)BaseMathObject_getWrapped, (setter)NULL, BaseMathObject_Wrapped_doc, NULL},
|
||||
{"_owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
|
||||
{"owner", (getter)BaseMathObject_getOwner, (setter)NULL, BaseMathObject_Owner_doc, NULL},
|
||||
|
||||
/* autogenerated swizzle attrs, see python script below */
|
||||
{"xx", (getter)Vector_getSwizzle, (setter)NULL, NULL, SET_INT_IN_POINTER(((0|SWIZZLE_VALID_AXIS) | ((0|SWIZZLE_VALID_AXIS)<<SWIZZLE_BITS_PER_AXIS)))}, // 36
|
||||
|
@ -57,7 +57,7 @@ void WM_init (struct bContext *C, int argc, char **argv);
|
||||
void WM_exit (struct bContext *C);
|
||||
void WM_main (struct bContext *C);
|
||||
|
||||
void WM_init_game (struct bContext *C);
|
||||
int WM_init_game (struct bContext *C);
|
||||
void WM_init_splash (struct bContext *C);
|
||||
|
||||
|
||||
|
@ -49,6 +49,7 @@
|
||||
#include "BKE_font.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_library.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_mball.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_utildefines.h"
|
||||
@ -94,6 +95,7 @@
|
||||
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_sound.h"
|
||||
#include "GHOST_C-api.h"
|
||||
|
||||
static void wm_init_reports(bContext *C)
|
||||
{
|
||||
@ -186,18 +188,113 @@ void WM_init_splash(bContext *C)
|
||||
}
|
||||
}
|
||||
|
||||
void WM_init_game(bContext *C)
|
||||
static ScrArea *biggest_view3d(bContext *C)
|
||||
{
|
||||
//XXX copied from WM_init_splash we may not even need those "window" related code
|
||||
//XXX not working yet, it fails at the game_start_operator pool (it needs an area)
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
wmWindow *prevwin= CTX_wm_window(C);
|
||||
|
||||
if(wm->windows.first) {
|
||||
CTX_wm_window_set(C, wm->windows.first);
|
||||
WM_operator_name_call(C, "VIEW3D_OT_game_start", WM_OP_EXEC_DEFAULT, NULL);
|
||||
CTX_wm_window_set(C, prevwin);
|
||||
bScreen *sc= CTX_wm_screen(C);
|
||||
ScrArea *sa, *big= NULL;
|
||||
int size, maxsize= 0;
|
||||
|
||||
for(sa= sc->areabase.first; sa; sa= sa->next) {
|
||||
if(sa->spacetype==SPACE_VIEW3D) {
|
||||
size= sa->winx * sa->winy;
|
||||
if(size > maxsize) {
|
||||
maxsize= size;
|
||||
big= sa;
|
||||
}
|
||||
}
|
||||
}
|
||||
return big;
|
||||
}
|
||||
|
||||
int WM_init_game(bContext *C)
|
||||
{
|
||||
wmWindowManager *wm= CTX_wm_manager(C);
|
||||
wmWindow* win;
|
||||
|
||||
ScrArea *sa;
|
||||
ARegion *ar;
|
||||
|
||||
Main *main = CTX_data_main(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
|
||||
if (!scene)
|
||||
scene= main->scene.first;
|
||||
|
||||
win = wm->windows.first;
|
||||
|
||||
//first to get a valid window
|
||||
if(win)
|
||||
CTX_wm_window_set(C, win);
|
||||
|
||||
sa = biggest_view3d(C);
|
||||
|
||||
if(sa)
|
||||
{
|
||||
for(ar=sa->regionbase.first; ar; ar=ar->next) {
|
||||
if(ar->regiontype == RGN_TYPE_WINDOW) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we have a valid 3D view
|
||||
if (sa && ar) {
|
||||
ARegion *arhide;
|
||||
|
||||
CTX_wm_area_set(C, sa);
|
||||
CTX_wm_region_set(C, ar);
|
||||
|
||||
/* disable quad view */
|
||||
if(ar->alignment == RGN_ALIGN_QSPLIT)
|
||||
WM_operator_name_call(C, "SCREEN_OT_region_quadview", WM_OP_EXEC_DEFAULT, NULL);
|
||||
|
||||
/* toolbox, properties panel and header are hidden */
|
||||
for(arhide=sa->regionbase.first; arhide; arhide=arhide->next) {
|
||||
if(arhide->regiontype != RGN_TYPE_WINDOW) {
|
||||
if(!(arhide->flag & RGN_FLAG_HIDDEN)) {
|
||||
ED_region_toggle_hidden(C, arhide);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* full screen the area */
|
||||
if(!sa->full) {
|
||||
ED_screen_full_toggle(C, wm->windows.first, sa);
|
||||
}
|
||||
|
||||
/* Fullscreen */
|
||||
if(scene->gm.fullscreen) {
|
||||
WM_operator_name_call(C, "WM_OT_window_fullscreen_toggle", WM_OP_EXEC_DEFAULT, NULL);
|
||||
wm_get_screensize(&ar->winrct.xmax, &ar->winrct.ymax);
|
||||
}
|
||||
else
|
||||
{
|
||||
GHOST_RectangleHandle rect = GHOST_GetClientBounds(win->ghostwin);
|
||||
ar->winrct.ymax = GHOST_GetHeightRectangle(rect);
|
||||
ar->winrct.xmax = GHOST_GetWidthRectangle(rect);
|
||||
GHOST_DisposeRectangle(rect);
|
||||
}
|
||||
|
||||
WM_operator_name_call(C, "VIEW3D_OT_game_start", WM_OP_EXEC_DEFAULT, NULL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReportTimerInfo *rti;
|
||||
|
||||
BKE_report(&wm->reports, RPT_ERROR, "No valid 3D View found. Game auto start is not possible.");
|
||||
|
||||
/* After adding the report to the global list, reset the report timer. */
|
||||
WM_event_remove_timer(wm, NULL, wm->reports.reporttimer);
|
||||
|
||||
/* Records time since last report was added */
|
||||
wm->reports.reporttimer = WM_event_add_timer(wm, CTX_wm_window(C), TIMER, 0.02);
|
||||
|
||||
rti = MEM_callocN(sizeof(ReportTimerInfo), "ReportTimerInfo");
|
||||
wm->reports.reporttimer->customdata = rti;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* free strings of open recent files */
|
||||
|
@ -73,7 +73,7 @@ static int prefsizx= 0, prefsizy= 0, prefstax= 0, prefstay= 0;
|
||||
|
||||
/* XXX this one should correctly check for apple top header...
|
||||
done for Cocoa : returns window contents (and not frame) max size*/
|
||||
static void wm_get_screensize(int *width_r, int *height_r)
|
||||
void wm_get_screensize(int *width_r, int *height_r)
|
||||
{
|
||||
unsigned int uiwidth;
|
||||
unsigned int uiheight;
|
||||
|
@ -36,6 +36,8 @@ struct wmOperator;
|
||||
void wm_ghost_init (bContext *C);
|
||||
void wm_ghost_exit(void);
|
||||
|
||||
void wm_get_screensize(int *width_r, int *height_r);
|
||||
|
||||
wmWindow *wm_window_new (bContext *C);
|
||||
void wm_window_free (bContext *C, wmWindowManager *wm, wmWindow *win);
|
||||
void wm_window_close (bContext *C, wmWindowManager *wm, wmWindow *win);
|
||||
|
@ -1144,8 +1144,10 @@ int main(int argc, char **argv)
|
||||
|
||||
else {
|
||||
if((G.fileflags & G_FILE_AUTOPLAY) && (G.f & G_SCRIPT_AUTOEXEC))
|
||||
WM_init_game(C);
|
||||
|
||||
{
|
||||
if(WM_init_game(C))
|
||||
return 0;
|
||||
}
|
||||
else if(!G.file_loaded)
|
||||
WM_init_splash(C);
|
||||
}
|
||||
|
@ -319,9 +319,6 @@ typedef struct KX_PYATTRIBUTE_DEF {
|
||||
} m_typeCheck;
|
||||
} PyAttributeDef;
|
||||
|
||||
#define KX_PYATTRIBUTE_DUMMY(name) \
|
||||
{ name, KX_PYATTRIBUTE_TYPE_DUMMY, KX_PYATTRIBUTE_RO, 0, 0, 0.f, 0.f, false, false, 0, 0, 1, NULL, NULL, NULL, {NULL, NULL, NULL, NULL, NULL, NULL, NULL} }
|
||||
|
||||
#define KX_PYATTRIBUTE_BOOL_RW(name,object,field) \
|
||||
{ name, KX_PYATTRIBUTE_TYPE_BOOL, KX_PYATTRIBUTE_RW, 0, 1, 0.f, 0.f, false, false, offsetof(object,field), 0, 1, NULL, NULL, NULL, {&((object *)0)->field, NULL, NULL, NULL, NULL, NULL, NULL} }
|
||||
#define KX_PYATTRIBUTE_BOOL_RW_CHECK(name,object,field,function) \
|
||||
|
@ -357,9 +357,8 @@ PyAttributeDef SCA_ISensor::Attributes[] = {
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("triggered", SCA_ISensor, pyattr_get_triggered),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("positive", SCA_ISensor, pyattr_get_positive),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("status", SCA_ISensor, pyattr_get_status),
|
||||
//KX_PYATTRIBUTE_TODO("links"),
|
||||
//KX_PYATTRIBUTE_TODO("posTicks"),
|
||||
//KX_PYATTRIBUTE_TODO("negTicks"),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("pos_ticks", SCA_ISensor, pyattr_get_posTicks),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("neg_ticks", SCA_ISensor, pyattr_get_negTicks),
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
@ -401,6 +400,18 @@ PyObject* SCA_ISensor::pyattr_get_status(void *self_v, const KX_PYATTRIBUTE_DEF
|
||||
return PyLong_FromSsize_t(status);
|
||||
}
|
||||
|
||||
PyObject* SCA_ISensor::pyattr_get_posTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v);
|
||||
return PyLong_FromLong(self->GetPosTicks());
|
||||
}
|
||||
|
||||
PyObject* SCA_ISensor::pyattr_get_negTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v);
|
||||
return PyLong_FromLong(self->GetNegTicks());
|
||||
}
|
||||
|
||||
int SCA_ISensor::pyattr_check_level(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
SCA_ISensor* self= static_cast<SCA_ISensor*>(self_v);
|
||||
|
@ -167,6 +167,18 @@ public:
|
||||
return m_prev_state;
|
||||
}
|
||||
|
||||
/** get the number of ticks since the last positive pulse */
|
||||
int GetPosTicks()
|
||||
{
|
||||
return m_pos_ticks;
|
||||
}
|
||||
|
||||
/** get the number of ticks since the last negative pulse */
|
||||
int GetNegTicks()
|
||||
{
|
||||
return m_neg_ticks;
|
||||
}
|
||||
|
||||
/** Resume sensing. */
|
||||
void Resume();
|
||||
|
||||
@ -185,6 +197,9 @@ public:
|
||||
static PyObject* pyattr_get_triggered(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_positive(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_status(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_posTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_negTicks(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
|
||||
static int pyattr_check_level(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static int pyattr_check_tap(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
|
||||
|
@ -290,7 +290,6 @@ PyAttributeDef SCA_JoystickSensor::Attributes[] = {
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("numButtons", SCA_JoystickSensor, pyattr_get_num_buttons),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("numHats", SCA_JoystickSensor, pyattr_get_num_hats),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("connected", SCA_JoystickSensor, pyattr_get_connected),
|
||||
//KX_PYATTRIBUTE_TODO("events"),
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
|
@ -178,7 +178,7 @@ PyObject* SCA_PythonController::sPyGetCurrentController(PyObject *self)
|
||||
{
|
||||
if(m_sCurrentController==NULL)
|
||||
{
|
||||
PyErr_SetString(PyExc_SystemError, "GameLogic.getCurrentController(), this function is being run outside the python controllers context, or blenders internal state is corrupt.");
|
||||
PyErr_SetString(PyExc_SystemError, "bge.logic.getCurrentController(), this function is being run outside the python controllers context, or blenders internal state is corrupt.");
|
||||
return NULL;
|
||||
}
|
||||
return m_sCurrentController->GetProxy();
|
||||
|
@ -794,9 +794,9 @@ PyMethodDef KX_BlenderMaterial::Methods[] =
|
||||
};
|
||||
|
||||
PyAttributeDef KX_BlenderMaterial::Attributes[] = {
|
||||
//KX_PYATTRIBUTE_TODO("shader"),
|
||||
//KX_PYATTRIBUTE_TODO("materialIndex"),
|
||||
//KX_PYATTRIBUTE_TODO("blending"),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("shader", KX_BlenderMaterial, pyattr_get_shader),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("material_index", KX_BlenderMaterial, pyattr_get_materialIndex),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("blending", KX_BlenderMaterial, pyattr_get_blending, pyattr_set_blending),
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
@ -822,6 +822,37 @@ PyTypeObject KX_BlenderMaterial::Type = {
|
||||
py_base_new
|
||||
};
|
||||
|
||||
PyObject* KX_BlenderMaterial::pyattr_get_shader(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_BlenderMaterial* self= static_cast<KX_BlenderMaterial*>(self_v);
|
||||
return self->PygetShader(NULL, NULL);
|
||||
}
|
||||
|
||||
PyObject* KX_BlenderMaterial::pyattr_get_materialIndex(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_BlenderMaterial* self= static_cast<KX_BlenderMaterial*>(self_v);
|
||||
return PyLong_FromSsize_t(self->GetMaterialIndex());
|
||||
}
|
||||
|
||||
PyObject* KX_BlenderMaterial::pyattr_get_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_BlenderMaterial* self= static_cast<KX_BlenderMaterial*>(self_v);
|
||||
unsigned int* bfunc = self->getBlendFunc();
|
||||
return Py_BuildValue("(ll)", (long int)bfunc[0], (long int)bfunc[1]);
|
||||
}
|
||||
|
||||
int KX_BlenderMaterial::pyattr_set_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_BlenderMaterial* self= static_cast<KX_BlenderMaterial*>(self_v);
|
||||
PyObject* obj = self->PysetBlending(value, NULL);
|
||||
if(obj)
|
||||
{
|
||||
Py_DECREF(obj);
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, getShader , "getShader()")
|
||||
{
|
||||
if( !GLEW_ARB_fragment_shader) {
|
||||
@ -908,7 +939,7 @@ static unsigned int GL_array[11] = {
|
||||
GL_SRC_ALPHA_SATURATE
|
||||
};
|
||||
|
||||
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, setBlending , "setBlending( GameLogic.src, GameLogic.dest)")
|
||||
KX_PYMETHODDEF_DOC( KX_BlenderMaterial, setBlending , "setBlending( bge.logic.src, bge.logic.dest)")
|
||||
{
|
||||
unsigned int b[2];
|
||||
if(PyArg_ParseTuple(args, "ii:setBlending", &b[0], &b[1]))
|
||||
|
@ -79,6 +79,9 @@ public:
|
||||
Image * getImage (unsigned int idx) {
|
||||
return (idx < MAXTEX && mMaterial) ? mMaterial->img[idx] : NULL;
|
||||
}
|
||||
unsigned int* getBlendFunc() {
|
||||
return mBlendFunc;
|
||||
}
|
||||
// for ipos
|
||||
void UpdateIPO(
|
||||
MT_Vector4 rgba, MT_Vector3 specrgb,
|
||||
@ -99,6 +102,11 @@ public:
|
||||
// --------------------------------
|
||||
virtual PyObject* py_repr(void) { return PyUnicode_FromString(mMaterial->matname.ReadPtr()); }
|
||||
|
||||
static PyObject* pyattr_get_shader(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_materialIndex(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static int pyattr_set_blending(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
|
||||
KX_PYMETHOD_DOC( KX_BlenderMaterial, getShader );
|
||||
KX_PYMETHOD_DOC( KX_BlenderMaterial, getMaterialIndex );
|
||||
KX_PYMETHOD_DOC( KX_BlenderMaterial, getTexture );
|
||||
|
@ -553,8 +553,8 @@ KX_PYMETHODDEF_DOC_VARARGS(KX_Camera, sphereInsideFrustum,
|
||||
"\tcenter = the center of the sphere (in world coordinates.)\n"
|
||||
"\tradius = the radius of the sphere\n\n"
|
||||
"\tExample:\n"
|
||||
"\timport GameLogic\n\n"
|
||||
"\tco = GameLogic.getCurrentController()\n"
|
||||
"\timport bge.logic\n\n"
|
||||
"\tco = bge.logic.getCurrentController()\n"
|
||||
"\tcam = co.GetOwner()\n\n"
|
||||
"\t# A sphere of radius 4.0 located at [x, y, z] = [1.0, 1.0, 1.0]\n"
|
||||
"\tif (cam.sphereInsideFrustum([1.0, 1.0, 1.0], 4) != cam.OUTSIDE):\n"
|
||||
@ -586,8 +586,8 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, boxInsideFrustum,
|
||||
"\tinside/outside/intersects this camera's viewing frustum.\n\n"
|
||||
"\tbox = a list of the eight (8) corners of the box (in world coordinates.)\n\n"
|
||||
"\tExample:\n"
|
||||
"\timport GameLogic\n\n"
|
||||
"\tco = GameLogic.getCurrentController()\n"
|
||||
"\timport bge.logic\n\n"
|
||||
"\tco = bge.logic.getCurrentController()\n"
|
||||
"\tcam = co.GetOwner()\n\n"
|
||||
"\tbox = []\n"
|
||||
"\tbox.append([-1.0, -1.0, -1.0])\n"
|
||||
@ -630,8 +630,8 @@ KX_PYMETHODDEF_DOC_O(KX_Camera, pointInsideFrustum,
|
||||
"\treturns 1 if the given point is inside this camera's viewing frustum.\n\n"
|
||||
"\tpoint = The point to test (in world coordinates.)\n\n"
|
||||
"\tExample:\n"
|
||||
"\timport GameLogic\n\n"
|
||||
"\tco = GameLogic.getCurrentController()\n"
|
||||
"\timport bge.logic\n\n"
|
||||
"\tco = bge.logic.getCurrentController()\n"
|
||||
"\tcam = co.GetOwner()\n\n"
|
||||
"\t# Test point [0.0, 0.0, 0.0]"
|
||||
"\tif (cam.pointInsideFrustum([0.0, 0.0, 0.0])):\n"
|
||||
|
@ -110,8 +110,14 @@ PyMethodDef KX_ConstraintWrapper::Methods[] = {
|
||||
};
|
||||
|
||||
PyAttributeDef KX_ConstraintWrapper::Attributes[] = {
|
||||
//KX_PYATTRIBUTE_TODO("constraintId"),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("constraint_id", KX_ConstraintWrapper, pyattr_get_constraintId),
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
PyObject* KX_ConstraintWrapper::pyattr_get_constraintId(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_ConstraintWrapper* self= static_cast<KX_ConstraintWrapper*>(self_v);
|
||||
return self->PyGetConstraintId();
|
||||
}
|
||||
|
||||
#endif // DISABLE_PYTHON
|
||||
|
@ -44,6 +44,8 @@ public:
|
||||
KX_PYMETHOD_NOARGS(KX_ConstraintWrapper,GetConstraintId);
|
||||
KX_PYMETHOD(KX_ConstraintWrapper,SetParam);
|
||||
KX_PYMETHOD(KX_ConstraintWrapper,GetParam);
|
||||
|
||||
static PyObject* pyattr_get_constraintId(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
@ -72,90 +72,19 @@ PyMethodDef KX_PolyProxy::Methods[] = {
|
||||
};
|
||||
|
||||
PyAttributeDef KX_PolyProxy::Attributes[] = {
|
||||
/* All dummy's so they come up in a dir() */
|
||||
//KX_PYATTRIBUTE_TODO("DummyProps"),
|
||||
KX_PYATTRIBUTE_DUMMY("matname"),
|
||||
KX_PYATTRIBUTE_DUMMY("texture"),
|
||||
KX_PYATTRIBUTE_DUMMY("material"),
|
||||
KX_PYATTRIBUTE_DUMMY("matid"),
|
||||
KX_PYATTRIBUTE_DUMMY("v1"),
|
||||
KX_PYATTRIBUTE_DUMMY("v2"),
|
||||
KX_PYATTRIBUTE_DUMMY("v3"),
|
||||
KX_PYATTRIBUTE_DUMMY("v4"),
|
||||
KX_PYATTRIBUTE_DUMMY("visible"),
|
||||
KX_PYATTRIBUTE_DUMMY("collide"),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("material_name", KX_PolyProxy, pyattr_get_material_name),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("texture_name", KX_PolyProxy, pyattr_get_texture_name),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("material", KX_PolyProxy, pyattr_get_material),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("material_id", KX_PolyProxy, pyattr_get_material_id),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("v1", KX_PolyProxy, pyattr_get_v1),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("v2", KX_PolyProxy, pyattr_get_v2),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("v3", KX_PolyProxy, pyattr_get_v3),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("v4", KX_PolyProxy, pyattr_get_v4),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("visible", KX_PolyProxy, pyattr_get_visible),
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("collide", KX_PolyProxy, pyattr_get_collide),
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
#if 0
|
||||
PyObject* KX_PolyProxy::py_getattro(PyObject *attr)
|
||||
{
|
||||
char *attr_str= _PyUnicode_AsString(attr);
|
||||
if (!strcmp(attr_str, "matname"))
|
||||
{
|
||||
return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetMaterialName());
|
||||
}
|
||||
if (!strcmp(attr_str, "texture"))
|
||||
{
|
||||
return PyUnicode_FromString(m_polygon->GetMaterial()->GetPolyMaterial()->GetTextureName());
|
||||
}
|
||||
if (!strcmp(attr_str, "material"))
|
||||
{
|
||||
RAS_IPolyMaterial *polymat = m_polygon->GetMaterial()->GetPolyMaterial();
|
||||
if(polymat->GetFlag() & RAS_BLENDERMAT)
|
||||
{
|
||||
KX_BlenderMaterial* mat = static_cast<KX_BlenderMaterial*>(polymat);
|
||||
return mat->GetProxy();
|
||||
}
|
||||
else
|
||||
{
|
||||
KX_PolygonMaterial* mat = static_cast<KX_PolygonMaterial*>(polymat);
|
||||
return mat->GetProxy();
|
||||
}
|
||||
}
|
||||
if (!strcmp(attr_str, "matid"))
|
||||
{
|
||||
// we'll have to scan through the material bucket of the mes and compare with
|
||||
// the one of the polygon
|
||||
RAS_MaterialBucket* polyBucket = m_polygon->GetMaterial();
|
||||
unsigned int matid;
|
||||
for (matid=0; matid<(unsigned int)m_mesh->NumMaterials(); matid++)
|
||||
{
|
||||
RAS_MeshMaterial* meshMat = m_mesh->GetMeshMaterial(matid);
|
||||
if (meshMat->m_bucket == polyBucket)
|
||||
// found it
|
||||
break;
|
||||
}
|
||||
return PyLong_FromSsize_t(matid);
|
||||
}
|
||||
if (!strcmp(attr_str, "v1"))
|
||||
{
|
||||
return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, 0));
|
||||
}
|
||||
if (!strcmp(attr_str, "v2"))
|
||||
{
|
||||
return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, 1));
|
||||
}
|
||||
if (!strcmp(attr_str, "v3"))
|
||||
{
|
||||
return PyLong_FromSsize_t(m_polygon->GetVertexOffsetAbs(m_mesh, 2));
|
||||
}
|
||||
if (!strcmp(attr_str, "v4"))
|
||||
{
|
||||
return PyLong_FromSsize_t(((m_polygon->VertexCount()>3)?m_polygon->GetVertexOffsetAbs(m_mesh, 3):0));
|
||||
}
|
||||
if (!strcmp(attr_str, "visible"))
|
||||
{
|
||||
return PyLong_FromSsize_t(m_polygon->IsVisible());
|
||||
}
|
||||
if (!strcmp(attr_str, "collide"))
|
||||
{
|
||||
return PyLong_FromSsize_t(m_polygon->IsCollider());
|
||||
}
|
||||
// py_getattro_up(CValue); // XXX -- todo, make all these attributes
|
||||
}
|
||||
#endif
|
||||
|
||||
KX_PolyProxy::KX_PolyProxy(const RAS_MeshObject*mesh, RAS_Polygon* polygon)
|
||||
: m_polygon(polygon),
|
||||
m_mesh((RAS_MeshObject*)mesh)
|
||||
@ -179,7 +108,75 @@ CValue* KX_PolyProxy::GetReplica() { return NULL;}
|
||||
|
||||
// stuff for python integration
|
||||
|
||||
KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialIndex,
|
||||
PyObject* KX_PolyProxy::pyattr_get_material_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v);
|
||||
return self->PygetMaterialName();
|
||||
}
|
||||
|
||||
PyObject* KX_PolyProxy::pyattr_get_texture_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v);
|
||||
return self->PygetTextureName();
|
||||
}
|
||||
|
||||
PyObject* KX_PolyProxy::pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v);
|
||||
return self->PygetMaterial();
|
||||
}
|
||||
|
||||
PyObject* KX_PolyProxy::pyattr_get_material_id(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v);
|
||||
return self->PygetMaterialIndex();
|
||||
}
|
||||
|
||||
PyObject* KX_PolyProxy::pyattr_get_v1(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v);
|
||||
|
||||
return PyLong_FromSsize_t(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 0));
|
||||
}
|
||||
|
||||
PyObject* KX_PolyProxy::pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v);
|
||||
|
||||
return PyLong_FromSsize_t(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 1));
|
||||
}
|
||||
|
||||
PyObject* KX_PolyProxy::pyattr_get_v3(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v);
|
||||
|
||||
return PyLong_FromSsize_t(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 2));
|
||||
}
|
||||
|
||||
PyObject* KX_PolyProxy::pyattr_get_v4(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v);
|
||||
|
||||
if (3 < self->m_polygon->VertexCount())
|
||||
{
|
||||
return PyLong_FromSsize_t(self->m_polygon->GetVertexOffsetAbs(self->m_mesh, 3));
|
||||
}
|
||||
return PyLong_FromSsize_t(0);
|
||||
}
|
||||
|
||||
PyObject* KX_PolyProxy::pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v);
|
||||
return self->PyisVisible();
|
||||
}
|
||||
|
||||
PyObject* KX_PolyProxy::pyattr_get_collide(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_PolyProxy* self= static_cast<KX_PolyProxy*>(self_v);
|
||||
return self->PyisCollider();
|
||||
}
|
||||
|
||||
KX_PYMETHODDEF_DOC_NOARGS(KX_PolyProxy, getMaterialIndex,
|
||||
"getMaterialIndex() : return the material index of the polygon in the mesh\n")
|
||||
{
|
||||
RAS_MaterialBucket* polyBucket = m_polygon->GetMaterial();
|
||||
|
@ -54,6 +54,16 @@ public:
|
||||
|
||||
|
||||
// stuff for python integration
|
||||
static PyObject* pyattr_get_material_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_texture_name(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_material(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_material_id(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_v1(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_v3(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_v4(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_visible(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_collide(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
|
||||
KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getMaterialIndex)
|
||||
KX_PYMETHOD_DOC_NOARGS(KX_PolyProxy,getNumVertex)
|
||||
|
@ -233,7 +233,7 @@ PyAttributeDef KX_PolygonMaterial::Attributes[] = {
|
||||
KX_PYATTRIBUTE_FLOAT_RW("shininess", 0.0f, 1000.0f, KX_PolygonMaterial, m_shininess),
|
||||
KX_PYATTRIBUTE_FLOAT_RW("specularity", 0.0f, 1000.0f, KX_PolygonMaterial, m_specularity),
|
||||
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("diffuse", KX_PolygonMaterial, pyattr_get_texture, pyattr_set_diffuse),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("diffuse", KX_PolygonMaterial, pyattr_get_diffuse, pyattr_set_diffuse),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("specular",KX_PolygonMaterial, pyattr_get_specular, pyattr_set_specular),
|
||||
|
||||
KX_PYATTRIBUTE_RO_FUNCTION("tface", KX_PolygonMaterial, pyattr_get_tface), /* How the heck is this even useful??? - Campbell */
|
||||
|
@ -73,247 +73,359 @@ PyMethodDef KX_VertexProxy::Methods[] = {
|
||||
};
|
||||
|
||||
PyAttributeDef KX_VertexProxy::Attributes[] = {
|
||||
//KX_PYATTRIBUTE_TODO("DummyProps"),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("x", KX_VertexProxy, pyattr_get_x, pyattr_set_x),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("y", KX_VertexProxy, pyattr_get_y, pyattr_set_y),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("z", KX_VertexProxy, pyattr_get_z, pyattr_set_z),
|
||||
|
||||
KX_PYATTRIBUTE_DUMMY("x"),
|
||||
KX_PYATTRIBUTE_DUMMY("y"),
|
||||
KX_PYATTRIBUTE_DUMMY("z"),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("r", KX_VertexProxy, pyattr_get_r, pyattr_set_r),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("g", KX_VertexProxy, pyattr_get_g, pyattr_set_g),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("b", KX_VertexProxy, pyattr_get_b, pyattr_set_b),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("a", KX_VertexProxy, pyattr_get_a, pyattr_set_a),
|
||||
|
||||
KX_PYATTRIBUTE_DUMMY("r"),
|
||||
KX_PYATTRIBUTE_DUMMY("g"),
|
||||
KX_PYATTRIBUTE_DUMMY("b"),
|
||||
KX_PYATTRIBUTE_DUMMY("a"),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("u", KX_VertexProxy, pyattr_get_u, pyattr_set_u),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("v", KX_VertexProxy, pyattr_get_v, pyattr_set_v),
|
||||
|
||||
KX_PYATTRIBUTE_DUMMY("u"),
|
||||
KX_PYATTRIBUTE_DUMMY("v"),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("u2", KX_VertexProxy, pyattr_get_u2, pyattr_set_u2),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("v2", KX_VertexProxy, pyattr_get_v2, pyattr_set_v2),
|
||||
|
||||
KX_PYATTRIBUTE_DUMMY("u2"),
|
||||
KX_PYATTRIBUTE_DUMMY("v2"),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("XYZ", KX_VertexProxy, pyattr_get_XYZ, pyattr_set_XYZ),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("UV", KX_VertexProxy, pyattr_get_UV, pyattr_set_UV),
|
||||
|
||||
KX_PYATTRIBUTE_DUMMY("XYZ"),
|
||||
KX_PYATTRIBUTE_DUMMY("UV"),
|
||||
|
||||
KX_PYATTRIBUTE_DUMMY("color"),
|
||||
KX_PYATTRIBUTE_DUMMY("colour"),
|
||||
|
||||
KX_PYATTRIBUTE_DUMMY("normal"),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("color", KX_VertexProxy, pyattr_get_color, pyattr_set_color),
|
||||
KX_PYATTRIBUTE_RW_FUNCTION("normal", KX_VertexProxy, pyattr_get_normal, pyattr_set_normal),
|
||||
|
||||
{ NULL } //Sentinel
|
||||
};
|
||||
|
||||
#if 0
|
||||
PyObject*
|
||||
KX_VertexProxy::py_getattro(PyObject *attr)
|
||||
PyObject* KX_VertexProxy::pyattr_get_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
char *attr_str= _PyUnicode_AsString(attr);
|
||||
if (attr_str[1]=='\0') { // Group single letters
|
||||
// pos
|
||||
if (attr_str[0]=='x')
|
||||
return PyFloat_FromDouble(m_vertex->getXYZ()[0]);
|
||||
if (attr_str[0]=='y')
|
||||
return PyFloat_FromDouble(m_vertex->getXYZ()[1]);
|
||||
if (attr_str[0]=='z')
|
||||
return PyFloat_FromDouble(m_vertex->getXYZ()[2]);
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyFloat_FromDouble(self->m_vertex->getXYZ()[0]);
|
||||
}
|
||||
|
||||
// Col
|
||||
if (attr_str[0]=='r')
|
||||
return PyFloat_FromDouble(m_vertex->getRGBA()[0]/255.0);
|
||||
if (attr_str[0]=='g')
|
||||
return PyFloat_FromDouble(m_vertex->getRGBA()[1]/255.0);
|
||||
if (attr_str[0]=='b')
|
||||
return PyFloat_FromDouble(m_vertex->getRGBA()[2]/255.0);
|
||||
if (attr_str[0]=='a')
|
||||
return PyFloat_FromDouble(m_vertex->getRGBA()[3]/255.0);
|
||||
PyObject* KX_VertexProxy::pyattr_get_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyFloat_FromDouble(self->m_vertex->getXYZ()[1]);
|
||||
}
|
||||
|
||||
// UV
|
||||
if (attr_str[0]=='u')
|
||||
return PyFloat_FromDouble(m_vertex->getUV1()[0]);
|
||||
if (attr_str[0]=='v')
|
||||
return PyFloat_FromDouble(m_vertex->getUV1()[1]);
|
||||
}
|
||||
PyObject* KX_VertexProxy::pyattr_get_z(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyFloat_FromDouble(self->m_vertex->getXYZ()[2]);
|
||||
}
|
||||
|
||||
PyObject* KX_VertexProxy::pyattr_get_r(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyFloat_FromDouble(self->m_vertex->getRGBA()[0]/255.0);
|
||||
}
|
||||
|
||||
if (!strcmp(attr_str, "XYZ"))
|
||||
return PyObjectFrom(MT_Vector3(m_vertex->getXYZ()));
|
||||
PyObject* KX_VertexProxy::pyattr_get_g(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyFloat_FromDouble(self->m_vertex->getRGBA()[1]/255.0);
|
||||
}
|
||||
|
||||
if (!strcmp(attr_str, "UV"))
|
||||
return PyObjectFrom(MT_Point2(m_vertex->getUV1()));
|
||||
PyObject* KX_VertexProxy::pyattr_get_b(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyFloat_FromDouble(self->m_vertex->getRGBA()[2]/255.0);
|
||||
}
|
||||
|
||||
if (!strcmp(attr_str, "color") || !strcmp(attr_str, "colour"))
|
||||
{
|
||||
const unsigned char *colp = m_vertex->getRGBA();
|
||||
PyObject* KX_VertexProxy::pyattr_get_a(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyFloat_FromDouble(self->m_vertex->getRGBA()[3]/255.0);
|
||||
}
|
||||
|
||||
PyObject* KX_VertexProxy::pyattr_get_u(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyFloat_FromDouble(self->m_vertex->getUV1()[0]);
|
||||
}
|
||||
|
||||
PyObject* KX_VertexProxy::pyattr_get_v(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyFloat_FromDouble(self->m_vertex->getUV1()[1]);
|
||||
}
|
||||
|
||||
PyObject* KX_VertexProxy::pyattr_get_u2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyFloat_FromDouble(self->m_vertex->getUV2()[0]);
|
||||
}
|
||||
|
||||
PyObject* KX_VertexProxy::pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyFloat_FromDouble(self->m_vertex->getUV2()[1]);
|
||||
}
|
||||
|
||||
PyObject* KX_VertexProxy::pyattr_get_XYZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyObjectFrom(MT_Vector3(self->m_vertex->getXYZ()));
|
||||
}
|
||||
|
||||
PyObject* KX_VertexProxy::pyattr_get_UV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyObjectFrom(MT_Point2(self->m_vertex->getUV1()));
|
||||
}
|
||||
|
||||
PyObject* KX_VertexProxy::pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
const unsigned char *colp = self->m_vertex->getRGBA();
|
||||
MT_Vector4 color(colp[0], colp[1], colp[2], colp[3]);
|
||||
color /= 255.0;
|
||||
return PyObjectFrom(color);
|
||||
}
|
||||
|
||||
if (!strcmp(attr_str, "normal"))
|
||||
{
|
||||
return PyObjectFrom(MT_Vector3(m_vertex->getNormal()));
|
||||
}
|
||||
|
||||
py_getattro_up(CValue);
|
||||
return PyObjectFrom(color);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
int KX_VertexProxy::py_setattro(PyObject *attr, PyObject *pyvalue)
|
||||
PyObject* KX_VertexProxy::pyattr_get_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef)
|
||||
{
|
||||
char *attr_str= _PyUnicode_AsString(attr);
|
||||
if (PySequence_Check(pyvalue))
|
||||
{
|
||||
if (!strcmp(attr_str, "XYZ"))
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
return PyObjectFrom(MT_Vector3(self->m_vertex->getNormal()));
|
||||
}
|
||||
|
||||
int KX_VertexProxy::pyattr_set_x(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point3 pos(self->m_vertex->getXYZ());
|
||||
pos.x() = val;
|
||||
self->m_vertex->SetXYZ(pos);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
int KX_VertexProxy::pyattr_set_y(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point3 pos(self->m_vertex->getXYZ());
|
||||
pos.y() = val;
|
||||
self->m_vertex->SetXYZ(pos);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
int KX_VertexProxy::pyattr_set_z(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point3 pos(self->m_vertex->getXYZ());
|
||||
pos.z() = val;
|
||||
self->m_vertex->SetXYZ(pos);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
int KX_VertexProxy::pyattr_set_u(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point2 uv = self->m_vertex->getUV1();
|
||||
uv[0] = val;
|
||||
self->m_vertex->SetUV(uv);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
int KX_VertexProxy::pyattr_set_v(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point2 uv = self->m_vertex->getUV1();
|
||||
uv[1] = val;
|
||||
self->m_vertex->SetUV(uv);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
int KX_VertexProxy::pyattr_set_u2(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point2 uv = self->m_vertex->getUV2();
|
||||
uv[0] = val;
|
||||
self->m_vertex->SetUV2(uv);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
int KX_VertexProxy::pyattr_set_v2(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
MT_Point2 uv = self->m_vertex->getUV2();
|
||||
uv[1] = val;
|
||||
self->m_vertex->SetUV2(uv);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
int KX_VertexProxy::pyattr_set_r(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
|
||||
unsigned char *cp = (unsigned char*) &icol;
|
||||
val *= 255.0;
|
||||
cp[0] = (unsigned char) val;
|
||||
self->m_vertex->SetRGBA(icol);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
int KX_VertexProxy::pyattr_set_g(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
|
||||
unsigned char *cp = (unsigned char*) &icol;
|
||||
val *= 255.0;
|
||||
cp[1] = (unsigned char) val;
|
||||
self->m_vertex->SetRGBA(icol);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
int KX_VertexProxy::pyattr_set_b(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
|
||||
unsigned char *cp = (unsigned char*) &icol;
|
||||
val *= 255.0;
|
||||
cp[2] = (unsigned char) val;
|
||||
self->m_vertex->SetRGBA(icol);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
int KX_VertexProxy::pyattr_set_a(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PyFloat_Check(value))
|
||||
{
|
||||
float val = PyFloat_AsDouble(value);
|
||||
unsigned int icol = *((const unsigned int *)self->m_vertex->getRGBA());
|
||||
unsigned char *cp = (unsigned char*) &icol;
|
||||
val *= 255.0;
|
||||
cp[3] = (unsigned char) val;
|
||||
self->m_vertex->SetRGBA(icol);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
int KX_VertexProxy::pyattr_set_XYZ(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PySequence_Check(value))
|
||||
{
|
||||
MT_Point3 vec;
|
||||
if (PyVecTo(pyvalue, vec))
|
||||
if (PyVecTo(value, vec))
|
||||
{
|
||||
m_vertex->SetXYZ(vec);
|
||||
m_mesh->SetMeshModified(true);
|
||||
self->m_vertex->SetXYZ(vec);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
if (!strcmp(attr_str, "UV"))
|
||||
int KX_VertexProxy::pyattr_set_UV(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PySequence_Check(value))
|
||||
{
|
||||
MT_Point2 vec;
|
||||
if (PyVecTo(pyvalue, vec))
|
||||
if (PyVecTo(value, vec))
|
||||
{
|
||||
m_vertex->SetUV(vec);
|
||||
m_mesh->SetMeshModified(true);
|
||||
self->m_vertex->SetUV(vec);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
if (!strcmp(attr_str, "color") || !strcmp(attr_str, "colour"))
|
||||
int KX_VertexProxy::pyattr_set_color(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PySequence_Check(value))
|
||||
{
|
||||
MT_Vector4 vec;
|
||||
if (PyVecTo(pyvalue, vec))
|
||||
if (PyVecTo(value, vec))
|
||||
{
|
||||
m_vertex->SetRGBA(vec);
|
||||
m_mesh->SetMeshModified(true);
|
||||
self->m_vertex->SetRGBA(vec);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
|
||||
if (!strcmp(attr_str, "normal"))
|
||||
int KX_VertexProxy::pyattr_set_normal(void *self_v, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
|
||||
{
|
||||
KX_VertexProxy* self= static_cast<KX_VertexProxy*>(self_v);
|
||||
if (PySequence_Check(value))
|
||||
{
|
||||
MT_Vector3 vec;
|
||||
if (PyVecTo(pyvalue, vec))
|
||||
if (PyVecTo(value, vec))
|
||||
{
|
||||
m_vertex->SetNormal(vec);
|
||||
m_mesh->SetMeshModified(true);
|
||||
self->m_vertex->SetNormal(vec);
|
||||
self->m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
if (PyFloat_Check(pyvalue))
|
||||
{
|
||||
float val = PyFloat_AsDouble(pyvalue);
|
||||
// pos
|
||||
MT_Point3 pos(m_vertex->getXYZ());
|
||||
if (!strcmp(attr_str, "x"))
|
||||
{
|
||||
pos.x() = val;
|
||||
m_vertex->SetXYZ(pos);
|
||||
m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
|
||||
if (!strcmp(attr_str, "y"))
|
||||
{
|
||||
pos.y() = val;
|
||||
m_vertex->SetXYZ(pos);
|
||||
m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
|
||||
if (!strcmp(attr_str, "z"))
|
||||
{
|
||||
pos.z() = val;
|
||||
m_vertex->SetXYZ(pos);
|
||||
m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
|
||||
// uv
|
||||
MT_Point2 uv = m_vertex->getUV1();
|
||||
if (!strcmp(attr_str, "u"))
|
||||
{
|
||||
uv[0] = val;
|
||||
m_vertex->SetUV(uv);
|
||||
m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
|
||||
if (!strcmp(attr_str, "v"))
|
||||
{
|
||||
uv[1] = val;
|
||||
m_vertex->SetUV(uv);
|
||||
m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
|
||||
// uv
|
||||
MT_Point2 uv2 = m_vertex->getUV2();
|
||||
if (!strcmp(attr_str, "u2"))
|
||||
{
|
||||
uv[0] = val;
|
||||
m_vertex->SetUV2(uv);
|
||||
m_mesh->SetMeshModified(true);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!strcmp(attr_str, "v2"))
|
||||
{
|
||||
uv[1] = val;
|
||||
m_vertex->SetUV2(uv);
|
||||
m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
|
||||
// col
|
||||
unsigned int icol = *((const unsigned int *)m_vertex->getRGBA());
|
||||
unsigned char *cp = (unsigned char*) &icol;
|
||||
val *= 255.0;
|
||||
if (!strcmp(attr_str, "r"))
|
||||
{
|
||||
cp[0] = (unsigned char) val;
|
||||
m_vertex->SetRGBA(icol);
|
||||
m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
if (!strcmp(attr_str, "g"))
|
||||
{
|
||||
cp[1] = (unsigned char) val;
|
||||
m_vertex->SetRGBA(icol);
|
||||
m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
if (!strcmp(attr_str, "b"))
|
||||
{
|
||||
cp[2] = (unsigned char) val;
|
||||
m_vertex->SetRGBA(icol);
|
||||
m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
if (!strcmp(attr_str, "a"))
|
||||
{
|
||||
cp[3] = (unsigned char) val;
|
||||
m_vertex->SetRGBA(icol);
|
||||
m_mesh->SetMeshModified(true);
|
||||
return PY_SET_ATTR_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return CValue::py_setattro(attr, pyvalue);
|
||||
return PY_SET_ATTR_FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
KX_VertexProxy::KX_VertexProxy(KX_MeshProxy*mesh, RAS_TexVert* vertex)
|
||||
: m_vertex(vertex),
|
||||
|
@ -56,6 +56,37 @@ public:
|
||||
|
||||
// stuff for python integration
|
||||
|
||||
static PyObject* pyattr_get_x(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_y(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_z(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_r(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_g(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_b(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_a(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_u(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_v(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_u2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_v2(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_XYZ(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_UV(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_color(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static PyObject* pyattr_get_normal(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
||||
static int pyattr_set_x(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_y(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_z(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_u(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_v(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_u2(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_v2(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_r(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_g(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_b(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_a(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_XYZ(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_UV(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_color(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
static int pyattr_set_normal(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
||||
|
||||
KX_PYMETHOD_NOARGS(KX_VertexProxy,GetXYZ);
|
||||
KX_PYMETHOD_O(KX_VertexProxy,SetXYZ);
|
||||
KX_PYMETHOD_NOARGS(KX_VertexProxy,GetUV);
|
||||
|
Loading…
Reference in New Issue
Block a user