本文整理汇总了C#中SculptType类的典型用法代码示例。如果您正苦于以下问题:C# SculptType类的具体用法?C# SculptType怎么用?C# SculptType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SculptType类属于命名空间,在下文中一共展示了SculptType类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SculptMeshFromFile
public SculptMesh SculptMeshFromFile(string fileName, SculptType sculptType, int lod, bool viewerMode)
{
Bitmap bitmap = (Bitmap) Image.FromFile(fileName);
SculptMesh sculptMesh = new SculptMesh(bitmap, sculptType, lod, viewerMode);
bitmap.Dispose();
return sculptMesh;
}
示例2: SculptMesh
public SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool mirror, bool invert)
{
if (mirror)
invert = !invert;
SculptMap smap = new SculptMap(sculptBitmap, lod);
List<List<Coord>> rows = smap.ToRows(mirror);
_SculptMesh(rows, sculptType, invert);
}
示例3: _SculptMesh
private void _SculptMesh(List<List<Coord>> rows, SculptType sculptType, bool viewerMode, bool mirror,
bool invert)
{
coords = new List<Coord>();
faces = new List<Face>();
normals = new List<Coord>();
uvs = new List<UVCoord>();
sculptType = (SculptType) (((int) sculptType) & 0x07);
if (mirror)
invert = !invert;
viewerFaces = new List<ViewerFace>();
int width = rows[0].Count;
int p1, p2, p3, p4;
int imageX, imageY;
if (sculptType != SculptType.plane)
{
if (rows.Count%2 == 0)
{
foreach (List<Coord> t in rows)
t.Add(t[0]);
}
else
{
int lastIndex = rows[0].Count - 1;
foreach (List<Coord> t in rows)
t[0] = t[lastIndex];
}
}
Coord topPole = rows[0][width/2];
Coord bottomPole = rows[rows.Count - 1][width/2];
if (sculptType == SculptType.sphere)
{
if (rows.Count%2 == 0)
{
int count = rows[0].Count;
List<Coord> topPoleRow = new List<Coord>(count);
List<Coord> bottomPoleRow = new List<Coord>(count);
for (int i = 0; i < count; i++)
{
topPoleRow.Add(topPole);
bottomPoleRow.Add(bottomPole);
}
rows.Insert(0, topPoleRow);
rows.Add(bottomPoleRow);
}
else
{
int count = rows[0].Count;
List<Coord> topPoleRow = rows[0];
List<Coord> bottomPoleRow = rows[rows.Count - 1];
for (int i = 0; i < count; i++)
{
topPoleRow[i] = topPole;
bottomPoleRow[i] = bottomPole;
}
}
}
if (sculptType == SculptType.torus)
rows.Add(rows[0]);
int coordsDown = rows.Count;
int coordsAcross = rows[0].Count;
float widthUnit = 1.0f/(coordsAcross - 1);
float heightUnit = 1.0f/(coordsDown - 1);
for (imageY = 0; imageY < coordsDown; imageY++)
{
int rowOffset = imageY*coordsAcross;
for (imageX = 0; imageX < coordsAcross; imageX++)
{
/*
* p1-----p2
* | \ f2 |
* | \ |
* | f1 \|
* p3-----p4
*/
p4 = rowOffset + imageX;
p3 = p4 - 1;
p2 = p4 - coordsAcross;
p1 = p3 - coordsAcross;
//.........这里部分代码省略.........
示例4: SculptMesh
public SculptMesh(List<List<Coord>> rows, SculptType sculptType, bool viewerMode, bool mirror, bool invert)
{
_SculptMesh(rows, sculptType, viewerMode, mirror, invert);
}
示例5: Deserialize
public void Deserialize(OSDMap map)
{
GroupID = map["group-id"].AsUUID();
Material = (Material)map["material"].AsInteger();
Name = map["name"].AsString();
Position = map["pos"].AsVector3();
Rotation = map["rotation"].AsQuaternion();
Scale = map["scale"].AsVector3();
// Extra params
OSDArray extraParams = map["extra_parameters"] as OSDArray;
if (extraParams != null)
{
ExtraParams = new ExtraParam[extraParams.Count];
for (int i = 0; i < extraParams.Count; i++)
{
ExtraParam extraParam = new ExtraParam();
extraParam.Deserialize(extraParams[i] as OSDMap);
ExtraParams[i] = extraParam;
}
}
else
{
ExtraParams = new ExtraParam[0];
}
// Faces
OSDArray faces = map["facelist"] as OSDArray;
if (faces != null)
{
Faces = new Face[faces.Count];
for (int i = 0; i < faces.Count; i++)
{
Face face = new Face();
face.Deserialize(faces[i] as OSDMap);
Faces[i] = face;
}
}
else
{
Faces = new Face[0];
}
// Shape
OSDMap shape = map["shape"] as OSDMap;
OSDMap path = shape["path"] as OSDMap;
PathBegin = (float)path["begin"].AsReal();
PathCurve = path["curve"].AsInteger();
PathEnd = (float)path["end"].AsReal();
RadiusOffset = (float)path["radius_offset"].AsReal();
Revolutions = (float)path["revolutions"].AsReal();
ScaleX = (float)path["scale_x"].AsReal();
ScaleY = (float)path["scale_y"].AsReal();
ShearX = (float)path["shear_x"].AsReal();
ShearY = (float)path["shear_y"].AsReal();
Skew = (float)path["skew"].AsReal();
TaperX = (float)path["taper_x"].AsReal();
TaperY = (float)path["taper_y"].AsReal();
Twist = (float)path["twist"].AsReal();
TwistBegin = (float)path["twist_begin"].AsReal();
OSDMap profile = shape["profile"] as OSDMap;
ProfileBegin = (float)profile["begin"].AsReal();
ProfileCurve = profile["curve"].AsInteger();
ProfileEnd = (float)profile["end"].AsReal();
ProfileHollow = (float)profile["hollow"].AsReal();
OSDMap sculpt = shape["sculpt"] as OSDMap;
if (sculpt != null)
{
SculptID = sculpt["id"].AsUUID();
SculptType = (SculptType)sculpt["type"].AsInteger();
}
else
{
SculptID = UUID.Zero;
SculptType = 0;
}
}
示例6: GenerateSculptMesh
private static List<Vertex> GenerateSculptMesh(int sculptWidth, int sculptHeight, int sizeS, int sizeT, SculptType sculptType, bool invert, bool mirror, Bitmap sculptTexture)
{
bool reverseHorizontal = (invert) ? !mirror : mirror;
List<Vertex> mesh = new List<Vertex>(sizeS * sizeT);
Rectangle rect = new Rectangle(0, 0, sculptWidth, sculptHeight);
BitmapData bmpData = sculptTexture.LockBits(rect, ImageLockMode.ReadOnly, sculptTexture.PixelFormat);
int components = (sculptTexture.PixelFormat == (sculptTexture.PixelFormat | PixelFormat.Alpha)) ? 4 : 3;
//int offset = bmpData.Stride - sculptWidth * components;
for (int s = sizeS - 1; s >= 0; s--)
{
// Run along the profile
for (int t = 0; t < sizeT; t++)
{
int reversedT = t;
if (reverseHorizontal)
reversedT = sizeT - t - 1;
int x = (int)((float)reversedT / (sizeT - 1) * (float)sculptWidth);
int y = (int)((float)s / (sizeS - 1) * (float)sculptHeight);
if (y == 0) // Top row stitching
{
// Pinch?
if (sculptType == SculptType.Sphere)
x = sculptWidth / 2;
}
if (y == sculptHeight) // Bottom row stitching
{
// Wrap?
if (sculptType == SculptType.Torus)
y = 0;
else
y = sculptHeight - 1;
// Pinch?
if (sculptType == SculptType.Sphere)
x = sculptWidth / 2;
}
if (x == sculptWidth) // Side stitching
{
// Wrap?
if (sculptType == SculptType.Sphere || sculptType == SculptType.Torus || sculptType == SculptType.Cylinder)
x = 0;
else
x = sculptWidth - 1;
}
Vector3 pos;
unsafe
{
byte* ptr = (byte*)bmpData.Scan0 + (y * bmpData.Stride) + (x * components);
pos = SculptRGBToVector(*(ptr + 2), *(ptr + 1), *(ptr + 0));
}
if (mirror)
pos.X *= -1f;
// The rest of the vertex parameters will be set later
mesh.Add(new Vertex { Position = pos });
}
}
sculptTexture.UnlockBits(bmpData);
return mesh;
}
示例7: GetSculptMesh
public Mesh GetSculptMesh(UUID assetid, TextureExtended sculpttex, SculptType stype, Primitive prim)
{
Mesh result = null;
lock (StoredMesh)
{
if (StoredMesh.ContainsKey(assetid.ToString()))
{
result = StoredMesh[assetid.ToString()];
return result;
}
}
if (result == null)
{
System.Drawing.Bitmap bm = sculpttex.DOTNETImage;
result = PrimMesherG.SculptIrrMesh(bm, stype);
if (!killed.Contains(sculpttex.Raw))
{
try
{
killed.Add(sculpttex.Raw);
device.VideoDriver.RemoveTexture(sculpttex);
}
catch (AccessViolationException)
{
VUtil.LogConsole(this.ToString() + "[ACCESSVIOLATION]", "MeshFactory::GetSculptMesh");
System.Console.WriteLine("Unable to remove a sculpt texture from the video driver!");
}
}
bm.Dispose();
if (result != null)
{
lock (StoredMesh)
{
if (!StoredMesh.ContainsKey(assetid.ToString()))
{
StoredMesh.Add(assetid.ToString(), result);
}
}
}
}
if (result != null)
{
return result;
}
return null;
}
示例8: _SculptMesh
void _SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode, bool mirror, bool invert)
{
coords = new List<Coord>();
faces = new List<Face>();
normals = new List<Coord>();
uvs = new List<UVCoord>();
sculptType = (SculptType)(((int)sculptType) & 0x07);
if (mirror)
if (sculptType == SculptType.plane)
invert = !invert;
float sourceScaleFactor = (float)(lod) / (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height);
int scale = (int)(1.0f / sourceScaleFactor);
if (scale < 1) scale = 1;
_SculptMesh(bitmap2Coords(sculptBitmap, scale, mirror), sculptType, viewerMode, mirror, invert);
}
示例9: _SculptMesh
void _SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode, bool mirror, bool invert)
{
coords = new List<Coord>();
faces = new List<Face>();
normals = new List<Coord>();
uvs = new List<UVCoord>();
sculptType = (SculptType)(((int)sculptType) & 0x07);
if (mirror)
if (sculptType == SculptType.plane)
invert = !invert;
float sourceScaleFactor = (float)(lod) / (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height);
int scale = (int)(1.0f / sourceScaleFactor);
if (scale < 1) scale = 1;
List<List<Coord>> rows = bitmap2Coords(sculptBitmap, scale, mirror);
viewerFaces = new List<ViewerFace>();
int width = sculptBitmap.Width / scale;
// int height = sculptBitmap.Height / scale;
int p1, p2, p3, p4;
int imageX, imageY;
if (sculptType != SculptType.plane)
{
for (int rowNdx = 0; rowNdx < rows.Count; rowNdx++)
rows[rowNdx].Add(rows[rowNdx][0]);
}
Coord topPole = rows[0][width / 2];
Coord bottomPole = rows[rows.Count - 1][width / 2];
if (sculptType == SculptType.sphere)
{
int count = rows[0].Count;
List<Coord> topPoleRow = new List<Coord>(count);
List<Coord> bottomPoleRow = new List<Coord>(count);
for (int i = 0; i < count; i++)
{
topPoleRow.Add(topPole);
bottomPoleRow.Add(bottomPole);
}
rows.Insert(0, topPoleRow);
rows.Add(bottomPoleRow);
}
else if (sculptType == SculptType.torus)
rows.Add(rows[0]);
int coordsDown = rows.Count;
int coordsAcross = rows[0].Count;
float widthUnit = 1.0f / (coordsAcross - 1);
float heightUnit = 1.0f / (coordsDown - 1);
for (imageY = 0; imageY < coordsDown; imageY++)
{
int rowOffset = imageY * coordsAcross;
for (imageX = 0; imageX < coordsAcross; imageX++)
{
/*
* p1-----p2
* | \ f2 |
* | \ |
* | f1 \|
* p3-----p4
*/
p4 = rowOffset + imageX;
p3 = p4 - 1;
p2 = p4 - coordsAcross;
p1 = p3 - coordsAcross;
this.coords.Add(rows[imageY][imageX]);
if (viewerMode)
{
this.normals.Add(new Coord());
this.uvs.Add(new UVCoord(widthUnit * imageX, heightUnit * imageY));
}
if (imageY > 0 && imageX > 0)
{
Face f1, f2;
if (viewerMode)
{
if (invert)
{
f1 = new Face(p1, p4, p3, p1, p4, p3);
f1.uv1 = p1;
f1.uv2 = p4;
f1.uv3 = p3;
//.........这里部分代码省略.........
示例10: calcVertexNormals
void calcVertexNormals(SculptType sculptType, int xSize, int ySize)
{ // compute vertex normals by summing all the surface normals of all the triangles sharing
// each vertex and then normalizing
int numFaces = faces.Count;
for (int i = 0; i < numFaces; i++)
{
Face face = faces[i];
Coord surfaceNormal = face.SurfaceNormal(this.coords);
normals[face.n1] += surfaceNormal;
normals[face.n2] += surfaceNormal;
normals[face.n3] += surfaceNormal;
}
int numNormals = normals.Count;
for (int i = 0; i < numNormals; i++)
normals[i] = normals[i].Normalize();
if (sculptType != SculptType.plane)
{ // blend the vertex normals at the cylinder seam
for (int y = 0; y < ySize; y++)
{
int rowOffset = y * xSize;
normals[rowOffset] = normals[rowOffset + xSize - 1] = (normals[rowOffset] + normals[rowOffset + xSize - 1]).Normalize();
}
}
foreach (Face face in faces)
{
ViewerFace vf = new ViewerFace(0);
vf.v1 = coords[face.v1];
vf.v2 = coords[face.v2];
vf.v3 = coords[face.v3];
vf.coordIndex1 = face.v1;
vf.coordIndex2 = face.v2;
vf.coordIndex3 = face.v3;
vf.n1 = normals[face.n1];
vf.n2 = normals[face.n2];
vf.n3 = normals[face.n3];
vf.uv1 = uvs[face.uv1];
vf.uv2 = uvs[face.uv2];
vf.uv3 = uvs[face.uv3];
viewerFaces.Add(vf);
}
}
示例11: _SculptMesh
private void _SculptMesh(List<List<Coord>> rows, SculptType sculptType, bool invert)
{
coords = new List<Coord>();
faces = new List<Face>();
sculptType = (SculptType)(((int)sculptType) & 0x07);
int width = rows[0].Count;
int p1, p2, p3, p4;
int imageX, imageY;
if (sculptType != SculptType.plane)
{
if (rows.Count % 2 == 0)
{
for (int rowNdx = 0; rowNdx < rows.Count; rowNdx++)
rows[rowNdx].Add(rows[rowNdx][0]);
}
else
{
int lastIndex = rows[0].Count - 1;
for (int i = 0; i < rows.Count; i++)
rows[i][0] = rows[i][lastIndex];
}
}
Coord topPole = rows[0][width / 2];
Coord bottomPole = rows[rows.Count - 1][width / 2];
if (sculptType == SculptType.sphere)
{
if (rows.Count % 2 == 0)
{
int count = rows[0].Count;
List<Coord> topPoleRow = new List<Coord>(count);
List<Coord> bottomPoleRow = new List<Coord>(count);
for (int i = 0; i < count; i++)
{
topPoleRow.Add(topPole);
bottomPoleRow.Add(bottomPole);
}
rows.Insert(0, topPoleRow);
rows.Add(bottomPoleRow);
}
else
{
int count = rows[0].Count;
List<Coord> topPoleRow = rows[0];
List<Coord> bottomPoleRow = rows[rows.Count - 1];
for (int i = 0; i < count; i++)
{
topPoleRow[i] = topPole;
bottomPoleRow[i] = bottomPole;
}
}
}
if (sculptType == SculptType.torus)
rows.Add(rows[0]);
int coordsDown = rows.Count;
int coordsAcross = rows[0].Count;
float widthUnit = 1.0f / (coordsAcross - 1);
float heightUnit = 1.0f / (coordsDown - 1);
for (imageY = 0; imageY < coordsDown; imageY++)
{
int rowOffset = imageY * coordsAcross;
for (imageX = 0; imageX < coordsAcross; imageX++)
{
/*
* p1-----p2
* | \ f2 |
* | \ |
* | f1 \|
* p3-----p4
*/
p4 = rowOffset + imageX;
p3 = p4 - 1;
p2 = p4 - coordsAcross;
p1 = p3 - coordsAcross;
this.coords.Add(rows[imageY][imageX]);
if (imageY > 0 && imageX > 0)
{
Face f1, f2;
if (invert)
{
//.........这里部分代码省略.........
示例12: calcVertexNormals
private void calcVertexNormals(SculptType sculptType, int xSize, int ySize)
{
// compute vertex normals by summing all the surface normals of all the triangles sharing
// each vertex and then normalizing
int numFaces = this.faces.Count;
for (int i = 0; i < numFaces; i++)
{
Face face = this.faces[i];
Coord surfaceNormal = face.SurfaceNormal(this.coords);
this.normals[face.n1] += surfaceNormal;
this.normals[face.n2] += surfaceNormal;
this.normals[face.n3] += surfaceNormal;
}
int numNormals = this.normals.Count;
for (int i = 0; i < numNormals; i++)
this.normals[i] = this.normals[i].Normalize();
if (sculptType != SculptType.plane)
{
// blend the vertex normals at the cylinder seam
for (int y = 0; y < ySize; y++)
{
int rowOffset = y*xSize;
this.normals[rowOffset] =
this.normals[rowOffset + xSize - 1] =
(this.normals[rowOffset] + this.normals[rowOffset + xSize - 1]).Normalize();
}
}
#if (!ISWIN)
foreach(Face face in this.faces)
{
ViewerFace vf = new ViewerFace(0)
{
v1 = this.coords[face.v1],
v2 = this.coords[face.v2],
v3 = this.coords[face.v3],
coordIndex1 = face.v1,
coordIndex2 = face.v2,
coordIndex3 = face.v3,
n1 = this.normals[face.n1],
n2 = this.normals[face.n2],
n3 = this.normals[face.n3],
uv1 = this.uvs[face.uv1],
uv2 = this.uvs[face.uv2],
uv3 = this.uvs[face.uv3]
};
this.viewerFaces.Add(vf);
}
#else
foreach (ViewerFace vf in this.faces.Select(face => new ViewerFace(0)
{
v1 = this.coords[face.v1],
v2 = this.coords[face.v2],
v3 = this.coords[face.v3],
coordIndex1 = face.v1,
coordIndex2 = face.v2,
coordIndex3 = face.v3,
n1 = this.normals[face.n1],
n2 = this.normals[face.n2],
n3 = this.normals[face.n3],
uv1 = this.uvs[face.uv1],
uv2 = this.uvs[face.uv2],
uv3 = this.uvs[face.uv3]
}))
{
this.viewerFaces.Add(vf);
}
#endif
}
示例13: SculptData
public SculptData(byte[] data, int pos)
{
if (data.Length >= 17)
{
SculptTexture = new LLUUID(data, pos);
Type = (SculptType)data[pos + 16];
}
else
{
SculptTexture = LLUUID.Zero;
Type = SculptType.None;
}
}
示例14: _SculptMesh
void _SculptMesh(Bitmap sculptBitmap, SculptType sculptType, int lod, bool viewerMode, bool mirror, bool invert)
{
coords = new List<Coord>();
faces = new List<Face>();
normals = new List<Coord>();
uvs = new List<UVCoord>();
sculptType = (SculptType)(((int)sculptType) & 0x07);
if (mirror)
if (sculptType == SculptType.plane)
invert = !invert;
float sculptBitmapLod = (float)Math.Sqrt(sculptBitmap.Width * sculptBitmap.Height);
float sourceScaleFactor = (float)(lod) / sculptBitmapLod;
float fScale = 1.0f / sourceScaleFactor;
int iScale = (int)fScale;
if (iScale < 1) iScale = 1;
if (iScale > 2 && iScale % 2 == 0)
_SculptMesh(bitmap2Coords(ScaleImage(sculptBitmap, 64.0f / sculptBitmapLod, true), 64 / lod, mirror), sculptType, viewerMode, mirror, invert);
else
_SculptMesh(bitmap2Coords(sculptBitmap, iScale, mirror), sculptType, viewerMode, mirror, invert);
}