zxdgsadf

I'm rather new at working in 3d at this level but not exactly new to C# and definitely not new to 3D models... but I usually work with a tool such as Blender, 3DS or Maya.

I have my simple mesh object and it displays just fine. When I use the sample code as a guide, I find that I need to make my own Bounding Box... and I understand the process in theory but applying it to the code is giving me fits.

****************

Issue1:

Using a Bounding Box with the dimentions of triangleBB in the sample causes this:

Nullable<float> result = pickRay.Intersects(triangleBB); // Returns NaN regardless of where clicked.

That's my shorthand... pasted code with what it results in after the comment....

Question... so why is this returning NaN Has anyone else run into this Where did I go wrong

****************

Issue2:

Using the bounding sphere of the mesh like this (look for RED) causes "Nullable<float> result = pickRay.Intersects(triangleBB); " to be equal to 0.0 ..... Code follows:

BoundingSphere triangleBB = new BoundingSphere(); // Declared in the class variables for later use.

protected override void Draw(GameTime gameTime)

{

// OTHER CODE HERE......

foreach (ModelMesh mesh in myModel.Meshes)

{

// OTHER CODE HERE.....

// Draw the mesh using the effects set above

triangleBB = mesh.BoundingSphere; // ******* Set the Bounding Sphere for Ray.intersects() test

mesh.Draw();

}

}

Examination of the sample code shows that it is doing something similar.

Question.... why is this always returning 0.0 And has anyone else chacked the sample code carefully by putting a breakpoint in at :

Nullable<float> result = pickRay.Intersects(triangleBB);

to watch and see exactly what this actually is returing

****************

Issue3:

If I have to create a bounding box manually, how do I find the bounds of the box so that I can set them when creating the box Is the mesh postioned at the min or max, which would make it easy to set that point The entire idea of importing an .x file's mesh and creating a box around it has been driving me crazy for three days because I can't find any sort of mesh.width, mesh.height, mesh.location properties to use in creating the box. Where should I be looking or what's an easier approach

Also, is there a way to set any sort of visible property so that it will draw the bounding box or am I going to have to manually write a page and a half of code just so that I can see where the box really ended up (Yea, it's a bit frustrating at this point but I'm trying to not punch the flat panel...)

****************

Last question (so far, anyway)... someone mentioned in the forums that it's possible to test a mesh rather than a bounding object in DX... is there a simple way to test for it, as in this pseudo code :

Ray.Intersects.Polygon() ; //"Theoretically would return the model.mesh.polygon data for the intersection or null"

Wouldn't it be nice... but I have a bad feeling that it's not going to be that easy. This whole bounding box thing is driving me a little crazy but apparently it's a "must master" technique...

Thanks to all for your help on this.

Scott



Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

zxdgsadf

Ok, finally caught a break on this BUT it lead to another, more sensible, issue...

Imagine your frustration with all this if your Matricies "view" and "proj" were never getting updated. This makes the following lines of code:

Vector3 nearPoint = graphics.GraphicsDevice.Viewport.Unproject(nearsource, proj, view, world);

Vector3 farPoint = graphics.GraphicsDevice.Viewport.Unproject(farsource, proj, view, world);

... each return {X:0 Y:0 Z:0} which, in turn, blows the ability to use Ray.Intersects() because the Ray has a lenght of Zero...

****** which is why it's returning NaN ******

No wonder no one replied to this yet.... the error probably made no sense at all to any of you.

Now, why was it doing that you ask

Because I'm wasn't using drawTriangles() and that's where the matricies are updated with:

effect.Parameters["worldViewProjection"].SetValue(world * view * proj);

However, I'm still fiddling with all this because I'm trying to figure out where it needs to go... which starts an entirely different quest for understanding. Apparently it's not as simple as plugging it into the effects parts of the Draw function, or maybe I have to tweak it a little more to get it to work with my .x file.

But for now, it's midnight and I have work in the AM... maybe some kind soul will point me down the Yellow Brick Road before I get home from work tomorrow (wink).

