This code converts allows to take a OpenMV.Primitive and get a OpenSim SOP
1. private SceneObjectPart FromPrim(Primitive orig)
2. {
3. bool root = orig.ParentID == 0;
4.
5. SceneObjectPart sop = new SceneObjectPart();
6. sop.LastOwnerID = orig.OwnerID;
7. sop.OwnerID = orig.OwnerID;
8. sop.GroupID = orig.GroupID;
9.
10. sop.CreatorID = orig.Properties.CreatorID;
11.
12. sop.OwnershipCost = orig.Properties.OwnershipCost;
13. sop.ObjectSaleType = (byte)orig.Properties.SaleType;
14. sop.SalePrice = orig.Properties.SalePrice;
15. sop.CreationDate = (int)Utils.DateTimeToUnixTime(orig.Properties.CreationDate);
16.
17. // Special
18. sop.ParentID = 0;
19.
20. sop.OwnerMask = (uint)orig.Properties.Permissions.OwnerMask;
21. sop.NextOwnerMask = (uint)orig.Properties.Permissions.NextOwnerMask;
22. sop.GroupMask = (uint)orig.Properties.Permissions.GroupMask;
23. sop.EveryoneMask = (uint)orig.Properties.Permissions.EveryoneMask;
24. sop.BaseMask = (uint)orig.Properties.Permissions.BaseMask;
25.
26. sop.ParticleSystem = orig.ParticleSys.GetBytes();
27.
28. // OS only
29. sop.TimeStampFull = 0;
30. sop.TimeStampLastActivity = 0;
31. sop.TimeStampTerse = 0;
32.
33. // Not sure nessecary
34. sop.UpdateFlag = 2;
35.
36. sop.InventorySerial = 0;
37. sop.UUID = orig.ID;
38. sop.LocalId = orig.LocalID;
39. sop.Name = orig.Properties.Name;
40. sop.Flags = orig.Flags;
41. sop.Material = 0;
42. sop.RegionHandle = orig.RegionHandle;
43.
44. sop.GroupPosition = orig.Position;
45.
46. if (!root)
47. sop.OffsetPosition = orig.Position;
48. else
49. sop.OffsetPosition = Vector3.Zero;
50.
51. sop.RotationOffset = orig.Rotation;
52. sop.Velocity = orig.Velocity;
53. sop.RotationalVelocity = Vector3.Zero;
54. sop.AngularVelocity = Vector3.Zero;
55. sop.Acceleration = Vector3.Zero;
56.
57. sop.Description = orig.Properties.Description;
58. sop.Color = Color.White;
59. sop.Text = orig.Text;
60. sop.SitName = orig.Properties.SitName;
61. sop.TouchName = orig.Properties.TouchName;
62. sop.ClickAction = (byte)orig.ClickAction;
63.
64. sop.PayPrice = new int[1];
65.
66. sop.Shape = new PrimitiveBaseShape(true);
67. sop.Shape.FlexiDrag = orig.Flexible.Drag;
68. sop.Shape.FlexiEntry = false;
69. sop.Shape.FlexiForceX = orig.Flexible.Force.X;
70. sop.Shape.FlexiForceY = orig.Flexible.Force.Y;
71. sop.Shape.FlexiForceZ = orig.Flexible.Force.Z;
72. sop.Shape.FlexiGravity = orig.Flexible.Gravity;
73. sop.Shape.FlexiSoftness = orig.Flexible.Softness;
74. sop.Shape.FlexiTension = orig.Flexible.Tension;
75. sop.Shape.FlexiWind = orig.Flexible.Wind;
76.
77. switch (orig.PrimData.ProfileHole)
78. {
79. case HoleType.Circle:
80. sop.Shape.HollowShape = HollowShape.Circle;
81. break;
82. case HoleType.Square:
83. sop.Shape.HollowShape = HollowShape.Square;
84. break;
85. case HoleType.Triangle:
86. sop.Shape.HollowShape = HollowShape.Triangle;
87. break;
88. default:
89. case HoleType.Same:
90. sop.Shape.HollowShape = HollowShape.Same;
91. break;
92. }
93.
94. sop.Shape.LightColorA = orig.Light.Color.A;
95. sop.Shape.LightColorB = orig.Light.Color.B;
96. sop.Shape.LightColorG = orig.Light.Color.G;
97. sop.Shape.LightColorR = orig.Light.Color.R;
98. sop.Shape.LightCutoff = orig.Light.Cutoff;
99. sop.Shape.LightEntry = false;
100. sop.Shape.LightFalloff = orig.Light.Falloff;
101. sop.Shape.LightIntensity = orig.Light.Intensity;
102. sop.Shape.LightRadius = orig.Light.Radius;
103.
104.
105. sop.Shape.PathBegin = Primitive.PackBeginCut(orig.PrimData.PathBegin);
106. sop.Shape.PathCurve = (byte)orig.PrimData.PathCurve;
107. sop.Shape.PathEnd = Primitive.PackEndCut(orig.PrimData.PathEnd);
108. sop.Shape.PathRadiusOffset = Primitive.PackPathTwist(orig.PrimData.PathRadiusOffset);
109. sop.Shape.PathRevolutions = Primitive.PackPathRevolutions(orig.PrimData.PathRevolutions);
110. sop.Shape.PathScaleX = Primitive.PackPathScale(orig.PrimData.PathScaleX);
111. sop.Shape.PathScaleY = Primitive.PackPathScale(orig.PrimData.PathScaleY);
112. sop.Shape.PathShearX = (byte)Primitive.PackPathShear(orig.PrimData.PathShearX);
113. sop.Shape.PathShearY = (byte)Primitive.PackPathShear(orig.PrimData.PathShearY);
114. sop.Shape.PathSkew = Primitive.PackPathTwist(orig.PrimData.PathSkew);
115. sop.Shape.PathTaperX = Primitive.PackPathTaper(orig.PrimData.PathTaperX);
116. sop.Shape.PathTaperY = Primitive.PackPathTaper(orig.PrimData.PathTaperY);
117. sop.Shape.PathTwist = Primitive.PackPathTwist(orig.PrimData.PathTwist);
118. sop.Shape.PathTwistBegin = Primitive.PackPathTwist(orig.PrimData.PathTwistBegin);
119. sop.Shape.PCode = (byte)orig.PrimData.PCode;
120. sop.Shape.ProfileBegin = Primitive.PackBeginCut(orig.PrimData.ProfileBegin);
121. sop.Shape.ProfileCurve = orig.PrimData.profileCurve;
122. sop.Shape.ProfileEnd = Primitive.PackEndCut(orig.PrimData.ProfileEnd);
123. sop.Shape.ProfileHollow = Primitive.PackProfileHollow(orig.PrimData.ProfileHollow);
124. sop.Shape.ProfileShape = (ProfileShape)(byte)orig.PrimData.ProfileCurve;
125.
126. sop.Shape.Textures = orig.Textures;
127.
128. return sop;
129. }
Source http://www.adamfrisby.com