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

« back to all changes in this revision

Viewing changes to source/gameengine/Ketsji/KX_ConvertPhysicsObjects.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_ConvertPhysicsObjects.cpp,v 1.12 2004/05/08 00:25:20 kester Exp $
 
2
 * $Id: KX_ConvertPhysicsObjects.cpp,v 1.16 2005/03/25 10:33:37 kester Exp $
3
3
 *
4
4
 * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5
5
 *
33
33
#pragma warning (disable : 4786)
34
34
#endif
35
35
 
 
36
#include "MT_assert.h"
 
37
 
36
38
// defines USE_ODE to choose physics engine
37
39
#include "KX_ConvertPhysicsObject.h"
38
40
#include "KX_GameObject.h"
51
53
 
52
54
#include "KX_MotionState.h" // bridge between motionstate and scenegraph node
53
55
 
54
 
#ifdef HAVE_CONFIG_H
55
 
#include <config.h>
56
 
#endif
57
 
 
58
56
#ifdef USE_ODE
59
57
 
60
58
#include "KX_OdePhysicsController.h"
77
75
 
78
76
#include "KX_SumoPhysicsController.h"
79
77
 
 
78
struct KX_PhysicsInstance
 
79
{
 
80
        DT_VertexBaseHandle     m_vertexbase;
 
81
        int                     m_vtxarray;
 
82
        RAS_IPolyMaterial*      m_material;
 
83
        
 
84
        KX_PhysicsInstance(DT_VertexBaseHandle vertex_base, int vtxarray, RAS_IPolyMaterial* mat)
 
85
                : m_vertexbase(vertex_base),
 
86
                  m_vtxarray(vtxarray),
 
87
                  m_material(mat)
 
88
        {
 
89
        }
 
90
        
 
91
        ~KX_PhysicsInstance()
 
92
        {
 
93
                DT_DeleteVertexBase(m_vertexbase);
 
94
        }
 
95
};
 
96
 
80
97
static GEN_Map<GEN_HashedPtr,DT_ShapeHandle> map_gamemesh_to_sumoshape;
 
98
static GEN_Map<GEN_HashedPtr, KX_PhysicsInstance*> map_gamemesh_to_instance;
81
99
 
82
100
// forward declarations
83
 
void    BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,class SM_Object* sumoObj,const STR_String& matname,bool isDynamic,bool isActor);
84
 
DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj);
85
 
 
 
101
static void     BL_RegisterSumoObject(KX_GameObject* gameobj,class SM_Scene* sumoScene,class SM_Object* sumoObj,const STR_String& matname,bool isDynamic,bool isActor);
 
102
static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope);
86
103
 