Thanks for reading these guys... it's getting there. This is far from my first time working my way up the learning curve but I can tell you that it gets more frustrating with age... you don't get used to it. Or, at least, I don't.

Scott





Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

zxdgsadf

Ok, doing better but still not there. I settled out the updating and got the ray to be created but now it simply doesn't seem to intersect anything no matter how large I make this bondingBox. Here's the code... the Ray is being created according to the debugger and I can see all it's data just fine... Ray.Intersects() is simply coming up null all the time.

Any ideas Thanks,

Scott

***************************************************

#region Using Statements

using System;

using System.Collections.Generic;

using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework.Audio;

using Microsoft.Xna.Framework.Content;

using Microsoft.Xna.Framework.Graphics;

using Microsoft.Xna.Framework.Input;

using Microsoft.Xna.Framework.Storage;

using Microsoft.DirectX.Direct3D;

#endregion

namespace MySW

{

public class Game1 : Microsoft.Xna.Framework.Game

{

#region Variables

GraphicsDeviceManager graphics;

ContentManager content;

// Model to render

Model myModel;

//Position of the Model in world spce, and rotation

Vector3 modelPosition = Vector3.Zero;

BoundingBox newBB = new BoundingBox(Vector3.Zero, new Vector3(1000.0f, 1000.0f, 1000.0f));

float modelRotation = 0.0f;

float rotX = MathHelper.ToRadians(90.0f);

// Aspect ratio to use for the projection matrix

float aspectRatio = 640.0f / 480.0f;

// Position of the camera in world space for hte view matrix

Vector3 cameraPosition = new Vector3(0.0f, -0.0f, -2500.0f);

// Matricies for use with Ray

Matrix view;

Matrix proj;

#endregion Variables

 

 

 

public Game1()

{

graphics = new GraphicsDeviceManager(this);

content = new ContentManager(Services);

//mouse is not visible by default

IsMouseVisible = true;

}

 

 

#region Init

/// <summary>

/// Allows the game to perform any initialization it needs to before starting to run.

/// This is where it can query for any required services and load any non-graphic

/// related content. Calling base.Initialize will enumerate through any components

/// and initialize them as well.

/// </summary>

protected override void Initialize()

{

// TODO: Add your initialization logic here

base.Initialize();

}

#endregion Init

 

 

#region Load Graphics

/// <summary>

/// Load your graphics content. If loadAllContent is true, you should

/// load content from both ResourceManagementMode pools. Otherwise, just

/// load ResourceManagementMode.Manual content.

/// </summary>

/// <param name="loadAllContent">Which type of content to load.</param>

protected override void LoadGraphicsContent(bool loadAllContent)

{

if (loadAllContent)

{

myModel = content.Load<Model>("Content\\Models\\chips01");

}

// TODO: Load any ResourceManagementMode.Manual content

}

#endregion Load Graphics

 

 

#region Unload Graphics

/// <summary>

/// Unload your graphics content. If unloadAllContent is true, you should

/// unload content from both ResourceManagementMode pools. Otherwise, just

/// unload ResourceManagementMode.Manual content. Manual content will get

/// Disposed by the GraphicsDevice during a Reset.

/// </summary>

/// <param name="unloadAllContent">Which type of content to unload.</param>

protected override void UnloadGraphicsContent(bool unloadAllContent)

{

if (unloadAllContent == true)

{

content.Unload();

}

}

#endregion Unload Graphics

 

 

#region Update logic

/// <summary>

/// Allows the game to run logic such as updating the world,

/// checking for collisions, gathering input and playing audio.

/// </summary>

/// <param name="gameTime">Provides a snapshot of timing values.</param>

protected override void Update(GameTime gameTime)

{

// Allows the default game to exit on Xbox 360 and Windows

if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)

this.Exit();

// Rotate the model

modelRotation += (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.1f);

// modelPosition.Y += 1;

checkMouseClick();

base.Update(gameTime);

}

#endregion Update logic

 

 

#region Draw

/// <summary>

/// This is called when the game should draw itself.

/// </summary>

/// <param name="gameTime">Provides a snapshot of timing values.</param>

protected override void Draw(GameTime gameTime)

{

graphics.GraphicsDevice.Clear(Color.Teal);

// Copy any parent transforms

Matrix[] transforms = new Matrix[myModel.Bones.Count];

myModel.CopyAbsoluteBoneTransformsTo(transforms);

// Draw the model, a model can have multiple meshes, so loop

foreach (ModelMesh mesh in myModel.Meshes)

{

// This is where the mesh oritnetation is set, as well as our camera and projection

foreach (BasicEffect effect in mesh.Effects)

{

effect.EnableDefaultLighting();

effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationX(rotX) * Matrix.CreateTranslation(modelPosition);

effect.View = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);

effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 5.0f, 10000.0f);

 

// Set up view matrix and projection matrix.

view = Matrix.CreateLookAt(cameraPosition, modelPosition, Vector3.Up);

proj = effect.Projection;

}

// Draw the mesh using the effects set above

mesh.Draw();

}

}

