Is There Documentation?

Jun 15, 2009 at 12:07 AM

Grinding my teeth trying to find my way through the original code is fun and all...

But is there documentation?

Coordinator
Jun 15, 2009 at 6:50 AM

Hi, Most classes and methods of the framework are documented with xml comments on them which means that help will show up during CodeInsight in Visual Studio.  There are also examples of using the framework (Look at the Oops.Xna.Framework.Testing.App\Screens\ExampleScreen.cs to start).  As far as tutuorials or usage documentation, there are currently none, unfortunately. 

If you have any questions in particular, you can ask them on this forum and I'd be happy to help with what I can.

Jun 15, 2009 at 4:41 PM

Thanks for a quick response, mate. Really appreciate it.

I am trying to do a few things that I can't find any refference for:

1. Change gravity settings:

In all your demos, the gravity is set to "Snail speed or slower". I am trying to improve that and make it more or less Earth-like or "close enough".

2. Body work:

You have a great way to combine bodies together in your rigidBogy object. Great work... but it took me 3 hours to figure out how to properly use offset coordinates.

Right now I am trying to figure out how to set a body to be "immobile", be able to move. I have a plate that is moved by user input (mouse or wasd), but it rotates alongside Y when you tilt it too much on X and then Z. I am trying to make it more... immobile. I still want things to bounce off of it, but I don't want those things to modify its position. Think Pong in 3D.

3. "Special" collision detection.

I have an object with a hole in it and a ball rolling around the object and finally falling into the hole. I would like to check when that ball fell through the hole to keep user's score... or otherwise when the ball hit the underneath plane surface, to subtract score points.

 

I'd be glad to write some basic tutorial for your engine, but I am not yet fluent in it.

Otherwise, I've seen at least 3 versions of 3d engines, and your code looks far superior... even if I would speak only about the syntax and implementation. =)

 

Cheers.

~T

 

Coordinator
Jun 17, 2009 at 2:01 AM

Hey, thanks for the positve feedback!

1) Set the RigidBody.Acceleration field to a larger vector pointing downwards to increase the gravity of an entity.  You can also set it to Vector3.Zero for objects that are suppose to float.

2) If you Include RigidBodyFlags.NoResponse to the RigidBody.Flags that represents your plate, the plate will still cause collisions but not be affected by them.  You can also set the RigidBody.InertiaTensor to Matrix.Zero(??).  This causes only linear motion from collisions.  Do one or the other.

3) You can create a CollisionGroup with a CollisionShape that represents an invisible object the ball must hit in order to register a score.  The CollisionGroup's Flags fields should include CollisionGroupFlags.Sensor so no collision response occurs.  Place it under the hole so as to know the score is successful on when hit.  You might use more than one CollisionGroup if you need some sort of pass-through volume.  To check if a collision occurred with your ball and the invisible "sensor(s)", pass a class that implements the ICollisionCallback interface to the PhysicsComponents constructor and you'll get notified of collision when ICollisionCallback.OnCollided gets called.

If you run into any problems or questions let me know.  Good luck! 

Jun 17, 2009 at 6:01 AM

Great... Thanks fro another quick response.

1. That worked... but now I am getting a strange thing going on with the object... the ball did not "roll" to begin with... I am not sure if I am doing somehting wrong. It kind of glidex around. When I set the Y gravity to -30, now it "cuts corners. Not sure how to explain better... The motion is not a smooth one.

2. There is no "RigidBodyFlags.NoResponse" in the latest engine. There's None, Static, Disabled, AutoDisable. I have the plate set to .None

3. I have not looked into this yet... its 1am and I am about to collapse and die. =) But off the top of my head I am not sure I follow.

Coordinator
Jun 18, 2009 at 2:52 AM

1) Example 2 uses "acceleration" of Vector3.Down * 25 and it seems to be working fine.  You might try looking at the code for that sample.  If that doesn't help let me know.

2) I am an idiot if I compiled the download incorrectly.  You can get the latest source code to get the "NoResponse" functionality.  You can get it here - http://oopsframework.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24781 or on the Source Code tab.

3) Let me know if you need more explanation on this one.