87
104
void    KX_ConvertSumoObject(   KX_GameObject* gameobj,
88
105
                                RAS_MeshObject* meshobj,
127
144
        if (objprop->m_dyna && objprop->m_isactor)
128
145
        {
129
146
                DT_ShapeHandle shape = NULL;
 
147
                bool polytope = false;
130
148
                switch (objprop->m_boundclass)
131
149
                {
132
150
                        case KX_BOUNDBOX:
151
169
                                        smprop->m_mass*objprop->m_boundobject.c.m_height*objprop->m_boundobject.c.m_height);
152
170
                                break;
153
171
                        /* Dynamic mesh objects.  WARNING! slow. */
 
172
                        case KX_BOUNDPOLYTOPE:
 
173
                                polytope = true;
 
174
                                // fall through
154
175
                        case KX_BOUNDMESH:
155
176
                                if (meshobj && meshobj->NumPolygons() > 0)
156
177
                                {
157
 
                                        if ((shape = CreateShapeFromMesh(meshobj)))
 
178
                                        if ((shape = CreateShapeFromMesh(meshobj, polytope)))
158
179
                                        {
159
180
                                                // TODO: calculate proper inertia
160
181
                                                smprop->m_inertia *= smprop->m_mass*smprop->m_radius*smprop->m_radius;
185
206
                        {
186
207
 
187
208
                                DT_ShapeHandle complexshape=0;
 
209
                                bool polytope = false;
188
210
 
189
211
                                switch (objprop->m_boundclass)
190
212
                                {
200
222
                                        case KX_BOUNDCONE:
201
223
                                                complexshape = DT_NewCone(objprop->m_boundobject.c.m_radius, objprop->m_boundobject.c.m_height);
202
224
                                                break;
 
225
                                        case KX_BOUNDPOLYTOPE:
 
226
                                                polytope = true;
 
227
                                                // fall through
203
228
                                        default:
204
229
                                        case KX_BOUNDMESH:
205
230
                                                if (numpolys>0)
206
231
                                                {
207
 
                                                        complexshape = CreateShapeFromMesh(meshobj);
 
232
                                                        complexshape = CreateShapeFromMesh(meshobj, polytope);
208
233
                                                        //std::cout << "Convert Physics Mesh: " << meshobj->GetName() << std::endl;
209
234
/*                                                      if (!complexshape) 
210
235
                                                        {
235
260
                                                        dynamicParent = sumoctrl->GetSumoObject();
236
261
                                                }
237
262
 
238
 
                                                assert(dynamicParent);
 
263
                                                MT_assert(dynamicParent);
239
264
                                        }
240
265
                                
241
266
                                        
267
292
 
268
293
 
269
294
 
270
 
void    BL_RegisterSumoObject(
 
295
static void     BL_RegisterSumoObject(
271
296
        KX_GameObject* gameobj,
272
297
        class SM_Scene* sumoScene,
273
298
        class SM_Object* sumoObj,
280
305
                // need easy access, not via 'node' etc.
281
306
                KX_SumoPhysicsController* physicscontroller = new KX_SumoPhysicsController(sumoScene,sumoObj,motionstate,isDynamic);
282
307
                gameobj->SetPhysicsController(physicscontroller);
283
 
                physicscontroller->setClientInfo(gameobj);
 
308
 
284
309
                
285
310
                if (!gameobj->getClientInfo())
286
311
                        std::cout << "BL_RegisterSumoObject: WARNING: Object " << gameobj->GetName() << " has no client info" << std::endl;
287
 
                sumoObj->setClientObject(gameobj->getClientInfo());
 
312
                physicscontroller->setNewClientInfo(gameobj->getClientInfo());
 
313
                
288
314
 
289
315
                gameobj->GetSGNode()->AddSGController(physicscontroller);
290
316
 
296
322
                physicscontroller->SetObject(gameobj->GetSGNode());
297
323
}
298
324
 
299
 
DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj)
 
325
static DT_ShapeHandle InstancePhysicsComplex(RAS_MeshObject* meshobj, int vtxarray, RAS_IPolyMaterial *mat)
 
326
{
 
327
        // instance a mesh from a single vertex array & material
 
328
        const RAS_TexVert *vertex_array = &((*meshobj->GetVertexCache(mat)[vtxarray])[0]);
 
329
        //const KX_IndexArray &index_array = *meshobj->GetIndexCache(mat)[vtxarray];
 
330
        DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getLocalXYZ(), sizeof(RAS_TexVert));
 
331
        
 
332
        DT_ShapeHandle shape = DT_NewComplexShape(vertex_base);
 
333
        
 
334
        std::vector<DT_Index> indices;
 
335
        for (int p = 0; p < meshobj->NumPolygons(); p++)
 
336
        {
 
337
                RAS_Polygon* poly = meshobj->GetPolygon(p);
 
338
        
 
339
                // only add polygons that have the collisionflag set
 
340
                if (poly->IsCollider())
 
341
                {
 
342
                        DT_VertexIndices(3, poly->GetVertexIndexBase().m_indexarray);
 
343
                        
 
344
                        // tesselate
 
345
                        if (poly->VertexCount() == 4)
 
346
                        {
 
347
                                DT_Begin();
 
348
                                  DT_VertexIndex(poly->GetVertexIndexBase().m_indexarray[0]);
 
349
                                  DT_VertexIndex(poly->GetVertexIndexBase().m_indexarray[2]);
 
350
                                  DT_VertexIndex(poly->GetVertexIndexBase().m_indexarray[3]);
 
351
                                DT_End();
 
352
                        }
 
353
                }
 
354
        }
 
355
 
 
356
        //DT_VertexIndices(indices.size(), &indices[0]);
 
357
        DT_EndComplexShape();
 
358
        
 
359
        map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, vtxarray, mat));
 
360
        return shape;
 
361
}
 
362
 
 
363
static DT_ShapeHandle InstancePhysicsPolytope(RAS_MeshObject* meshobj, int vtxarray, RAS_IPolyMaterial *mat)
 
364
{
 
365
        // instance a mesh from a single vertex array & material
 
366
        const RAS_TexVert *vertex_array = &((*meshobj->GetVertexCache(mat)[vtxarray])[0]);
 
367
        //const KX_IndexArray &index_array = *meshobj->GetIndexCache(mat)[vtxarray];
 
368
        DT_VertexBaseHandle vertex_base = DT_NewVertexBase(vertex_array[0].getLocalXYZ(), sizeof(RAS_TexVert));
 
369
        
 
370
        std::vector<DT_Index> indices;
 
371
        for (int p = 0; p < meshobj->NumPolygons(); p++)
 
372
        {
 
373
                RAS_Polygon* poly = meshobj->GetPolygon(p);
 
374
        
 
375
                // only add polygons that have the collisionflag set
 
376
                if (poly->IsCollider())
 
377
                {
 
378
                        indices.push_back(poly->GetVertexIndexBase().m_indexarray[0]);
 
379
                        indices.push_back(poly->GetVertexIndexBase().m_indexarray[1]);
 
380
                        indices.push_back(poly->GetVertexIndexBase().m_indexarray[2]);
 
381
                        
 
382
                        if (poly->VertexCount() == 4)
 
383
                                indices.push_back(poly->GetVertexIndexBase().m_indexarray[3]);
 
384
                }
 
385
        }
 
386
 
 
387
        DT_ShapeHandle shape = DT_NewPolytope(vertex_base);
 
388
        DT_VertexIndices(indices.size(), &indices[0]);
 
389
        DT_EndPolytope();
 
390
        
 
391
        map_gamemesh_to_instance.insert(GEN_HashedPtr(meshobj), new KX_PhysicsInstance(vertex_base, vtxarray, mat));
 
392
        return shape;
 
393
}
 
394
 
 
395
// This will have to be a method in a class somewhere...
 
396
// Update SOLID with a changed physics mesh.
 
397
// not used... yet.
 
398
bool KX_ReInstanceShapeFromMesh(RAS_MeshObject* meshobj)
 
399
{
 
400
        KX_PhysicsInstance *instance = *map_gamemesh_to_instance[GEN_HashedPtr(meshobj)];
 
401
        if (instance)
 
402
        {
 
403
                const RAS_TexVert *vertex_array = &((*meshobj->GetVertexCache(instance->m_material)[instance->m_vtxarray])[0]);
 
404
                DT_ChangeVertexBase(instance->m_vertexbase, vertex_array[0].getLocalXYZ());
 
405
                return true;
 
406
        }
 
407
        return false;
 
408
}
 
409
 
 
410
static DT_ShapeHandle CreateShapeFromMesh(RAS_MeshObject* meshobj, bool polytope)
300
411
{
301
412
 
302
413
        DT_ShapeHandle *shapeptr = map_gamemesh_to_sumoshape[GEN_HashedPtr(meshobj)];
 
414
        // Mesh has already been converted: reuse
303
415
        if (shapeptr)
304
416
        {
305
417
                return *shapeptr;
306
418
        }
307
419
        
 
420
        // Mesh has no polygons!
308
421
        int numpolys = meshobj->NumPolygons();
309
422
        if (!numpolys)
310
423
        {
311
424
                return NULL;
312
425
        }
 
426
        
 
427
        // Count the number of collision polygons and check they all come from the same 
 
428
        // vertex array
313
429
        int numvalidpolys = 0;
 
430
        int vtxarray = -1;
 
431
        RAS_IPolyMaterial *poly_material = NULL;
 
432
        bool reinstance = true;
314
433
 
315
434
        for (int p=0; p<numpolys; p++)
316
435
        {
319
438
                // only add polygons that have the collisionflag set
320
439
                if (poly->IsCollider())
321
440
                {
 
441
                        // check polygon is from the same vertex array
 
442
                        if (poly->GetVertexIndexBase().m_vtxarray != vtxarray)
 
443
                        {
 
444
                                if (vtxarray < 0)
 
445
                                        vtxarray = poly->GetVertexIndexBase().m_vtxarray;
 
446
                                else
 
447
                                {
 
448
                                        reinstance = false;
 
449
                                        vtxarray = -1;
 
450
                                }
 
451
                        }
 
452
                        
 
453
                        // check poly is from the same material
 
454
                        if (poly->GetMaterial()->GetPolyMaterial() != poly_material)
 
455
                        {
 
456
                                if (poly_material)
 
457
                                {
 
458
                                        reinstance = false;
 
459
                                        poly_material = NULL;
 
460
                                }
 
461
                                else
 
462
                                        poly_material = poly->GetMaterial()->GetPolyMaterial();
 
463
                        }
 
464
                        
 
465
                        // count the number of collision polys
322
466
                        numvalidpolys++;
323
 
                        break;
 
467
                        
 
468
                        // We have one collision poly, and we can't reinstance, so we
 
469
                        // might as well break here.
 
470
                        if (!reinstance)
 
471
                                break;
324
472
                }
325
473
        }
326
474
        
 
475
        // No collision polygons
327
476
        if (numvalidpolys < 1)
328
477
                return NULL;
329
478
        
330
 
        DT_ShapeHandle shape = DT_NewComplexShape(NULL);
331
 
        
332
 
        
333
 
        numvalidpolys = 0;
334
 
 
335
 
        for (int p2=0; p2<numpolys; p2++)
336
 
        {
337
 
                RAS_Polygon* poly = meshobj->GetPolygon(p2);
338
 
        
339
 
                // only add polygons that have the collisionflag set
340
 
                if (poly->IsCollider())
341
 
                {   /* We have to tesselate here because SOLID can only raycast triangles */
342
 
                    DT_Begin();
343
 
                        DT_Vector3 pt;
344
 
                        /* V1 */
345
 
                        meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, 
346
 
                                poly->GetVertexIndexBase().m_indexarray[2],
347
 
                                poly->GetMaterial()->GetPolyMaterial())->xyz().getValue(pt);
348
 
                        DT_Vertex(pt);
349
 
                        /* V2 */
350
 
                        meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, 
351
 
                                poly->GetVertexIndexBase().m_indexarray[1],
352
 
                                poly->GetMaterial()->GetPolyMaterial())->xyz().getValue(pt);
353
 
                        DT_Vertex(pt);
354
 
                        /* V3 */
355
 
                        meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, 
356
 
                                poly->GetVertexIndexBase().m_indexarray[0],
357
 
                                poly->GetMaterial()->GetPolyMaterial())->xyz().getValue(pt);
358
 
                        DT_Vertex(pt);
359
 
                        
360
 
                        numvalidpolys++;
361
 
                    DT_End();
362
 
                        
363
 
                        if (poly->VertexCount() == 4)
364
 
                        {
365
 
                            DT_Begin();
 
479
        DT_ShapeHandle shape;
 
480
        if (reinstance)
 
481
        {
 
482
                if (polytope)
 
483
                        shape = InstancePhysicsPolytope(meshobj, vtxarray, poly_material);
 
484
                else
 
485
                        shape = InstancePhysicsComplex(meshobj, vtxarray, poly_material);
 
486
        }
 
487
        else
 
488
        {
 
489
                if (polytope)
 
490
                {
 
491
                        std::cout << "CreateShapeFromMesh: " << meshobj->GetName() << " is not suitable for polytope." << std::endl;
 
492
                        if (!poly_material)
 
493
                                std::cout << "                     Check mesh materials." << std::endl;
 
494
                        if (vtxarray < 0)
 
495
                                std::cout << "                     Check number of vertices." << std::endl;
 
496
                }
 
497
                
 
498
                shape = DT_NewComplexShape(NULL);
 
499
                        
 
500
                numvalidpolys = 0;
 
501
        
 
502
                for (int p2=0; p2<numpolys; p2++)
 
503
                {
 
504
                        RAS_Polygon* poly = meshobj->GetPolygon(p2);
 
505
                
 
506
                        // only add polygons that have the collisionflag set
 
507
                        if (poly->IsCollider())
 
508
                        {   /* We have to tesselate here because SOLID can only raycast triangles */
 
509
                           DT_Begin();
366
510
                                /* V1 */
367
 
                                meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, 
368
 
                                        poly->GetVertexIndexBase().m_indexarray[3],
369
 
                                        poly->GetMaterial()->GetPolyMaterial())->xyz().getValue(pt);
370
 
                                DT_Vertex(pt);
 
511
                                DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, 
 
512
                                        poly->GetVertexIndexBase().m_indexarray[2],
 
513
                                        poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ());
 
514
                                /* V2 */
 
515
                                DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, 
 
516
                                        poly->GetVertexIndexBase().m_indexarray[1],
 
517
                                        poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ());
371
518
                                /* V3 */
372
 
                                meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, 
373
 
                                        poly->GetVertexIndexBase().m_indexarray[2],
374
 
                                        poly->GetMaterial()->GetPolyMaterial())->xyz().getValue(pt);
375
 
                                DT_Vertex(pt);
376
 
                                /* V4 */
377
 
                                meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, 
 
519
                                DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, 
378
520
                                        poly->GetVertexIndexBase().m_indexarray[0],
379
 
                                        poly->GetMaterial()->GetPolyMaterial())->xyz().getValue(pt);
380
 
                                DT_Vertex(pt);
381
 
                        
 
521
                                        poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ());
 
522
                                
382
523
                                numvalidpolys++;
383
 
                            DT_End();
 
524
                           DT_End();
 
525
                                
 
526
                                if (poly->VertexCount() == 4)
 
527
                                {
 
528
                                   DT_Begin();
 
529
                                        /* V1 */
 
530
                                        DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, 
 
531
                                                poly->GetVertexIndexBase().m_indexarray[3],
 
532
                                                poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ());
 
533
                                        /* V3 */
 
534
                                        DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, 
 
535
                                                poly->GetVertexIndexBase().m_indexarray[2],
 
536
                                                poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ());
 
537
                                        /* V4 */
 
538
                                        DT_Vertex(meshobj->GetVertex(poly->GetVertexIndexBase().m_vtxarray, 
 
539
                                                poly->GetVertexIndexBase().m_indexarray[0],
 
540
                                                poly->GetMaterial()->GetPolyMaterial())->getLocalXYZ());
 
541
                                
 
542
                                        numvalidpolys++;
 
543
                                   DT_End();
 
544
                                }
 
