How to retrieve the position of a ModelMesh whose position was set in blender?

Hi there, I have a tree that I have created in blender:

Where each one of the “Bushes” of sorts is it’s own ModelMesh. I load this into my game and render it using this to apply the positions and scales:

        Matrix[] modelTransforms = new Matrix[TreeModel.Bones.Count];

        foreach (var Mesh in TreeModel.Meshes)
            foreach (BasicEffect effect in Mesh.Effects)
                effect.AmbientLightColor = new Vector3(0.35f);

                effect.View = Cam.viewMatrix;
                effect.Projection = RotatingCam.projectionMatrix;

                effect.World = modelTransforms[Mesh.ParentBone.Index];

It renders just fine, and now I am using a separate render target and color IDs to get which “Bush” the mouse is over.
What I need is a way to get the Position of the bush in Coordinates so that I can move my camera over it when it’s clicked.
All help is greatly appreciated!

Mesh.BoundingSphere ???

I tried that, but it didn’t work. I eventually just reset the origins in blender to the geometry. Thank you!

Vector3.Transform(Mesh.BoundingSphere.Center, modelTransforms[Mesh.ParentBone.Index])

I’ve got it working now. I just have to figure out the trig :grin:

Just another quick question, when I run my program, I get an increasing amount of memory usage. When I look at the memory usage and take snapshots, I see that it’s using thousands of WeakReferences of things like Spritebatch, VertexBuffer, ContentManager etc. Is anyone else experiencing this? Also should I open a new thread for this?

Refer to this for decreasing memory usage in this context. Are you calling CopyAbsoluteBoneTransformsTo every frame?

I made a wrapper for stringbuilder to prevent garbage from text.
It’s not 100% perfect but it will do the job and despite its size its fast.

If you do use the above stringbuilder when you add numbers just append them by themselves and don’t ToString them first you can then clear and re-add as much as you want with no garbage.,

it’s far more complete then the given code in the link on that page

Hey there, in my camera class, I define my viewMatrix like so:

public static Matrix viewMatrix
        return Matrix.CreateLookAt(Position, Target,

Since my target and position changes quite frequently, how can I make this more efficient? I don’t know how view matrices work in this aspect.

I followed your tips and read the thread and I decreased the memory usage from 54mb @ startup -> 105mb @ 1min to 53mb constantly.

Don’t worry about this. It’s relatively cheap and doesn’t allocate any memory (because matrix is a struct).