本文整理汇总了C#中OpenMetaverse.Primitive.TextureEntry.GetBytes方法的典型用法代码示例。如果您正苦于以下问题:C# Primitive.TextureEntry.GetBytes方法的具体用法?C# Primitive.TextureEntry.GetBytes怎么用?C# Primitive.TextureEntry.GetBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenMetaverse.Primitive.TextureEntry
的用法示例。
在下文中一共展示了Primitive.TextureEntry.GetBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadCompleteHandler
//.........这里部分代码省略.........
if (faceMap.ContainsKey ("diffuse_color"))
f.RGBA = faceMap["diffuse_color"].AsColor4();
int textureNum = faceMap["image"].AsInteger();
float imagerot = faceMap["imagerot"].AsInteger();
float offsets = (float)faceMap["offsets"].AsReal();
float offsett = (float)faceMap["offsett"].AsReal();
float scales = (float)faceMap["scales"].AsReal();
float scalet = (float)faceMap["scalet"].AsReal();
if(imagerot != 0)
f.Rotation = imagerot;
if(offsets != 0)
f.OffsetU = offsets;
if (offsett != 0)
f.OffsetV = offsett;
if (scales != 0)
f.RepeatU = scales;
if (scalet != 0)
f.RepeatV = scalet;
if (textures.Count > textureNum)
f.TextureID = textures[textureNum];
else
f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE;
textureEntry.FaceTextures[face] = f;
}
pbs.TextureEntry = textureEntry.GetBytes();
AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, "");
meshAsset.Data = mesh_list[i].AsBinary();
m_assetService.Store(meshAsset);
pbs.SculptEntry = true;
pbs.SculptTexture = meshAsset.FullID;
pbs.SculptType = (byte)SculptType.Mesh;
pbs.SculptData = meshAsset.Data;
Vector3 position = inner_instance_list["position"].AsVector3();
Vector3 scale = inner_instance_list["scale"].AsVector3();
Quaternion rotation = inner_instance_list["rotation"].AsQuaternion();
// int physicsShapeType = inner_instance_list["physics_shape_type"].AsInteger();
// int material = inner_instance_list["material"].AsInteger();
// int mesh = inner_instance_list["mesh"].AsInteger();
OSDMap permissions = (OSDMap)inner_instance_list["permissions"];
int base_mask = permissions["base_mask"].AsInteger();
int everyone_mask = permissions["everyone_mask"].AsInteger();
UUID creator_id = permissions["creator_id"].AsUUID();
UUID group_id = permissions["group_id"].AsUUID();
int group_mask = permissions["group_mask"].AsInteger();
// bool is_owner_group = permissions["is_owner_group"].AsBoolean();
// UUID last_owner_id = permissions["last_owner_id"].AsUUID();
int next_owner_mask = permissions["next_owner_mask"].AsInteger();
UUID owner_id = permissions["owner_id"].AsUUID();
int owner_mask = permissions["owner_mask"].AsInteger();
SceneObjectPart prim
= new SceneObjectPart(owner_id, pbs, position, Quaternion.Identity, Vector3.Zero);
示例2: ProcessAdd
//.........这里部分代码省略.........
pbs.PathTaperX = (sbyte) obj.TaperX;
pbs.PathTaperY = (sbyte) obj.TaperY;
pbs.PathTwist = (sbyte) obj.Twist;
pbs.PathTwistBegin = (sbyte) obj.TwistBegin;
pbs.HollowShape = (HollowShape) obj.ProfileHollow;
pbs.PCode = (byte) PCode.Prim;
pbs.ProfileBegin = (ushort) obj.ProfileBegin;
pbs.ProfileCurve = (byte) obj.ProfileCurve;
pbs.ProfileEnd = (ushort) obj.ProfileEnd;
pbs.Scale = obj.Scale;
pbs.State = (byte) 0;
pbs.LastAttachPoint = (byte) 0;
SceneObjectPart prim = new SceneObjectPart();
prim.UUID = UUID.Random();
prim.CreatorID = AgentId;
prim.OwnerID = AgentId;
prim.GroupID = obj.GroupID;
prim.LastOwnerID = prim.OwnerID;
prim.CreationDate = Util.UnixTimeSinceEpoch();
prim.Name = obj.Name;
prim.Description = "";
prim.PayPrice[0] = -2;
prim.PayPrice[1] = -2;
prim.PayPrice[2] = -2;
prim.PayPrice[3] = -2;
prim.PayPrice[4] = -2;
Primitive.TextureEntry tmp =
new Primitive.TextureEntry(UUID.Parse("89556747-24cb-43ed-920b-47caed15465f"));
for (int j = 0; j < obj.Faces.Length; j++)
{
UploadObjectAssetMessage.Object.Face face = obj.Faces[j];
Primitive.TextureEntryFace primFace = tmp.CreateFace((uint) j);
primFace.Bump = face.Bump;
primFace.RGBA = face.Color;
primFace.Fullbright = face.Fullbright;
primFace.Glow = face.Glow;
primFace.TextureID = face.ImageID;
primFace.Rotation = face.ImageRot;
primFace.MediaFlags = ((face.MediaFlags & 1) != 0);
primFace.OffsetU = face.OffsetS;
primFace.OffsetV = face.OffsetT;
primFace.RepeatU = face.ScaleS;
primFace.RepeatV = face.ScaleT;
primFace.TexMapType = (MappingType) (face.MediaFlags & 6);
}
pbs.TextureEntry = tmp.GetBytes();
prim.Shape = pbs;
prim.Scale = obj.Scale;
SceneObjectGroup grp = new SceneObjectGroup();
grp.SetRootPart(prim);
prim.ParentID = 0;
if (i == 0)
{
rootGroup = grp;
}
grp.AttachToScene(m_scene);
grp.AbsolutePosition = obj.Position;
prim.RotationOffset = obj.Rotation;
// Required for linking
grp.RootPart.ClearUpdateSchedule();
if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos))
{
m_scene.AddSceneObject(grp);
grp.AbsolutePosition = obj.Position;
}
allparts[i] = grp;
}
for (int j = 1; j < allparts.Length; j++)
{
// Required for linking
rootGroup.RootPart.ClearUpdateSchedule();
allparts[j].RootPart.ClearUpdateSchedule();
rootGroup.LinkToGroup(allparts[j]);
}
rootGroup.ScheduleGroupForFullUpdate();
pos
= m_scene.GetNewRezLocation(
Vector3.Zero, rootpos, UUID.Zero, rot, (byte)1, 1, true, allparts[0].GroupScale, false);
responsedata["int_response_code"] = 200; //501; //410; //404;
responsedata["content_type"] = "text/plain";
responsedata["keepalive"] = false;
responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>", ConvertUintToBytes(allparts[0].LocalId));
return responsedata;
}
示例3: RenderMaterialsPostCap
public string RenderMaterialsPostCap(string request, UUID agentID)
{
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
OSDMap resp = new OSDMap();
OSDMap materialsFromViewer = null;
OSDArray respArr = new OSDArray();
if (req.ContainsKey("Zipped"))
{
OSD osd = null;
byte[] inBytes = req["Zipped"].AsBinary();
try
{
osd = ZDecompressBytesToOsd(inBytes);
if (osd != null)
{
if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries
{
foreach (OSD elem in (OSDArray)osd)
{
try
{
UUID id = new UUID(elem.AsBinary(), 0);
lock (m_regionMaterials)
{
if (m_regionMaterials.ContainsKey(id))
{
OSDMap matMap = new OSDMap();
matMap["ID"] = OSD.FromBinary(id.GetBytes());
matMap["Material"] = m_regionMaterials[id];
respArr.Add(matMap);
}
else
{
m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString());
// Theoretically we could try to load the material from the assets service,
// but that shouldn't be necessary because the viewer should only request
// materials that exist in a prim on the region, and all of these materials
// are already stored in m_regionMaterials.
}
}
}
catch (Exception e)
{
m_log.Error("Error getting materials in response to viewer request", e);
continue;
}
}
}
else if (osd is OSDMap) // request to assign a material
{
materialsFromViewer = osd as OSDMap;
if (materialsFromViewer.ContainsKey("FullMaterialsPerFace"))
{
OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"];
if (matsOsd is OSDArray)
{
OSDArray matsArr = matsOsd as OSDArray;
try
{
foreach (OSDMap matsMap in matsArr)
{
uint primLocalID = 0;
try {
primLocalID = matsMap["ID"].AsUInteger();
}
catch (Exception e) {
m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message);
continue;
}
OSDMap mat = null;
try
{
mat = matsMap["Material"] as OSDMap;
}
catch (Exception e)
{
m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
continue;
}
SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID);
if (sop == null)
{
m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString());
continue;
}
if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID))
{
//.........这里部分代码省略.........
示例4: TextureEntry
public void TextureEntry()
{
Primitive.TextureEntry te = new Primitive.TextureEntry(UUID.Random());
Primitive.TextureEntryFace face = te.CreateFace(0);
face.Bump = Bumpiness.Concrete;
face.Fullbright = true;
face.MediaFlags = true;
face.OffsetU = 0.5f;
face.OffsetV = -0.5f;
face.RepeatU = 3.0f;
face.RepeatV = 4.0f;
face.RGBA = new Color4(0f, 0.25f, 0.75f, 1f);
face.Rotation = 1.5f;
face.Shiny = Shininess.Medium;
face.TexMapType = MappingType.Planar;
face.TextureID = UUID.Random();
byte[] teBytes = te.GetBytes();
Primitive.TextureEntry te2 = new Primitive.TextureEntry(teBytes, 0, teBytes.Length);
byte[] teBytes2 = te2.GetBytes();
Assert.IsTrue(teBytes.Length == teBytes2.Length);
for (int i = 0; i < teBytes.Length; i++)
{
Assert.IsTrue(teBytes[i] == teBytes2[i], "Byte " + i + " is not equal");
}
}
示例5: UploadCompleteHandler
//.........这里部分代码省略.........
if (faceMap.ContainsKey("diffuse_color"))
f.RGBA = faceMap["diffuse_color"].AsColor4();
int textureNum = faceMap["image"].AsInteger();
float imagerot = faceMap["imagerot"].AsInteger();
float offsets = (float)faceMap["offsets"].AsReal();
float offsett = (float)faceMap["offsett"].AsReal();
float scales = (float)faceMap["scales"].AsReal();
float scalet = (float)faceMap["scalet"].AsReal();
if (imagerot != 0)
f.Rotation = imagerot;
if (offsets != 0)
f.OffsetU = offsets;
if (offsett != 0)
f.OffsetV = offsett;
if (scales != 0)
f.RepeatU = scales;
if (scalet != 0)
f.RepeatV = scalet;
if (textures.Count > textureNum)
f.TextureID = textures[textureNum];
else
f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE;
textureEntry.FaceTextures[face] = f;
}
pbs.TextureEntry = textureEntry.GetBytes();
bool hasmesh = false;
if (inner_instance_list.ContainsKey("mesh")) // seems to happen always but ...
{
int meshindx = inner_instance_list["mesh"].AsInteger();
if (meshAssets.Count > meshindx)
{
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();
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.convex; // default is simple convex
// int material = inner_instance_list["material"].AsInteger();
byte material = (byte)Material.Wood;
// no longer used - begin ------------------------
// int mesh = inner_instance_list["mesh"].AsInteger();
// OSDMap permissions = (OSDMap)inner_instance_list["permissions"];
// int base_mask = permissions["base_mask"].AsInteger();
// int everyone_mask = permissions["everyone_mask"].AsInteger();
// UUID creator_id = permissions["creator_id"].AsUUID();
示例6: UploadCompleteHandler
//.........这里部分代码省略.........
new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE);
OSDMap inner_instance_list = (OSDMap) instance_list[i];
OSDArray face_list = (OSDArray) inner_instance_list["face_list"];
for (uint face = 0; face < face_list.Count; face++)
{
OSDMap faceMap = (OSDMap) face_list[(int) face];
Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face);
if (faceMap.ContainsKey("fullbright"))
f.Fullbright = faceMap["fullbright"].AsBoolean();
if (faceMap.ContainsKey("diffuse_color"))
f.RGBA = faceMap["diffuse_color"].AsColor4();
int textureNum = faceMap["image"].AsInteger();
float imagerot = faceMap["imagerot"].AsInteger();
float offsets = (float) faceMap["offsets"].AsReal();
float offsett = (float) faceMap["offsett"].AsReal();
float scales = (float) faceMap["scales"].AsReal();
float scalet = (float) faceMap["scalet"].AsReal();
if (imagerot != 0)
f.Rotation = imagerot;
if (offsets != 0)
f.OffsetU = offsets;
if (offsett != 0)
f.OffsetV = offsett;
if (scales != 0)
f.RepeatU = scales;
if (scalet != 0)
f.RepeatV = scalet;
f.TextureID = textures.Count > textureNum ? textures[textureNum] : Primitive.TextureEntry.WHITE_TEXTURE;
textureEntry.FaceTextures[face] = f;
}
pbs.TextureEntry = textureEntry.GetBytes();
AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, AssetType.Mesh, m_service.AgentID)
{Data = mesh_list[i].AsBinary()};
meshAsset.ID = m_assetService.Store(meshAsset);
if (meshFolder == null)
{
m_inventoryService.CreateUserInventory(m_service.AgentID, false);
meshFolder = m_inventoryService.GetFolderForType(m_service.AgentID, InventoryType.Mesh,
AssetType.Mesh);
}
InventoryItemBase itemBase = new InventoryItemBase(UUID.Random(), m_service.AgentID)
{
AssetType = (sbyte) AssetType.Mesh,
AssetID = meshAsset.ID,
CreatorId = m_service.AgentID.ToString(),
Folder = meshFolder.ID,
InvType = (int) InventoryType.Texture,
Name = "(Mesh) - " + assetName,
CurrentPermissions = (uint) PermissionMask.All,
BasePermissions = (uint) PermissionMask.All,
EveryOnePermissions = everyone_mask,
GroupPermissions = group_mask,
NextPermissions = next_owner_mask
};
//Bad... but whatever
m_inventoryService.AddItem(itemBase);
pbs.SculptEntry = true;
pbs.SculptTexture = meshAsset.ID;
pbs.SculptType = (byte) SculptType.Mesh;
示例7: replacer_lols
public AgentSetAppearancePacket replacer_lols(AgentSetAppearancePacket packet)
{
AgentSetAppearancePacket p = cloneASA(packet);
if (p.ObjectData != null)
{
if (p.ObjectData.TextureEntry != null)
{
Primitive.TextureEntry te = new Primitive.TextureEntry(p.ObjectData.TextureEntry, 0, p.ObjectData.TextureEntry.Length);
if (te != null)
{
if (te.FaceTextures != null)
{
if (te.FaceTextures.Length > 0)
{
//Console.WriteLine("Coin is replacing textures...");
UUID replace = lols[lolcounter];
lolcounter++;
if (lolcounter >= lols.Length)
lolcounter = 0;
for (int i = 0; i <= 7; i++)
{
if (te.FaceTextures[i] != null)
te.FaceTextures[i].TextureID = replace;
}
for (int i = 12; i <= 18; i++)
{
if (te.FaceTextures[i] != null)
te.FaceTextures[i].TextureID = replace;
}
if (p.ObjectData != null)
p.ObjectData.TextureEntry = te.GetBytes();
//Console.WriteLine("OK!");
}
}
}
}
}
return p;
}
示例8: SetFaceColor
/// <summary>
/// Set the color of prim faces
/// </summary>
/// <param name="color"></param>
/// <param name="face"></param>
public void SetFaceColor(Vector3 color, int face)
{
// The only way to get a deep copy/ If we don't do this, we can
// mever detect color changes further down.
Byte[] buf = Shape.Textures.GetBytes();
Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length);
Color4 texcolor;
if (face >= 0 && face < GetNumberOfSides())
{
texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor;
UpdateTextureEntry(tex.GetBytes());
return;
}
else if (face == ALL_SIDES)
{
for (uint i = 0; i < GetNumberOfSides(); i++)
{
if (tex.FaceTextures[i] != null)
{
texcolor = tex.FaceTextures[i].RGBA;
texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
tex.FaceTextures[i].RGBA = texcolor;
}
texcolor = tex.DefaultTexture.RGBA;
texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor;
}
UpdateTextureEntry(tex.GetBytes());
return;
}
}
示例9: UploadCompleteHandler
//.........这里部分代码省略.........
if (faceMap.ContainsKey ("diffuse_color"))
f.RGBA = faceMap["diffuse_color"].AsColor4();
int textureNum = faceMap["image"].AsInteger();
float imagerot = faceMap["imagerot"].AsInteger();
float offsets = (float)faceMap["offsets"].AsReal();
float offsett = (float)faceMap["offsett"].AsReal();
float scales = (float)faceMap["scales"].AsReal();
float scalet = (float)faceMap["scalet"].AsReal();
if(imagerot != 0)
f.Rotation = imagerot;
if(offsets != 0)
f.OffsetU = offsets;
if (offsett != 0)
f.OffsetV = offsett;
if (scales != 0)
f.RepeatU = scales;
if (scalet != 0)
f.RepeatV = scalet;
if (textures.Count > textureNum)
f.TextureID = textures[textureNum];
else
f.TextureID = Primitive.TextureEntry.WHITE_TEXTURE;
textureEntry.FaceTextures[face] = f;
}
pbs.TextureEntry = textureEntry.GetBytes();
AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, (sbyte)AssetType.Mesh, "");
meshAsset.Data = mesh_list[i].AsBinary();
m_assetService.Store(meshAsset);
pbs.SculptEntry = true;
pbs.SculptTexture = meshAsset.FullID;
pbs.SculptType = (byte)SculptType.Mesh;
pbs.SculptData = meshAsset.Data;
Vector3 position = inner_instance_list["position"].AsVector3();
Vector3 scale = inner_instance_list["scale"].AsVector3();
Quaternion rotation = inner_instance_list["rotation"].AsQuaternion();
// 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();
// OSDMap permissions = (OSDMap)inner_instance_list["permissions"];
// int base_mask = permissions["base_mask"].AsInteger();
// int everyone_mask = permissions["everyone_mask"].AsInteger();
// UUID creator_id = permissions["creator_id"].AsUUID();
// UUID group_id = permissions["group_id"].AsUUID();
// int group_mask = permissions["group_mask"].AsInteger();
// bool is_owner_group = permissions["is_owner_group"].AsBoolean();
// UUID last_owner_id = permissions["last_owner_id"].AsUUID();
// int next_owner_mask = permissions["next_owner_mask"].AsInteger();
// UUID owner_id = permissions["owner_id"].AsUUID();
// int owner_mask = permissions["owner_mask"].AsInteger();
// no longer used - end ------------------------
示例10: ApHand
public Packet ApHand(Packet packet, IPEndPoint sim)
{
if (form.getChecked()==false)
{
return packet;
}
AgentSetAppearancePacket packet2 = (AgentSetAppearancePacket) packet;
if ((packet2.ObjectData == null) || (packet2.ObjectData.TextureEntry == null))
{
return packet;
}
Primitive.TextureEntry entry = new Primitive.TextureEntry(packet2.ObjectData.TextureEntry, 0, packet2.ObjectData.TextureEntry.Length);
if (((entry == null) || (entry.FaceTextures == null)) || (entry.FaceTextures.Length <= 0))
{
return packet;
}
Console.WriteLine("Penny is replacing textures...");
UUID uuid = new UUID("5aa5c70d-d787-571b-0495-4fc1bdef1500");
for (int i = 0; i <= 7; i++)
{
if (entry.FaceTextures[i] != null)
{
entry.FaceTextures[i].TextureID = uuid;
}
}
for (int j = 12; j <= 0x12; j++)
{
if (entry.FaceTextures[j] != null)
{
entry.FaceTextures[j].TextureID = uuid;
}
}
if (packet2.ObjectData != null)
{
packet2.ObjectData.TextureEntry = entry.GetBytes();
}
Console.WriteLine("OK! Thanks Day!");
return packet2;
}
示例11: AssignSingleMaterial
//.........这里部分代码省略.........
return;
}
lock (m_knownMaterials)
{
UUID id = UUID.Zero;
// Record what we currently have
var currentMaterialIDs = getMaterialIDsFromTextureEntry(te);
// If there is a material being set see if we've seen it before.
// If not we'll add it to the region cache
if (matData != null)
{
RenderMaterial material = RenderMaterial.FromOSD(matData);
id = sop.Shape.RenderMaterials.AddMaterial(material);
if (m_knownMaterials.ContainsKey(id))
{
material = m_knownMaterials[id].material;
var entry = m_knownMaterials[id];
if (entry.partIds.Contains(sop.LocalId) == false)
entry.partIds.Add(sop.LocalId);
}
else
{
m_knownMaterials[id] = new RenderMaterialEntry(material, sop.LocalId);
}
m_log.DebugFormat("[RenderMaterials]: SOP {0}, Face {1}, Adding RenderMaterial {2}",
sop.LocalId, face, material.ToString());
}
// Set the Material ID in the sop texture entry. If there's a face defined
// use that else use the Default entry. ID can either be a material ID
// we set from the lookup above or Zero when we are clearing a material.
if (face < 0)
{
te.DefaultTexture.MaterialID = id;
}
else
{
var faceEntry = te.CreateFace((uint)face);
faceEntry.MaterialID = id;
}
// Get the updated list of Materials from the TextureEntry. We will
// Use that to rebuild the RenderMaterials for the part. We'll also get a list
// of entries that have been removed based on what we fetched initially so we
// can clean that up in our cache.
var newMaterialIDs = getMaterialIDsFromTextureEntry(te);
// If there was an update and the material id has changed, clean up the old value.
// Have to be careful here. It might still be in use in another slot. So we build
// a list of keys and walk the texture entries subtracting keys in use. Whatever
// is left are candidates to clean up.
foreach (var entry in newMaterialIDs)
{
if (currentMaterialIDs.Contains(entry))
{
currentMaterialIDs.Remove(entry);
}
if (sop.Shape.RenderMaterials.ContainsMaterial(entry) == false)
{
m_log.WarnFormat("[RenderMaterials]: SOP {0}, Face {1}, RenderMaterials {2} should be present but isn't!",
sop.LocalId, face, entry.ToString());
}
}
// currentMaterialsIDs contains orphans if any. Remove them from the sop.Shape and the cache (if needed)
foreach (var entry in currentMaterialIDs)
{
if (sop.Shape.RenderMaterials.ContainsMaterial(entry) == true)
{
m_log.DebugFormat("[RenderMaterials]: SOP {0}, Face {1}, Removing unused RenderMaterials {2} from shape.",
sop.LocalId, face, entry.ToString());
sop.Shape.RenderMaterials.RemoveMaterial(entry);
}
else
{
m_log.WarnFormat("[RenderMaterials]: SOP {0}, Face {1}, ORPHANED RenderMaterials {2} should be present but isn't!",
sop.LocalId, face, entry.ToString());
}
if (m_knownMaterials.ContainsKey(entry))
{
m_knownMaterials[entry].partIds.Remove(sop.LocalId);
if (m_knownMaterials[entry].partIds.Count <= 0)
{
m_log.DebugFormat("[RenderMaterials]: Removing unused RenderMaterials {0} from region cache.", entry.ToString());
m_knownMaterials.Remove(entry);
}
}
}
}
// Update the texture entry which will force an update to connected clients
sop.UpdateTextureEntry(te.GetBytes());
}
示例12: GetShape
private static PrimitiveBaseShape GetShape(int vShape)
{
PrimitiveBaseShape shape = new PrimitiveBaseShape();
shape.PCode = 9;
shape.PathBegin = 0;
shape.PathEnd = 0;
shape.PathScaleX = 100;
shape.PathScaleY = 100;
shape.PathShearX = 0;
shape.PathShearY = 0;
shape.PathSkew = 0;
shape.ProfileBegin = 0;
shape.ProfileEnd = 0;
shape.Scale = new Vector3(0.5f, 0.5f, 0.5f);
//shape.Scale.X = shape.Scale.Y = shape.Scale.Z = 0.5f;
shape.PathCurve = 16;
shape.ProfileCurve = 1;
shape.ProfileHollow = 0;
shape.PathRadiusOffset = 0;
shape.PathRevolutions = 0;
shape.PathTaperX = 0;
shape.PathTaperY = 0;
shape.PathTwist = 0;
shape.PathTwistBegin = 0;
Primitive.TextureEntry ntex = new Primitive.TextureEntry(new UUID("00000000-0000-1111-9999-000000000005"));
shape.TextureEntry = ntex.GetBytes();//ntex.ToBytes();
return shape;
}
示例13: replacer_tails
public AgentSetAppearancePacket replacer_tails(AgentSetAppearancePacket packet)
{
AgentSetAppearancePacket p = cloneASA(packet);
if (p.ObjectData != null)
{
if (p.ObjectData.TextureEntry != null)
{
Primitive.TextureEntry te = new Primitive.TextureEntry(p.ObjectData.TextureEntry, 0, p.ObjectData.TextureEntry.Length);
if (te != null)
{
if (te.FaceTextures != null)
{
if (te.FaceTextures.Length > 0)
{
//Console.WriteLine("Coin is replacing textures...");
UUID replace = new UUID("8183e823-c443-2142-6eb6-2ab763d4f81c");
for (int i = 0; i <= 7; i++)
{
if (te.FaceTextures[i] != null)
te.FaceTextures[i].TextureID = replace;
}
for (int i = 12; i <= 18; i++)
{
if (te.FaceTextures[i] != null)
te.FaceTextures[i].TextureID = replace;
}
if (p.ObjectData != null)
p.ObjectData.TextureEntry = te.GetBytes();
//Console.WriteLine("OK!");
}
}
}
}
}
return p;
}
示例14: MakeAppearancePacket
//.........这里部分代码省略.........
case 842:
agentSizeVPHipLength = paramValue;
break;
}
if (vpIndex == nrParams) break;
}
MyVisualParameters = new byte[set.VisualParam.Length];
for (int i = 0; i < set.VisualParam.Length; i++)
{
MyVisualParameters[i] = set.VisualParam[i].ParamValue;
}
#endregion VisualParam
#region TextureEntry
Primitive.TextureEntry te = new Primitive.TextureEntry(DEFAULT_AVATAR_TEXTURE);
for (uint i = 0; i < Textures.Length; i++)
{
if ((i == 0 || i == 5 || i == 6) && Client.Settings.CLIENT_IDENTIFICATION_TAG != UUID.Zero)
{
Primitive.TextureEntryFace face = te.CreateFace(i);
face.TextureID = Client.Settings.CLIENT_IDENTIFICATION_TAG;
Logger.DebugLog("Sending client identification tag: " + Client.Settings.CLIENT_IDENTIFICATION_TAG, Client);
}
else if (Textures[i].TextureID != UUID.Zero)
{
Primitive.TextureEntryFace face = te.CreateFace(i);
face.TextureID = Textures[i].TextureID;
Logger.DebugLog("Sending texture entry for " + (AvatarTextureIndex)i + " to " + Textures[i].TextureID, Client);
}
}
set.ObjectData.TextureEntry = te.GetBytes();
MyTextures = te;
#endregion TextureEntry
#region WearableData
set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[BAKED_TEXTURE_COUNT];
// Build hashes for each of the bake layers from the individual components
for (int bakedIndex = 0; bakedIndex < BAKED_TEXTURE_COUNT; bakedIndex++)
{
UUID hash = UUID.Zero;
for (int wearableIndex = 0; wearableIndex < WEARABLES_PER_LAYER; wearableIndex++)
{
WearableType type = WEARABLE_BAKE_MAP[bakedIndex][wearableIndex];
WearableData wearable;
if (type != WearableType.Invalid && Wearables.TryGetValue(type, out wearable))
hash ^= wearable.AssetID;
}
if (hash != UUID.Zero)
{
// Hash with our magic value for this baked layer
hash ^= BAKED_TEXTURE_HASH[bakedIndex];
}
// Tell the server what cached texture assetID to use for each bake layer
set.WearableData[bakedIndex] = new AgentSetAppearancePacket.WearableDataBlock();
set.WearableData[bakedIndex].TextureIndex = BakeIndexToTextureIndex[bakedIndex];
set.WearableData[bakedIndex].CacheID = hash;
Logger.DebugLog("Sending TextureIndex " + (BakeType)bakedIndex + " with CacheID " + hash, Client);
}
#endregion WearableData
#region Agent Size
// Takes into account the Shoe Heel/Platform offsets but not the HeadSize offset. Seems to work.
double agentSizeBase = 1.706;
// The calculation for the HeadSize scalar may be incorrect, but it seems to work
double agentHeight = agentSizeBase + (agentSizeVPLegLength * .1918) + (agentSizeVPHipLength * .0375) +
(agentSizeVPHeight * .12022) + (agentSizeVPHeadSize * .01117) + (agentSizeVPNeckLength * .038) +
(agentSizeVPHeelHeight * .08) + (agentSizeVPPlatformHeight * .07);
set.AgentData.Size = new Vector3(0.45f, 0.6f, (float)agentHeight);
#endregion Agent Size
if (Client.Settings.AVATAR_TRACKING)
{
Avatar me;
if (Client.Network.CurrentSim.ObjectsAvatars.TryGetValue(Client.Self.LocalID, out me))
{
me.Textures = MyTextures;
me.VisualParameters = MyVisualParameters;
}
}
}
return set;
}
示例15: SendAgentSetAppearance
//.........这里部分代码省略.........
break;
case 756:
AgentSizeVPNeckLength = data.Asset.Params[vp.ParamID];
break;
case 842:
AgentSizeVPHipLength = data.Asset.Params[vp.ParamID];
break;
}
break;
}
}
++vpIndex;
}
}
// Build the texture entry for our agent
Primitive.TextureEntry te = new Primitive.TextureEntry(DEFAULT_AVATAR_TEXTURE);
// Put our AgentTextures array in to TextureEntry
lock (AgentTextures)
{
for (uint i = 0; i < AgentTextures.Length; i++)
{
if (AgentTextures[i] != UUID.Zero)
{
Primitive.TextureEntryFace face = te.CreateFace(i);
face.TextureID = AgentTextures[i];
}
}
}
foreach (WearableData data in Wearables.Dictionary.Values)
{
if (data.Asset != null)
{
foreach (KeyValuePair<TextureIndex, UUID> texture in data.Asset.Textures)
{
Primitive.TextureEntryFace face = te.CreateFace((uint)texture.Key);
face.TextureID = texture.Value;
Log.DebugLog("Setting agent texture " + ((TextureIndex)texture.Key).ToString() + " to " +
texture.Value.ToString());
}
}
}
// Set the packet TextureEntry
set.ObjectData.TextureEntry = te.GetBytes();
}
// FIXME: Our hackish algorithm is making squished avatars. See
// http://www.OpenMetaverse.org/wiki/Agent_Size for discussion of the correct algorithm
//float height = Utils.ByteToFloat(set.VisualParam[33].ParamValue, VisualParams.Params[33].MinValue,
// VisualParams.Params[33].MaxValue);
// Takes into account the Shoe Heel/Platform offsets but not the Head Size Offset. But seems to work.
double AgentSizeBase = 1.706;
// The calculation for the Head Size scalar may be incorrect. But seems to work.
double AgentHeight = AgentSizeBase + (AgentSizeVPLegLength * .1918) + (AgentSizeVPHipLength * .0375) +
(AgentSizeVPHeight * .12022) + (AgentSizeVPHeadSize * .01117) + (AgentSizeVPNeckLength * .038) +
(AgentSizeVPHeelHeight * .08) + (AgentSizeVPPlatformHeight * .07);
set.AgentData.Size = new Vector3(0.45f, 0.6f, (float)AgentHeight);
// TODO: Account for not having all the textures baked yet
set.WearableData = new AgentSetAppearancePacket.WearableDataBlock[BAKED_TEXTURE_COUNT];
// Build hashes for each of the bake layers from the individual components
for (int bakedIndex = 0; bakedIndex < BAKED_TEXTURE_COUNT; bakedIndex++)
{
UUID hash = new UUID();
for (int wearableIndex = 0; wearableIndex < WEARABLES_PER_LAYER; wearableIndex++)
{
WearableType type = WEARABLE_BAKE_MAP[bakedIndex][wearableIndex];
UUID assetID = GetWearableAsset(type);
// Build a hash of all the texture asset IDs in this baking layer
if (assetID != UUID.Zero) hash ^= assetID;
}
if (hash != UUID.Zero)
{
// Hash with our secret value for this baked layer
hash ^= BAKED_TEXTURE_HASH[bakedIndex];
}
// Tell the server what cached texture assetID to use for each bake layer
set.WearableData[bakedIndex] = new AgentSetAppearancePacket.WearableDataBlock();
set.WearableData[bakedIndex].TextureIndex = (byte)bakedIndex;
set.WearableData[bakedIndex].CacheID = hash;
Log.DebugLog("Setting baked agent texture hash " + ((BakeType)bakedIndex).ToString() + " to " + hash);
}
// Finally, send the packet
Network.SendPacket(set);
}