Binding BoundingSpheres to a world matrix in XNA
Posted
by
NDraskovic
on Game Development
See other posts from Game Development
or by NDraskovic
Published on 2012-07-11T13:06:45Z
Indexed on
2012/07/11
15:24 UTC
Read the original article
Hit count: 235
collision-detection
|xna-4.0
I made a program that loads the locations of items on the scene from a file like this:
using (StreamReader sr = new StreamReader(OpenFileDialog1.FileName))
{
String line;
while ((line = sr.ReadLine()) != null)
{
red = line.Split(',');
model = row[0];
x = row[1];
y = row[2];
z = row[3];
elements.Add(Convert.ToInt32(model));
data.Add(new Vector3(Convert.ToSingle(x), Convert.ToSingle(y), Convert.ToSingle(z)));
sfepheres.Add(new BoundingSphere(new Vector3(Convert.ToSingle(x), Convert.ToSingle(y), Convert.ToSingle(z)), 1f));
}
I also have a list of BoundingSpheres (called spheres) that adds a new bounding sphere for each line from the file. In this program I have one item (a simple box) that moves (it has its world matrix called matrixBox), and other items are static entire time (there is a world matrix that holds those elements called simply world). The problem i that when I move the box, bounding spheres move with it. So how can I bind all BoundingSpheres (except the one corresponding to the box) to the static world matrix so that they stay in their place when the box moves?
© Game Development or respective owner