#endregion Draw

 

#region checkMouseClick

void checkMouseClick()

{

MouseState mouseState = Mouse.GetState();

if (mouseState.LeftButton == ButtonState.Pressed)

{

Ray pickRay = GetPickRay();

Nullable<float> result = pickRay.Intersects(newBB); // ****Always returns NULL ******

if (result.HasValue == true)

{

//intersects the triangle

// Add code to interact with the selected object.

rotX += MathHelper.ToRadians(1.0f);

}

}

}

#endregion checkMouseClick

 

 

#region GetPickRay()

Ray GetPickRay()

{

MouseState mouseState = Mouse.GetState();

int mouseX = mouseState.X;

int mouseY = mouseState.Y;

Vector3 nearsource = new Vector3((float)mouseX, (float)mouseY, -5000f);

Vector3 farsource = new Vector3((float)mouseX, (float)mouseY, 10000f);

Matrix world = Matrix.CreateTranslation(0, 0, 0);

Vector3 nearPoint = graphics.GraphicsDevice.Viewport.Unproject(nearsource, proj, view, world);

Vector3 farPoint = graphics.GraphicsDevice.Viewport.Unproject(farsource, proj, view, world);

// Create a ray from the near clip plane to the far clip plane.

Vector3 direction = farPoint - nearPoint;

direction.Normalize();

Ray pickRay = new Ray(nearPoint, direction);

return pickRay;

}

#endregion GetPickRay()

}

}





Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

Pocketmnky

I'm curious as to why you are using

Vector3 nearsoruce = new Vector3((float)mouseX, (float)mouseY, -5000f);
Vector3 farsoruce = new Vector3((float)mouseX, (float)mouseY, 10000);

When the example in the XNA documentation says to set it to

Vector3 nearsoruce = new Vector3((float)mouseX, (float)mouseY, 0f);
Vector3 farsoruce = new Vector3((float)mouseX, (float)mouseY, 1);

Otherwise everything looks about the same as the example's setup.






Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

zxdgsadf

The last argument is the z depth and I needed more depth because the sample was putting a box around a much smaller object. My model is about 800.0f wide and deep, with about 75.0f of height.

I've tried all sorts of box dimentions and can't make a difference. What gets me is even if I use a box of:

Vector3.Zero, new Vector3(1000.0f, 1000.0f, 1.0f)

I still get a null return in all 4 quadrants of the frustum. With those dimentions, shouldn't the bounding box fill 1/4 of the frustum if the frustum is aimed at Vercto3.Zero

Dunno, I've had a long one at the day job and will be relaxing a bit tonight. the issue witht he code, at present, is that it returns null no matter what size box I use... and yes, I've made sure that the camera location is in front of the box edge. Though, at one point, I had thought that this might have been the issue. It wasn't.

Thanks for looking, any other tips or thoughts are certainly appreciated.

Scott





Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

killfr0g

I just had some success with something like this.. basically I create the bounding box for my mesh with the method described here: http://andyq.no-ip.com/blog/ p=16

