<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Adam Frisby &#187; openmetaverse</title>
	<atom:link href="http://www.adamfrisby.com/blog/tag/openmetaverse/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.adamfrisby.com/blog</link>
	<description>ZOMGWTFHAI</description>
	<lastBuildDate>Sat, 26 Dec 2009 07:02:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Code Snippet: Converting OpenMetaverse.Primitive to OpenSimulator.SceneObjectPart</title>
		<link>http://www.adamfrisby.com/blog/2008/10/code-snippet-converting-openmetaverseprimitive-to-opensimulatorsceneobjectpart/</link>
		<comments>http://www.adamfrisby.com/blog/2008/10/code-snippet-converting-openmetaverseprimitive-to-opensimulatorsceneobjectpart/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 08:51:21 +0000</pubDate>
		<dc:creator>Adam Frisby</dc:creator>
				<category><![CDATA[OpenSim]]></category>
		<category><![CDATA[openmetaverse]]></category>
		<category><![CDATA[primitive]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://www.adamfrisby.com/blog/?p=79</guid>
		<description><![CDATA[Pardon this being a code-only post, but I figured it might be useful to anyone doing work with both OpenMetaverse and OpenSim &#8211; currently we store primitive data in a fairly different manner internally, this code converts between the two, and allows you to take a OpenMV.Primitive and get a OpenSim SOP out of it.

 [...]]]></description>
			<content:encoded><![CDATA[<p>Pardon this being a code-only post, but I figured it might be useful to anyone doing work with both OpenMetaverse and OpenSim &#8211; currently we store primitive data in a fairly different manner internally, this code converts between the two, and allows you to take a OpenMV.Primitive and get a OpenSim SOP out of it.</p>
<textarea name="code" class="C#:nocontrols" cols="60" rows="10">
        private SceneObjectPart FromPrim(Primitive orig)
        {
            bool root = orig.ParentID == 0;

            SceneObjectPart sop = new SceneObjectPart();
            sop.LastOwnerID = orig.OwnerID;
            sop.OwnerID = orig.OwnerID;
            sop.GroupID = orig.GroupID;

            sop.CreatorID = orig.Properties.CreatorID;

            sop.OwnershipCost = orig.Properties.OwnershipCost;
            sop.ObjectSaleType = (byte)orig.Properties.SaleType;
            sop.SalePrice = orig.Properties.SalePrice;
            sop.CreationDate = (int)Utils.DateTimeToUnixTime(orig.Properties.CreationDate);

            // Special
            sop.ParentID = 0;

            sop.OwnerMask = (uint)orig.Properties.Permissions.OwnerMask;
            sop.NextOwnerMask = (uint)orig.Properties.Permissions.NextOwnerMask;
            sop.GroupMask = (uint)orig.Properties.Permissions.GroupMask;
            sop.EveryoneMask = (uint)orig.Properties.Permissions.EveryoneMask;
            sop.BaseMask = (uint)orig.Properties.Permissions.BaseMask;

            sop.ParticleSystem = orig.ParticleSys.GetBytes();

            // OS only
            sop.TimeStampFull = 0;
            sop.TimeStampLastActivity = 0;
            sop.TimeStampTerse = 0;

            // Not sure nessecary
            sop.UpdateFlag = 2;

            sop.InventorySerial = 0;
            sop.UUID = orig.ID;
            sop.LocalId = orig.LocalID;
            sop.Name = orig.Properties.Name;
            sop.Flags = orig.Flags;
            sop.Material = 0;
            sop.RegionHandle = orig.RegionHandle;

            sop.GroupPosition = orig.Position;

            if (!root)
                sop.OffsetPosition = orig.Position;
            else
                sop.OffsetPosition = Vector3.Zero;

            sop.RotationOffset = orig.Rotation;
            sop.Velocity = orig.Velocity;
            sop.RotationalVelocity = Vector3.Zero;
            sop.AngularVelocity = Vector3.Zero;
            sop.Acceleration = Vector3.Zero;

            sop.Description = orig.Properties.Description;
            sop.Color = Color.White;
            sop.Text = orig.Text;
            sop.SitName = orig.Properties.SitName;
            sop.TouchName = orig.Properties.TouchName;
            sop.ClickAction = (byte)orig.ClickAction;

            sop.PayPrice = new int[1];

            sop.Shape = new PrimitiveBaseShape(true);
            sop.Shape.FlexiDrag = orig.Flexible.Drag;
            sop.Shape.FlexiEntry = false;
            sop.Shape.FlexiForceX = orig.Flexible.Force.X;
            sop.Shape.FlexiForceY = orig.Flexible.Force.Y;
            sop.Shape.FlexiForceZ = orig.Flexible.Force.Z;
            sop.Shape.FlexiGravity = orig.Flexible.Gravity;
            sop.Shape.FlexiSoftness = orig.Flexible.Softness;
            sop.Shape.FlexiTension = orig.Flexible.Tension;
            sop.Shape.FlexiWind = orig.Flexible.Wind;

            switch (orig.PrimData.ProfileHole)
            {
                case HoleType.Circle:
                    sop.Shape.HollowShape = HollowShape.Circle;
                    break;
                case HoleType.Square:
                    sop.Shape.HollowShape = HollowShape.Square;
                    break;
                case HoleType.Triangle:
                    sop.Shape.HollowShape = HollowShape.Triangle;
                    break;
                default:
                case HoleType.Same:
                    sop.Shape.HollowShape = HollowShape.Same;
                    break;
            }

            sop.Shape.LightColorA = orig.Light.Color.A;
            sop.Shape.LightColorB = orig.Light.Color.B;
            sop.Shape.LightColorG = orig.Light.Color.G;
            sop.Shape.LightColorR = orig.Light.Color.R;
            sop.Shape.LightCutoff = orig.Light.Cutoff;
            sop.Shape.LightEntry = false;
            sop.Shape.LightFalloff = orig.Light.Falloff;
            sop.Shape.LightIntensity = orig.Light.Intensity;
            sop.Shape.LightRadius = orig.Light.Radius;


            sop.Shape.PathBegin = Primitive.PackBeginCut(orig.PrimData.PathBegin);
            sop.Shape.PathCurve = (byte)orig.PrimData.PathCurve;
            sop.Shape.PathEnd = Primitive.PackEndCut(orig.PrimData.PathEnd);
            sop.Shape.PathRadiusOffset = Primitive.PackPathTwist(orig.PrimData.PathRadiusOffset);
            sop.Shape.PathRevolutions = Primitive.PackPathRevolutions(orig.PrimData.PathRevolutions);
            sop.Shape.PathScaleX = Primitive.PackPathScale(orig.PrimData.PathScaleX);
            sop.Shape.PathScaleY = Primitive.PackPathScale(orig.PrimData.PathScaleY);
            sop.Shape.PathShearX = (byte)Primitive.PackPathShear(orig.PrimData.PathShearX);
            sop.Shape.PathShearY = (byte)Primitive.PackPathShear(orig.PrimData.PathShearY);
            sop.Shape.PathSkew = Primitive.PackPathTwist(orig.PrimData.PathSkew);
            sop.Shape.PathTaperX = Primitive.PackPathTaper(orig.PrimData.PathTaperX);
            sop.Shape.PathTaperY = Primitive.PackPathTaper(orig.PrimData.PathTaperY);
            sop.Shape.PathTwist = Primitive.PackPathTwist(orig.PrimData.PathTwist);
            sop.Shape.PathTwistBegin = Primitive.PackPathTwist(orig.PrimData.PathTwistBegin);
            sop.Shape.PCode = (byte)orig.PrimData.PCode;
            sop.Shape.ProfileBegin = Primitive.PackBeginCut(orig.PrimData.ProfileBegin);
            sop.Shape.ProfileCurve = orig.PrimData.profileCurve;
            sop.Shape.ProfileEnd = Primitive.PackEndCut(orig.PrimData.ProfileEnd);
            sop.Shape.ProfileHollow = Primitive.PackProfileHollow(orig.PrimData.ProfileHollow);
            sop.Shape.ProfileShape = (ProfileShape)(byte)orig.PrimData.ProfileCurve;

            sop.Shape.Textures = orig.Textures;

            return sop;
        }
</textarea>
]]></content:encoded>
			<wfw:commentRss>http://www.adamfrisby.com/blog/2008/10/code-snippet-converting-openmetaverseprimitive-to-opensimulatorsceneobjectpart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
