@@ -484,225 +484,6 @@ void KX_BlenderSceneConverter::RegisterWorldInfo(KX_WorldInfo *worldinfo)
484
484
m_worldinfos.push_back (pair<KX_Scene *, KX_WorldInfo *> (m_currentScene, worldinfo));
485
485
}
486
486
487
- void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo (bool clearIpo)
488
- {
489
- // TODO this entire function is deprecated, written for 2.4x
490
- // the functionality should be rewritten, currently it does nothing
491
-
492
- CListValue *scenes = m_ketsjiEngine->CurrentScenes ();
493
- for (CListValue::iterator sceit = scenes->GetBegin (); sceit != scenes->GetEnd (); ++sceit) {
494
- KX_Scene *scene = (KX_Scene *)*sceit;
495
- // PHY_IPhysicsEnvironment* physEnv = scene->GetPhysicsEnvironment();
496
- CListValue* parentList = scene->GetRootParentList ();
497
- int numObjects = parentList->GetCount ();
498
- int g;
499
- for (g = 0 ; g < numObjects; g++) {
500
- KX_GameObject *gameObj = (KX_GameObject *)parentList->GetValue (g);
501
- if (gameObj->IsRecordAnimation ()) {
502
- Object *blenderObject = gameObj->GetBlenderObject ();
503
- if (blenderObject) {
504
- #if 0
505
- //erase existing ipo's
506
- Ipo* ipo = blenderObject->ipo;//findIpoForName(blenderObject->id.name+2);
507
- if (ipo) { //clear the curve data
508
- if (clearIpo) {//rcruiz
509
- IpoCurve *icu1;
510
-
511
- int numCurves = 0;
512
- for ( icu1 = (IpoCurve*)ipo->curve.first; icu1; ) {
513
-
514
- IpoCurve* tmpicu = icu1;
515
-
516
- /*int i;
517
- BezTriple *bezt;
518
- for ( bezt = tmpicu->bezt, i = 0; i < tmpicu->totvert; i++, bezt++) {
519
- 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]);
520
- }*/
521
-
522
- icu1 = icu1->next;
523
- numCurves++;
524
-
525
- BLI_remlink( &( blenderObject->ipo->curve ), tmpicu );
526
- if ( tmpicu->bezt )
527
- MEM_freeN( tmpicu->bezt );
528
- MEM_freeN( tmpicu );
529
- localDel_ipoCurve( tmpicu );
530
- }
531
- }
532
- }
533
- else {
534
- ipo = NULL; // XXX add_ipo(blenderObject->id.name+2, ID_OB);
535
- blenderObject->ipo = ipo;
536
- }
537
- #endif
538
- }
539
- }
540
- }
541
- }
542
- }
543
-
544
- void KX_BlenderSceneConverter::resetNoneDynamicObjectToIpo ()
545
- {
546
- // TODO the functionality should be rewritten
547
- }
548
-
549
- // this generates ipo curves for position, rotation, allowing to use game physics in animation
550
- void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo (int frameNumber)
551
- {
552
- CListValue *scenes = m_ketsjiEngine->CurrentScenes ();
553
- for (CListValue::iterator sceit = scenes->GetBegin (); sceit != scenes->GetEnd (); ++sceit) {
554
- KX_Scene *scene = (KX_Scene *)*sceit;
555
- // PHY_IPhysicsEnvironment* physEnv = scene->GetPhysicsEnvironment();
556
- CListValue *parentList = scene->GetObjectList ();
557
- int numObjects = parentList->GetCount ();
558
- int g;
559
- for (g = 0 ; g < numObjects; g++) {
560
- KX_GameObject *gameObj = (KX_GameObject *)parentList->GetValue (g);
561
- Object *blenderObject = gameObj->GetBlenderObject ();
562
- if (blenderObject && blenderObject->parent == NULL && gameObj->IsRecordAnimation ()) {
563
- if (blenderObject->adt == NULL )
564
- BKE_animdata_add_id (&blenderObject->id );
565
-
566
- if (blenderObject->adt ) {
567
- const MT_Vector3 &position = gameObj->NodeGetWorldPosition ();
568
- // const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
569
- const MT_Matrix3x3 &orn = gameObj->NodeGetWorldOrientation ();
570
-
571
- position.getValue (blenderObject->loc );
572
-
573
- float tmat[3 ][3 ];
574
- for (int r = 0 ; r < 3 ; r++)
575
- for (int c = 0 ; c < 3 ; c++)
576
- tmat[r][c] = (float )orn[c][r];
577
-
578
- mat3_to_compatible_eul (blenderObject->rot , blenderObject->rot , tmat);
579
-
580
- insert_keyframe (NULL , &blenderObject->id , NULL , NULL , " location" , -1 , (float )frameNumber, INSERTKEY_FAST);
581
- insert_keyframe (NULL , &blenderObject->id , NULL , NULL , " rotation_euler" , -1 , (float )frameNumber, INSERTKEY_FAST);
582
-
583
- #if 0
584
- const MT_Vector3& position = gameObj->NodeGetWorldPosition();
585
- //const MT_Vector3& scale = gameObj->NodeGetWorldScaling();
586
- const MT_Matrix3x3& orn = gameObj->NodeGetWorldOrientation();
587
-
588
- float eulerAngles[3];
589
- float eulerAnglesOld[3] = {0.0f, 0.0f, 0.0f};
590
- float tmat[3][3];
591
-
592
- // XXX animato
593
- Ipo* ipo = blenderObject->ipo;
594
-
595
- //create the curves, if not existing, set linear if new
596
-
597
- IpoCurve *icu_lx = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX");
598
- if (!icu_lx) {
599
- icu_lx = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X, 1);
600
- if (icu_lx) icu_lx->ipo = IPO_LIN;
601
- }
602
- IpoCurve *icu_ly = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY");
603
- if (!icu_ly) {
604
- icu_ly = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y, 1);
605
- if (icu_ly) icu_ly->ipo = IPO_LIN;
606
- }
607
- IpoCurve *icu_lz = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ");
608
- if (!icu_lz) {
609
- icu_lz = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z, 1);
610
- if (icu_lz) icu_lz->ipo = IPO_LIN;
611
- }
612
- IpoCurve *icu_rx = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX");
613
- if (!icu_rx) {
614
- icu_rx = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X, 1);
615
- if (icu_rx) icu_rx->ipo = IPO_LIN;
616
- }
617
- IpoCurve *icu_ry = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY");
618
- if (!icu_ry) {
619
- icu_ry = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y, 1);
620
- if (icu_ry) icu_ry->ipo = IPO_LIN;
621
- }
622
- IpoCurve *icu_rz = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ");
623
- if (!icu_rz) {
624
- icu_rz = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z, 1);
625
- if (icu_rz) icu_rz->ipo = IPO_LIN;
626
- }
627
-
628
- if (icu_rx) eulerAnglesOld[0] = eval_icu( icu_rx, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
629
- if (icu_ry) eulerAnglesOld[1] = eval_icu( icu_ry, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
630
- if (icu_rz) eulerAnglesOld[2] = eval_icu( icu_rz, frameNumber - 1 ) / ((180 / 3.14159265f) / 10);
631
-
632
- // orn.getValue((float *)tmat); // uses the wrong ordering, cant use this
633
- for (int r = 0; r < 3; r++)
634
- for (int c = 0; c < 3; c++)
635
- tmat[r][c] = orn[c][r];
636
-
637
- // mat3_to_eul( eulerAngles,tmat); // better to use Mat3ToCompatibleEul
638
- mat3_to_compatible_eul( eulerAngles, eulerAnglesOld,tmat);
639
-
640
- //eval_icu
641
- for (int x = 0; x < 3; x++)
642
- eulerAngles[x] *= (float) ((180 / 3.14159265f) / 10.0);
643
-
644
- //fill the curves with data
645
- if (icu_lx) insert_vert_icu(icu_lx, frameNumber, position.x(), 1);
646
- if (icu_ly) insert_vert_icu(icu_ly, frameNumber, position.y(), 1);
647
- if (icu_lz) insert_vert_icu(icu_lz, frameNumber, position.z(), 1);
648
- if (icu_rx) insert_vert_icu(icu_rx, frameNumber, eulerAngles[0], 1);
649
- if (icu_ry) insert_vert_icu(icu_ry, frameNumber, eulerAngles[1], 1);
650
- if (icu_rz) insert_vert_icu(icu_rz, frameNumber, eulerAngles[2], 1);
651
-
652
- // Handles are corrected at the end, testhandles_ipocurve isn't needed yet
653
- #endif
654
- }
655
- }
656
- }
657
- }
658
- }
659
-
660
- void KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo ()
661
- {
662
- CListValue *scenes = m_ketsjiEngine->CurrentScenes ();
663
- for (CListValue::iterator sceit = scenes->GetBegin (); sceit != scenes->GetEnd (); ++sceit) {
664
- KX_Scene *scene = (KX_Scene *)*sceit;
665
- // PHY_IPhysicsEnvironment* physEnv = scene->GetPhysicsEnvironment();
666
- CListValue *parentList = scene->GetRootParentList ();
667
- int numObjects = parentList->GetCount ();
668
- int g;
669
- for (g = 0 ; g < numObjects; g++) {
670
- KX_GameObject *gameObj = (KX_GameObject *)parentList->GetValue (g);
671
- if (gameObj->IsRecordAnimation ()) {
672
- Object *blenderObject = gameObj->GetBlenderObject ();
673
- if (blenderObject && blenderObject->adt ) {
674
- bAction *act = verify_adt_action (&blenderObject->id , false );
675
- FCurve *fcu;
676
-
677
- if (!act) {
678
- continue ;
679
- }
680
-
681
- /* for now, not much choice but to run this on all curves... */
682
- for (fcu = (FCurve *)act->curves .first ; fcu; fcu = fcu->next ) {
683
- /* Note: calling `sort_time_fcurve()` here is not needed, since
684
- * all keys have been added in 'right' order. */
685
- calchandles_fcurve (fcu);
686
- }
687
- #if 0
688
- // XXX animato
689
- Ipo* ipo = blenderObject->ipo;
690
-
691
- //create the curves, if not existing
692
- //testhandles_ipocurve checks for NULL
693
- testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"LocX"));
694
- testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"LocY"));
695
- testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ"));
696
- testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotX"));
697
- testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotY"));
698
- testhandles_ipocurve(findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ"));
699
- #endif
700
- }
701
- }
702
- }
703
- }
704
- }
705
-
706
487
#ifdef WITH_PYTHON
707
488
PyObject *KX_BlenderSceneConverter::GetPyNamespace ()
708
489
{
0 commit comments