Code Monkey home page Code Monkey logo

Comments (4)

AndresTraks avatar AndresTraks commented on July 28, 2024

Hi!
Maybe your graphics framework has a different layout for matrices than BulletSharp.
Try transposing the matrix that you get from the motion state.

from bulletsharp.

AndresLeonardoMartinez avatar AndresLeonardoMartinez commented on July 28, 2024

Hi!
Thanks for your response.
Here the code:
phisics class:

`private void inicializarMundo()
{cantidad = 1;
broadphase = new DbvtBroadphase();
collisionConfiguration = new DefaultCollisionConfiguration();
dispatcher = new CollisionDispatcher(collisionConfiguration);
//solver = new SequentialImpulseConstraintSolver();
//mundo
DynamicsWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, null, collisionConfiguration);
DynamicsWorld.Gravity = new Vector3(0, -10, 0);
//aca se realizan las acciones
CollisionShape groundShape = new StaticPlaneShape(new Vector3(0, 1, 0), 0);
DefaultMotionState myMotionState = new DefaultMotionState(Matrix4.CreateTranslation(0, -1, 0));
RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(0, myMotionState, groundShape, new Vector3(0, 0, 0));
Rplano = new RigidBody(rbInfo);

        DynamicsWorld.AddRigidBody(Rplano);


        //    CollisionShape fallShape = new SphereShape(1);
        //esfera 1
        for (int i = 0; i < cantidad; i++)
        {
            CollisionShape esf2 = new **SphereShape**(1);
            //Matrix4 M =Matrix4.Mult( Matrix4.CreateRotationZ(0.2f), Matrix4.CreateTranslation(0, 20 + 2 * i, 0));
            Matrix4 M = Matrix4.CreateTranslation(new Vector3(0, 8 + 2 * i, 0));
            ListaMV.Add(M);
            DefaultMotionState fallMotionState2 = new DefaultMotionState(M);
            Vector3 localInertia2 = esf2.CalculateLocalInertia(1);
            RigidBodyConstructionInfo fallRigidBodyCI2 = new RigidBodyConstructionInfo(1, fallMotionState2, esf2, localInertia2);
            fallRigidBody = new RigidBody(fallRigidBodyCI2);
            ListaRB.Add(fallRigidBody);

            DynamicsWorld.AddRigidBody(fallRigidBody);


        }`

I'm working with OpenTK 1.1, Visual Studio 2015 in a windows form.
Here the code of the timer:
` private void timer1_Tick(object sender, EventArgs e)
{
fisica.DynamicsWorld.StepSimulation(10);

        for (int i = 0; i < fisica.getCantidad(); i++)
        {
            // Matrix4 M = fisica.ListaRB[i].MotionState.WorldTransform;
            // M.Transpose();
            // fisica.ListaMV[i] = M;
            fisica.ListaMV[i] = fisica.ListaRB[i].MotionState.WorldTransform;

        }
       glControl3.Invalidate();

    }`

Result with SphereSharp: https://youtu.be/4HKtbGSU2Og
Result with BoxSharp:https://youtu.be/XDFeHNSXHtM

from bulletsharp.

AndresLeonardoMartinez avatar AndresLeonardoMartinez commented on July 28, 2024

Forget all:
I had a problem in the form of multiply the model with the View.
Again: thanks for the code!
Regards,
Andres

from bulletsharp.

AndresTraks avatar AndresTraks commented on July 28, 2024

Ok, cool!

from bulletsharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.