Then I used the example of "clicking 3D objects" in the XNA Help, and it works perfectly for me. My meshes are cubes so it's a bit simpler, don't know about yours.






Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

dczraptor

I don't know if this will help, but this little piece of code was the gem that made my 3d object selection finally work. I think the pickRay direction was some large value, and it would essentially skip over my object. Because of this, pickRay.Intersects() always returned false. However, once i added the normalize function, my game finally worked.

Ray pickRay = new Ray(pickRay.Position, Vector3.Normalize(pickRay.Direction));






Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

zxdgsadf

 dczraptor wrote:

I don't know if this will help, but this little piece of code was the gem that made my 3d object selection finally work. I think the pickRay direction was some large value, and it would essentially skip over my object. Because of this, pickRay.Intersects() always returned false. However, once i added the normalize function, my game finally worked.

Ray pickRay = new Ray(pickRay.Position, Vector3.Normalize(pickRay.Direction));

I think I  had this covered already by using Normalize(direction); but I changed the syntax to your style just in case. Unfortunately it wasn't that easy to fix... thanks for the thought.

 killfr0g wrote:

I just had some success with something like this.. basically I create the bounding box for my mesh with the method described here: http://andyq.no-ip.com/blog/ p=16

Then I used the example of "clicking 3D objects" in the XNA Help, and it works perfectly for me. My meshes are cubes so it's a bit simpler, don't know about yours.

Thanks for the bb code.. though it made life a LOT easier when dealing with the whole bb issue, the result is still returning null. Just to be sure, I called for the bb this way:

*******

Ray pickRay = GetPickRay();

bb = (BoundingBox)myModel.Tag; // NEW CODE HERE

Nullable<float> result = pickRay.Intersects(bb);

if (result.HasValue == true)

*******

So, looking carefully at each part of the puzzle:

1) This is the debugger's info on the bb generated... I got this while stepping through and copied the bb info while " if (result.HasValue == true) " was highlited:

+  bb {Min:{X:-1 Y:-1 Z:-1} Max:{X:1 Y:1 Z:1}} Microsoft.Xna.Framework.BoundingBox

2) Ok.... so that's the bb. Here's the camera postion code:

Vector3 cameraPosition = new Vector3(0.0f, -0.0f, -100.0f);

3) Next is the view and proj matricies withing the over-ridden Draw():

**************

// Draw the model, a model can have multiple meshes, so loop

foreach (ModelMesh mesh in myModel.Meshes)

{

// This is where the mesh oritnetation is set, as well as our camera and projection

foreach (BasicEffect effect in mesh.Effects)

{

effect.EnableDefaultLighting();

effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationX(rotX) * Matrix.CreateTranslation(modelPosition);

effect.View = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);

effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 5.0f, 10000.0f);

 

// Set up view matrix and projection matrix.

view = Matrix.CreateLookAt(cameraPosition, modelPosition, Vector3.Up);

proj = effect.Projection;

}

// Draw the mesh using the effects set above

mesh.Draw();

}

**************

 

4) Here's all of GetPickRay():

**************

Ray GetPickRay()

{

MouseState mouseState = Mouse.GetState();

int mouseX = mouseState.X;

int mouseY = mouseState.Y;

Vector3 nearsource = new Vector3((float)mouseX, (float)mouseY, -50.0f);

Vector3 farsource = new Vector3((float)mouseX, (float)mouseY, 10.0f);

Matrix world = Matrix.CreateTranslation(0, 0, 0);

Vector3 nearPoint = graphics.GraphicsDevice.Viewport.Unproject(nearsource, proj, view, world);

Vector3 farPoint = graphics.GraphicsDevice.Viewport.Unproject(farsource, proj, view, world);

// Create a ray from the near clip plane to the far clip plane.

Vector3 direction = farPoint - nearPoint;

Ray pickRay = new Ray(nearPoint, Vector3.Normalize(direction)); // dczraptor's addition

 return pickRay;

}

5) And finally, the part that keeps giving me indigestion...

Nullable<float> result = pickRay.Intersects(bb);

Which returns this in the degugger:

  result null float

Lastly, just for giggles, the pickRay data:

