Page 1 of 1

Sample Demo

Posted: Sun Sep 18, 2011 4:53 am
by KahunaCoder
Hey guys! First of all, I just wanted to say thank you for the work you've put into this engine. I just started messing around with it tonight and it's pretty easy to set up.

I do have a quick question as I go through the demo. I created a sphere in Blender 2.5 and exported an fbx file. I was able to load the mesh into the game and fire off instances whenever the player fires. The problem I'm finding is that the cubes collides with the plane, but the spheres goes right through them. I'm not sure what's causing this. Is there a tutorial or an example somewhere that would help shed some light on this?

Thanks!

Re: Sample Demo

Posted: Sun Sep 18, 2011 5:10 am
by Norbo
It's most likely a graphical offset issue. If the sphere's model is centered somewhere other than the origin, the sphere will appear to rotate around a point which is offset from its true center of mass and collisions won't look right (the graphics go through other geometry). This happens because the collision shape geometry is centered on its own center of mass. To resolve this, either center the model on the origin in the model editor or apply a local transform that translates the model such that it is properly centered before applying the world transform and drawing. Some of the barebones display classes in the BasicSetupDemo and GettingStartedDemo show how the local transform works. I believe it was the DisplayModel's Draw method that creates a world matrix from the local * world matrices.

Re: Sample Demo

Posted: Sun Sep 18, 2011 3:52 pm
by KahunaCoder
Hello Norbo, thank you for taking your time to answer my question. Definitely good info to know especially since I'm just starting out. However, I found out my problem....I wasn't giving my spheres a mass value during instantiation. One of the things I noticed was that the plane wasn't being affected by the gravity and I wondered what was causing this. When I examined the way the plane was instantianted and the cubes, I noticed the cubes had a mass value. Once I added a mass value to my spheres, it fixed my collision issues.

Again, thanks and I look forward to diving deeper into BEPU!

Re: Sample Demo

Posted: Sun Sep 18, 2011 5:07 pm
by Norbo
Good to hear you found it; if you're curious, objects without a specified mass considered kinematic, and objects with mass are considered dynamic. Dynamic entities do all the normal bouncing and collision response things. Kinematic entities have what amounts to infinite mass and inertia, so that's why they don't respond to gravity or collisions. They are an "unstoppable force" or "immovable object" depending on your frame of reference :)

Re: Sample Demo

Posted: Mon Sep 19, 2011 1:13 am
by KahunaCoder
Hello again Norbo. Again, thanks for the great info. Knowing that will definitely help me decide how to use kinematic vs. dynamic.

I have another question, since I haven't really seen many examples of how this engine is being used, would you say this engine is mainly used for object interaction/simulation and not general collision detection between a complex level geometry and say player and projectiles?

Re: Sample Demo

Posted: Mon Sep 19, 2011 1:35 am
by Norbo
It can do both quite well :) For example, I know of projects that have successfully used it for collision detection alone while handling all the dynamics manually, and the engine is designed to accommodate different usages (collision rules, events, modular update stages, etc.).

For another example, the CharacterController is fully integrated into physical simulation, which tends to avoid nasty corner cases which a nonphysical character might have to work around. On the other hand, hitscan weapons will involve using the built in ray cast support against the broad phase acceleration structure as opposed to extremely fast physical objects.

If you are curious about the best path to take with a given feature, just ask and I can give more tailored advice.

Re: Sample Demo

Posted: Mon Sep 19, 2011 3:23 pm
by KahunaCoder
Cool! Thanks again Norbo! I am definitely looking forward to learning how to use this engine. I've worked with 2D physics engines before but this will be my first real attempt at getting into 3D. So far, the API is very clean and well documented. I just have to get myself familiar with how things work and I'm thankful you'll be available to answer my questions. :)