本文整理汇总了C#中OpenMetaverse.Primitive.TextureEntry.CreateFace方法的典型用法代码示例。如果您正苦于以下问题:C# Primitive.TextureEntry.CreateFace方法的具体用法?C# Primitive.TextureEntry.CreateFace怎么用?C# Primitive.TextureEntry.CreateFace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenMetaverse.Primitive.TextureEntry
的用法示例。
在下文中一共展示了Primitive.TextureEntry.CreateFace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestCreate
public void TestCreate()
{
TestHelper.InMethod();
// log4net.Config.XmlConfigurator.Configure();
IConfigSource config = new IniConfigSource();
config.AddConfig("NPC");
config.Configs["NPC"].Set("Enabled", "true");
AvatarFactoryModule afm = new AvatarFactoryModule();
TestScene scene = SceneSetupHelpers.SetupScene();
SceneSetupHelpers.SetupSceneModules(scene, config, afm, new NPCModule());
TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1));
// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
// 8 is the index of the first baked texture in AvatarAppearance
UUID originalFace8TextureId = TestHelper.ParseTail(0x10);
Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
originalTef.TextureID = originalFace8TextureId;
// We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
// ScenePresence.SendInitialData() to reset our entire appearance.
scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId));
afm.SetAppearance(originalClient, originalTe, null);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId);
ScenePresence npc = scene.GetScenePresence(npcId);
Assert.That(npc, Is.Not.Null);
Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId));
}
示例2: TestSetAppearance
public void TestSetAppearance()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID userId = TestHelpers.ParseTail(0x1);
UUID bakedTextureID = TestHelpers.ParseTail(0x2);
// We need an asset cache because otherwise the LocalAssetServiceConnector will short-circuit directly
// to the AssetService, which will then store temporary and local assets permanently
CoreAssetCache assetCache = new CoreAssetCache();
AvatarFactoryModule afm = new AvatarFactoryModule();
TestScene scene = new SceneHelpers(assetCache).SetupScene();
SceneHelpers.SetupSceneModules(scene, afm);
ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
// TODO: Use the actual BunchOfCaps functionality once we slot in the CapabilitiesModules
AssetBase bakedTextureAsset;
bakedTextureAsset
= new AssetBase(
bakedTextureID, "Test Baked Texture", (sbyte)AssetType.Texture, userId.ToString());
bakedTextureAsset.Data = new byte[] { 2 }; // Not necessary to have a genuine JPEG2000 asset here yet
bakedTextureAsset.Temporary = true;
bakedTextureAsset.Local = true;
scene.AssetService.Store(bakedTextureAsset);
byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT];
for (byte i = 0; i < visualParams.Length; i++)
visualParams[i] = i;
Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10));
uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes);
Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex);
int rebakeRequestsReceived = 0;
((TestClient)sp.ControllingClient).OnReceivedSendRebakeAvatarTextures += id => rebakeRequestsReceived++;
// This is the alpha texture
eyesFace.TextureID = bakedTextureID;
afm.SetAppearance(sp, bakedTextureEntry, visualParams, null);
Assert.That(rebakeRequestsReceived, Is.EqualTo(0));
AssetBase eyesBake = scene.AssetService.Get(bakedTextureID.ToString());
Assert.That(eyesBake, Is.Not.Null);
Assert.That(eyesBake.Temporary, Is.True);
Assert.That(eyesBake.Local, Is.True);
}
示例3: RenderMaterialsPostCap
//.........这里部分代码省略.........
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))
{
m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID);
continue;
}
Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
if (te == null)
{
m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID);
continue;
}
UUID id;
if (mat == null)
{
// This happens then the user removes a material from a prim
id = UUID.Zero;
}
else
{
id = StoreMaterialAsAsset(agentID, mat, sop);
}
int face = -1;
if (matsMap.ContainsKey("Face"))
{
face = matsMap["Face"].AsInteger();
Primitive.TextureEntryFace faceEntry = te.CreateFace((uint)face);
faceEntry.MaterialID = id;
}
else
{
if (te.DefaultTexture == null)
m_log.WarnFormat("[Materials]: TextureEntry.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID);
else
te.DefaultTexture.MaterialID = id;
}
//m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id);
// We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually
sop.Shape.TextureEntry = te.GetBytes();
if (sop.ParentGroup != null)
{
sop.TriggerScriptChangedEvent(Changed.TEXTURE);
sop.UpdateFlag = UpdateRequired.FULL;
sop.ParentGroup.HasGroupChanged = true;
sop.ScheduleFullUpdate();
}
}
}
catch (Exception e)
{
m_log.Warn("[Materials]: exception processing received material ", e);
}
}
}
}
}
}
catch (Exception e)
{
m_log.Warn("[Materials]: exception decoding zipped CAP payload ", e);
//return "";
}
}
resp["Zipped"] = ZCompressOSD(respArr, false);
string response = OSDParser.SerializeLLSDXmlString(resp);
//m_log.Debug("[Materials]: cap request: " + request);
//m_log.Debug("[Materials]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary()));
//m_log.Debug("[Materials]: cap response: " + response);
return response;
}
示例4: 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;
}
示例5: TestCreate
public void TestCreate()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
// 8 is the index of the first baked texture in AvatarAppearance
UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
originalTef.TextureID = originalFace8TextureId;
// We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
// ScenePresence.SendInitialData() to reset our entire appearance.
scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
afm.SetAppearance(sp, originalTe, null);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance);
ScenePresence npc = scene.GetScenePresence(npcId);
Assert.That(npc, Is.Not.Null);
Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId));
Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
}
示例6: TestAddRemoveNPCs
private void TestAddRemoveNPCs(int numberOfNpcs)
{
ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
// 8 is the index of the first baked texture in AvatarAppearance
UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
originalTef.TextureID = originalFace8TextureId;
// We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
// ScenePresence.SendInitialData() to reset our entire appearance.
scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
afm.SetAppearance(sp, originalTe, null);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
List<UUID> npcs = new List<UUID>();
long startGcMemory = GC.GetTotalMemory(true);
Stopwatch sw = new Stopwatch();
sw.Start();
for (int i = 0; i < numberOfNpcs; i++)
{
npcs.Add(
npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, scene, sp.Appearance));
}
for (int i = 0; i < numberOfNpcs; i++)
{
Assert.That(npcs[i], Is.Not.Null);
ScenePresence npc = scene.GetScenePresence(npcs[i]);
Assert.That(npc, Is.Not.Null);
}
for (int i = 0; i < numberOfNpcs; i++)
{
Assert.That(npcModule.DeleteNPC(npcs[i], scene), Is.True);
ScenePresence npc = scene.GetScenePresence(npcs[i]);
Assert.That(npc, Is.Null);
}
sw.Stop();
long endGcMemory = GC.GetTotalMemory(true);
Console.WriteLine("Took {0} ms", sw.ElapsedMilliseconds);
Console.WriteLine(
"End {0} MB, Start {1} MB, Diff {2} MB",
endGcMemory / 1024 / 1024,
startGcMemory / 1024 / 1024,
(endGcMemory - startGcMemory) / 1024 / 1024);
}
示例7: 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");
}
}
示例8: AssignSingleMaterial
/// <summary>
/// Assign a single material value. Based on the values passed we'll either set (or clear) the materials for a SOP.
/// </summary>
/// <param name="sop">The SOP being affected.</param>
/// <param name="face">The face to assign, or -1 if the default texture is being set.</param>
/// <param name="id">The ID assigned to this material. Setting a Zero UUID clears it.</param>
/// <param name="material">If not null, the material to set. Otherwise we are clearing.</param>
private void AssignSingleMaterial(SceneObjectPart sop, int face, OSDMap matData)
{
UUID id = UUID.Zero;
// If there is a material being set, see if we've seen it before.
// If not we'll add it to the Shape RenderMaterials and the region cache
if (matData != null)
{
RenderMaterial material = RenderMaterial.FromOSD(matData);
id = sop.Shape.RenderMaterials.AddMaterial(material);
m_scene.EventManager.TriggerRenderMaterialAddedToPrim(sop, id, material);
m_log.DebugFormat("[RenderMaterials]: SOP {0}, Face {1}, Adding RenderMaterial {2}",
sop.LocalId, face, material.ToString());
}
// If the new material is replacing one lets record it so we can clean up
UUID oldMaterialID = UUID.Zero;
/// Get a copy of the texture entry so we can make changes.
var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
// Set the Material ID in the TextureEntry. If face is ALL_SIDES then
// set the default entry, otherwise fetch the face and set it there.
if (face < 0)
{
oldMaterialID = te.DefaultTexture.MaterialID;
te.DefaultTexture.MaterialID = id;
}
else
{
var faceEntry = te.CreateFace((uint)face);
oldMaterialID = faceEntry.MaterialID;
faceEntry.MaterialID = id;
}
// Update the texture entry which will force an update to connected clients
sop.UpdateTexture(te);
// If the material has changed and it wasn't previously Zero
// Deallocate the old value if its not in use and signal the change
if ((oldMaterialID != id) &&
(oldMaterialID != UUID.Zero))
{
var currentMaterialIDs = sop.Shape.GetMaterialIDs();
if (currentMaterialIDs.Contains(oldMaterialID) == false)
{
if (sop.Shape.RenderMaterials.ContainsMaterial(oldMaterialID) == true)
sop.Shape.RenderMaterials.RemoveMaterial(oldMaterialID);
m_scene.EventManager.TriggerRenderMaterialRemovedFromPrim(sop, oldMaterialID);
}
}
}
示例9: ProcessAdd
//.........这里部分代码省略.........
pbs.PathScaleY = (byte) obj.ScaleY;
pbs.PathShearX = (byte) obj.ShearX;
pbs.PathShearY = (byte) obj.ShearY;
pbs.PathSkew = (sbyte) obj.Skew;
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 = 0;
SceneObjectPart prim = new SceneObjectPart(AgentId, pbs, obj.Position, obj.Rotation,
Vector3.Zero, obj.Name)
{
UUID = UUID.Random(),
CreatorID = AgentId,
OwnerID = AgentId,
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(prim, m_scene);
prim.ParentID = 0;
if (i == 0)
rootGroup = grp;
grp.AbsolutePosition = obj.Position;
prim.SetRotationOffset(true, obj.Rotation, true);
grp.RootPart.IsAttachment = false;
string reason;
if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos, out reason))
{
m_scene.SceneGraph.AddPrimToScene(grp);
grp.AbsolutePosition = obj.Position;
}
else
{
//Stop now then
avatar.ControllingClient.SendAlertMessage("You do not have permission to rez objects here: " +
reason);
return MainServer.BlankResponse;
}
allparts[i] = grp;
}
for (int j = 1; j < allparts.Length; j++)
{
rootGroup.LinkToGroup(allparts[j]);
}
rootGroup.ScheduleGroupUpdate(PrimUpdateFlags.ForcedFullUpdate);
pos = m_scene.SceneGraph.GetNewRezLocation(Vector3.Zero, rootpos, UUID.Zero, rot, 1, 1, true,
allparts[0].GroupScale(), false);
OSDMap map = new OSDMap();
map["local_id"] = allparts[0].LocalId;
return OSDParser.SerializeLLSDXmlBytes(map);
}
示例10: TestCreate
public void TestCreate()
{
TestHelpers.InMethod();
// log4net.Config.XmlConfigurator.Configure();
ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
// 8 is the index of the first baked texture in AvatarAppearance
UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
originalTef.TextureID = originalFace8TextureId;
// We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
// ScenePresence.SendInitialData() to reset our entire appearance.
m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
m_afMod.SetAppearance(sp, originalTe, null, null);
UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance);
ScenePresence npc = m_scene.GetScenePresence(npcId);
Assert.That(npc, Is.Not.Null);
Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId));
Assert.That(m_umMod.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
IClientAPI client;
Assert.That(m_scene.TryGetClient(npcId, out client), Is.True);
// Have to account for both SP and NPC.
Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(2));
}
示例11: 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;
}
}
示例12: GetDefaultTexture
public static Primitive.TextureEntry GetDefaultTexture()
{
Primitive.TextureEntry textu = new Primitive.TextureEntry(new UUID("C228D1CF-4B5D-4BA8-84F4-899A0796AA97"));
textu.CreateFace(0).TextureID = new UUID("00000000-0000-1111-9999-000000000012");
textu.CreateFace(1).TextureID = Util.BLANK_TEXTURE_UUID;
textu.CreateFace(2).TextureID = Util.BLANK_TEXTURE_UUID;
textu.CreateFace(3).TextureID = new UUID("6522E74D-1660-4E7F-B601-6F48C1659A77");
textu.CreateFace(4).TextureID = new UUID("7CA39B4C-BD19-4699-AFF7-F93FD03D3E7B");
textu.CreateFace(5).TextureID = new UUID("00000000-0000-1111-9999-000000000010");
textu.CreateFace(6).TextureID = new UUID("00000000-0000-1111-9999-000000000011");
return textu;
}
示例13: TestSetAppearanceAlphaBakedTextures
public void TestSetAppearanceAlphaBakedTextures()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID userId = TestHelpers.ParseTail(0x1);
UUID alphaTextureID = new UUID("3a367d1c-bef1-6d43-7595-e88c1e3aadb3");
// We need an asset cache because otherwise the LocalAssetServiceConnector will short-circuit directly
// to the AssetService, which will then store temporary and local assets permanently
CoreAssetCache assetCache = new CoreAssetCache();
AvatarFactoryModule afm = new AvatarFactoryModule();
TestScene scene = new SceneHelpers(assetCache).SetupScene();
SceneHelpers.SetupSceneModules(scene, afm);
ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);
AssetBase libraryAsset;
libraryAsset
= new AssetBase(
alphaTextureID, "Default Alpha Layer Texture", (sbyte)AssetType.Texture, userId.ToString());
libraryAsset.Data = new byte[] { 2 }; // Not necessary to have a genuine JPEG2000 asset here yet
libraryAsset.Temporary = false;
libraryAsset.Local = false;
scene.AssetService.Store(libraryAsset);
byte[] visualParams = new byte[AvatarAppearance.VISUALPARAM_COUNT];
for (byte i = 0; i < visualParams.Length; i++)
visualParams[i] = i;
Primitive.TextureEntry bakedTextureEntry = new Primitive.TextureEntry(TestHelpers.ParseTail(0x10));
uint eyesFaceIndex = (uint)AppearanceManager.BakeTypeToAgentTextureIndex(BakeType.Eyes);
Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex);
int rebakeRequestsReceived = 0;
((TestClient)sp.ControllingClient).OnReceivedSendRebakeAvatarTextures += id => rebakeRequestsReceived++;
// This is the alpha texture
eyesFace.TextureID = alphaTextureID;
afm.SetAppearance(sp, bakedTextureEntry, visualParams, null);
Assert.That(rebakeRequestsReceived, Is.EqualTo(0));
}
示例14: AssignSingleMaterial
/// <summary>
/// Assign a single material value. Based on the values passed we'll either set (or clear) the materials for a SOP.
/// </summary>
/// <param name="sop">The SOP being affected.</param>
/// <param name="face">The face to assign, or -1 if the default texture is being set.</param>
/// <param name="id">The ID assigned to this material. Setting a Zero UUID clears it.</param>
/// <param name="material">If not null, the material to set. Otherwise we are clearing.</param>
private void AssignSingleMaterial(SceneObjectPart sop, int face, OSDMap matData)
{
/// Get a copy of the texture entry so we can make changes.
var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
if (te == null)
{
m_log.Warn("[RenderMaterials]: null TextureEntry for localId: " + sop.LocalId.ToString());
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))
//.........这里部分代码省略.........
示例15: MakeAppearancePacket
//.........这里部分代码省略.........
case 682:
agentSizeVPHeadSize = paramValue;
break;
case 692:
agentSizeVPLegLength = paramValue;
break;
case 756:
agentSizeVPNeckLength = paramValue;
break;
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;