545
                
384
546
                        }
385
 
        
386
547
                }
 
548
                
 
549
                DT_EndComplexShape();
387
550
        }
388
 
        
389
 
        DT_EndComplexShape();
390
551
 
391
552
        if (numvalidpolys > 0)
392
553
        {
398
559
        return NULL;
399
560
}
400
561
 
401
 
 
402
562
void    KX_ClearSumoSharedShapes()
403
563
{
404
564
        int numshapes = map_gamemesh_to_sumoshape.size();
405
 
        for (int i=0;i<numshapes ;i++)
 
565
        int i;
 
566
        for (i=0;i<numshapes ;i++)
406
567
        {
407
568
                DT_ShapeHandle shape = *map_gamemesh_to_sumoshape.at(i);
408
569
                DT_DeleteShape(shape);
409
570
        }
410
571
        
411
572
        map_gamemesh_to_sumoshape.clear();
 
573
        
 
574
        for (i=0; i < map_gamemesh_to_instance.size(); i++)
 
575
                delete *map_gamemesh_to_instance.at(i);
 
576
        
 
577
        map_gamemesh_to_instance.clear();
412
578
}
413
579
 
414
 
 
415
 
 
416
 
 
417
 
 
418
580
#endif //USE_SUMO_SOLID
419
581
 
