Thursday 24 March 2011

OK - Partial Success!!!

K so I've been hacking vanilla opensim 0.7.2 which initially wasn't doing anything. Discovered that for whatever reason the osNPCCreate commands aren't working. Probably something to do with the %$%^#$#%-ing virtual machine I'm running on my trusty little mac (which is more than a *little* bit slow).

Anyways, I digress. I'm now back to where Haplo Voss got us near christmas: the code below this picture of success (yay!) rezzes a nice couple of physical (though cloudlike) Jane Doe NPCs...




void m_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
lock (p_lock)
{
if (p_inUse)
{
p_inUse = false;

p_scene = m_scene;

p_firstname = "Jane";
p_lastname = "Doe";
p_position.X = 128;
p_position.Y = 128;
p_position.Z = 23;



NPCAvatar npcAvatar = new NPCAvatar(p_firstname,
p_lastname, p_position, p_scene);


//
AgentCircuitData ACD = new AgentCircuitData(); ;
uint circuitcode;


circuitcode = (uint) Util.RandomClass.Next(0, int.MaxValue);
ACD.circuitcode = circuitcode;
npcAvatar.CircuitCode = circuitcode;
ACD.firstname = p_firstname;
ACD.lastname = p_lastname;
ACD.startpos = p_position;
ACD.AgentID = npcAvatar.getAgentId();
ACD.SessionID = UUID.Zero;
ACD.SecureSessionID = UUID.Zero;
ACD.child = false; //should be a root instead of a child - yes beacause it's being instantiated for the first time
ACD.Viewer = "NPC";
//ACD.Appearance = ; //this should be set to something I think...

// not setting everything in the AgentCircuitData: missing out the following:
// child, InventoryFolder,
// BaseFolder, CapsPath, ChildrenCapSeeds
// Are they needed? Don't know....
//dan

p_scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode,ACD);

//


p_scene.AddNewClient(npcAvatar);

ScenePresence sp;
ScenePresence sp_tmp;
//up to this next line works - but this code returns a null scenepresence...
//find out why....

if (p_scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
{
p_scene.TryGetAvatarByName("Jane Doe", out sp_tmp);

p_cloneAppearanceFrom = sp_tmp.UUID;

AvatarAppearance x =
GetAppearance(p_cloneAppearanceFrom, p_scene);

sp.SetAppearance(x.Texture,
(byte[])x.VisualParams.Clone());
}

m_avatars.Add(npcAvatar.AgentId, npcAvatar);

p_returnUuid = npcAvatar.AgentId;
}
}
}

No comments:

Post a Comment