Object popping in and out of view problem.

rated by 0 users
This post has 12 Replies | 4 Followers

Top 50 Contributor
Posts 93
SunBurn_Community_Licensee
Kristafer Vale Posted: 09-09-2010 10:20 AM

Hi All,

 

I've just started getting back into XNA development using SunBurn, so I'm sure this bug is happening because of something dumb I'm doing, however I thought I'd ask in case someone can help me figure out what's going on.

Here's a video of what's happening.

http://www.youtube.com/watch?v=xNa8WwBjcMI

The object is simply a .fbx file that I've loaded in to my project and submitted to SunBurn as a dynamic object to be rendered. As you can see from the video the object seems to pop in and out of visibility as if it's hitting some invisible barrier or wall.

I'm loading the model like this:

            // Ship Model
            shipModel = Content.Load<Model>("Models/ship");
            ship_obj = new SceneObject(shipModel);
            ship_obj.ObjectType = ObjectType.Dynamic;
            ship_obj.World = world;
            sceneInterface.ObjectManager.Submit(ship_obj);

and moving it's meshes in space like this:

            // ship update
            if (ship_obj != null)
            {
                for (int m = 0; m < ship_obj.RenderableMeshes.Count; m++)
                {
                    RenderableMesh mesh = ship_obj.RenderableMeshes[m];
                    mesh.MeshToObject = Matrix.CreateScale(ballScale) * ship.World ;
                }
            }

ship.World is being transformed correctly as if it wasn't the camera wouldn't be behaving correctly either as it's a chase camera following ship.World.

So am I missing something simple? Like maybe the bounding boxes need to be transformed seperately or something?

Any tips are greatly appreciated!

Thanks!

Top 10 Contributor
Posts 699
SunBurn_Community_Licensee
SunBurn_Contributor

You may need to update the boundingspheres after moving the meshes around. I believe there is a method call: ship_obj.CalculateBounds();  try this after manipulating the MeshToObject matrices. 

Contributor on the SunBurn sgMotion Animation Library open source project.

Top 100 Contributor
Posts 31
SunBurn_Community_Licensee

hi there, i'm having the exact same problem and unfortunately this "CalculateBounds" function doesn't provide the fix.  would anyone have any other suggestions?  thanks in advance.

Top 10 Contributor
Posts 699
SunBurn_Community_Licensee
SunBurn_Contributor

Is your object set to Dynamic before adding it to the ObjectManager? Moving static objects will cause the visibility glitches.

Contributor on the SunBurn sgMotion Animation Library open source project.

Top 100 Contributor
Posts 31
SunBurn_Community_Licensee

thanks for the quick reply.  yes, the ObjectType is definitely set to Dynamic.

Top 10 Contributor
Posts 4,546
Employee
SunBurn_Studio_Licensee

Hi secluder,

Are you scaling the meshes (as opposed to just moving them)?

If so it may be necessary to update the mesh's ObjectSpaceBoundingSphere to ensure it completely encapsulates the mesh.

We didn't anticipate that moving meshes would be so popular, so the mesh bounds information was designed to be in the most optimal format, not necessarily the easiest to use.

To address this, in SunBurn 2.0 we switched the mesh bounds to mesh space, so it's based on the raw mesh geometry not the transforms, meaning you no longer need to worry about the mesh bounds when moving and scaling meshes.

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 100 Contributor
Posts 31
SunBurn_Community_Licensee

hey John,

i'm not doing any scaling at all, i'm simply moving a model across the screen.  as a test, i even disabled the moving of the object and the problem still persists.  if i bring up the Editor and just pan around slowly, there are times when the model simply disappears!  I verified that it's not the Visible Distance setting as well.

thanks!

Top 50 Contributor
Posts 93
SunBurn_Community_Licensee

FWIW what I ended up doing is changing the import type of my model to a sgAnimation model and the problem went away.

I know that's a lot of overhead for a simple static yet moving model, but that's what worked for me.

best of luck!

Top 100 Contributor
Posts 31
SunBurn_Community_Licensee

hey there,

i'm not sure how to set the import type of a model to "sgAnimation".  i checked all the properties of my models and the "Content Importer" is currently set to "Autodesk FBX - XNA Framework".

please note that my model is setup as Dynamic and not Static.

thanks.

Top 50 Contributor
Posts 93
SunBurn_Community_Licensee

Sorry I should have been more clear.

In my case (and this may not work for what you're doing) I included the sgMotion library found here:

http://sgmotion.codeplex.com/

and then changed the Content Importer to "sgMotion Model" (i'm not at home so that may not be the exact name). This allowed me to use the sgMotion API to move the animated model around in space. Like I said this may be way overkill for what you are trying, and it certainly doesn't address the underlying problem of simply moving a dynamic object and letting Sunburn render it. . . but it is a workaround that worked for me.

Hope that helps.

~Kris

 

Top 100 Contributor
Posts 31
SunBurn_Community_Licensee

hey Kris,

thanks but i don't think i'll be adding an animation library just to get a model to always render =)

i'm glad this worked for you but i guess i'll have to figure out another solution...

Top 10 Contributor
Posts 4,546
Employee
SunBurn_Studio_Licensee

Hi secluder,

Try updating the ObjectSpaceBoundingSphere's center to see if that helps.  For instance if the mesh is moved {10, 0, 0} units in object space, also add that to the ObjectSpaceBoundingSphere center, then call CalculateBounds() on the object.

I think this could be an issue related to the bounds being in object space (and is resolved in 2.0 with the mesh space bounds).

Let me know if this helps!

Follow me on Twitter – development and personal tweets
Awesome XNA Videos – Lighting, Rendering, and game videos

Top 100 Contributor
Posts 31
SunBurn_Community_Licensee

hey John -

your suggestion worked - thanks for your promptness!

Page 1 of 1 (13 items) | RSS