Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork

avinationmerge
ubit 2012-09-21 01:36:16 +02:00
commit a6b2a35ddf
1 changed files with 57 additions and 104 deletions

View File

@ -128,9 +128,6 @@ namespace OpenSim.Region.ClientStack.Linden
} }
private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle; private FileAgentInventoryState m_FileAgentInventoryState = FileAgentInventoryState.idle;
// private bool m_addNewTextures = false;
// private bool m_addNewMeshes = false;
public BunchOfCaps(Scene scene, Caps caps) public BunchOfCaps(Scene scene, Caps caps)
{ {
m_Scene = scene; m_Scene = scene;
@ -641,6 +638,7 @@ namespace OpenSim.Region.ClientStack.Linden
} }
} }
// strings to types
if (inventoryType == "sound") if (inventoryType == "sound")
{ {
inType = (sbyte)InventoryType.Sound; inType = (sbyte)InventoryType.Sound;
@ -687,45 +685,6 @@ namespace OpenSim.Region.ClientStack.Linden
textureAsset.Data = texture_list[i].AsBinary(); textureAsset.Data = texture_list[i].AsBinary();
m_assetService.Store(textureAsset); m_assetService.Store(textureAsset);
textures.Add(textureAsset.FullID); textures.Add(textureAsset.FullID);
/*
don't do this
replace it by optionaly making model textures cost less than if individually uploaded
since they can't be used for other purpuses
// save it to inventory
if (m_addNewTextures && AddNewInventoryItem != null)
{
string name = assetName;
if (name.Length > 25)
name = name.Substring(0, 24);
name += "_Texture#" + i.ToString();
InventoryItemBase texitem = new InventoryItemBase();
texitem.Owner = m_HostCapsObj.AgentID;
texitem.CreatorId = m_HostCapsObj.AgentID.ToString();
texitem.CreatorData = String.Empty;
texitem.ID = UUID.Random();
texitem.AssetID = textureAsset.FullID;
texitem.Description = "mesh model texture";
texitem.Name = name;
texitem.AssetType = (int)AssetType.Texture;
texitem.InvType = (int)InventoryType.Texture;
texitem.Folder = UUID.Zero; // send to default
// If we set PermissionMask.All then when we rez the item the next permissions will replace the current
// (owner) permissions. This becomes a problem if next permissions are changed.
texitem.CurrentPermissions
= (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
texitem.BasePermissions = (uint)PermissionMask.All;
texitem.EveryOnePermissions = 0;
texitem.NextPermissions = (uint)PermissionMask.All;
texitem.CreationDate = Util.UnixTimeSinceEpoch();
AddNewInventoryItem(m_HostCapsObj.AgentID, texitem, 0);
texitem = null;
}
*/
textureAsset = null;
} }
// create and store meshs assets // create and store meshs assets
@ -736,47 +695,9 @@ namespace OpenSim.Region.ClientStack.Linden
meshAsset.Data = mesh_list[i].AsBinary(); meshAsset.Data = mesh_list[i].AsBinary();
m_assetService.Store(meshAsset); m_assetService.Store(meshAsset);
meshAssets.Add(meshAsset.FullID); meshAssets.Add(meshAsset.FullID);
/* this was a test, funny and showed viewers deal with mesh inventory itens
* nut also same reason as for textures
* let integrated in a model cost eventually less than hipotetical independent meshs assets
* that will be in inventory
// save it to inventory
if (m_addNewMeshes && AddNewInventoryItem != null)
{
string name = assetName;
if (name.Length > 25)
name = name.Substring(0, 24);
name += "_Mesh#" + i.ToString();
InventoryItemBase meshitem = new InventoryItemBase();
meshitem.Owner = m_HostCapsObj.AgentID;
meshitem.CreatorId = m_HostCapsObj.AgentID.ToString();
meshitem.CreatorData = String.Empty;
meshitem.ID = UUID.Random();
meshitem.AssetID = meshAsset.FullID;
meshitem.Description = "mesh ";
meshitem.Name = name;
meshitem.AssetType = (int)AssetType.Mesh;
meshitem.InvType = (int)InventoryType.Mesh;
meshitem.Folder = UUID.Zero; // send to default
// If we set PermissionMask.All then when we rez the item the next permissions will replace the current
// (owner) permissions. This becomes a problem if next permissions are changed.
meshitem.CurrentPermissions
= (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer);
meshitem.BasePermissions = (uint)PermissionMask.All;
meshitem.EveryOnePermissions = 0;
meshitem.NextPermissions = (uint)PermissionMask.All;
meshitem.CreationDate = Util.UnixTimeSinceEpoch();
AddNewInventoryItem(m_HostCapsObj.AgentID, meshitem, 0);
meshitem = null;
}
*/
meshAsset = null;
} }
int skipedMeshs = 0;
// build prims from instances // build prims from instances
for (int i = 0; i < instance_list.Count; i++) for (int i = 0; i < instance_list.Count; i++)
{ {
@ -784,9 +705,12 @@ namespace OpenSim.Region.ClientStack.Linden
// skip prims that are 2 small // skip prims that are 2 small
Vector3 scale = inner_instance_list["scale"].AsVector3(); Vector3 scale = inner_instance_list["scale"].AsVector3();
if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin) if (scale.X < m_PrimScaleMin || scale.Y < m_PrimScaleMin || scale.Z < m_PrimScaleMin)
{
skipedMeshs++;
continue; continue;
}
PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();
@ -836,21 +760,33 @@ namespace OpenSim.Region.ClientStack.Linden
pbs.TextureEntry = textureEntry.GetBytes(); pbs.TextureEntry = textureEntry.GetBytes();
int meshindx = inner_instance_list["mesh"].AsInteger(); bool hasmesh = false;
if (meshAssets.Count > meshindx) if (inner_instance_list.ContainsKey("mesh")) // seems to happen always but ...
{ {
pbs.SculptEntry = true; int meshindx = inner_instance_list["mesh"].AsInteger();
pbs.SculptType = (byte)SculptType.Mesh; if (meshAssets.Count > meshindx)
pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction {
// data will be requested from asset on rez (i hope) pbs.SculptEntry = true;
pbs.SculptType = (byte)SculptType.Mesh;
pbs.SculptTexture = meshAssets[meshindx]; // actual asset UUID after meshs suport introduction
// data will be requested from asset on rez (i hope)
hasmesh = true;
}
} }
Vector3 position = inner_instance_list["position"].AsVector3(); Vector3 position = inner_instance_list["position"].AsVector3();
Quaternion rotation = inner_instance_list["rotation"].AsQuaternion(); Quaternion rotation = inner_instance_list["rotation"].AsQuaternion();
// for now viwers do send fixed defaults
// but this may change
// int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger();
byte physicsShapeType = (byte)PhysShapeType.prim; // default for mesh is simple convex
if(hasmesh)
physicsShapeType = (byte) PhysShapeType.convex; // default for mesh is simple convex
// int material = inner_instance_list["material"].AsInteger();
byte material = (byte)Material.Wood;
// no longer used - begin ------------------------ // no longer used - begin ------------------------
// int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger();
// int material = inner_instance_list["material"].AsInteger();
// int mesh = inner_instance_list["mesh"].AsInteger(); // int mesh = inner_instance_list["mesh"].AsInteger();
// OSDMap permissions = (OSDMap)inner_instance_list["permissions"]; // OSDMap permissions = (OSDMap)inner_instance_list["permissions"];
@ -872,7 +808,7 @@ namespace OpenSim.Region.ClientStack.Linden
= new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero); = new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero);
prim.Scale = scale; prim.Scale = scale;
prim.OffsetPosition = position; // prim.OffsetPosition = position;
rotations.Add(rotation); rotations.Add(rotation);
positions.Add(position); positions.Add(position);
prim.UUID = UUID.Random(); prim.UUID = UUID.Random();
@ -883,6 +819,8 @@ namespace OpenSim.Region.ClientStack.Linden
prim.CreationDate = Util.UnixTimeSinceEpoch(); prim.CreationDate = Util.UnixTimeSinceEpoch();
prim.Name = assetName; prim.Name = assetName;
prim.Description = ""; prim.Description = "";
prim.Material = material;
prim.PhysicsShapeType = physicsShapeType;
// prim.BaseMask = (uint)base_mask; // prim.BaseMask = (uint)base_mask;
// prim.EveryoneMask = (uint)everyone_mask; // prim.EveryoneMask = (uint)everyone_mask;
@ -896,25 +834,40 @@ namespace OpenSim.Region.ClientStack.Linden
grp.AddPart(prim); grp.AddPart(prim);
} }
// Fix first link number Vector3 rootPos = positions[0];
if (grp.Parts.Length > 1) if (grp.Parts.Length > 1)
{
// Fix first link number
grp.RootPart.LinkNum++; grp.RootPart.LinkNum++;
Vector3 rootPos = positions[0]; Quaternion rootRotConj = Quaternion.Conjugate(rotations[0]);
grp.AbsolutePosition = rootPos; Quaternion tmprot;
for (int i = 0; i < positions.Count; i++) Vector3 offset;
// fix children rotations and positions
for (int i = 1; i < rotations.Count; i++)
{
tmprot = rotations[i];
tmprot = rootRotConj * tmprot;
grp.Parts[i].RotationOffset = tmprot;
offset = positions[i] - rootPos;
offset *= rootRotConj;
grp.Parts[i].OffsetPosition = offset;
}
grp.AbsolutePosition = rootPos;
grp.UpdateGroupRotationR(rotations[0]);
}
else
{ {
Vector3 offset = positions[i] - rootPos; grp.AbsolutePosition = rootPos;
grp.Parts[i].OffsetPosition = offset; grp.UpdateGroupRotationR(rotations[0]);
} }
for (int i = 0; i < rotations.Count; i++)
{
if (i != 0)
grp.Parts[i].RotationOffset = rotations[i];
}
grp.UpdateGroupRotationR(rotations[0]);
data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp)); data = ASCIIEncoding.ASCII.GetBytes(SceneObjectSerializer.ToOriginalXmlFormat(grp));
} }