~ubuntu-branches/ubuntu/gutsy/blender/gutsy-security

« back to all changes in this revision

Viewing changes to source/gameengine/Converter/KX_ConvertActuators.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Florian Ernst
  • Date: 2005-11-06 12:40:03 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051106124003-3pgs7tcg5rox96xg
Tags: 2.37a-1.1
* Non-maintainer upload.
* Split out parts of 01_SConstruct_debian.dpatch again: root_build_dir
  really needs to get adjusted before the clean target runs - closes: #333958,
  see #288882 for reference

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/**
2
 
* $Id: KX_ConvertActuators.cpp,v 1.4 2004/03/22 22:01:25 jesterking Exp $
 
2
* $Id: KX_ConvertActuators.cpp,v 1.7 2004/11/30 19:10:43 sirdude Exp $
3
3
*
4
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
 *
31
31
* Convert Blender actuators for use in the GameEngine
32
32
*/
33
33
 
34
 
#ifdef HAVE_CONFIG_H
35
 
#include <config.h>
36
 
#endif
37
 
 
38
34
#ifdef WIN32
39
35
#pragma warning (disable : 4786) 
40
36
#endif //WIN32
405
401
                                                        tmpsoundact->SetName(bact->name);
406
402
                                                        baseact = tmpsoundact;
407
403
                                                        soundscene->AddObject(sndobj);
 
404
                                                } else {
 
405
                                                        std::cout << "WARNING: Sound actuator " << bact->name << " failed to load sample." << std::endl;
408
406
                                                }
409
407
                                        }
410
408
                                }
449
447
                                
450
448
                                if (cdActuatorType != KX_CDActuator::KX_CDACT_NODEF) 