-  pickRay {Position:{X:-0.000135427 Y:0 Z:-99.90192} Direction:{X:0.001380689 Y:0 Z:-0.9999991}} Microsoft.Xna.Framework.Ray

Note that this data is translated into a different matrix than the bb data is given in. Checking the near and far source definitions show that a small bb such as the one centered on 000 here should be well within the ray's middle area.

****************************************************

It has to be something simple. Could one of you please make the "Hello World" version of this, as I've tried to do here... a 1x1x1 cube at 000 with a working pickRay that returns a non-null value when tested and verified in the debugger Maybe I could take that and compare it to this attempt at the same thing and see what the differences are. It's got to be something simple or something stupid at this point.

Thanks for the help!

Scott






Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

dczraptor

zxdgsadf wrote:

I think I had this covered already by using Normalize(direction); but I changed the syntax to your style just in case. Unfortunately it wasn't that easy to fix... thanks for the thought.

Sorry, I hadn't read the entire code segment at the time. However, after going through your pick function, I noticed a couple differences from mine. First, you didn't convert your mouse coords to screen space, which may explain quite a bit, and second, I seem to have an inverse matrix in there. However, I am not a math genious; I merely followed the step off of the msdn tutorial, so I can't tell you exactly what to fix, although you may know more than me. I hope this helps; my version of GetPickRay() is as follows:

public Ray GetPickRay()

{

MouseState mouseState = Mouse.GetState();

int mouseX = mouseState.X;

int mouseY = mouseState.Y;

// Determine the mouse position in screen space.

double screenSpaceX = ((float)mouseX / (width / 2) - 1.0f) * aspectRatio;

double screenSpaceY = (1.0f - (float)mouseY / (height / 2));

// Calculating the tangent in this method is for clarity. Normally, the

// tangent would be calculated only once at start up and recalculated

// if the camera field of view changes.

double viewRatio = Math.Tan(fov / 2);

screenSpaceX = screenSpaceX * viewRatio;

screenSpaceY = screenSpaceY * viewRatio;

// Determine the mouse position in camera space on the near clip plane.

Vector3 cameraSpaceNear = new Vector3((float)(screenSpaceX * nearClip), (float)(screenSpaceY * nearClip), (float)(-nearClip));

// Deetermine the mouse position in camera space on the far clip plane.

Vector3 cameraSpaceFar = new Vector3((float)(screenSpaceX * farClip), (float)(screenSpaceY * farClip), (float)(-farClip));

// Use the inverted view matrix to transform from camera space to world space.

Matrix invView = Matrix.Invert(camera.View);

Vector3 worldSpaceNear = Vector3.Transform(cameraSpaceNear, invView);

Vector3 worldSpaceFar = Vector3.Transform(cameraSpaceFar, invView);

// Create a ray from the near clip plane to the far clip plane.

Ray pickRay = new Ray(worldSpaceNear, worldSpaceFar - worldSpaceNear);

return new Ray(pickRay.Position, Vector3.Normalize(pickRay.Direction));

}






Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

zxdgsadf

Thanks, this may be something good here. However, it's 04:15 in the morning ( I went to bed early after a long day and woke up in the night). I need to get back to sleep for the moment but I'll run through this within the next 24 hours.

Scott





Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

zxdgsadf

***Please excusae typos... I jsut got called into work and have to rush****

 

It took about 20 minutes to adapt your variable terms to mine but now it always returns a number... but it's looking better because the number is always different. I'm wondering if I misunderstood some of your assignmnets and so set them to the wrong values Not sure...

The bb is 2x2x2 centered at 000 and the camera is at -100 Z so I'd tink that when I click on the far corner of the 640x480 frustum that it would miss and return null. Instead, the right corners are returning 6.xxxxx and the left forners are returning 2.xxxx (xx being various decimal nubers).

This is my adaptation... the only thing you may not recognize is the use of proj and where fov is set which are set here (gotta fix the duplication):

*****

effect.View = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);

effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f), aspectRatio, 5.0f, 10000.0f);

fov = effect.Projection;

