Possible solution to orbit (untested)
I'll test this after i make a test frame for it. Though i think this might be it as long as i got the ideal down. After i tried to go to sleep my brain broke down the changes pre rotation. If Y axis changes the XZ distance change. If Z Axis changes YX distance changes. If X Axis changes YZ axis changes. After figuring that out now i can use sin cos to get the radian angles and times that by radius to get the delta change in position.... or at least that is what i think. Testing will prove me right or wrong.
This commit is contained in:
parent
10788a58b2
commit
8724a1023d
1 changed files with 25 additions and 9 deletions
|
@ -107,7 +107,12 @@ public class NetworkOrbit
|
|||
IOrbitingEntity entity = it.next().getKey();
|
||||
if (entity instanceof Entity)
|
||||
{
|
||||
width += ((Entity) entity).width;
|
||||
width += ((Entity) entity).width > ((Entity) entity).height ? ((Entity) entity).width : ((Entity) entity).height;
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO get size threw the interface or detect other possible orbit objects
|
||||
width += 1;
|
||||
}
|
||||
}
|
||||
width = width / this.getOrbitMemebers().size();
|
||||
|
@ -124,17 +129,28 @@ public class NetworkOrbit
|
|||
*
|
||||
* http://en.wikipedia.org/wiki/Spherical_coordinates
|
||||
*/
|
||||
public Vector3 getOrbitOffset(int pos)
|
||||
public Vector3 getOrbitOffset(Entity entity, int pos)
|
||||
{
|
||||
double minRadius = this.getMinRadius();
|
||||
if (this.orbitRadius < minRadius)
|
||||
double r = this.getMinRadius();
|
||||
if (this.orbitRadius < r)
|
||||
{
|
||||
this.orbitRadius = minRadius;
|
||||
this.orbitRadius = r;
|
||||
}
|
||||
double spacing = this.orbitRadius / this.getOrbitMemebers().size();
|
||||
else
|
||||
{
|
||||
r = this.orbitRadius;
|
||||
}
|
||||
if (entity instanceof IOrbitingEntity && this.getOrbitMemebers().containsKey(entity))
|
||||
{
|
||||
r += this.getOrbitMemebers().get(entity);
|
||||
}
|
||||
double spacing = r / this.getOrbitMemebers().size();
|
||||
Vector3 t = this.getRotation();
|
||||
|
||||
double inclination = 0;
|
||||
double azimuth = (spacing * pos) + this.getRotation().y;
|
||||
return LinearAlg.sphereAnglesToVec(this.orbitRadius, inclination, azimuth);
|
||||
double deltaX = (r * Math.cos(t.y + spacing)) + (r * Math.sin(t.z));
|
||||
double deltaY = (r * Math.sin(t.x)) + (r * Math.sin(t.z));
|
||||
double deltaZ = (r * Math.sin(t.y + spacing)) + (r * Math.cos(t.x));
|
||||
|
||||
return new Vector3(deltaX, deltaY, deltaZ);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue