This project is read-only.

VertexProcessor

Jan 17, 2009 at 1:20 AM
I have been reading on this site and others, that, in order for me to use my own models (mostly FBX) with the TriangleMeshObject, I have to use the VertexProcessor as my Content Processor. However, when I click on the model and go to the list of content processor in the model properties, I do not see a VertexProcessor. Should I be doing this somewhere else instead of in the properties? Can someone please push me in the direction I need to be going to get this work? Currently, when I use the TriangleMeshObject for my models and set EnableBody( ), my models simply fall thru the floor of my building and right thru the ground without stopping. Any help would be greatly appreciated.

Thanks in advance. BTW, nice job with this. I've learned A LOT from looking thru it.
Jan 22, 2009 at 9:11 AM
I think there is another way to do it now but it involves writing a bit of code yourself...

Ok this is from memory so forgive me if it's wrong. Compile the vertex processor (I think it's a seperate project? If so, open it and run it once). Then go into your game, click on Content then right click references (the one that's inside content!) and click Add Reference. Click browse then go into the Vertex Processor bin folder, then x86 then debug and there should be Vertex Processor.dll. Add that.

You should now be able to choose the processor. I tried loads of times to get it working but realised I was adding the reference inside my project but NOT inside the content folder which is what you need to do. So basically, just find VertexProcessor.dll (wherever that may be - I think it was in it's own project but maybe not) and add it to the Content>References.

Hope that helps.
Jan 22, 2009 at 9:37 PM
I had already tried that. I got the VertexProcessor out of an older version of JigLibX and did exactly what you said. But, it didn't help. My objects still fall from the sky like they're suppose to, but they don't stop when they hit the ground or any other objects (TriangleMeshObjects) along the way. I'm looking at it now to see what the problem is. I'll post whatever I find on here in case it helps anyone else.

Thanks for your help though. Getting input from other developers is DEFINITELY a big help with all of my projects.
Jan 22, 2009 at 10:30 PM
So it's only TriangleMeshObjects that won't collide with anything? I am actually having a similar problem myself, are you rotating the TriMeshObjects? It seems to cause problem for me when I try.

To be honest, I've been trying to work with TriangleMesh's as there is a bug with sphere/box collision. So, I've been using TriangleMesh's to recreate boxes but it seems to be a whole lot more difficult and even when I get it working I still get odd collisions occasionaly like the mesh isn't right.

Good luck :).
Jan 22, 2009 at 11:31 PM
Yes, it's only with TriangleMeshes. They work-ish. I have a soccerball (sphere object) that I can throw at the TriangleMeshes and it bounces back. But, when I turn on "enableBody( )", the triangle mesh object simply falls thru the ground. The gravity seems to be working. But, not the collision between the triangle mesh and other objects. However, even with "enableBody( )" turned on, I can still bounce my soccerball object off of the triangle mesh object as it's falling from the sky.
Jan 23, 2009 at 8:22 AM
Only thing I can think of is that I was under the impression that TriangleMeshes must be static, as in they aren't allowed to move, and it sounds like your dropping a triangle mesh and hoping it will collide with some objects? If that is the case then I'm guessing the vertices of the trianglemesh are not being moved with your object which is why collisions never occur?

To be honest, I'm pretty much a beginner at this too, maybe someone who knows abit more could help out.... :)
Jan 23, 2009 at 4:33 PM
I still appreciate your feedback. I'm going to look into your suggestion about the trianglemesh not moving with my object. Plus, I've also started creating my own PhysicObjects. So, hopefully I'll learn a lot during that process. I'm also starting a blog about my XNA development. I'm getting ready to upload some screenshots of some of the projects I'm working on. Once I get something uploaded, I'll come back here and post some links so that peeps can see what I'm working on. They'll also be able to download my code to better help with any issues I'm having.
Jan 23, 2009 at 4:45 PM
Here are some screen shots of projects where I took some tutorials and built on top of them during my learning stages. All of these implement the JigLibX engine for either physics, collisions, or both.

P.S. Ignore the soccerballs thrown all over most of the screens. Those were tests for JigLibX stuff.


http://www.prodigyproductionsllc.com/~xnagamer/
Jan 25, 2009 at 9:16 AM
Edited Jan 25, 2009 at 12:11 PM
Nice,

Here is a project I am working on, as you can see the ball bounces round funny because of the bugs with sphere/box collision :(. So I converted all the platforms to triangle-meshes but that made the performance really bad and the collision detection was dodgy on the ones that weren't completely flat. So I gave up with triangle meshes and worked with boxes instead.

http://uk.youtube.com/watch?v=_EBFsjSocD8
Jan 27, 2009 at 1:40 AM
How did you get your ball to roll in the first place? I have just a flat plane with a ball on it. But, when I add a velocity to my ball, it just sits there. I'm assuming it's because the plane has collision on it and so does the ball. I eventually want to have it so that I can push boxes around on a plane, up and down ramps, and have the box react to the angle of the ramps and so on.
Jan 27, 2009 at 8:31 AM
You need to create a controller to handle forces acting upon the ball. You need to inherit from Controller. Here is abit of mine...i've taken out some of teh fields etc but you should get the idea. As you can see, you assign a body to the controller, in my case a sphere. Then you applyworldtorque to make it roll.

public class BallController : Controller
    {
        public BallController(Game game)
        {
            this.game = game;
            previousKeyboardState = Keyboard.GetState();
            previousPadState = GamePad.GetState(PlayerIndex.One);
        }
        public void Initialise(Body body)
        {
            this.body = body;
        }

        public override void UpdateController(float dt)
        {
            // The torque to be applied to the ball to make it spin
            Vector3 torque = Vector3.Zero;
            currentKeyboardState = Keyboard.GetState(PlayerIndex.One);
            padState = GamePad.GetState(PlayerIndex.One);
           
            // Apply torque from keyboard
            if (currentKeyboardState.IsKeyDown(Keys.A))
                torque += Vector3.Transform(new Vector3(0, 0, 6), game.Camera.Rotation);
            if (currentKeyboardState.IsKeyDown(Keys.D))
                torque += Vector3.Transform(new Vector3(0, 0, -6), game.Camera.Rotation);
            if (currentKeyboardState.IsKeyDown(Keys.S))
                torque += Vector3.Transform(new Vector3(6, 0, 0), game.Camera.Rotation);
            if (currentKeyboardState.IsKeyDown(Keys.W))
                torque += Vector3.Transform(new Vector3(-6, 0, 0), game.Camera.Rotation);

            // Apply the torque from the pad
            torque += Vector3.Transform(new Vector3(padState.ThumbSticks.Left.Y * -6, 0, 0), game.Camera.Rotation);
            torque += Vector3.Transform(new Vector3(0, 0, padState.ThumbSticks.Left.X * -6), game.Camera.Rotation);

            // If there is some torque in the system then apply it
            if (torque != Vector3.Zero)
                body.AddWorldTorque(torque);

            previousKeyboardState = currentKeyboardState;
            previousPadState = padState;
        }

    }
Jan 27, 2009 at 11:18 PM
AWESOME! That did the trick. Thanks again.