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

« back to all changes in this revision

Viewing changes to source/gameengine/Converter/KX_ConvertSensors.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_ConvertSensors.cpp,v 1.5 2004/05/02 23:45:02 kester Exp $
 
2
 * $Id: KX_ConvertSensors.cpp,v 1.7 2005/03/25 10:33:35 kester Exp $
3
3
 *
4
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
 *
65
65
#include "KX_NearSensor.h"
66
66
#include "KX_RadarSensor.h"
67
67
#include "KX_MouseFocusSensor.h"
68
 
 
 
68
#include "SCA_JoystickSensor.h"
69
69
#include "KX_NetworkMessageSensor.h"
70
70
 
71
71
#include "SCA_PropertySensor.h"
79
79
#include "KX_BlenderKeyboardDevice.h"
80
80
#include "KX_BlenderGL.h"
81
81
#include "RAS_ICanvas.h"
 
82
#include "PHY_IPhysicsEnvironment.h"
82
83
 
83
84
#include "KX_KetsjiEngine.h"
84
85
#include "KX_BlenderSceneConverter.h"
374
375
                                        
375
376
                                        // this sumoObject is not deleted by a gameobj, so delete it ourself
376
377
                                        // later (memleaks)!
377
 
                                        //SM_Object* sumoObj            =       new SM_Object(shape,NULL,NULL,NULL);
378
 
                                        //sumoObj->setMargin(blendernearsensor->dist);
379
 
                                        //sumoObj->setPosition(gameobj->NodeGetWorldPosition());
 
378
                                        float radius = blendernearsensor->dist;
 
379
                                        PHY__Vector3 pos;
 
380
                                        const MT_Vector3& wpos = gameobj->NodeGetWorldPosition();
 
381
                                        pos[0] = wpos[0];
 
382
                                        pos[1] = wpos[1];
 
383
                                        pos[2] = wpos[2];
 
384
                                        pos[3] = 0.f;
380
385
                                        bool bFindMaterial = false;
381
 
                                        gamesensor = new KX_NearSensor(eventmgr,gameobj,blendernearsensor->dist,blendernearsensor->resetdist,bFindMaterial,nearpropertyname,kxscene);
 
386
                                        PHY_IPhysicsController* physCtrl = kxscene->GetPhysicsEnvironment()->CreateSphereController(radius,pos);
 
387
 
 
388
                                        gamesensor = new KX_NearSensor(eventmgr,gameobj,
 
389
                                                blendernearsensor->dist,
 
390
                                                blendernearsensor->resetdist,
 
391
                                                bFindMaterial,
 
392
                                                nearpropertyname,kxscene,
 
393
                                                physCtrl
 
394
                                                );
382
395
                                        
383
396
                                }
384
397
                                break;
548
561
                                        // this sumoObject is not deleted by a gameobj, so delete it ourself
549
562
                                        // later (memleaks)!
550
563
                                        MT_Scalar smallmargin = 0.0;
551
 
                                        MT_Scalar largemargin = 0.1;
 
564
                                        MT_Scalar largemargin = 0.0;
552
565
                                        
553
566
                                        bool bFindMaterial = false;
 
567
                                        PHY_IPhysicsController* ctrl = kxscene->GetPhysicsEnvironment()->CreateConeController(coneradius,coneheight);
 
568
 
554
569
                                        gamesensor = new KX_RadarSensor(
555
570
                                                eventmgr,
556
571
                                                gameobj,
 
572
                                                ctrl,
557
573
                                                coneradius,
558
574
                                                coneheight,
559
575
                                                radaraxis,
611
627
                                }
612
628
                                break;
613
629
                        }
 
630
                case SENS_JOYSTICK:
 
631
                        {
 
632
                                int joysticktype = SCA_JoystickSensor::KX_JOYSENSORMODE_NODEF;
 
633
                                
 
634
                                bJoystickSensor* bjoy = (bJoystickSensor*) sens->data;
 
635
                                
 
636
                                SCA_JoystickManager *eventmgr 
 
637
                                        = (SCA_JoystickManager*) logicmgr->FindEventManager(SCA_EventManager::JOY_EVENTMGR);
 
638
                                if (eventmgr) 
 
639
                                {
 
640
                                        int axis        =0;
 
641
                                        int axisf       =0;
 
642
                                        int button      =0;
 
643
                                        int buttonf =0; 
 
644
                                        int hat         =0; 
 
645
                                        int hatf        =0;
 
646
                                        int prec        =0;
 
647
                                        
 
648
                                        switch(bjoy->type)
 
649
                                        {
 
650
                                        case SENS_JOY_AXIS:
 
651
                                                axis    = bjoy->axis;
 
652
                                                axisf   = bjoy->axisf;
 
653
                                                prec    = bjoy->precision;
 
654
                                                joysticktype  = SCA_JoystickSensor::KX_JOYSENSORMODE_AXIS;
 
655
                                                break;
 
656
                                        case SENS_JOY_BUTTON:
 
657
                                                button  = bjoy->button;
 
658
                                                buttonf = bjoy->buttonf;
 
659
                                                joysticktype  = SCA_JoystickSensor::KX_JOYSENSORMODE_BUTTON;
 
660
                                                break;
 
661
                                        case SENS_JOY_HAT:
 
662
                                                hat             = bjoy->hat;
 
663
                                                hatf    = bjoy->hatf;
 
664
                                                joysticktype  = SCA_JoystickSensor::KX_JOYSENSORMODE_HAT;
 
665
                                                break;
 
666
                                        default:
 
667
                                                printf("Error: bad case statement\n");
 
668
                                                break;
 
669
                                        }
 
670
                                        gamesensor = new SCA_JoystickSensor(
 
671
                                                eventmgr,
 
672
                                                gameobj,
 
673
                                                joysticktype,
 
674
                                                axis,axisf,
 
675
                                                prec,
 
676
                                                button,buttonf,
 
677
                                                hat,hatf);
 
678
                                } 
 
679
                                else
 
680
                                {
 
681
                                        printf("Error there was a problem finding the event manager\n");
 
682
                                }
 
683
 
 
684
                                break;
 
685
                        }
614
686
                default:
615
687
                        {
616
688
                        }