public bool Run() { m_Log.Info("Test num of faces 1 encoding"); bool success = true; ObjectPart.PrimitiveShape shape = new ObjectPart.PrimitiveShape { PCode = PrimitiveCode.Prim, ProfileCurve = (byte)PrimitiveProfileShape.Circle, PathCurve = (byte)PrimitiveExtrusion.Curve1, PathScaleX = 100, PathScaleY = 150 }; if (!shape.IsSane) { m_Log.Error("faces 1 encoding not sane"); success = false; } if (shape.NumberOfSides != 1) { m_Log.Error("faces 1 encoding not showing 1 faces"); success = false; } m_Log.Info("Test num of faces 2 encoding"); shape = new ObjectPart.PrimitiveShape { PCode = PrimitiveCode.Prim, ProfileCurve = (byte)PrimitiveProfileShape.Circle, PathCurve = (byte)PrimitiveExtrusion.Curve1, ProfileHollow = 27500, PathScaleX = 100, PathScaleY = 150 }; if (!shape.IsSane) { m_Log.Error("faces 2 encoding not sane"); success = false; } if (shape.NumberOfSides != 2) { m_Log.Error("faces 2 encoding not showing 2 faces"); success = false; } m_Log.Info("Test num of faces 3 encoding"); shape = new ObjectPart.PrimitiveShape { PCode = PrimitiveCode.Prim, ProfileCurve = (byte)PrimitiveProfileShape.Circle, PathCurve = (byte)PrimitiveExtrusion.Straight, PathScaleX = 100, PathScaleY = 100 }; if (!shape.IsSane) { m_Log.Error("faces 3 encoding not sane"); success = false; } if (shape.NumberOfSides != 3) { m_Log.Error("faces 3 encoding not showing 3 faces"); success = false; } m_Log.Info("Test num of faces 4 encoding"); shape = new ObjectPart.PrimitiveShape { PCode = PrimitiveCode.Prim, ProfileCurve = (byte)PrimitiveProfileShape.Circle, PathCurve = (byte)PrimitiveExtrusion.Straight, ProfileHollow = 27500, PathScaleX = 100, PathScaleY = 100 }; if (!shape.IsSane) { m_Log.Error("faces 4 encoding not sane"); success = false; } if (shape.NumberOfSides != 4) { m_Log.Error("faces 4 encoding not showing 4 faces"); success = false; } m_Log.Info("Test num of faces 5 encoding"); shape = new ObjectPart.PrimitiveShape { PCode = PrimitiveCode.Prim, ProfileCurve = (byte)PrimitiveProfileShape.EquilateralTriangle, PathCurve = (byte)PrimitiveExtrusion.Straight, PathScaleX = 100, PathScaleY = 100 }; if (!shape.IsSane) { m_Log.Error("faces 5 encoding not sane"); success = false; } if (shape.NumberOfSides != 5) { m_Log.Error("faces 5 encoding not showing 5 faces"); success = false; } m_Log.Info("Test num of faces 6 encoding"); shape = new ObjectPart.PrimitiveShape { PCode = PrimitiveCode.Prim, ProfileCurve = (byte)PrimitiveProfileShape.Square, PathCurve = (byte)PrimitiveExtrusion.Straight, PathScaleX = 100, PathScaleY = 100 }; if (!shape.IsSane) { m_Log.Error("faces 6 encoding not sane"); success = false; } if (shape.NumberOfSides != 6) { m_Log.Error("faces 6 encoding not showing 6 faces"); success = false; } m_Log.Info("Test num of faces 7 encoding"); shape = new ObjectPart.PrimitiveShape { PCode = PrimitiveCode.Prim, ProfileCurve = (byte)PrimitiveProfileShape.Square, PathCurve = (byte)PrimitiveExtrusion.Straight, ProfileHollow = 27500, PathScaleX = 100, PathScaleY = 100 }; if (!shape.IsSane) { m_Log.Error("faces 7 encoding not sane"); success = false; } if (shape.NumberOfSides != 7) { m_Log.Error("faces 7 encoding not showing 7 faces"); success = false; } m_Log.Info("Test num of faces 8 encoding"); shape = new ObjectPart.PrimitiveShape { PCode = PrimitiveCode.Prim, ProfileCurve = (byte)PrimitiveProfileShape.Square, PathCurve = (byte)PrimitiveExtrusion.Straight, ProfileBegin = 9375, PathScaleX = 100, PathScaleY = 100 }; if (!shape.IsSane) { m_Log.Error("faces 8 encoding not sane"); success = false; } if (shape.NumberOfSides != 8) { m_Log.Error("faces 8 encoding not showing 8 faces"); success = false; } m_Log.Info("Test num of faces 9 encoding"); shape = new ObjectPart.PrimitiveShape { PCode = PrimitiveCode.Prim, ProfileCurve = (byte)PrimitiveProfileShape.Square, PathCurve = (byte)PrimitiveExtrusion.Straight, ProfileBegin = 9375, ProfileHollow = 27500, PathScaleX = 100, PathScaleY = 100 }; if (!shape.IsSane) { m_Log.Error("faces 9 encoding not sane"); success = false; } if (shape.NumberOfSides != 9) { m_Log.Error("faces 9 encoding not showing 9 faces"); success = false; } m_Log.Info("****** Use actual function *****"); m_Log.Info("Test num of faces 1 encoding"); shape = new ObjectPart.PrimitiveShape { PCode = PrimitiveCode.Prim, SculptType = PrimitiveSculptType.Mesh }; shape.SetMeshNumFaces(1); if (!shape.IsSane) { m_Log.Error("faces 1 encoding not sane"); success = false; } if (shape.NumberOfSides != 1) { m_Log.Error("faces 1 encoding not showing 1 faces"); success = false; } m_Log.Info("Test num of faces 2 encoding"); shape.SetMeshNumFaces(2); if (!shape.IsSane) { m_Log.Error("faces 2 encoding not sane"); success = false; } if (shape.NumberOfSides != 2) { m_Log.Error("faces 2 encoding not showing 2 faces"); success = false; } m_Log.Info("Test num of faces 3 encoding"); shape.SetMeshNumFaces(3); if (!shape.IsSane) { m_Log.Error("faces 3 encoding not sane"); success = false; } if (shape.NumberOfSides != 3) { m_Log.Error("faces 3 encoding not showing 3 faces"); success = false; } m_Log.Info("Test num of faces 4 encoding"); shape.SetMeshNumFaces(4); if (!shape.IsSane) { m_Log.Error("faces 4 encoding not sane"); success = false; } if (shape.NumberOfSides != 4) { m_Log.Error("faces 4 encoding not showing 4 faces"); success = false; } m_Log.Info("Test num of faces 5 encoding"); shape.SetMeshNumFaces(5); if (!shape.IsSane) { m_Log.Error("faces 5 encoding not sane"); success = false; } if (shape.NumberOfSides != 5) { m_Log.Error("faces 5 encoding not showing 5 faces"); success = false; } m_Log.Info("Test num of faces 6 encoding"); shape.SetMeshNumFaces(6); if (!shape.IsSane) { m_Log.Error("faces 6 encoding not sane"); success = false; } if (shape.NumberOfSides != 6) { m_Log.Error("faces 6 encoding not showing 6 faces"); success = false; } m_Log.Info("Test num of faces 7 encoding"); shape.SetMeshNumFaces(7); if (!shape.IsSane) { m_Log.Error("faces 7 encoding not sane"); success = false; } if (shape.NumberOfSides != 7) { m_Log.Error("faces 7 encoding not showing 7 faces"); success = false; } m_Log.Info("Test num of faces 8 encoding"); shape.SetMeshNumFaces(8); if (!shape.IsSane) { m_Log.Error("faces 8 encoding not sane"); success = false; } if (shape.NumberOfSides != 8) { m_Log.Error("faces 8 encoding not showing 8 faces"); success = false; } m_Log.Info("Test num of faces 9 encoding"); shape.SetMeshNumFaces(9); if (!shape.IsSane) { m_Log.Error("faces 9 encoding not sane"); success = false; } if (shape.NumberOfSides != 9) { m_Log.Error("faces 9 encoding not showing 9 faces"); success = false; } return(success); }
private static void ProcessInstances(AnArray instanceList, MeshInventoryItem item, AssetData objectAsset = null) { var grp = new ObjectGroup(); foreach (Map instanceData in instanceList.OfType <Map>()) { var shape = new ObjectPart.PrimitiveShape { SculptType = PrimitiveSculptType.Mesh, ProfileCurve = 1, PathBegin = 0, PathCurve = 16, PathEnd = 0, PathRadiusOffset = 0, PathRevolutions = 0, PathScaleX = 100, PathScaleY = 100, PathShearX = 0, PathShearY = 0, PathSkew = 0, PathTaperX = 0, PathTaperY = 0, PathTwist = 0, PathTwistBegin = 0, PCode = PrimitiveCode.Prim, ProfileBegin = 9375, ProfileEnd = 0, ProfileHollow = 0, State = 0, SculptMap = item.MeshMap[instanceData["mesh"].AsInt] }; int numfaces; if (item.MeshFaces.TryGetValue(instanceData["mesh"].AsInt, out numfaces)) { shape.SetMeshNumFaces(numfaces); } var part = new ObjectPart { Name = item.Name, Shape = shape, IsReturnAtEdge = true, Size = GetVector(instanceData["scale"]), PhysicsShapeType = (PrimitivePhysicsShapeType)instanceData["physics_shape_type"].AsInt, Material = (PrimitiveMaterial)instanceData["material"].AsInt }; grp.AddLink(part); /* use our build in transformation */ grp.GlobalPosition = GetVector(instanceData["position"]); grp.GlobalRotation = GetRotation(instanceData["rotation"]); var faceList = (AnArray)instanceData["face_list"]; var te = new TextureEntry(); uint faceidx = 0; foreach (Map face in faceList.OfType <Map>()) { TextureEntryFace teface = te[faceidx]; IValue iv; teface.FullBright = face["fullbright"].AsBoolean; teface.TextureColor = GetColorAlpha(face["diffuse_color"]); if (face.TryGetValue("image", out iv)) { teface.TextureID = item.TextureMap[iv.AsInt]; } if (face.TryGetValue("scales", out iv)) { teface.RepeatU = (float)iv.AsReal; } if (face.TryGetValue("scalet", out iv)) { teface.RepeatV = (float)iv.AsReal; } if (face.TryGetValue("offsets", out iv)) { teface.OffsetU = (float)iv.AsReal; } if (face.TryGetValue("offsett", out iv)) { teface.OffsetV = (float)iv.AsReal; } if (face.TryGetValue("imagerot", out iv)) { teface.Rotation = (float)iv.AsReal; } ++faceidx; } part.TextureEntry = te; part.Owner = item.Owner; part.Creator = item.Owner; part.OwnerMask = InventoryPermissionsMask.Every; part.BaseMask = InventoryPermissionsMask.Every; } grp.Owner = item.Owner; grp.LastOwner = item.Owner; AssetData objectasset = grp.Asset(XmlSerializationOptions.WriteXml2 | XmlSerializationOptions.WriteOwnerInfo); if (objectAsset != null) { objectAsset.Data = objectasset.Data; item.AssetID = objectAsset.ID; objectAsset.Type = AssetType.Object; } else { item.AssetID = objectasset.ID; item.Assets.Add(objectasset); } }