bug fixes to rotation
parent
0f3b9ef3dc
commit
7d6417d5fd
|
@ -146,19 +146,14 @@ namespace Flocking
|
|||
|
||||
protected void SimChatSent (Object x, OSChatMessage msg)
|
||||
{
|
||||
m_log.Info ("got msg");
|
||||
if (m_scene.ConsoleScene () != m_scene)
|
||||
if (m_scene.ConsoleScene () != m_scene || msg.Channel != m_chatChannel)
|
||||
return; // not for us
|
||||
|
||||
m_log.Info ("got channel" + msg.Channel);
|
||||
if (msg.Channel != m_chatChannel)
|
||||
return; // not for us
|
||||
|
||||
// try and parse a valid cmd from this msg
|
||||
string cmd = msg.Message.ToLower ();
|
||||
m_log.Info ("got cmd " + cmd);
|
||||
|
||||
//stick ui in the args so we know to respond in world
|
||||
//bit of a hack - but lets us us CommandDelegate inWorld
|
||||
string[] args = (cmd + " <ui>").Split (" ".ToCharArray ());
|
||||
|
||||
if (cmd.StartsWith ("stop")) {
|
||||
|
@ -257,12 +252,9 @@ namespace Flocking
|
|||
{
|
||||
if (ShouldHandleCmd ()) {
|
||||
lock( m_sync ) {
|
||||
//m_enabled = false;
|
||||
//m_log.Info( args );
|
||||
int newSize = Convert.ToInt32(args[1]);
|
||||
m_model.Size = newSize;
|
||||
m_view.Clear();
|
||||
//m_enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +270,6 @@ namespace Flocking
|
|||
public void HandleSetPrimCmd (string module, string[] args)
|
||||
{
|
||||
if (ShouldHandleCmd ()) {
|
||||
//m_log.Info ("set prim not implemented yet");
|
||||
string primName = args[1];
|
||||
lock(m_sync) {
|
||||
m_view.BoidPrim = primName;
|
||||
|
|
|
@ -34,8 +34,6 @@ namespace Flocking
|
|||
{
|
||||
public class FlockingView
|
||||
{
|
||||
private const float DEG_TO_RAD = 0.01745329238f;
|
||||
|
||||
private Scene m_scene;
|
||||
private UUID m_owner;
|
||||
private String m_boidPrim;
|
||||
|
@ -89,27 +87,19 @@ namespace Flocking
|
|||
}
|
||||
|
||||
Quaternion rotation = CalcRotationToEndpoint (sog, sog.AbsolutePosition, boid.Location);
|
||||
sog.UpdateGroupPosition(boid.Location);
|
||||
sog.UpdateGroupRotationR (rotation);
|
||||
sog.UpdateGroupRotationPR( boid.Location, rotation);
|
||||
}
|
||||
|
||||
private static Quaternion CalcRotationToEndpoint (SceneObjectGroup copy, Vector3 sv, Vector3 ev)
|
||||
{
|
||||
//llSetRot(llRotBetween(<1,0,0>,llVecNorm(targetPosition - llGetPos())));
|
||||
// boid wil fly x forwards and Z up
|
||||
|
||||
Vector3 currDirVec = Vector3.UnitX;
|
||||
float angle = 0f;
|
||||
|
||||
copy.GroupRotation.GetAxisAngle (out currDirVec, out angle);
|
||||
currDirVec.Normalize ();
|
||||
|
||||
|
||||
Vector3 desiredDirVec = Vector3.Subtract (ev, sv);
|
||||
desiredDirVec.Normalize ();
|
||||
|
||||
Quaternion rot = Vector3.RotationBetween (currDirVec, desiredDirVec);
|
||||
|
||||
//Quaternion x90 = Quaternion.CreateFromEulers (90f * DEG_TO_RAD, 0f, 0f);
|
||||
//rot = rot * x90;
|
||||
|
||||
return rot;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue