214
214
* Find the specified scene by name, or the first
215
215
* scene if nothing matches (shouldn't happen).
217
if((sce= (Scene *)BLI_findstring(&m_maggie->scene, name.ReadPtr(), offsetof(ID, name) + 2)))
217
if ((sce= (Scene *)BLI_findstring(&m_maggie->scene, name.ReadPtr(), offsetof(ID, name) + 2)))
220
220
for (vector<Main*>::iterator it=m_DynamicMaggie.begin(); !(it==m_DynamicMaggie.end()); it++) {
223
if((sce= (Scene *)BLI_findstring(&main->scene, name.ReadPtr(), offsetof(ID, name) + 2)))
223
if ((sce= (Scene *)BLI_findstring(&main->scene, name.ReadPtr(), offsetof(ID, name) + 2)))
537
519
RAS_MeshObject *gamemesh,
538
520
struct Mesh *for_blendermesh)
540
if(for_blendermesh) { /* dynamically loaded meshes we dont want to keep lookups for */
522
if (for_blendermesh) { /* dynamically loaded meshes we don't want to keep lookups for */
541
523
m_map_mesh_to_gamemesh.insert(CHashedPtr(for_blendermesh),gamemesh);
543
525
m_meshobjects.push_back(pair<KX_Scene*,RAS_MeshObject*>(m_currentScene,gamemesh));
661
643
Ipo* ipo = blenderObject->ipo;//findIpoForName(blenderObject->id.name+2);
663
645
{ //clear the curve data
664
if (clearIpo){//rcruiz
646
if (clearIpo) {//rcruiz
667
649
int numCurves = 0;
668
for( icu1 = (IpoCurve*)ipo->curve.first; icu1; ) {
650
for ( icu1 = (IpoCurve*)ipo->curve.first; icu1; ) {
670
652
IpoCurve* tmpicu = icu1;
674
for( bezt = tmpicu->bezt, i = 0; i < tmpicu->totvert; i++, bezt++){
656
for ( bezt = tmpicu->bezt, i = 0; i < tmpicu->totvert; i++, bezt++) {
675
657
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]);
706
688
void KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo()
708
if (addInitFromFrame){
690
if (addInitFromFrame) {
709
691
KX_SceneList* scenes = m_ketsjiEngine->CurrentScenes();
710
692
int numScenes = scenes->size();
712
694
KX_Scene* scene = scenes->at(0);
713
695
CListValue* parentList = scene->GetRootParentList();
714
for (int ix=0;ix<parentList->GetCount();ix++){
696
for (int ix=0;ix<parentList->GetCount();ix++) {
715
697
KX_GameObject* gameobj = (KX_GameObject*)parentList->GetValue(ix);
716
if (!gameobj->IsDynamic()){
698
if (!gameobj->IsDynamic()) {
717
699
Object* blenderobject = gameobj->GetBlenderObject();
718
700
if (!blenderobject)
807
789
IpoCurve *icu_lx = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX");
809
791
icu_lx = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X, 1);
810
if(icu_lx) icu_lx->ipo = IPO_LIN;
792
if (icu_lx) icu_lx->ipo = IPO_LIN;
812
794
IpoCurve *icu_ly = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY");
814
796
icu_ly = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y, 1);
815
if(icu_ly) icu_ly->ipo = IPO_LIN;
797
if (icu_ly) icu_ly->ipo = IPO_LIN;
817
799
IpoCurve *icu_lz = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ");
819
801
icu_lz = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z, 1);
820
if(icu_lz) icu_lz->ipo = IPO_LIN;
802
if (icu_lz) icu_lz->ipo = IPO_LIN;
822
804
IpoCurve *icu_rx = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX");
824
806
icu_rx = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X, 1);
825
if(icu_rx) icu_rx->ipo = IPO_LIN;
807
if (icu_rx) icu_rx->ipo = IPO_LIN;
827
809
IpoCurve *icu_ry = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY");
829
811
icu_ry = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y, 1);
830
if(icu_ry) icu_ry->ipo = IPO_LIN;
812
if (icu_ry) icu_ry->ipo = IPO_LIN;
832
814
IpoCurve *icu_rz = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ");
834
816
icu_rz = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z, 1);
835
if(icu_rz) icu_rz->ipo = IPO_LIN;
817
if (icu_rz) icu_rz->ipo = IPO_LIN;
838
if(icu_rx) eulerAnglesOld[0]= eval_icu( icu_rx, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
839
if(icu_ry) eulerAnglesOld[1]= eval_icu( icu_ry, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
840
if(icu_rz) eulerAnglesOld[2]= eval_icu( icu_rz, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
820
if (icu_rx) eulerAnglesOld[0]= eval_icu( icu_rx, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
821
if (icu_ry) eulerAnglesOld[1]= eval_icu( icu_ry, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
822
if (icu_rz) eulerAnglesOld[2]= eval_icu( icu_rz, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
842
824
// orn.getValue((float *)tmat); // uses the wrong ordering, cant use this
843
825
for (int r=0;r<3;r++)
859
841
if (icu_ry) insert_vert_icu(icu_ry, frameNumber, eulerAngles[1], 1);
860
842
if (icu_rz) insert_vert_icu(icu_rz, frameNumber, eulerAngles[2], 1);
862
// Handles are corrected at the end, testhandles_ipocurve isnt needed yet
844
// Handles are corrected at the end, testhandles_ipocurve isn't needed yet
953
935
Main *main_tmp= NULL; /* created only for linking, then freed */
954
936
LinkNode *names = NULL;
955
937
int idcode= BKE_idcode_from_name(group);
956
short flag= 0; /* dont need any special options */
938
short flag= 0; /* don't need any special options */
957
939
ReportList reports;
958
940
static char err_local[255];
960
942
/* only scene and mesh supported right now */
961
if(idcode!=ID_SCE && idcode!=ID_ME &&idcode!=ID_AC) {
943
if (idcode!=ID_SCE && idcode!=ID_ME &&idcode!=ID_AC) {
962
944
snprintf(err_local, sizeof(err_local), "invalid ID type given \"%s\"\n", group);
963
945
*err_str= err_local;
964
946
BLO_blendhandle_close(bpy_openlib);
968
if(GetMainDynamicPath(path)) {
950
if (GetMainDynamicPath(path)) {
969
951
snprintf(err_local, sizeof(err_local), "blend file already open \"%s\"\n", path);
970
952
*err_str= err_local;
971
953
BLO_blendhandle_close(bpy_openlib);
975
if(bpy_openlib==NULL) {
957
if (bpy_openlib==NULL) {
976
958
snprintf(err_local, sizeof(err_local), "could not open blendfile \"%s\"\n", path);
977
959
*err_str= err_local;
1027
1009
strncpy(main_newlib->name, path, sizeof(main_newlib->name));
1012
if (idcode==ID_ME) {
1031
1013
/* Convert all new meshes into BGE meshes */
1034
for(mesh= (ID *)main_newlib->mesh.first; mesh; mesh= (ID *)mesh->next ) {
1016
for (mesh= (ID *)main_newlib->mesh.first; mesh; mesh= (ID *)mesh->next ) {
1035
1017
if (options & LIB_LOAD_VERBOSE)
1036
1018
printf("MeshName: %s\n", mesh->name+2);
1037
1019
RAS_MeshObject *meshobj = BL_ConvertMesh((Mesh *)mesh, NULL, scene_merge, this);
1038
1020
scene_merge->GetLogicManager()->RegisterMeshName(meshobj->GetName(),meshobj);
1041
else if(idcode==ID_AC) {
1023
else if (idcode==ID_AC) {
1042
1024
/* Convert all actions */
1045
for(action= (ID *)main_newlib->action.first; action; action= (ID *)action->next) {
1027
for (action= (ID *)main_newlib->action.first; action; action= (ID *)action->next) {
1046
1028
if (options & LIB_LOAD_VERBOSE)
1047
1029
printf("ActionName: %s\n", action->name+2);
1048
1030
scene_merge->GetLogicManager()->RegisterActionName(action->name+2, action);
1051
else if(idcode==ID_SCE) {
1033
else if (idcode==ID_SCE) {
1052
1034
/* Merge all new linked in scene into the existing one */
1054
for(scene= (ID *)main_newlib->scene.first; scene; scene= (ID *)scene->next ) {
1036
for (scene= (ID *)main_newlib->scene.first; scene; scene= (ID *)scene->next ) {
1055
1037
if (options & LIB_LOAD_VERBOSE)
1056
1038
printf("SceneName: %s\n", scene->name+2);
1116
1098
for (int scene_idx=0;scene_idx<numScenes;scene_idx++)
1118
1100
KX_Scene* scene = scenes->at(scene_idx);
1119
if(IS_TAGGED(scene->GetBlenderScene())) {
1101
if (IS_TAGGED(scene->GetBlenderScene())) {
1120
1102
RemoveScene(scene); // XXX - not tested yet
1126
/* incase the mesh might be refered to later */
1108
/* in case the mesh might be refered to later */
1128
1110
CTR_Map<STR_HashedString,void*> &mapStringToMeshes = scene->GetLogicManager()->GetMeshMap();
1130
for(int i=0; i<mapStringToMeshes.size(); i++)
1112
for (int i=0; i<mapStringToMeshes.size(); i++)
1132
1114
RAS_MeshObject *meshobj= (RAS_MeshObject *) *mapStringToMeshes.at(i);
1133
if(meshobj && IS_TAGGED(meshobj->GetMesh()))
1115
if (meshobj && IS_TAGGED(meshobj->GetMesh()))
1135
1117
STR_HashedString mn = meshobj->GetName();
1136
1118
mapStringToMeshes.remove(mn);
1233
/* Worlds dont reference original blender data so we need to make a set from them */
1216
/* Worlds don't reference original blender data so we need to make a set from them */
1234
1217
typedef std::set<KX_WorldInfo*> KX_WorldInfoSet;
1235
1218
KX_WorldInfoSet worldset;
1236
1219
for (int scene_idx=0;scene_idx<numScenes;scene_idx++)
1238
1221
KX_Scene* scene = scenes->at(scene_idx);
1239
if(scene->GetWorldInfo())
1222
if (scene->GetWorldInfo())
1240
1223
worldset.insert( scene->GetWorldInfo() );
1418
1401
/* Find a mesh in the current main */
1419
1402
ID *me= static_cast<ID *>(BLI_findstring(&m_maggie->mesh, name, offsetof(ID, name) + 2));
1422
1405
printf("Could not be found \"%s\"\n", name);
1426
1409
/* Watch this!, if its used in the original scene can cause big troubles */
1428
1411
printf("Mesh has a user \"%s\"\n", name);
1429
1412
me = (ID*)copy_mesh((Mesh*)me);
1438
1421
Mesh *mesh= (Mesh *)me;
1440
1423
/* ensure all materials are tagged */
1441
for(int i=0; i<mesh->totcol; i++)
1424
for (int i=0; i<mesh->totcol; i++)
1443
1426
mesh->mat[i]->id.flag &= ~LIB_DOIT;
1445
for(int i=0; i<mesh->totcol; i++)
1428
for (int i=0; i<mesh->totcol; i++)
1447
1430
Material *mat_old= mesh->mat[i];
1449
1432
/* if its tagged its a replaced material */
1450
if(mat_old && (mat_old->id.flag & LIB_DOIT)==0)
1433
if (mat_old && (mat_old->id.flag & LIB_DOIT)==0)
1452
1435
Material *mat_old= mesh->mat[i];
1453
1436
Material *mat_new= copy_material( mat_old );