forked from bartvdbraak/blender
contribution from RCRuiz:
drawing of rigidbody constraint pivots, and allow passing of full constraint frame.
This commit is contained in:
parent
3c9a11f24e
commit
92379ec21f
@ -296,3 +296,7 @@ void antialias_tagbuf(int xsize, int ysize, char *rectmove) {}
|
||||
|
||||
/* imagetexture.c stub */
|
||||
void ibuf_sample(struct ImBuf *ibuf, float fx, float fy, float dx, float dy, float *result) {}
|
||||
|
||||
void update_for_newframe()
|
||||
{
|
||||
}
|
||||
|
@ -324,6 +324,8 @@ typedef struct bRigidBodyJointConstraint{
|
||||
|
||||
#define LIMIT_NOPARENT 0x01
|
||||
|
||||
#define CONSTRAINT_DRAW_PIVOT 0x40
|
||||
|
||||
/* important: these defines need to match up with PHY_DynamicTypes headerfile */
|
||||
#define CONSTRAINT_RB_BALL 1
|
||||
#define CONSTRAINT_RB_HINGE 2
|
||||
|
@ -1159,14 +1159,16 @@ static void draw_constraint (uiBlock *block, ListBase *list, bConstraint *con, s
|
||||
{
|
||||
//uiDefBut(block, ROUNDBOX, B_DIFF, "", *xco-10, *yco-height, width+40,height-1, NULL, 5.0, 0.0, 12, rb_col, "");
|
||||
uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "toObject:", *xco, *yco-50, 130, 18, &data->tar, "Child Object");
|
||||
uiDefButBitS(block, TOG, CONSTRAINT_DRAW_PIVOT, B_CONSTRAINT_TEST, "ShowPivot", *xco+135, *yco-50, 130, 18, &data->flag, 0, 24, 0, 0, "Show pivot position and rotation");
|
||||
//if (data->tar)
|
||||
// uiDefIDPoinBut(block, test_obpoin_but, ID_OB, B_CONSTRAINT_CHANGETARGET, "Child:", *xco+135, *yco-50, 130, 18, &data->child, "Child2 Object (if this exist then this object will be the pivot Only)");
|
||||
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot X:", *xco, *yco-75, 130, 18, &data->pivX, -10000, 10000, 100.0, 0.0, "Offset Joint");
|
||||
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Y:", *xco, *yco-100, 130, 18, &data->pivY, -10000, 10000, 100.0, 0.0, "Offset Joint");
|
||||
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Z:", *xco, *yco-125, 130, 18, &data->pivZ, -10000, 10000, 100.0, 0.0, "Offset Joint");
|
||||
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax X:", *xco+135, *yco-75, 130, 18, &data->axX, -10000, 10000, 100.0, 0.0, "Offset Joint");
|
||||
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax Y:", *xco+135, *yco-100, 130, 18, &data->axY, -10000, 10000, 100.0, 0.0, "Offset Joint");
|
||||
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Ax Z:", *xco+135, *yco-125, 130, 18, &data->axZ, -10000, 10000, 100.0, 0.0, "Offset Joint");
|
||||
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot X:", *xco, *yco-75, 130, 18, &data->pivX, -1000, 1000, 0.1, 0.0, "Offset pivot on X");
|
||||
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Y:", *xco, *yco-100, 130, 18, &data->pivY, -1000, 1000, 0.1, 0.0, "Offset pivot on Y");
|
||||
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "Pivot Z:", *xco, *yco-125, 130, 18, &data->pivZ, -1000, 1000, 0.1, 0.0, "Offset pivot on z");
|
||||
|
||||
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "AxEX:", *xco+135, *yco-75, 130, 18, &data->axX, -3.141592, 3.141592, 0.1, 0.0, "Rotate pivot on X Axis");
|
||||
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "AxEY:", *xco+135, *yco-100, 130, 18, &data->axY, -3.141592, 3.141592, 0.1, 0.0, "Rotate pivot on Y Axis");
|
||||
uiDefButF(block, NUM, B_CONSTRAINT_TEST, "AxEZ:", *xco+135, *yco-125, 130, 18, &data->axZ, -3.141592, 3.141592, 0.1, 0.0, "Rotate pivot on Z Axis");
|
||||
|
||||
if (data->type==CONSTRAINT_RB_GENERIC6DOF){
|
||||
/* Draw Pairs of LimitToggle+LimitValue */
|
||||
|
@ -3636,6 +3636,51 @@ static void draw_hooks(Object *ob)
|
||||
}
|
||||
}
|
||||
|
||||
//<rcruiz>
|
||||
void drawRBpivot(bRigidBodyJointConstraint *data){
|
||||
float size=1.0f;
|
||||
int axis;
|
||||
float v1[3]= {data->pivX, data->pivY, data->pivZ};
|
||||
float eu[3]= {data->axX, data->axY, data->axZ};
|
||||
float mat[4][4];
|
||||
EulToMat4(eu,mat);
|
||||
glLineWidth (4.0f);
|
||||
setlinestyle(2);
|
||||
for (axis=0; axis<3; axis++) {
|
||||
float dir[3] = {0,0,0};
|
||||
float v[3]= {data->pivX, data->pivY, data->pivZ};
|
||||
int arrow_axis= (axis==0)?1:0;
|
||||
dir[axis] = 1.f;
|
||||
glBegin(GL_LINES);
|
||||
Mat4MulVecfl(mat,dir);
|
||||
v[0] += dir[0];
|
||||
v[1] += dir[1];
|
||||
v[2] += dir[2];
|
||||
glVertex3fv(v1);
|
||||
glVertex3fv(v);
|
||||
/* v1[axis]= size*0.8;
|
||||
v1[arrow_axis]= -size*0.125;
|
||||
glVertex3fv(v1);
|
||||
glVertex3fv(v2);
|
||||
|
||||
v1[arrow_axis]= size*0.125;
|
||||
glVertex3fv(v1);
|
||||
glVertex3fv(v2);
|
||||
*/
|
||||
glEnd();
|
||||
glRasterPos3fv(v);
|
||||
if (axis==0)
|
||||
BMF_DrawString(G.font, "px");
|
||||
else if (axis==1)
|
||||
BMF_DrawString(G.font, "py");
|
||||
else
|
||||
BMF_DrawString(G.font, "pz");
|
||||
|
||||
}
|
||||
glLineWidth (1.0f);
|
||||
setlinestyle(0);
|
||||
}
|
||||
|
||||
/* flag can be DRAW_PICKING and/or DRAW_CONSTCOLOR */
|
||||
void draw_object(Base *base, int flag)
|
||||
{
|
||||
@ -4001,6 +4046,18 @@ void draw_object(Base *base, int flag)
|
||||
}
|
||||
if(ob->pd && ob->pd->forcefield) draw_forcefield(ob);
|
||||
|
||||
{
|
||||
bConstraint *con;
|
||||
for(con=ob->constraints.first; con; con= con->next)
|
||||
{
|
||||
if(con->type==CONSTRAINT_TYPE_RIGIDBODYJOINT)
|
||||
{
|
||||
bRigidBodyJointConstraint *data = (bRigidBodyJointConstraint*)con->data;
|
||||
if(data->flag&CONSTRAINT_DRAW_PIVOT)
|
||||
drawRBpivot(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* draw extra: after normal draw because of makeDispList */
|
||||
if(dtx) {
|
||||
|
@ -83,6 +83,15 @@
|
||||
#include "DNA_scene_types.h"
|
||||
/***/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "BSE_headerbuttons.h"
|
||||
void update_for_newframe();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
static BlendFileData *load_game_data(char *filename) {
|
||||
BlendReadError error;
|
||||
//this doesn't work anymore for relative paths, so use BLO_read_from_memory instead
|
||||
@ -310,7 +319,7 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
|
||||
// create a scene converter, create and convert the startingscene
|
||||
KX_ISceneConverter* sceneconverter = new KX_BlenderSceneConverter(blenderdata,sipo, ketsjiengine);
|
||||
ketsjiengine->SetSceneConverter(sceneconverter);
|
||||
|
||||
sceneconverter->addInitFromFrame=false;
|
||||
if (always_use_expand_framing)
|
||||
sceneconverter->SetAlwaysUseExpandFraming(true);
|
||||
|
||||
@ -452,14 +461,6 @@ extern "C" void StartKetsjiShell(struct ScrArea *area,
|
||||
|
||||
if (bfd) BLO_blendfiledata_free(bfd);
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "BSE_headerbuttons.h"
|
||||
void update_for_newframe();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
|
||||
char* scenename,
|
||||
@ -481,7 +482,6 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
|
||||
|
||||
do
|
||||
{
|
||||
// View3D *v3d= (View3D*) area->spacedata.first;
|
||||
|
||||
// get some preferences
|
||||
SYS_SystemHandle syshandle = SYS_GetSystem();
|
||||
@ -493,19 +493,6 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
|
||||
bool displaylists = (SYS_GetCommandLineInt(syshandle, "displaylists", 0) != 0);
|
||||
bool usemat = false;
|
||||
|
||||
/* #ifdef GL_ARB_multitexture
|
||||
if(bgl::RAS_EXT_support._ARB_multitexture && bgl::QueryVersion(1, 1)) {
|
||||
usemat = (SYS_GetCommandLineInt(syshandle, "blender_material", 0) != 0);
|
||||
int unitmax=0;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&unitmax);
|
||||
bgl::max_texture_units = MAXTEX>unitmax?unitmax:MAXTEX;
|
||||
//std::cout << "using(" << bgl::max_texture_units << ") of(" << unitmax << ") texture units." << std::endl;
|
||||
} else {
|
||||
bgl::max_texture_units = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
*/
|
||||
// create the canvas, rasterizer and rendertools
|
||||
RAS_ICanvas* canvas = new KX_BlenderCanvas(area);
|
||||
//canvas->SetMouseState(RAS_ICanvas::MOUSE_INVISIBLE);
|
||||
@ -544,83 +531,8 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
|
||||
// create the ketsjiengine
|
||||
KX_KetsjiEngine* ketsjiengine = new KX_KetsjiEngine(kxsystem);
|
||||
|
||||
/* // set the devices
|
||||
ketsjiengine->SetKeyboardDevice(keyboarddevice);
|
||||
ketsjiengine->SetMouseDevice(mousedevice);
|
||||
ketsjiengine->SetNetworkDevice(networkdevice);
|
||||
ketsjiengine->SetCanvas(canvas);
|
||||
ketsjiengine->SetRenderTools(rendertools);
|
||||
ketsjiengine->SetRasterizer(rasterizer);
|
||||
ketsjiengine->SetNetworkDevice(networkdevice);
|
||||
ketsjiengine->SetAudioDevice(audiodevice);
|
||||
ketsjiengine->SetUseFixedTime(usefixed);
|
||||
ketsjiengine->SetTimingDisplay(frameRate, profile, properties);
|
||||
|
||||
*/
|
||||
|
||||
// some blender stuff
|
||||
MT_CmMatrix4x4 projmat;
|
||||
MT_CmMatrix4x4 viewmat;
|
||||
int i;
|
||||
|
||||
/* for (i = 0; i < 16; i++)
|
||||
{
|
||||
float *viewmat_linear= (float*) v3d->viewmat;
|
||||
viewmat.setElem(i, viewmat_linear[i]);
|
||||
}
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
float *projmat_linear = (float*) area->winmat;
|
||||
projmat.setElem(i, projmat_linear[i]);
|
||||
}
|
||||
*/
|
||||
/* float camzoom = (1.41421 + (v3d->camzoom / 50.0));
|
||||
camzoom *= camzoom;
|
||||
camzoom = 4.0 / camzoom;
|
||||
*/
|
||||
// ketsjiengine->SetDrawType(v3d->drawtype);
|
||||
// ketsjiengine->SetCameraZoom(camzoom);
|
||||
/*
|
||||
// if we got an exitcode 3 (KX_EXIT_REQUEST_START_OTHER_GAME) load a different file
|
||||
if (exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME || exitrequested == KX_EXIT_REQUEST_RESTART_GAME)
|
||||
{
|
||||
exitrequested = KX_EXIT_REQUEST_NO_REQUEST;
|
||||
if (bfd) BLO_blendfiledata_free(bfd);
|
||||
|
||||
char basedpath[160];
|
||||
// base the actuator filename with respect
|
||||
// to the original file working directory
|
||||
if (exitstring != "")
|
||||
strcpy(basedpath, exitstring.Ptr());
|
||||
|
||||
BLI_convertstringcode(basedpath, pathname, 0);
|
||||
bfd = load_game_data(basedpath);
|
||||
|
||||
// if it wasn't loaded, try it forced relative
|
||||
if (!bfd)
|
||||
{
|
||||
// just add "//" in front of it
|
||||
char temppath[162];
|
||||
strcpy(temppath, "//");
|
||||
strcat(temppath, basedpath);
|
||||
|
||||
BLI_convertstringcode(temppath, pathname, 0);
|
||||
bfd = load_game_data(temppath);
|
||||
}
|
||||
|
||||
// if we got a loaded blendfile, proceed
|
||||
if (bfd)
|
||||
{
|
||||
blenderdata = bfd->main;
|
||||
startscenename = bfd->curscene->id.name + 2;
|
||||
}
|
||||
// else forget it, we can't find it
|
||||
else
|
||||
{
|
||||
exitrequested = KX_EXIT_REQUEST_QUIT_GAME;
|
||||
}
|
||||
}
|
||||
*/
|
||||
Scene *blscene = NULL;
|
||||
if (!bfd)
|
||||
{
|
||||
@ -652,17 +564,10 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
|
||||
|
||||
if (exitrequested != KX_EXIT_REQUEST_QUIT_GAME)
|
||||
{
|
||||
/*if (v3d->persp != 2)
|
||||
{
|
||||
ketsjiengine->EnableCameraOverride(startscenename);
|
||||
ketsjiengine->SetCameraOverrideUseOrtho((v3d->persp == 0));
|
||||
ketsjiengine->SetCameraOverrideProjectionMatrix(projmat);
|
||||
ketsjiengine->SetCameraOverrideViewMatrix(viewmat);
|
||||
}*/
|
||||
|
||||
// create a scene converter, create and convert the startingscene
|
||||
KX_ISceneConverter* sceneconverter = new KX_BlenderSceneConverter(maggie,sipo, ketsjiengine);
|
||||
ketsjiengine->SetSceneConverter(sceneconverter);
|
||||
sceneconverter->addInitFromFrame=true;
|
||||
|
||||
if (always_use_expand_framing)
|
||||
sceneconverter->SetAlwaysUseExpandFraming(true);
|
||||
@ -675,7 +580,6 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
|
||||
networkdevice,
|
||||
audiodevice,
|
||||
startscenename);
|
||||
|
||||
// some python things
|
||||
PyObject* dictionaryobject = initGamePythonScripting("Ketsji", psl_Lowest);
|
||||
ketsjiengine->SetPythonDictionary(dictionaryobject);
|
||||
@ -696,9 +600,6 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
|
||||
canvas);
|
||||
ketsjiengine->AddScene(startscene);
|
||||
|
||||
// init the rasterizer
|
||||
//rasterizer->Init();
|
||||
|
||||
// start the engine
|
||||
ketsjiengine->StartEngine(false);
|
||||
|
||||
@ -708,38 +609,22 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
|
||||
printf("frame %i\n",blscene->r.cfra);
|
||||
// first check if we want to exit
|
||||
exitrequested = ketsjiengine->GetExitCode();
|
||||
/*for (int ix=0;i<geobjs->GetCount();ix++){
|
||||
KX_GameObject* gameobj = (KX_GameObject*) geobjs->GetValue(ix);
|
||||
if (!gameobj->IsDynamic()){
|
||||
//gameobj->UpdateNonDynas();//UpdateIPO((float)blscene->r.cfra,true, true, true);
|
||||
struct Object* blenderobject = sceneconverter->FindBlenderObject(gameobj);
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
// kick the engine
|
||||
ketsjiengine->NextFrame();
|
||||
blscene->r.cfra=blscene->r.cfra+1;
|
||||
update_for_newframe();
|
||||
// render the frame
|
||||
//ketsjiengine->Render();
|
||||
|
||||
// test for the ESC key
|
||||
/*while (qtest())
|
||||
{
|
||||
short val;
|
||||
unsigned short event = extern_qread(&val);
|
||||
|
||||
if (keyboarddevice->ConvertBlenderEvent(event,val))
|
||||
exitrequested = KX_EXIT_REQUEST_BLENDER_ESC;
|
||||
|
||||
if (event==MOUSEX) {
|
||||
val = val - scrarea_get_win_x(area);
|
||||
} else if (event==MOUSEY) {
|
||||
val = scrarea_get_win_height(area) - (val - scrarea_get_win_y(area)) - 1;
|
||||
}
|
||||
|
||||
mousedevice->ConvertBlenderEvent(event,val);
|
||||
}*/
|
||||
}
|
||||
exitstring = ketsjiengine->GetExitString();
|
||||
// when exiting the mainloop
|
||||
//dictionaryClearByHand(gameLogic);
|
||||
//ketsjiengine->StopEngine();
|
||||
//exitGamePythonScripting();
|
||||
//networkdevice->Disconnect();
|
||||
}
|
||||
if (sceneconverter)
|
||||
{
|
||||
@ -778,21 +663,6 @@ extern "C" void StartKetsjiShellSimulation(struct ScrArea *area,
|
||||
delete mousedevice;
|
||||
mousedevice = NULL;
|
||||
}
|
||||
/*if (rasterizer)
|
||||
{
|
||||
delete rasterizer;
|
||||
rasterizer = NULL;
|
||||
}
|
||||
if (rendertools)
|
||||
{
|
||||
delete rendertools;
|
||||
rendertools = NULL;
|
||||
}
|
||||
if (canvas)
|
||||
{
|
||||
delete canvas;
|
||||
canvas = NULL;
|
||||
}*/
|
||||
SND_DeviceManager::Unsubscribe();
|
||||
|
||||
} while (exitrequested == KX_EXIT_REQUEST_RESTART_GAME || exitrequested == KX_EXIT_REQUEST_START_OTHER_GAME);
|
||||
|
@ -167,6 +167,18 @@
|
||||
#include "BL_ArmatureObject.h"
|
||||
#include "BL_DeformableGameObject.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "BSE_headerbuttons.h"
|
||||
void update_for_newframe();
|
||||
//void scene_update_for_newframe(struct Scene *sce, unsigned int lay);
|
||||
//#include "BKE_ipo.h"
|
||||
//void do_all_data_ipos(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
static int default_face_mode = TF_DYNAMIC;
|
||||
|
||||
static unsigned int KX_rgbaint2uint_new(unsigned int icol)
|
||||
@ -1618,7 +1630,7 @@ KX_GameObject* getGameOb(STR_String busc,CListValue* sumolist){
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
#include "BLI_arithb.h"
|
||||
// convert blender objects into ketsji gameobjects
|
||||
void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
const STR_String& scenename,
|
||||
@ -1642,6 +1654,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
RAS_FrameSettings::RAS_FrameType frame_type;
|
||||
int aspect_width;
|
||||
int aspect_height;
|
||||
vector<MT_Vector3> inivel,iniang;
|
||||
|
||||
if (alwaysUseExpandFraming) {
|
||||
frame_type = RAS_FrameSettings::e_frame_extend;
|
||||
@ -1720,6 +1733,10 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
|
||||
if (gameobj)
|
||||
{
|
||||
MT_Point3 posPrev;
|
||||
MT_Matrix3x3 angor;
|
||||
if (converter->addInitFromFrame) blenderscene->r.cfra=blenderscene->r.sfra;
|
||||
|
||||
MT_Point3 pos = MT_Point3(
|
||||
blenderobject->loc[0]+blenderobject->dloc[0],
|
||||
blenderobject->loc[1]+blenderobject->dloc[1],
|
||||
@ -1735,6 +1752,25 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
blenderobject->size[1],
|
||||
blenderobject->size[2]
|
||||
);
|
||||
if (converter->addInitFromFrame){//rcruiz
|
||||
float eulxyzPrev[3];
|
||||
blenderscene->r.cfra=blenderscene->r.sfra-1;
|
||||
update_for_newframe();
|
||||
MT_Vector3 tmp=pos-MT_Point3(blenderobject->loc[0]+blenderobject->dloc[0],
|
||||
blenderobject->loc[1]+blenderobject->dloc[1],
|
||||
blenderobject->loc[2]+blenderobject->dloc[2]
|
||||
);
|
||||
eulxyzPrev[0]=blenderobject->rot[0];
|
||||
eulxyzPrev[1]=blenderobject->rot[1];
|
||||
eulxyzPrev[2]=blenderobject->rot[2];
|
||||
tmp.scale((float)blenderscene->r.frs_sec,(float)blenderscene->r.frs_sec,(float)blenderscene->r.frs_sec);
|
||||
inivel.push_back(tmp);
|
||||
tmp=eulxyz-eulxyzPrev;
|
||||
tmp.scale((float)blenderscene->r.frs_sec,(float)blenderscene->r.frs_sec,(float)blenderscene->r.frs_sec);
|
||||
iniang.push_back(tmp);
|
||||
blenderscene->r.cfra=blenderscene->r.sfra;
|
||||
update_for_newframe();
|
||||
}
|
||||
|
||||
gameobj->NodeSetLocalPosition(pos);
|
||||
gameobj->NodeSetLocalOrientation(MT_Matrix3x3(eulxyz));
|
||||
@ -1759,7 +1795,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
templist->Add(gameobj->AddRef());
|
||||
|
||||
// update children/parent hierarchy
|
||||
if (blenderobject->parent != 0)
|
||||
if ((blenderobject->parent != 0)&&(!converter->addInitFromFrame))
|
||||
{
|
||||
// blender has an additional 'parentinverse' offset in each object
|
||||
SG_Node* parentinversenode = new SG_Node(NULL,NULL,SG_Callbacks());
|
||||
@ -1790,12 +1826,15 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
logicmgr->RegisterGameMeshName(gameobj->GetMesh(i)->GetName(), blenderobject);
|
||||
|
||||
converter->RegisterGameObject(gameobj, blenderobject);
|
||||
|
||||
// this was put in rapidly, needs to be looked at more closely
|
||||
// only draw/use objects in active 'blender' layers
|
||||
|
||||
logicbrick_conversionlist->Add(gameobj->AddRef());
|
||||
|
||||
if (converter->addInitFromFrame){
|
||||
posPrev=gameobj->NodeGetWorldPosition();
|
||||
angor=gameobj->NodeGetWorldOrientation();
|
||||
}
|
||||
if (isInActiveLayer)
|
||||
{
|
||||
objectlist->Add(gameobj->AddRef());
|
||||
@ -1805,6 +1844,10 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
gameobj->Bucketize();
|
||||
|
||||
}
|
||||
if (converter->addInitFromFrame){
|
||||
gameobj->NodeSetLocalPosition(posPrev);
|
||||
gameobj->NodeSetLocalOrientation(angor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1929,6 +1972,20 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
BL_CreatePhysicsObjectNew(gameobj,blenderobject,meshobj,kxscene,activeLayerBitInfo,physics_engine,converter,processCompoundChildren);
|
||||
}
|
||||
|
||||
|
||||
//set ini linearVel and int angularVel //rcruiz
|
||||
if (converter->addInitFromFrame)
|
||||
for (i=0;i<sumolist->GetCount();i++)
|
||||
{
|
||||
KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
|
||||
if (gameobj->IsDynamic()){
|
||||
gameobj->setLinearVelocity(inivel[i],false);
|
||||
gameobj->setAngularVelocity(iniang[i],false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// create physics joints
|
||||
for (i=0;i<sumolist->GetCount();i++)
|
||||
{
|
||||
@ -1956,8 +2013,19 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
if (gameobj->GetPhysicsController())
|
||||
{
|
||||
PHY_IPhysicsController* physctrl = (PHY_IPhysicsController*) gameobj->GetPhysicsController()->GetUserData();
|
||||
//we need to pass a full constraint frame, not just axis
|
||||
|
||||
int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX,(float)dat->pivY,(float)dat->pivZ,(float)dat->axX,(float)dat->axY,(float)dat->axZ);
|
||||
//localConstraintFrameBasis
|
||||
MT_Matrix3x3 localCFrame(MT_Vector3(dat->axX,dat->axY,dat->axZ));
|
||||
MT_Vector3 axis0 = localCFrame.getColumn(0);
|
||||
MT_Vector3 axis1 = localCFrame.getColumn(1);
|
||||
MT_Vector3 axis2 = localCFrame.getColumn(2);
|
||||
|
||||
int constraintId = kxscene->GetPhysicsEnvironment()->createConstraint(physctrl,physctr2,(PHY_ConstraintType)dat->type,(float)dat->pivX,(float)dat->pivY,(float)dat->pivZ,
|
||||
(float)axis0.x(),(float)axis0.y(),(float)axis0.z(),
|
||||
(float)axis1.x(),(float)axis1.y(),(float)axis1.z(),
|
||||
(float)axis2.x(),(float)axis2.y(),(float)axis2.z()
|
||||
);
|
||||
//if it is a generic 6DOF constraint, set all the limits accordingly
|
||||
if (dat->type == PHY_GENERIC_6DOF_CONSTRAINT)
|
||||
{
|
||||
@ -1984,40 +2052,9 @@ void BL_ConvertBlenderObjects(struct Main* maggie,
|
||||
|
||||
}
|
||||
|
||||
//Intento de actualizar posicion
|
||||
/*for (i=0;i<sumolist->GetCount();i++)
|
||||
{
|
||||
KX_GameObject* gameobj = (KX_GameObject*) sumolist->GetValue(i);
|
||||
struct Object* blenderobject = converter->FindBlenderObject(gameobj);
|
||||
|
||||
MT_Point3 pos = MT_Point3(
|
||||
blenderobject->loc[0]+blenderobject->dloc[0],
|
||||
blenderobject->loc[1]+blenderobject->dloc[1],
|
||||
blenderobject->loc[2]+blenderobject->dloc[2]
|
||||
);
|
||||
MT_Vector3 eulxyz = MT_Vector3(
|
||||
blenderobject->rot[0],
|
||||
blenderobject->rot[1],
|
||||
blenderobject->rot[2]
|
||||
);
|
||||
MT_Vector3 scale = MT_Vector3(
|
||||
blenderobject->size[0],
|
||||
blenderobject->size[1],
|
||||
blenderobject->size[2]
|
||||
);
|
||||
|
||||
gameobj->NodeSetLocalPosition(pos);
|
||||
gameobj->NodeSetLocalOrientation(MT_Matrix3x3(eulxyz));
|
||||
gameobj->NodeSetLocalScale(scale);
|
||||
gameobj->NodeUpdateGS(0,true);
|
||||
}*/
|
||||
//rcruiz>
|
||||
|
||||
|
||||
templist->Release();
|
||||
sumolist->Release();
|
||||
|
||||
|
||||
int executePriority=0; /* incremented by converter routines */
|
||||
|
||||
// convert global sound stuff
|
||||
|
@ -77,6 +77,8 @@
|
||||
#include "DNA_world_types.h"
|
||||
#include "BKE_main.h"
|
||||
|
||||
#include "BLI_arithb.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "DNA_object_types.h"
|
||||
@ -560,7 +562,8 @@ IpoCurve* findIpoCurve(IpoCurve* first,char* searchName)
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ipo* KX_BlenderSceneConverter::findIpoForName(char* objName)
|
||||
// this is not longer necesary //rcruiz
|
||||
/*Ipo* KX_BlenderSceneConverter::findIpoForName(char* objName)
|
||||
{
|
||||
Ipo* ipo_iter = (Ipo*)m_maggie->ipo.first;
|
||||
|
||||
@ -574,7 +577,7 @@ Ipo* KX_BlenderSceneConverter::findIpoForName(char* objName)
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
|
||||
{
|
||||
@ -600,16 +603,23 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
|
||||
if (blenderObject)
|
||||
{
|
||||
//erase existing ipo's
|
||||
Ipo* ipo = findIpoForName(blenderObject->id.name+2);
|
||||
Ipo* ipo = blenderObject->ipo;//findIpoForName(blenderObject->id.name+2);
|
||||
if (ipo)
|
||||
{
|
||||
//clear the curve data
|
||||
if (clearIpo){
|
||||
{ //clear the curve data
|
||||
if (clearIpo){//rcruiz
|
||||
IpoCurve *icu1;
|
||||
|
||||
int numCurves = 0;
|
||||
for( icu1 = (IpoCurve*)ipo->curve.first; icu1; ) {
|
||||
|
||||
IpoCurve* tmpicu = icu1;
|
||||
|
||||
/*int i;
|
||||
BezTriple *bezt;
|
||||
for( bezt = tmpicu->bezt, i = 0; i < tmpicu->totvert; i++, bezt++){
|
||||
printf("(%f,%f,%f),(%f,%f,%f),(%f,%f,%f)\n",bezt->vec[0][0],bezt->vec[0][1],bezt->vec[0][2],bezt->vec[1][0],bezt->vec[1][1],bezt->vec[1][2],bezt->vec[2][0],bezt->vec[2][1],bezt->vec[2][2]);
|
||||
}*/
|
||||
|
||||
icu1 = icu1->next;
|
||||
numCurves++;
|
||||
|
||||
@ -621,8 +631,7 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
ipo = add_ipo(blenderObject->id.name+2, ID_OB);
|
||||
{ ipo = add_ipo(blenderObject->id.name+2, ID_OB);
|
||||
blenderObject->ipo = ipo;
|
||||
|
||||
}
|
||||
@ -643,6 +652,48 @@ void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo(bool clearIpo)
|
||||
|
||||
}
|
||||
|
||||
void KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo(){
|
||||
|
||||
if (addInitFromFrame){
|
||||
KX_SceneList* scenes = m_ketsjiEngine->CurrentScenes();
|
||||
int numScenes = scenes->size();
|
||||
if (numScenes>=0){
|
||||
KX_Scene* scene = scenes->at(0);
|
||||
CListValue* parentList = scene->GetRootParentList();
|
||||
for (int ix=0;ix<parentList->GetCount();ix++){
|
||||
KX_GameObject* gameobj = (KX_GameObject*)parentList->GetValue(ix);
|
||||
if (!gameobj->IsDynamic()){
|
||||
Object* blenderobject = FindBlenderObject(gameobj);
|
||||
if (!blenderobject)
|
||||
continue;
|
||||
if (blenderobject->type==OB_ARMATURE)
|
||||
continue;
|
||||
float eu[3];
|
||||
Mat4ToEul(blenderobject->obmat,eu);
|
||||
MT_Point3 pos = MT_Point3(
|
||||
blenderobject->obmat[3][0],
|
||||
blenderobject->obmat[3][1],
|
||||
blenderobject->obmat[3][2]
|
||||
);
|
||||
MT_Vector3 eulxyz = MT_Vector3(
|
||||
eu[0],
|
||||
eu[1],
|
||||
eu[2]
|
||||
);
|
||||
MT_Vector3 scale = MT_Vector3(
|
||||
blenderobject->size[0],
|
||||
blenderobject->size[1],
|
||||
blenderobject->size[2]
|
||||
);
|
||||
gameobj->NodeSetLocalPosition(pos);
|
||||
gameobj->NodeSetLocalOrientation(MT_Matrix3x3(eulxyz));
|
||||
gameobj->NodeSetLocalScale(scale);
|
||||
gameobj->NodeUpdateGS(0,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define TEST_HANDLES_GAME2IPO 0
|
||||
|
||||
@ -800,7 +851,6 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ class KX_BlenderSceneConverter : public KX_ISceneConverter
|
||||
bool m_usemat;
|
||||
|
||||
void localDel_ipoCurve ( IpoCurve * icu ,struct SpaceIpo* sipo);
|
||||
struct Ipo* findIpoForName(char* objName);
|
||||
// struct Ipo* findIpoForName(char* objName);
|
||||
|
||||
public:
|
||||
KX_BlenderSceneConverter(
|
||||
@ -132,6 +132,9 @@ public:
|
||||
|
||||
virtual void ResetPhysicsObjectsAnimationIpo(bool clearIpo);
|
||||
|
||||
///this is for reseting the position,rotation and scale of the gameobjet that is not dynamic
|
||||
virtual void resetNoneDynamicObjectToIpo();
|
||||
|
||||
///this generates ipo curves for position, rotation, allowing to use game physics in animation
|
||||
virtual void WritePhysicsObjectToAnimationIpo(int frameNumber);
|
||||
virtual void TestHandlesPhysicsObjectToAnimationIpo();
|
||||
|
@ -86,7 +86,8 @@ void KX_BulletPhysicsController::ApplyForce(const MT_Vector3& force,bool local)
|
||||
MT_Vector3 KX_BulletPhysicsController::GetLinearVelocity()
|
||||
{
|
||||
float angVel[3];
|
||||
CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);
|
||||
//CcdPhysicsController::GetAngularVelocity(angVel[0],angVel[1],angVel[2]);
|
||||
CcdPhysicsController::GetLinearVelocity(angVel[0],angVel[1],angVel[2]);//rcruiz
|
||||
return MT_Vector3(angVel[0],angVel[1],angVel[2]);
|
||||
}
|
||||
MT_Vector3 KX_BulletPhysicsController::GetVelocity(const MT_Point3& pos)
|
||||
|
@ -59,14 +59,18 @@ public:
|
||||
|
||||
virtual void SetNewFileName(const STR_String& filename) = 0;
|
||||
virtual bool TryAndLoadNewFile() = 0;
|
||||
|
||||
bool addInitFromFrame;//rcruiz
|
||||
|
||||
virtual void ResetPhysicsObjectsAnimationIpo(bool clearIpo) = 0;
|
||||
|
||||
|
||||
///this generates ipo curves for position, rotation, allowing to use game physics in animation
|
||||
virtual void WritePhysicsObjectToAnimationIpo(int frameNumber) = 0;
|
||||
virtual void TestHandlesPhysicsObjectToAnimationIpo() = 0;
|
||||
|
||||
///this is for reseting the position,rotation and scale of the gameobjet that is not dynamic
|
||||
virtual void resetNoneDynamicObjectToIpo()=0;
|
||||
|
||||
// use blender materials
|
||||
virtual void SetMaterials(bool val) =0;
|
||||
virtual bool GetMaterials()=0;
|
||||
|
@ -394,6 +394,9 @@ else
|
||||
* the settings for that preceed the logic and physics
|
||||
* update. */
|
||||
m_logger->StartLog(tc_logic, m_kxsystem->GetTimeInSeconds(), true);
|
||||
|
||||
m_sceneconverter->resetNoneDynamicObjectToIpo();//this is for none dynamic objects with ipo
|
||||
|
||||
scene->UpdateObjectActivity();
|
||||
|
||||
if (!scene->IsSuspended())
|
||||
|
@ -1002,7 +1002,10 @@ PHY_IPhysicsController* CcdPhysicsEnvironment::CreateSphereController(float radi
|
||||
|
||||
int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl0,class PHY_IPhysicsController* ctrl1,PHY_ConstraintType type,
|
||||
float pivotX,float pivotY,float pivotZ,
|
||||
float axisX,float axisY,float axisZ)
|
||||
float axisX,float axisY,float axisZ,
|
||||
float axis1X,float axis1Y,float axis1Z,
|
||||
float axis2X,float axis2Y,float axis2Z
|
||||
)
|
||||
{
|
||||
|
||||
|
||||
@ -1066,8 +1069,11 @@ int CcdPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl
|
||||
btTransform frameInA;
|
||||
btTransform frameInB;
|
||||
|
||||
btVector3 axis1, axis2;
|
||||
btVector3 axis1(axis1X,axis1Y,axis1Z), axis2(axis2X,axis2Y,axis2Z);
|
||||
if (axis1.length() == 0.0)
|
||||
{
|
||||
btPlaneSpace1( axisInA, axis1, axis2 );
|
||||
}
|
||||
|
||||
frameInA.getBasis().setValue( axisInA.x(), axis1.x(), axis2.x(),
|
||||
axisInA.y(), axis1.y(), axis2.y(),
|
||||
|
@ -117,7 +117,10 @@ protected:
|
||||
|
||||
virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
|
||||
float pivotX,float pivotY,float pivotZ,
|
||||
float axisX,float axisY,float axisZ);
|
||||
float axisX,float axisY,float axisZ,
|
||||
float axis1X=0,float axis1Y=0,float axis1Z=0,
|
||||
float axis2X=0,float axis2Y=0,float axis2Z=0
|
||||
);
|
||||
|
||||
|
||||
//Following the COLLADA physics specification for constraints
|
||||
|
@ -93,7 +93,11 @@ void DummyPhysicsEnvironment::setGravity(float x,float y,float z)
|
||||
|
||||
|
||||
int DummyPhysicsEnvironment::createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
|
||||
float pivotX,float pivotY,float pivotZ,float axisX,float axisY,float axisZ)
|
||||
float pivotX,float pivotY,float pivotZ,float axisX,float axisY,float axisZ,
|
||||
float axis1X,float axis1Y,float axis1Z,
|
||||
float axis2X,float axis2Y,float axis2Z
|
||||
|
||||
)
|
||||
{
|
||||
|
||||
int constraintid = 0;
|
||||
|
@ -59,7 +59,10 @@ public:
|
||||
|
||||
virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
|
||||
float pivotX,float pivotY,float pivotZ,
|
||||
float axisX,float axisY,float axisZ);
|
||||
float axisX,float axisY,float axisZ,
|
||||
float axis1X=0,float axis1Y=0,float axis1Z=0,
|
||||
float axis2X=0,float axis2Y=0,float axis2Z=0
|
||||
);
|
||||
|
||||
virtual void removeConstraint(int constraintid);
|
||||
|
||||
|
@ -111,7 +111,11 @@ int SumoPhysicsEnvironment::createConstraint(
|
||||
class PHY_IPhysicsController* ctrl2,
|
||||
PHY_ConstraintType type,
|
||||
float pivotX,float pivotY,float pivotZ,
|
||||
float axisX,float axisY,float axisZ)
|
||||
float axisX,float axisY,float axisZ,
|
||||
float axis1X,float axis1Y,float axis1Z,
|
||||
float axis2X,float axis2Y,float axis2Z
|
||||
|
||||
)
|
||||
{
|
||||
int constraintid = 0;
|
||||
return constraintid;
|
||||
|
@ -64,7 +64,11 @@ public:
|
||||
virtual void setGravity(float x,float y,float z);
|
||||
virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
|
||||
float pivotX,float pivotY,float pivotZ,
|
||||
float axisX,float axisY,float axisZ);
|
||||
float axisX,float axisY,float axisZ,
|
||||
float axis1X=0,float axis1Y=0,float axis1Z=0,
|
||||
float axis2X=0,float axis2Y=0,float axis2Z=0
|
||||
|
||||
);
|
||||
|
||||
virtual void removeConstraint(int constraintid);
|
||||
|
||||
|
@ -86,7 +86,10 @@ class PHY_IPhysicsEnvironment
|
||||
|
||||
virtual int createConstraint(class PHY_IPhysicsController* ctrl,class PHY_IPhysicsController* ctrl2,PHY_ConstraintType type,
|
||||
float pivotX,float pivotY,float pivotZ,
|
||||
float axisX,float axisY,float axisZ)=0;
|
||||
float axis0X,float axis0Y,float axis0Z,
|
||||
float axis1X=0,float axis1Y=0,float axis1Z=0,
|
||||
float axis2X=0,float axis2Y=0,float axis2Z=0
|
||||
)=0;
|
||||
virtual void removeConstraint(int constraintid)=0;
|
||||
virtual float getAppliedImpulse(int constraintid){ return 0.f;}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user