当前位置: 首页>>代码示例>>C#>>正文


C# Primitive.TextureEntry.ToBytes方法代码示例

本文整理汇总了C#中OpenMetaverse.Primitive.TextureEntry.ToBytes方法的典型用法代码示例。如果您正苦于以下问题:C# Primitive.TextureEntry.ToBytes方法的具体用法?C# Primitive.TextureEntry.ToBytes怎么用?C# Primitive.TextureEntry.ToBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenMetaverse.Primitive.TextureEntry的用法示例。


在下文中一共展示了Primitive.TextureEntry.ToBytes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TextureEntry

        public void TextureEntry()
        {
            Primitive.TextureEntry te = new Primitive.TextureEntry(Guid.NewGuid());
            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 = Guid.NewGuid();

            byte[] teBytes = te.ToBytes();

            Primitive.TextureEntry te2 = new Primitive.TextureEntry(teBytes, 0, teBytes.Length);

            byte[] teBytes2 = te2.ToBytes();

            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");
            }
        }
开发者ID:RavenB,项目名称:gridsearch,代码行数:30,代码来源:PrimObjectTests.cs

示例2: SendAgentSetAppearance


//.........这里部分代码省略.........
                                    case 692:
                                        AgentSizeVPLegLength = data.Asset.Params[vp.ParamID];
                                        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] != Guid.Empty)
                        {
                            Primitive.TextureEntryFace face = te.CreateFace(i);
                            face.TextureID = AgentTextures[i];
                        }
                    }
                }

                foreach (WearableData data in Wearables.Dictionary.Values)
                {
                    if (data.Asset != null)
                    {
                        foreach (KeyValuePair<TextureIndex, Guid> texture in data.Asset.Textures)
                        {
                            Primitive.TextureEntryFace face = te.CreateFace((uint)texture.Key);
                            face.TextureID = texture.Value;

                            Logger.DebugLog("Setting agent texture " + ((TextureIndex)texture.Key).ToString() + " to " +
                                texture.Value.ToString(), Client);
                        }
                    }
                }

                // Set the packet TextureEntry
                set.ObjectData.TextureEntry = te.ToBytes();
            }

            // 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 Vector3f(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++)
            {
                Guid hash = new Guid();

                for (int wearableIndex = 0; wearableIndex < WEARABLES_PER_LAYER; wearableIndex++)
                {
                    WearableType type = WEARABLE_BAKE_MAP[bakedIndex][wearableIndex];
                    Guid assetID = GetWearableAsset(type);

                    // Build a hash of all the texture asset IDs in this baking layer
                    if (assetID != Guid.Empty) hash.Xor(assetID);
                }

                if (hash != Guid.Empty)
                {
                    // Hash with our secret value for this baked layer
                    hash.Xor(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;
            }

            // Finally, send the packet
            Client.Network.SendPacket(set);
        }
开发者ID:RavenB,项目名称:gridsearch,代码行数:101,代码来源:AppearanceManager.cs


注:本文中的OpenMetaverse.Primitive.TextureEntry.ToBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。