Teravus,<br><br>Awesome!<br>I'll play with this over the weekend.<br><br>Thanks.<br><br><div class="gmail_quote">On Thu, Oct 28, 2010 at 9:54 AM, Teravus Ovares <span dir="ltr"><<a href="mailto:teravus@gmail.com">teravus@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">You need to pump avatar movement updates for the autopilot code to work.<br><br>Even if there are no movement flags, calling ScenePresence.HandleAgentUpdate with a proper AgentUpdateArgs will 'move' the avatar a step towards the target of the autopilot.<br>
<br>The following code is for an older version of OpenSimulator but it might work with a few modifications on the current version.<br>(AddRegion is INonSharedRegionModule.AddRegion)<br><br>private int m_agentupdatepump = 5;<br>
private Scene m_scene;<br>private List<ScenePresence> m_activeCharactersSP;<br>private List<Character> m_activeCharacters;<br><br>private Quaternion fourtyFiveDegreeAngle = new Quaternion(0,0,-0.70711f,0.70711f);<br>
<br><br>public virtual void AddRegion(Scene scene)<br>{<br> m_scene = scene;<br> m_scene.EventManager.OnFrame += EventManager_OnFrame;<br>}<br><br> void EventManager_OnFrame()<br>{<br> m_frame++;<br><br> if ((m_frame % m_agentupdatepump) == 0)<br>
{<br> PumpAgentUpdate();<br> }<br><br> if (m_frame >= (int.MaxValue - 1))<br> {<br> m_frame = 0;<br> }<br> }<br><br>void PumpAgentUpdate()<br>{<br> lock (m_activeCharacters)<br>
{<br> foreach (Character c in m_activeCharacters)<br> {<br> ScenePresence cSP = m_scene.GetScenePresence(c.AgentId);<br> PumpAgentUpdate(c, cSP);<br> }<br> }<br>
}<br>
<br>void PumpAgentUpdate(Character pC, ScenePresence pSP)<br>{<br> AgentUpdateArgs updateargs = new AgentUpdateArgs();<br> updateargs.AgentID = pC.AgentId;<br><br> updateargs.BodyRotation = Vector3.RotationBetween(Vector3.UnitX, Vector3.Normalize(pC.m_lastTarget - pSP.AbsolutePosition));<br>
<br> if (pC.ClientSideOrientation == fourtyFiveDegreeAngle)<br> pC.ClientSideOrientation = Quaternion.Identity;<br><br> updateargs.CameraAtAxis = Vector3.Zero;<br> updateargs.CameraCenter = new Vector3(pSP.AbsolutePosition - (new Vector3(0,0,1) * updateargs.BodyRotation));<br>
updateargs.CameraLeftAxis = Vector3.Zero;<br> updateargs.CameraUpAxis = Vector3.Zero;<br> updateargs.ControlFlags = uint.MinValue;// +(uint)OpenMetaverse.AgentManager.ControlFlags.AGENT_CONTROL_FLY;<br> updateargs.Far = 128f;<br>
updateargs.Flags = byte.MinValue;<br> updateargs.HeadRotation = Quaternion.Identity;<br> updateargs.SessionID = pC.SessionId;<br> updateargs.State = byte.MinValue;<br> <br> pSP.HandleAgentUpdate(pC,updateargs);<br>
}<br><br><br>Note that the Character class had NPC related stuff in it like 'last target'. We need that information to send a proper BodyRotation in the AgentUpdateArgs<br>updateargs.BodyRotation = Vector3.RotationBetween(Vector3.UnitX, Vector3.Normalize(Character.m_lastTarget - ScenePresence.AbsolutePosition));<br>
<br>Hopefully, I've given you enough code to get started.<br><br><br>Teravus<br><br><div class="gmail_quote"><div><div></div><div class="h5">On Wed, Oct 27, 2010 at 4:47 PM, bodzette Coignet <span dir="ltr"><<a href="mailto:bodzettecoignet@gmail.com" target="_blank">bodzettecoignet@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div></div><div class="h5">After some hair pulling and running into someone with complementary skills I've made some progress: <br>
I've managed to get a server side NPC to do the following:<br>Rezz, Say something, Play an Animation and Delete itself.<br>
<br>Unfortunately at the moment I can't get it to move and am currently investigating why not. Right now my understanding of things is somewhat limited so forgive me if my questions sound stupid to those in the know:<br>
<br>A couple questions:<br><br>Given that the NPC code appears to use a bunch of different autopilot code, I'm guessing that this is specific to NPCs and is not the way regular avatars move. It appears to be broken somehow, because the code is called but the NPC doesn't move. What is the difference between movement for a regular avatar and an NPC? It's my position that there really shouldn't be one, but could someone fill me in?<br>
<br>What is the code that moves a standard (i.e. non-NPC avatar) is it Region.Framework.Scenes.ScenePresence.DoMoveToPosition or is it somewhere else?<br><br>What is a ScenePresence? Is it that portion of a scene corresponding to a single avatar? If so is there any reason why an NPC avatar should exhibit different behavior here than a regular avatar?<br>
<br>Can anyone give a program flow of how a regular avatar moves?<br>My guess is it's something like this:<br> Intecerpt Arrow Key or Movement Control Arrow -> <br>Pass avatar UUID and force and vector to server -> <br>
server finds avatar in scene (looping through scene dictionary of avatars till it identifies the right one?) -> <br>server applies force and vector to appropriate avatar in dictionary -><br>avatar enters, does and completes movement -><br>
server updates entire scene x times per second until avatar movement is completed <br><br>Anyone verify the flow?<br><br>Thanks in advance.<br>
<br></div></div>_______________________________________________<br>
Opensim-users mailing list<br>
<a href="mailto:Opensim-users@lists.berlios.de" target="_blank">Opensim-users@lists.berlios.de</a><br>
<a href="https://lists.berlios.de/mailman/listinfo/opensim-users" target="_blank">https://lists.berlios.de/mailman/listinfo/opensim-users</a><br>
<br></blockquote></div><br>
<br>_______________________________________________<br>
Opensim-users mailing list<br>
<a href="mailto:Opensim-users@lists.berlios.de">Opensim-users@lists.berlios.de</a><br>
<a href="https://lists.berlios.de/mailman/listinfo/opensim-users" target="_blank">https://lists.berlios.de/mailman/listinfo/opensim-users</a><br>
<br></blockquote></div><br>