420
582
 
427
589
                                                        struct  PHY_MaterialProps*      smmaterial,
428
590
                                                        struct  KX_ObjectProperties*    objprop)
429
591
{
 
592
        
430
593
        // not yet, future extension :)
431
594
        bool dyna=objprop->m_dyna;
432
595
        bool fullRigidBody= ( objprop->m_dyna && objprop->m_angular_rigidbody) != 0;
439
602
        dxSpace* space = odeEnv->GetOdeSpace();
440
603
        dxWorld* world = odeEnv->GetOdeWorld();
441
604
 
442
 
        if (!objprop->m_implicitsphere &&
443
 
                MT_fuzzyZero(objprop->m_boundingbox.m_extends[0]) ||
444
 
                MT_fuzzyZero(objprop->m_boundingbox.m_extends[1]) ||
445
 
                MT_fuzzyZero(objprop->m_boundingbox.m_extends[2])
446
 
                )
447
 
        {
448
 
 
449
 
        } else
450
 
        {
451
 
 
452
 
                KX_OdePhysicsController* physicscontroller = 
453
 
                        new KX_OdePhysicsController(
454
 
                        dyna,
455
 
                        fullRigidBody,
456
 
                        phantom,
457
 
                        motionstate,
458
 
                        space,
459
 
                        world,
460
 
                        shapeprops->m_mass,
461
 
                        smmaterial->m_friction,
462
 
                        smmaterial->m_restitution,
463
 
                        objprop->m_implicitsphere,
464
 
                        objprop->m_boundingbox.m_center,
465
 
                        objprop->m_boundingbox.m_extends,
466
 
                        objprop->m_radius
467
 
                        );
468
 
 
469
 
                gameobj->SetPhysicsController(physicscontroller);
470
 
                physicscontroller->setClientInfo(gameobj);                                              
471
 
                gameobj->GetSGNode()->AddSGController(physicscontroller);
472
 
 
473
 
                bool isActor = objprop->m_isactor;
474
 
                STR_String materialname;
475
 
                if (meshobj)
476
 
                        materialname = meshobj->GetMaterialName(0);
477
 
 
478
 
                const char* matname = materialname.ReadPtr();
479
 
 
480
 
 
481
 
                physicscontroller->SetObject(gameobj->GetSGNode());
482
 
                                
483
 
        }
 
605
        bool isSphere = false;
 
606
 
 
607
        switch (objprop->m_boundclass)
 
608
        {
 
609
        case KX_BOUNDBOX:
 
610
                {
 
611
 
 
612
                                KX_OdePhysicsController* physicscontroller = 
 
613
                                        new KX_OdePhysicsController(
 
614
                                        dyna,
 
615
                                        fullRigidBody,
 
616
                                        phantom,
 
617
                                        motionstate,
 
618
                                        space,
 
619
                                        world,
 
620
                                        shapeprops->m_mass,
 
621
                                        smmaterial->m_friction,
 
622
                                        smmaterial->m_restitution,
 
623
                                        isSphere,
 
624
                                        objprop->m_boundobject.box.m_center,
 
625
                                        objprop->m_boundobject.box.m_extends,
 
626
                                        objprop->m_boundobject.c.m_radius
 
627
                                        );
 
628
 
 
629
                                gameobj->SetPhysicsController(physicscontroller);
 
630
                                physicscontroller->setNewClientInfo(gameobj->getClientInfo());                                          
 
631
                                gameobj->GetSGNode()->AddSGController(physicscontroller);
 
632
 
 
633
                                bool isActor = objprop->m_isactor;
 
634
                                STR_String materialname;
 
635
                                if (meshobj)
 
636
                                        materialname = meshobj->GetMaterialName(0);
 
637
 
 
638
                                const char* matname = materialname.ReadPtr();
 
639
 
 
640
 
 
641
                                physicscontroller->SetObject(gameobj->GetSGNode());
 
642
 
 
643
                                break;
 
644
                        }
 
645
        default:
 
646
                {
 
647
                }
 
648
        };
 
649
 
484
650
}
485
651
 
486
652