// Prim type torus, tube and ring. protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte profileshape, byte pathcurve) { float tempFloat; // Use in float expressions below to avoid byte cast precision issues. ObjectShapePacket.ObjectDataBlock shapeBlock; shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); // profile/path swapped for a torrus, tube, ring shapeBlock.PathBegin = shapeBlock.ProfileBegin; shapeBlock.PathEnd = shapeBlock.ProfileEnd; if (holesize.x < 0.05f) { holesize.x = 0.05f; } if (holesize.x > 1f) { holesize.x = 1f; } if (holesize.y < 0.05f) { holesize.y = 0.05f; } if (holesize.y > 0.5f) { holesize.y = 0.5f; } tempFloat = (float)(100.0d * (2.0d - holesize.x)); shapeBlock.PathScaleX = (byte)tempFloat; tempFloat = (float)(100.0d * (2.0d - holesize.y)); shapeBlock.PathScaleY = (byte)tempFloat; if (topshear.x < -0.5f) { topshear.x = -0.5f; } if (topshear.x > 0.5f) { topshear.x = 0.5f; } if (topshear.y < -0.5f) { topshear.y = -0.5f; } if (topshear.y > 0.5f) { topshear.y = 0.5f; } tempFloat = (float)(100.0d * topshear.x); shapeBlock.PathShearX = (byte)tempFloat; tempFloat = (float)(100.0d * topshear.y); shapeBlock.PathShearY = (byte)tempFloat; if (profilecut.x < 0f) { profilecut.x = 0f; } if (profilecut.x > 1f) { profilecut.x = 1f; } if (profilecut.y < 0f) { profilecut.y = 0f; } if (profilecut.y > 1f) { profilecut.y = 1f; } if (profilecut.y - profilecut.x < 0.05f) { profilecut.x = profilecut.y - 0.05f; if (profilecut.x < 0.0f) { profilecut.x = 0.0f; profilecut.y = 0.05f; } } shapeBlock.ProfileBegin = (ushort)(50000 * profilecut.x); shapeBlock.ProfileEnd = (ushort)(50000 * (1 - profilecut.y)); if (taper_a.x < -1f) { taper_a.x = -1f; } if (taper_a.x > 1f) { taper_a.x = 1f; } if (taper_a.y < -1f) { taper_a.y = -1f; } if (taper_a.y > 1f) { taper_a.y = 1f; } tempFloat = (float)(100.0d * taper_a.x); shapeBlock.PathTaperX = (sbyte)tempFloat; tempFloat = (float)(100.0d * taper_a.y); shapeBlock.PathTaperY = (sbyte)tempFloat; if (revolutions < 1f) { revolutions = 1f; } if (revolutions > 4f) { revolutions = 4f; } tempFloat = 66.66667f * (revolutions - 1.0f); shapeBlock.PathRevolutions = (byte)tempFloat; // limits on radiusoffset depend on revolutions and hole size (how?) seems like the maximum range is 0 to 1 if (radiusoffset < 0f) { radiusoffset = 0f; } if (radiusoffset > 1f) { radiusoffset = 1f; } tempFloat = 100.0f * radiusoffset; shapeBlock.PathRadiusOffset = (sbyte)tempFloat; if (skew < -0.95f) { skew = -0.95f; } if (skew > 0.95f) { skew = 0.95f; } tempFloat = 100.0f * skew; shapeBlock.PathSkew = (sbyte)tempFloat; part.Shape.SculptEntry = false; part.UpdateShape(shapeBlock); }
// Prim type sculpt. protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) { ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); UUID sculptId; if (!UUID.TryParse(map, out sculptId)) { sculptId = InventoryKey(map, (int)AssetType.Texture); } if (sculptId == UUID.Zero) return; shapeBlock.PathCurve = pathcurve; shapeBlock.ObjectLocalID = part.LocalId; shapeBlock.PathScaleX = 100; shapeBlock.PathScaleY = 150; int flag = type & (ScriptBaseClass.PRIM_SCULPT_FLAG_INVERT | ScriptBaseClass.PRIM_SCULPT_FLAG_MIRROR); if (type != (ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER | flag) && type != (ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE | flag) && type != (ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE | flag) && type != (ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS | flag)) { // default type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; } part.Shape.SetSculptProperties((byte)type, sculptId); part.Shape.SculptEntry = true; part.UpdateShape(shapeBlock); }
// Prim type sphere. protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) { ObjectShapePacket.ObjectDataBlock shapeBlock; shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); // profile/path swapped for a sphere shapeBlock.PathBegin = shapeBlock.ProfileBegin; shapeBlock.PathEnd = shapeBlock.ProfileEnd; shapeBlock.PathScaleX = 100; shapeBlock.PathScaleY = 100; if (dimple.x < 0f) { dimple.x = 0f; } if (dimple.x > 1f) { dimple.x = 1f; } if (dimple.y < 0f) { dimple.y = 0f; } if (dimple.y > 1f) { dimple.y = 1f; } if (dimple.y - cut.x < 0.05f) { dimple.x = cut.y - 0.05f; } shapeBlock.ProfileBegin = (ushort)(50000 * dimple.x); shapeBlock.ProfileEnd = (ushort)(50000 * (1 - dimple.y)); part.Shape.SculptEntry = false; part.UpdateShape(shapeBlock); }
// Prim type box, cylinder and prism. protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte profileshape, byte pathcurve) { float tempFloat; // Use in float expressions below to avoid byte cast precision issues. ObjectShapePacket.ObjectDataBlock shapeBlock; shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); if (taper_b.x < 0f) { taper_b.x = 0f; } if (taper_b.x > 2f) { taper_b.x = 2f; } if (taper_b.y < 0f) { taper_b.y = 0f; } if (taper_b.y > 2f) { taper_b.y = 2f; } tempFloat = (float)(100.0d * (2.0d - taper_b.x)); shapeBlock.PathScaleX = (byte)tempFloat; tempFloat = (float)(100.0d * (2.0d - taper_b.y)); shapeBlock.PathScaleY = (byte)tempFloat; if (topshear.x < -0.5f) { topshear.x = -0.5f; } if (topshear.x > 0.5f) { topshear.x = 0.5f; } if (topshear.y < -0.5f) { topshear.y = -0.5f; } if (topshear.y > 0.5f) { topshear.y = 0.5f; } tempFloat = (float)(100.0d * topshear.x); shapeBlock.PathShearX = (byte)tempFloat; tempFloat = (float)(100.0d * topshear.y); shapeBlock.PathShearY = (byte)tempFloat; part.Shape.SculptEntry = false; part.UpdateShape(shapeBlock); }
protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) { ObjectShapePacket.ObjectDataBlock shapeBlock; shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); shapeBlock.ProfileCurve += fudge; if (taper_b.x < 0f) { taper_b.x = 0f; } if (taper_b.x > 2f) { taper_b.x = 2f; } if (taper_b.y < 0f) { taper_b.y = 0f; } if (taper_b.y > 2f) { taper_b.y = 2f; } shapeBlock.PathScaleX = (byte)(100 * (2.0 - taper_b.x)); shapeBlock.PathScaleY = (byte)(100 * (2.0 - taper_b.y)); if (topshear.x < -0.5f) { topshear.x = -0.5f; } if (topshear.x > 0.5f) { topshear.x = 0.5f; } if (topshear.y < -0.5f) { topshear.y = -0.5f; } if (topshear.y > 0.5f) { topshear.y = 0.5f; } shapeBlock.PathShearX = (byte)(100 * topshear.x); shapeBlock.PathShearY = (byte)(100 * topshear.y); part.Shape.SculptEntry = false; part.UpdateShape(shapeBlock); }
protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte fudge) { ObjectShapePacket.ObjectDataBlock shapeBlock; shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); shapeBlock.ProfileCurve += fudge; // profile/path swapped for a torrus, tube, ring shapeBlock.PathBegin = shapeBlock.ProfileBegin; shapeBlock.PathEnd = shapeBlock.ProfileEnd; if (holesize.x < 0.05f) { holesize.x = 0.05f; } if (holesize.x > 1f) { holesize.x = 1f; } if (holesize.y < 0.05f) { holesize.y = 0.05f; } if (holesize.y > 0.5f) { holesize.y = 0.5f; } shapeBlock.PathScaleX = (byte)(100 * (2 - holesize.x)); shapeBlock.PathScaleY = (byte)(100 * (2 - holesize.y)); if (topshear.x < -0.5f) { topshear.x = -0.5f; } if (topshear.x > 0.5f) { topshear.x = 0.5f; } if (topshear.y < -0.5f) { topshear.y = -0.5f; } if (topshear.y > 0.5f) { topshear.y = 0.5f; } shapeBlock.PathShearX = (byte)(100 * topshear.x); shapeBlock.PathShearY = (byte)(100 * topshear.y); if (profilecut.x < 0f) { profilecut.x = 0f; } if (profilecut.x > 1f) { profilecut.x = 1f; } if (profilecut.y < 0f) { profilecut.y = 0f; } if (profilecut.y > 1f) { profilecut.y = 1f; } if (profilecut.y - cut.x < 0.05f) { profilecut.x = cut.y - 0.05f; } shapeBlock.ProfileBegin = (ushort)(50000 * profilecut.x); shapeBlock.ProfileEnd = (ushort)(50000 * (1 - profilecut.y)); if (taper_a.x < -1f) { taper_a.x = -1f; } if (taper_a.x > 1f) { taper_a.x = 1f; } if (taper_a.y < -1f) { taper_a.y = -1f; } if (taper_a.y > 1f) { taper_a.y = 1f; } shapeBlock.PathTaperX = (sbyte)(100 * taper_a.x); shapeBlock.PathTaperY = (sbyte)(100 * taper_a.y); if (revolutions < 1f) { revolutions = 1f; } if (revolutions > 4f) { revolutions = 4f; } shapeBlock.PathRevolutions = (byte)(66.666667 * (revolutions - 1.0)); // limits on radiusoffset depend on revolutions and hole size (how?) seems like the maximum range is 0 to 1 if (radiusoffset < 0f) { radiusoffset = 0f; } if (radiusoffset > 1f) { radiusoffset = 1f; } shapeBlock.PathRadiusOffset = (sbyte)(100 * radiusoffset); if (skew < -0.95f) { skew = -0.95f; } if (skew > 0.95f) { skew = 0.95f; } shapeBlock.PathSkew = (sbyte)(100 * skew); part.Shape.SculptEntry = false; part.UpdateShape(shapeBlock); }
protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) { ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); UUID sculptId; if (!UUID.TryParse(map, out sculptId)) { sculptId = InventoryKey(map, (int)AssetType.Texture); } if (sculptId == UUID.Zero) return; shapeBlock.ObjectLocalID = part.LocalId; shapeBlock.PathScaleX = 100; shapeBlock.PathScaleY = 150; int onlytype = (type & 7);//Removes the sculpt flags according to libOMV if (onlytype != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_CYLINDER && onlytype != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_PLANE && onlytype != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE && onlytype != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_TORUS && onlytype != (int)ScriptBaseClass.PRIM_SCULPT_TYPE_MESH) { // default type |= (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; } // retain pathcurve shapeBlock.PathCurve = part.Shape.PathCurve; part.Shape.SetSculptProperties((byte)type, sculptId); part.Shape.SculptEntry = true; part.UpdateShape(shapeBlock); }