Physics Simulation Forum

 

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Thu Jun 21, 2012 4:33 am 
Offline

Joined: Thu Jun 21, 2012 4:30 am
Posts: 1
i have a quick question about bullets raytest and i hope some experienced user can help me. I'm using BulletSharp ( with OpenTK ), the C# wrapper of bullet. I set up a very basic collision system to raytrace the scene for collisions. So i added a box to my scene and created a rigidBody with it and added it to the scene. When i now raytest the scene a collision is only detected for the aabb of the box ( world transformation is set to rotation in motion state). Is there a simple option i'm missing to let bullet use obb for raytesting? Maybe i need to use a different shape? If you need any code snippets just let me know.

Edit:

CollisionSystem.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BulletSharp;
using Naps.Game.Math;
using OpenTK;
namespace Naps.Game.Systems
{
    public class CollisionSystem
    {
        DbvtBroadphase broadphase;
        DefaultCollisionConfiguration configuration;
        CollisionDispatcher dispatcher;
        SequentialImpulseConstraintSolver solver;
        public DiscreteDynamicsWorld world;

        public void Initialize()
        {
            broadphase = new DbvtBroadphase();   
            configuration = new DefaultCollisionConfiguration();
            dispatcher = new CollisionDispatcher(configuration);
            solver = new SequentialImpulseConstraintSolver();
            world = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, configuration);
            world.Gravity = new OpenTK.Vector3(0, -9.81f, 0);
        }

        public BulletSharp.CollisionWorld.RayResultCallback Raycast(Ray ray)
        {
            Vector3 start = new Vector3(ray.position);
            Vector3 end = new Vector3(start + ray.direction * ray.length);
            BulletSharp.CollisionWorld.ClosestRayResultCallback callback = new CollisionWorld.ClosestRayResultCallback(start,end);
            world.RayTest(start, end, callback);
            return callback;
        }

        public void Update()
        {
        }

        public void Dispose()
        {
            broadphase.Dispose();
            configuration.Dispose();
            dispatcher.Dispose();
            solver.Dispose();
            world.Dispose();
        }
    }
}


Another snippet where the box is created
Code:
CollisionShape box = new BoxShape(0.5f);
            Matrix4 mat = model.bone.CalculateTransformation();
            DefaultMotionState state = new DefaultMotionState(mat);
            RigidBodyConstructionInfo ci = new RigidBodyConstructionInfo(0, state, box);
            body = new RigidBody(ci);


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot], fractile and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group