// Set up view matrix and projection matrix.

view = Matrix.CreateLookAt(cameraPosition, modelPosition, Vector3.Up);

proj = effect.Projection;

*****

Here is the current Ray (yours with adaptations):

*****

public Ray GetPickRay()

{

MouseState mouseState = Mouse.GetState();

int mouseX = mouseState.X;

int mouseY = mouseState.Y;

float height = 640.0f;

float width = 480.0f;

// Determine the mouse position in screen space.

double screenSpaceX = ((float)mouseX / (width / 2) - 1.0f) * aspectRatio;

double screenSpaceY = (1.0f - (float)mouseY / (height / 2));

// Calculating the tangent in this method is for clarity. Normally, the

// tangent would be calculated only once at start up and recalculated

// if the camera field of view changes.

double viewRatio = Math.Tan(MathHelper.ToRadians(45.0f) / 2);

screenSpaceX = screenSpaceX * viewRatio;

screenSpaceY = screenSpaceY * viewRatio;

// Determine the mouse position in camera space on the near clip plane.

float nearClip = -10.0f;

float farClip = 50.0f;

Vector3 cameraSpaceNear = new Vector3((float)(screenSpaceX * nearClip), (float)(screenSpaceY * nearClip), (float)(-nearClip));

// Deetermine the mouse position in camera space on the far clip plane.

Vector3 cameraSpaceFar = new Vector3((float)(screenSpaceX * farClip), (float)(screenSpaceY * farClip), (float)(-farClip));

// Use the inverted view matrix to transform from camera space to world space.

Matrix invView = Matrix.Invert(proj);

Vector3 worldSpaceNear = Vector3.Transform(cameraSpaceNear, invView);

Vector3 worldSpaceFar = Vector3.Transform(cameraSpaceFar, invView);

// Create a ray from the near clip plane to the far clip plane.

Ray pickRay = new Ray(worldSpaceNear, worldSpaceFar - worldSpaceNear);

return new Ray(pickRay.Position, Vector3.Normalize(pickRay.Direction));

}

*****

Thanks for helping with this!

Scott





Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

dczraptor

I noticed that i used the line: Matrix invView = Matrix.Invert(view);

and you have Matrix invView = Matrix.Invert(proj);

The view and projection matrices are two separate things. Try it with the view matrix instead.






Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

zxdgsadf

I knew that the issue had to be in the Ray code but I got so turned around with all this that I decided to go back and study the sample Ray intently to make sure that I understood every little nuance of it. To that end, I copied ONLY the Ray GetPickRay() part of the sample and inserted it into my code. I then made sure that it was plugged in (all the variables were properly created, etc.) and then hit F5 to see which problem it would show this time...

The silly thing worked immediately... and perfectly.

So, I watched some more of the Seattle / Dallas game....

I've since gone through my code, cleaning out all excess, ensuring that it still works and commenting it to death so that anyone can follow it's every move. I'll post it as another topic, something along the lines of "How To: Get your .x model to work with clicking on a 3D object..."

For now, I'm going back to the game. Look for the post within the next few hours.

Scott





Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

zxdgsadf

I'm going to hold off on that post for just a little bit because a larger model gets the same small bb as the small cube... and yes, I set the content processor for the larger model. As long as I click on the tiny little bb, it works... but in order for this to be a real, workable and complete solution the bb has to be able to automatically scale itself to the model or meshes of the model to which it belongs.

Tomorrow's another day...

Scott





Re: XNA Game Studio Express Problems with: Detecting if a user clicked on a 3D object

zxdgsadf

Problems with the bb generation for other models was traced to the fact that the box is generated from the vertice list, not from the final build of the model. This means that if there is any sort of scaling in the transformation matrix, then the visual model will be a completely different size than the generated bb which does not get scaled.

For those who know modeling the answer is simple... clear your size and rotations before saving. Those are the blender terms. For other modeling programs I think the idea is that you have to set your model so that it's baseline size and orientation are the same as the finalized size and orientation. You export an unscaled and unrotated model and then apply those translations in your application.

Scott