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];
TreeModel.CopyAbsoluteBoneTransformsTo(modelTransforms);
foreach (var Mesh in TreeModel.Meshes)
{
foreach (BasicEffect effect in Mesh.Effects)
{
effect.EnableDefaultLighting();
effect.AmbientLightColor = new Vector3(0.35f);
effect.View = Cam.viewMatrix;
effect.Projection = RotatingCam.projectionMatrix;
effect.World = modelTransforms[Mesh.ParentBone.Index];
}
Mesh.Draw();
}
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!
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?
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.,