Jun 22, 2009 at 12:23 AM

Oh boy... Finally got around to troubleshooting these upgrades and did it break more things then it fixed. I should have used the latest version from the beginning. =\

At least before I was able to rotate my object with WASD keys... now the whole rotation thing is out of control. Well I guess "rotate" is the wrong word... I am trying to "tilt" my box object along X and Z axisses.

What I am essentially trying to do is have a ball roll around a plate, that I can tilt with WASD or Mouse... Like I've said... it is out of control. If I tilt the plane on one axis and then the other, it "rotates" along the Y axis. Is there a way to avoid it?

 

I am also trying to re-purpose your FPS display to show Acceleration and velocity of my ball. I am rewriting the FPS module a bit, but is there a way to display heads up things in an easier?

I've tried to remove the plane, the brown thing on the bottom. While it was deleted from the physics model and my objects can now go through it, the texture is still there. I will look at it in more details in a bit, but am I missing anything? Or is there a way to make the plane be there, but invisible? That way I could connect it to my collision detection.

 

I would love to hear more info about my previous #3 question... I am not sure I am getting any results from my playing around with Collision Group.

 

Another thing I was trying to do, but as a new person in XNA was no table to find a way to do... Maybe oyu know something. I am trying to create a way to show graphically velocity and acceleraion of my ball... say, take coordinates of my ball (for example 0,0,0) and have live starting there and extending into direction of where the ball is going (I would guess AccelerationX*10,AccelerationY*10,AccelerationZ*10). Problem #1, I found no easy way to draw a thin visible line in 3d environment connecting two sets of coordinates.

 

Thanks a lot.

~T

Coordinator
Jun 23, 2009 at 5:26 AM

Rotation Issues with "plate" - I'm not sure how you are tilting the plate but make sure you modifying the Torque and/or Rotation of the RigidBody of the plate.  Don't modify the Orientation or call UpdateTransform.  Collision response is based primarily on relative velocities so most movement of objects should be done with modifying force/torque/velociyt rotation.  And of the ApplyXXXmethods work.  You may also want to bump up the collision iterations of the PhysicsComponent and see if that helps collision response.  As far as the plate rotating along the y axis this will always occur if the plate responds to collisions.  You can try the "NoResponse" flag stated in a previous post.  You can also modify the inertia tensor of the plate's rigid body to be zero in M22 (I think).

Unfortunately, I haven't spent much time in GUI or HUD items of the framework.  I mainly just use a SpriteFont and SpriteBatch still.

The ugly brown ground gets drawn in the ExampleScreenN.DrawWorld methods using a Quadrilateral class.  Just comment out or remove those DrawUserIndexedPrimitives calls.

#3 - You can get notifications of collisions as they occur by implementing the ICollisionCallback methods on a class and passing an instance of that class to "new PhysicsComponent()" overload.  An example of this in the MainMenuScreen.  I have an invisible CollisionPlane (see MainMenuScreen.Initialize) that I use to get notification every time a CollisionShape touches it (see MainMenuScreen.OnCollide). You can do something similar but instead of an invisible CollisionPlane,  You might need to use a CollisionSphere.  Place the collision sphere under your "hole" far enough down to know that when the OnCollided method gets called for your ball and this invisible CollisionShere it should register as a "score".

You can draw lines with GraphicsDevice.DrawUserPrimitives() passing in PrimitiveType.LineList as the the primitive type and an array of Vector3 structs.  each pair of Vector3s represents a line.  You could loop through all the PhysicsComponent.RigidBodies and add two Vector3s to the array for each RigidBody's Velocity - one for the RigidBody.Position and the other for RigidBody.Position + RigidBody.Velocity (or similar).  To make sure you can see these "lines", You'll have to turn off your GraphicsDevice.RenderState.DepthTestEnabled(?) and DepthWriteEnabled temporarily while drawing the lines and make sure to draw them last.  This is, of course, all theory.  An example of drawing lines can be found in PhysicsComponent.UpdateDebug and PhysicsComponent.Draw for when I draw bounding boxes around all the primitives.  You might add your velocity drawing code here.  I'm not doing any RenderState changes though.