451
449
                                {
452
 
                                        SND_Scene* soundscene = scene->GetSoundScene();
453
450
                                        SND_CDObject* pCD = SND_CDObject::Instance();
454
451
                                        
455
452
                                        if (pCD)
484
481
                                - let the object-with-property report itself to the act when converted
485
482
                                */
486
483
                                if (propact->ob)
487
 
                                {
488
 
                                        KX_GameObject* tempObj = converter->FindGameObject(propact->ob);
489
 
                                        if (tempObj)
490
 
                                        {
491
 
                                                destinationObj = tempObj;
492
 
                                        }
493
 
                                } 
 
484
                                        destinationObj = converter->FindGameObject(propact->ob);
494
485
                                
495
486
                                SCA_PropertyActuator* tmppropact = new SCA_PropertyActuator(
496
487
                                        gameobj,
515
506
                                                
516
507
                                                // does the 'original' for replication exists, and 
517
508
                                                // is it in a non-active layer ?
 
509
                                                CValue* originalval = NULL;
518
510
                                                if (editobact->ob && !(editobact->ob->lay & activeLayerBitInfo))
519
 
                                                {
520
 
                                                        CValue* originalval = converter->FindGameObject(editobact->ob);
 
511
                                                        originalval = converter->FindGameObject(editobact->ob);
 
512
                                                
 
513
                                                MT_Vector3 linvelvec ( KX_BLENDERTRUNC(editobact->linVelocity[0]),
 
514
                                                        KX_BLENDERTRUNC(editobact->linVelocity[1]),
 
515
                                                        KX_BLENDERTRUNC(editobact->linVelocity[2]));
521
516
                                                        
522
 
                                                        if (originalval)
523
 
                                                        {
524
 
                                                                MT_Vector3 linvelvec ( KX_BLENDERTRUNC(editobact->linVelocity[0]),
525
 
                                                                        KX_BLENDERTRUNC(editobact->linVelocity[1]),
526
 
                                                                        KX_BLENDERTRUNC(editobact->linVelocity[2]));
527
 
                                                                KX_SCA_AddObjectActuator* tmpaddact = 
528
 
                                                                        new KX_SCA_AddObjectActuator(
529
 
                                                                        
530
 
                                                                        gameobj, 
531
 
                                                                        originalval,
532
 
                                                                        editobact->time,
533
 
                                                                        scene,
534
 
                                                                        linvelvec.getValue(),
535
 
                                                                        editobact->localflag!=0
536
 
                                                                        
537
 
                                                                        );
 
517
                                                KX_SCA_AddObjectActuator* tmpaddact = 
 
518
                                                        new KX_SCA_AddObjectActuator(
 
519
                                                                gameobj, 
 
520
                                                                originalval,
 
521
                                                                editobact->time,
 
522
                                                                scene,
 
523
                                                                linvelvec.getValue(),
 
524
                                                                editobact->localflag!=0
 
525
                                                                );
538
526
                                                                
539
527
                                                                //editobact->ob to gameobj
540
528
                                                                baseact = tmpaddact;
541
 
                                                        } 
542
 
                                                        else
543
 
                                                        {
544
 
                                                                // let's pretend this never happened
545
 
                                                                exit(0);
546
 
                                                        }
547
 
                                                } else
548
 
                                                {
549
 
                                                        printf ("ERROR: GameObject %s has a AddObjectActuator %s without object (in 'nonactive' layer)\n",
550
 
                                                                objectname.ReadPtr(),
551
 
                                                                uniquename.ReadPtr()    );
552
 
                                                }
553
529
                                        }
554
530
                                        break;
555
531
                                case ACT_EDOB_END_OBJECT:
561
537
                                        break;
562
538
                                case ACT_EDOB_REPLACE_MESH:
563
539
                                        {
 
540
                                                RAS_MeshObject *tmpmesh = NULL;
564
541
                                                if (editobact->me)
565
 
                                                {
566
 
                                                        RAS_MeshObject *tmpmesh = BL_ConvertMesh(
 
542
                                                        tmpmesh = BL_ConvertMesh(
567
543
                                                                editobact->me,
568
544
                                                                blenderobject,
569
545
                                                                rendertools,
570
546
                                                                scene,
571
547
                                                                converter
572
548
                                                                );
573
 
                                                        KX_SCA_ReplaceMeshActuator* tmpreplaceact
574
 
                                                                = new KX_SCA_ReplaceMeshActuator(
 
549
 
 
550
                                                KX_SCA_ReplaceMeshActuator* tmpreplaceact
 
551
                                                        = new KX_SCA_ReplaceMeshActuator(
575
552
                                                                gameobj,
576
553
                                                                tmpmesh,
577
554
                                                                scene
578
555
                                                                );
579
556
                                                        
580
557
                                                        baseact = tmpreplaceact;
581
 
                                                }
582
 
                                                else
583
 
                                                {
584
 
                                                        printf ("ERROR: GameObject %s ReplaceMeshActuator %s without object\n",
585
 
                                                                objectname.ReadPtr(),
586
 
                                                                uniquename.ReadPtr());
587
 
                                                }
588
558
                                        }
589
559
                                        break;
590
560
                                case ACT_EDOB_TRACK_TO:
591
561
                                        {
 
562
                                                SCA_IObject* originalval = NULL;
592
563
                                                if (editobact->ob)
593
 
                                                {
594
 
                                                        SCA_IObject* originalval = converter->FindGameObject(editobact->ob);
 
564
                                                        originalval = converter->FindGameObject(editobact->ob);
595
565
                                                        
596
 
                                                        KX_TrackToActuator* tmptrackact 
597
 
                                                                = new KX_TrackToActuator(gameobj, 
 
566
                                                KX_TrackToActuator* tmptrackact 
 
567
                                                        = new KX_TrackToActuator(gameobj, 
598
568
                                                                originalval,
599
569
                                                                editobact->time,
600
570
                                                                editobact->flag,
602
572
                                                                blenderobject->upflag
603
573
                                                                );
604
574
                                                        baseact = tmptrackact;
605
 
                                                }
606
 
                                                else
607
 
                                                {
608
 
                                                        printf("ERROR: GameObject %s no object in EditObjectActuator %s\n",
609
 
                                                                objectname.ReadPtr(),
610
 
                                                                uniquename.ReadPtr()    );
611
 
                                                        
612
 
                                                        
613
 
                                                }
614
575
                                        }
615
576
                                }
616
577
                                break;
674
635
                case ACT_SCENE:
675
636
                        {
676
637
                                bSceneActuator *sceneact = (bSceneActuator *) bact->data;
677
 
                                bool scenevalid = true;
678
 
                                STR_String nextSceneName;
 
638
                                STR_String nextSceneName("");
679
639
                                
680
640
                                KX_SceneActuator* tmpsceneact;
681
641
                                int mode = KX_SceneActuator::KX_SCENE_NODEF;
718
678
                                                        nextSceneName = sceneact->scene->id.name + 2; // this '2' is necessary to remove prefix 'SC'
719
679
                                                }
720
680
                                                
721
 
                                                if (!nextSceneName.Length())
722
 
                                                {
723
 
                                                        printf ("ERROR: GameObject %s has a SceneActuator %s (SetScene) without scene\n",
724
 
                                                                objectname.ReadPtr(),
725
 
                                                                uniquename.ReadPtr());
726
 
                                                        scenevalid = false;
727
 
                                                        
728
 
                                                }
729
681
                                                break;
730
682
                                        }
731
683
                                case ACT_SCENE_CAMERA:
748
700
                                default:
749
701
                                        ; /* flag error */
750
702
                                }
751
 
                                if (scenevalid )
752
 
                                {
753
 
                                        tmpsceneact = new KX_SceneActuator(gameobj,
 
703
                                tmpsceneact = new KX_SceneActuator(gameobj,
754
704
                                                mode,
755
705
                                                scene,
756
706
                                                ketsjiEngine,
757
707
                                                nextSceneName,
758
708
                                                cam);
759
709
                                        baseact = tmpsceneact;
760
 
                                }
761
710
                                break;
762
711
                        }
763
712
                case ACT_GAME: