[Opensim-users] Autopilot and osNPC bugs

Teravus Ovares teravus at gmail.com
Wed Jul 13 02:29:26 UTC 2011


A while a go, I wrote something that took advantage of exactly what I'm
talking about..

I added my own character class called, 'Character',  to manage some internal
data like way-points...   but that's not required.

Should be something like:

public class Character : IClientAPI
>>        internal void AutoPilot(Vector3 vector3, uint localid)
>>        {
>>            UpdateVector ap = OnAutoPilotGo;
>>            if (ap != null)
>>                ap(localid, vector3, this);
>>        }
>>
> In the script engine there would be a timer or some other time based
trigger..   like the EventManager OnFrame event.

private Quaternion fourtyFiveDegreeAngle = new
> Quaternion(0,0,-0.70711f,0.70711f);
> void EventManager_OnFrame()
>        {
>            m_frame++;
>            if ((m_frame % m_agentupdatepump) == 0)
>            {
>                PumpAgentUpdate();
>            }
>            if (m_frame >= (int.MaxValue - 1))
>            {
>                m_frame = 0;
>            }
>        }
> void PumpAgentUpdate()
>        {
>            foreach (Character c in ActiveCharacters)
>           {
>           ScenePresence cSP = m_scene.GetScenePresence(c.AgentId);
>           PumpAgentUpdate(c, cSP);
>           }
>        }
>
> // NOTE HERE how we're doing a bit of math to figure out our appropriate
> rotation! to feed back to the agent update method
> void PumpAgentUpdate(Character pC, ScenePresence pSP)
>        {
>            AgentUpdateArgs updateargs = new AgentUpdateArgs();
>            updateargs.AgentID = pC.AgentId;
>            updateargs.BodyRotation = Vector3.RotationBetween(Vector3.UnitX,
> Vector3.Normalize(pC.m_lastTarget - pSP.AbsolutePosition));
>            if (pC.ClientSideOrientation == fourtyFiveDegreeAngle)
>                pC.ClientSideOrientation = Quaternion.Identity;
>            updateargs.CameraAtAxis = Vector3.Zero;
>            updateargs.CameraCenter = new Vector3(pSP.AbsolutePosition  -
> (new Vector3(0,0,1) * updateargs.BodyRotation));
>            updateargs.CameraLeftAxis = Vector3.Zero;
>            updateargs.CameraUpAxis = Vector3.Zero;
>            updateargs.ControlFlags = uint.MinValue;//
> +(uint)OpenMetaverse.AgentManager.ControlFlags.AGENT_CONTROL_FLY;
>            updateargs.Far = 128f;
>            updateargs.Flags = byte.MinValue;
>            updateargs.HeadRotation = Quaternion.Identity;
>            updateargs.SessionID = pC.SessionId;
>            updateargs.State = byte.MinValue;
>
>            pSP.HandleAgentUpdate(pC,updateargs);
>        }



Note that last method call.   That's probably the minimum AgentUpdateArgs
that you can construct.

Anyway, if we're using the NPC character in the script engine, then this
type of stuff should probably be handled in the Async area of the Script
engine.  Hopefully this helps.

-Teravus

On Tue, Jul 12, 2011 at 10:02 PM, Teravus Ovares <teravus at gmail.com> wrote:
> In order to fix the autopilot, the script engine needs to feed the
> ScenePresence minimal position/rotation updates.   There's an event
> handler in ScenePresence that handles AvatarUpdates and is the proper
> method for the script engine to call.   Last I checked, the server
> side autopilot code is IN that event handler, so, unless something has
> significantly changed, it just needs to be wired up.
>
> Teravus
>
> On Tue, Jul 12, 2011 at 8:55 PM, Justin Clark-Casey
> <jjustincc at googlemail.com> wrote:
>> On 12/07/11 14:53, David Burden wrote:
>>>
>>>  From my experience and what I've read elsewhere both the LibOMV
Autopilot
>>> function in OpenSim and the osNPC
>>> functionality are broken in the latest versions of OpenSim. Since one of
>>> my favourite uses for virtual worlds is playing
>>> around autonomous avatars this is a real pain. Has anyone got any idea
of
>>> the amount of effort needed to fix one or both
>>> of these, as if it's reasonable and practical we might be able to find
>>> some resource to help fix them.
>>
>> Hi David.  As it happens, I've started to look at osNPC*() functions in
the
>> last couple of weeks (e.g. commits 22f25fa, ed12e38) with a view to
>> eventually restoring the original functionality and buttressing it with
some
>> automated regression tests.  I would also love to see the code in a state
>> where NPCs would work without a client object attached.
>>
>> At the moment in git master, say, create and delete work, though
appearance
>> and autopilot are broken.  For an experienced OpenSim developer fixing
>> appearance shouldn't be too hard - I think it's a case of digging around
to
>> find out why the copied avatar baked textures aren't being used properly
on
>> the NPC.
>>
>> Fixing autopilot is more difficult.  In principle, it should use much the
>> same code paths as sit and "go here" on version 1 viewers, though "go
here"
>> itself doesn't appear to be working consistently.  It's probably a case
of
>> fixing go and then reusing the code for npc autopilot.  This would be
>> somewhat involved, more so than fixing appearance.  Fixing autopilot of
NPCs
>> should also fix it for client-side bots.
>>
>> Any resource to help fix these would be very welcome.  I have to confess,
>> they are low down on my priority list right now.
>>
>> --
>> Justin Clark-Casey (justincc)
>> http://justincc.org/blog
>> http://twitter.com/justincc
>> _______________________________________________
>> Opensim-users mailing list
>> Opensim-users at lists.berlios.de
>> https://lists.berlios.de/mailman/listinfo/opensim-users
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://opensimulator.org/pipermail/opensim-users/attachments/20110712/538c2f9f/attachment.html>


More information about the Opensim-users mailing list