many questions from sueds

Discuss any questions about BEPUphysics or problems encountered.
sueds
Posts: 43
Joined: Tue Feb 05, 2008 10:40 am

Re: many questions from sueds

Post by sueds »

It depends but most of the time the mesh is set to the same position and orientation and just after the first collision the box start fly over the screen or going aside its original position.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: many questions from sueds

Post by Norbo »

So it never flies into infinity or anything like that, but after a collision it does wonky stuff? It sounds as if the center of the mesh is offset from its origin in model space, so when it gets rotated, it flies around away from where it should. Have you tried putting it into a zero gravity environment away from any possible collisions and giving it an initial angular velocity (put angularMomentum at some nonzero value)? I suspect it will spin around the screen in this case as well.
sueds
Posts: 43
Joined: Tue Feb 05, 2008 10:40 am

Re: many questions from sueds

Post by sueds »

I tried it and it was spinning. Maybe you could add an example using a mesh ( I can make one if you want ) in your next release? It would be pretty useful ( understand how to use properly etc...). I'll look more deeper in my code to see were I'm mistaken.

Did you found out the differences between the v0.4 and the v.041 ? I mean I'm really waiting to see the next release with the triangle mesh to start working on my game so I'm asking myself if the performance would be the same as v.041 ? Because they were really bad on my laptop.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: many questions from sueds

Post by Norbo »

The performance drop you see in v0.4.1 is problematic because it was entirely a demos version, with no associated engine changes. It was released because of an OutOfVideoMemoryException that occurred occasionally on switching simulations quickly in v0.4.0's demos, but the fix for it should not cause any slowdown. The other changes have no reason to affect performance except for backface culling, which should actually help noticably. I don't think there were any other changes, as I was under pressure to get the crash fix out the door.

The only thing that I can think of is that there might be some new render state changing, but I don't recall if that was already in v0.4.0 demos or not. If it was new in v0.4.1, there still should have been a speedup because I the render state changing eliminated the need to save state on sprite batch calls. A few of the states are inconsequential for the most part, you could try disabling them in the Draw method. Turning off DepthBufferEnable and turning on AlphaBlendEnable will cause some noticable problems, though.

I'll try to get an example in if I can for meshes.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: many questions from sueds

Post by Norbo »

Alright, I've added a DisplayModel type in. Here's a snippet from the draw method that shows the world matrix being updated if the DisplayModel is following an entity:

Code: Select all

        public void draw(Matrix viewMatrix, Matrix projectionMatrix)
        {
            if (entity != null)//Update the world matrix if the model is following an entity.
                worldMatrix = entity.rotationMatrix * Matrix.CreateTranslation(entity.centerPosition);
            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World = worldMatrix;
                    effect.View = viewMatrix;
                    effect.Projection = projectionMatrix;
                }
                mesh.Draw();
            }
        }
Note that matrix multiplication is noncommutative, as can be seen by switching the multiplication order. Putting the translation matrix first will cause all sorts of ugly.
sueds
Posts: 43
Joined: Tue Feb 05, 2008 10:40 am

Re: many questions from sueds

Post by sueds »

thanks for you code ! I was doing it right but I forgot to tell that my crate wasn't centred on its origin so I add an offset but I didn't transform it. It was my own mistake ! :S

thanks
Post Reply