29 using System.Collections.Generic;
34 using System.Drawing.Imaging;
39 public class SculptMesh
42 public List<Face>
faces;
54 List<List<Coord>> rows = smap.ToRows(mirror);
56 _SculptMesh(rows, sculptType, invert);
59 private void _SculptMesh(List<List<Coord>> rows,
SculptType sculptType,
bool invert)
61 coords =
new List<Coord>();
62 faces =
new List<Face>();
64 sculptType = (
SculptType)(((
int)sculptType) & 0x07);
66 int width = rows[0].Count;
74 if (rows.Count % 2 == 0)
76 for (
int rowNdx = 0; rowNdx < rows.Count; rowNdx++)
77 rows[rowNdx].Add(rows[rowNdx][0]);
81 int lastIndex = rows[0].Count - 1;
83 for (
int i = 0; i < rows.Count; i++)
84 rows[i][0] = rows[i][lastIndex];
88 Coord topPole = rows[0][width / 2];
89 Coord bottomPole = rows[rows.Count - 1][width / 2];
93 if (rows.Count % 2 == 0)
95 int count = rows[0].Count;
96 List<Coord> topPoleRow =
new List<Coord>(count);
97 List<Coord> bottomPoleRow =
new List<Coord>(count);
99 for (
int i = 0; i < count; i++)
101 topPoleRow.Add(topPole);
102 bottomPoleRow.Add(bottomPole);
104 rows.Insert(0, topPoleRow);
105 rows.Add(bottomPoleRow);
109 int count = rows[0].Count;
111 List<Coord> topPoleRow = rows[0];
112 List<Coord> bottomPoleRow = rows[rows.Count - 1];
114 for (
int i = 0; i < count; i++)
116 topPoleRow[i] = topPole;
117 bottomPoleRow[i] = bottomPole;
125 int coordsDown = rows.Count;
126 int coordsAcross = rows[0].Count;
128 float widthUnit = 1.0f / (coordsAcross - 1);
129 float heightUnit = 1.0f / (coordsDown - 1);
131 for (imageY = 0; imageY < coordsDown; imageY++)
133 int rowOffset = imageY * coordsAcross;
135 for (imageX = 0; imageX < coordsAcross; imageX++)
145 p4 = rowOffset + imageX;
148 p2 = p4 - coordsAcross;
149 p1 = p3 - coordsAcross;
151 this.coords.Add(rows[imageY][imageX]);
153 if (imageY > 0 && imageX > 0)
159 f1 =
new Face(p1, p4, p3);
160 f2 =
new Face(p1, p2, p4);
164 f1 =
new Face(p1, p3, p4);
165 f2 =
new Face(p1, p4, p2);
186 coords =
new List<Coord>(sm.coords);
187 faces =
new List<Face>(sm.faces);
190 public void Scale(
float x,
float y,
float z)
193 int numVerts = this.coords.Count;
196 for (i = 0; i < numVerts; i++)
200 public void DumpRaw(String path, String name, String title)
204 String fileName = name +
"_" + title +
".raw";
205 String completePath = System.IO.Path.Combine(path, fileName);
206 StreamWriter sw =
new StreamWriter(completePath);
208 for (
int i = 0; i < this.faces.Count; i++)
210 string s = this.coords[this.faces[i].v1].ToString();
211 s +=
" " + this.coords[this.faces[i].v2].ToString();
212 s +=
" " + this.coords[this.faces[i].v3].ToString();
void DumpRaw(String path, String name, String title)
SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool mirror, bool invert)
OpenSim.Region.OptionalModules.Scripting.Minimodule.Object.SculptType SculptType
SculptMesh(string fileName, int sculptType, int lod, int viewerMode, int mirror, int invert)
void Scale(float x, float y, float z)
SculptMesh(SculptMesh sm)
SculptMesh Copy()
Duplicates a SculptMesh object. All object properties are copied by value, including lists...