本文整理汇总了C#中MegaShape类的典型用法代码示例。如果您正苦于以下问题:C# MegaShape类的具体用法?C# MegaShape怎么用?C# MegaShape使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MegaShape类属于命名空间,在下文中一共展示了MegaShape类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ParseShape
public void ParseShape(MegaXMLNode node, MegaShape shape)
{
for ( int i = 0; i < node.values.Count; i++ )
{
MegaXMLValue val = node.values[i];
//Debug.Log("Shape val " + val.name);
switch ( val.name )
{
case "name": break;
case "p": break;
case "r": break;
case "s": break;
}
}
foreach ( MegaXMLNode n in node.children )
{
//Debug.Log("Shape tagName " + n.tagName);
switch ( n.tagName )
{
case "Spline":
ParseSpline(n, shape);
break;
}
}
}
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:28,代码来源:MegaShapeSXL.cs
示例2: ParseSpline
public void ParseSpline(MegaXMLNode node, MegaShape shape)
{
MegaSpline spline = new MegaSpline();
for ( int i = 0; i < node.values.Count; i++ )
{
MegaXMLValue val = node.values[i];
//Debug.Log("Spline val " + val.name);
switch ( val.name )
{
case "flags": break;
case "closed": spline.closed = int.Parse(val.value) > 0 ? true : false; break;
}
}
foreach ( MegaXMLNode n in node.children )
{
//Debug.Log("Spline tagName " + n.tagName);
switch ( n.tagName )
{
case "K": ParseKnot(n, shape, spline); break;
}
}
//Debug.Log("************** Add Spline");
shape.splines.Add(spline);
}
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:28,代码来源:MegaShapeSXL.cs
示例3: Export
public static string Export(MegaShape shape, int x, int y, float strokewidth, Color col)
{
string file = "";
Color32 c = col;
file += "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
file += "<!-- MegaShapes SVG Exporter v1.0 -->\n";
file += "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n";
file += "<svg version=\"1.1\" id=\"" + shape.name + "\" x=\"0px\" y=\"0px\" width=\"640.0px\" height=\"480.0px\">\n";
for ( int i = 0; i < shape.splines.Count; i++ )
{
MegaSpline spline = shape.splines[i];
file += "<path d=\"";
MegaKnot k1;
MegaKnot k = spline.knots[0];
k1 = k;
file += "M" + k.p[x] + "," + -k.p[y];
//Vector3 cp = k.p;
for ( int j = 1; j < spline.knots.Count; j++ )
{
k = spline.knots[j];
Vector3 po = k1.outvec; // - cp; // - k1.p;
Vector3 pi = k.invec; // - cp; // - k.p;
Vector3 kp = k.p; // - cp;
kp[y] = -kp[y];
po[y] = -po[y];
pi[y] = -pi[y];
file += "C" + po[x] + "," + po[y];
file += " " + pi[x] + "," + pi[y];
file += " " + kp[x] + "," + kp[y];
k1 = k;
}
if ( spline.closed )
{
file += "z\"";
}
file += " fill=\"none\"";
file += " stroke=\"#" + c.r.ToString("x") + c.g.ToString("x") + c.b.ToString("x") + "\"";
file += " stroke-width=\"" + strokewidth + "\"";
file += "/>\n";
}
file += "</svg>\n";
return file;
}
开发者ID:Morac,项目名称:Orca6,代码行数:57,代码来源:MegaShapeSVG.cs
示例4: BuildObjectLinks
void BuildObjectLinks(MegaShape path)
{
float len = path.splines[curve].length;
if ( LinkSize < 0.1f )
LinkSize = 0.1f;
// Assume z axis for now
float linklen = (linkOff1.y - linkOff.y) * linkScale.x * LinkSize;
int lc = (int)(len / linklen);
if ( lc != linkcount )
InitLinkObjects(path);
Quaternion linkrot1 = Quaternion.identity;
linkrot1 = Quaternion.Euler(rotate);
float spos = start * 0.01f;
Vector3 poff = linkPivot * linkScale.x * LinkSize;
float lastalpha = spos;
Vector3 pos = Vector3.zero;
Matrix4x4 pmat = Matrix4x4.TRS(poff, linkrot1, Vector3.one);
Vector3 lrot = Vector3.zero;
Quaternion frot = Quaternion.identity;
Random.seed = seed;
for ( int i = 0; i < linkcount; i++ )
{
float alpha = ((float)(i + 1) / (float)linkcount) + spos;
Quaternion lq = GetLinkQuat(alpha, lastalpha, out pos, path);
lastalpha = alpha;
Quaternion lr = Quaternion.Euler(lrot);
frot = lq * linkrot1 * lr;
if ( linkobjs[i] )
{
Matrix4x4 lmat = Matrix4x4.TRS(pos, lq, Vector3.one) * pmat;
linkobjs[i].localPosition = lmat.GetColumn(3);
linkobjs[i].localRotation = frot;
linkobjs[i].localScale = linkScale * LinkSize;
}
if ( randRot )
{
float r = Random.Range(0.0f, 1.0f);
lrot = (int)(r * (int)(360.0f / MegaUtils.LargestValue1(linkRot))) * linkRot;
}
else
lrot += linkRot;
}
}
开发者ID:Morac,项目名称:Orca6,代码行数:56,代码来源:MegaTracks.cs
示例5: ParseXML
public void ParseXML(MegaXMLNode node, MegaShape shape)
{
foreach ( MegaXMLNode n in node.children )
{
switch ( n.tagName )
{
case "Shape": ParseShape(n, shape); break;
}
ParseXML(n, shape);
}
}
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:12,代码来源:MegaShapeSXL.cs
示例6: LoadXML
public void LoadXML(string svgdata, MegaShape shape, bool clear, int start)
{
MegaXMLReader xml = new MegaXMLReader();
MegaXMLNode node = xml.read(svgdata);
if ( !clear )
shape.splines.Clear();
shape.selcurve = start;
splineindex = start;
ParseXML(node, shape);
}
开发者ID:jsr2k1,项目名称:gato-book-test,代码行数:12,代码来源:MegaShapeSVG.cs
示例7: NewSpline
public MegaSpline NewSpline(MegaShape shape)
{
if ( shape.splines.Count == 0 )
{
MegaSpline newspline = new MegaSpline();
shape.splines.Add(newspline);
}
MegaSpline spline = shape.splines[0];
spline.knots.Clear();
spline.closed = false;
return spline;
}
开发者ID:Morac,项目名称:Orca6,代码行数:14,代码来源:MegaDrawLoft.cs
示例8: AddTarget
public MegaPathTarget AddTarget(MegaShape shape, int curve, float weight)
{
MegaPathTarget target = new MegaPathTarget();
target.shape = shape;
target.Weight = weight;
target.curve = curve;
target.modifier = 1.0f;
target.offset = 0.0f;
Targets.Add(target);
return target;
}
开发者ID:Morac,项目名称:Orca6,代码行数:14,代码来源:MegaShapeFollow.cs
示例9: GetSpline
MegaSpline GetSpline(MegaShape shape)
{
MegaSpline spline;
if ( splineindex < shape.splines.Count )
spline = shape.splines[splineindex];
else
{
spline = new MegaSpline();
shape.splines.Add(spline);
}
splineindex++;
return spline;
}
开发者ID:jsr2k1,项目名称:gato-book-test,代码行数:15,代码来源:MegaShapeSVG.cs
示例10: importData
public void importData(string svgdata, MegaShape shape, float scale, bool clear, int start)
{
LoadXML(svgdata, shape, clear, start);
for ( int i = start; i < splineindex; i++ )
{
float area = shape.splines[i].Area();
if ( area < 0.0f )
shape.splines[i].reverse = false;
else
shape.splines[i].reverse = true;
}
//shape.Centre(0.01f, new Vector3(-1.0f, 1.0f, 1.0f));
shape.Centre(scale, new Vector3(-1.0f, 1.0f, 1.0f), start);
shape.CalcLength(); //10);
}
开发者ID:jsr2k1,项目名称:gato-book-test,代码行数:16,代码来源:MegaShapeSVG.cs
示例11: ParseXML
public void ParseXML(MegaXMLNode node, MegaShape shape)
{
foreach ( MegaXMLNode n in node.children )
{
switch ( n.tagName )
{
case "circle": ParseCircle(n, shape); break;
case "path": ParsePath(n, shape); break;
case "ellipse": ParseEllipse(n, shape); break;
case "rect": ParseRect(n, shape); break;
case "polygon": ParsePolygon(n, shape); break;
default: break;
}
ParseXML(n, shape);
}
}
开发者ID:jsr2k1,项目名称:gato-book-test,代码行数:17,代码来源:MegaShapeSVG.cs
示例12: BuildObjectLinks
void BuildObjectLinks(MegaShape path)
{
float len = path.splines[curve].length;
if ( LinkSize < 0.1f )
LinkSize = 0.1f;
// Assume z axis for now
float linklen = (linkOff1.y - linkOff.y) * linkScale.x * LinkSize;
int lc = (int)(len / linklen);
if ( lc != linkcount )
InitLinkObjects(path);
Quaternion linkrot1 = Quaternion.identity;
linkrot1 = Quaternion.Euler(rotate);
float spos = start * 0.01f;
Vector3 poff = linkPivot * linkScale.x * LinkSize;
float lastalpha = spos;
Vector3 pos = Vector3.zero;
Matrix4x4 pmat = Matrix4x4.TRS(poff, linkrot1, Vector3.one);
Quaternion frot = Quaternion.identity;
for ( int i = 0; i < linkcount; i++ )
{
float alpha = ((float)(i + 1) / (float)linkcount) + spos;
Quaternion lq = GetLinkQuat(alpha, lastalpha, out pos, path);
lastalpha = alpha;
frot = lq * linkrot1;
if ( linkobjs[i] )
{
Matrix4x4 lmat = Matrix4x4.TRS(pos, lq, Vector3.one) * pmat;
linkobjs[i].localPosition = lmat.GetColumn(3);
linkobjs[i].localRotation = frot;
linkobjs[i].localScale = linkScale * LinkSize;
}
}
}
开发者ID:jsr2k1,项目名称:videojocjj,代码行数:45,代码来源:MegaTracks.cs
示例13: ParseKnot
public void ParseKnot(MegaXMLNode node, MegaShape shape, MegaSpline spline)
{
Vector3 p = Vector3.zero;
Vector3 invec = Vector3.zero;
Vector3 outvec = Vector3.zero;
for ( int i = 0; i < node.values.Count; i++ )
{
MegaXMLValue val = node.values[i];
//Debug.Log("Knot val " + val.name);
switch ( val.name )
{
case "p": p = ParseV3Split(val.value, 0); break;
case "i": invec = ParseV3Split(val.value, 0); break;
case "o": outvec = ParseV3Split(val.value, 0); break;
case "l": break;
}
}
spline.AddKnot(p, invec, outvec);
}
开发者ID:Morac,项目名称:Orca6,代码行数:22,代码来源:MegaShapeSXL.cs
示例14: ClearAnim
void ClearAnim(MegaShape shape)
{
MegaSpline spline = shape.splines[shape.selcurve];
if ( spline.splineanim != null )
{
spline.splineanim.Init(spline);
}
}
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:9,代码来源:MegaShapeEditor.cs
示例15: AnimationKeyFrames
// Animation keyframe stuff
// Need system to grab state of curve
void AnimationKeyFrames(MegaShape shape)
{
MegaSpline spline = shape.splines[shape.selcurve];
shape.showanimations = EditorGUILayout.Foldout(shape.showanimations, "Animations");
if ( shape.showanimations )
{
shape.keytime = EditorGUILayout.FloatField("Key Time", shape.keytime);
if ( shape.keytime < 0.0f )
shape.keytime = 0.0f;
spline.splineanim.Enabled = EditorGUILayout.BeginToggleGroup("Enabled", spline.splineanim.Enabled);
EditorGUILayout.BeginHorizontal();
//if ( spline.splineanim == null )
//{
//}
//else
{
//if ( GUILayout.Button("Create") )
//{
//spline.splineanim = new MegaSplineAnim();
//spline.splineanim.Init(spline);
//}
if ( GUILayout.Button("Add Key") )
{
AddKeyFrame(shape, shape.keytime);
}
if ( GUILayout.Button("Clear") )
{
ClearAnim(shape);
}
//if ( GUILayout.Button("Delete") )
//{
// spline.splineanim = null;
//}
}
EditorGUILayout.EndHorizontal();
//if ( spline.splineanim == null )
// return;
// Need to show each keyframe
if ( spline.splineanim != null )
{
//EditorGUILayout.LabelField("Frames " + spline.splineanim.knots[0].)
int nk = spline.splineanim.NumKeys();
float mt = 0.0f;
for ( int i = 0; i < nk; i++ )
{
EditorGUILayout.BeginHorizontal();
mt = spline.splineanim.GetKeyTime(i);
EditorGUILayout.LabelField("" + i, GUILayout.MaxWidth(20)); //" + " Time: " + mt);
float t = EditorGUILayout.FloatField("", mt, GUILayout.MaxWidth(100));
if ( t != mt )
spline.splineanim.SetKeyTime(spline, i, t);
if ( GUILayout.Button("Delete", GUILayout.MaxWidth(50)) )
spline.splineanim.RemoveKey(i);
if ( GUILayout.Button("Update", GUILayout.MaxWidth(50)) )
spline.splineanim.UpdateKey(spline, i);
if ( GUILayout.Button("Get", GUILayout.MaxWidth(50)) )
{
spline.splineanim.GetKey(spline, i);
EditorUtility.SetDirty(target);
}
EditorGUILayout.EndHorizontal();
}
shape.MaxTime = mt;
float at = EditorGUILayout.Slider("T", shape.testtime, 0.0f, mt);
if ( at != shape.testtime )
{
shape.testtime = at;
if ( !shape.animate )
{
for ( int s = 0; s < shape.splines.Count; s++ )
{
if ( shape.splines[s].splineanim != null && shape.splines[s].splineanim.Enabled )
{
shape.splines[s].splineanim.GetState1(shape.splines[s], at);
shape.splines[s].CalcLength(); //(10); // could use less here
}
}
}
}
}
//.........这里部分代码省略.........
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:101,代码来源:MegaShapeEditor.cs
示例16: DrawGizmos
// Dont want this in here, want in editor
// If we go over a knot then should draw to the knot
static void DrawGizmos(MegaShape shape, Color modcol1)
{
if ( ((1 << shape.gameObject.layer) & Camera.current.cullingMask) == 0 )
return;
if ( !shape.drawspline )
return;
Matrix4x4 tm = shape.transform.localToWorldMatrix;
for ( int s = 0; s < shape.splines.Count; s++ )
{
float ldist = shape.stepdist * 0.1f;
if ( ldist < 0.01f )
ldist = 0.01f;
Color modcol = modcol1;
if ( s != shape.selcurve && modcol1.a == 1.0f )
modcol.a *= 0.5f;
if ( shape.splines[s].length / ldist > 500.0f )
ldist = shape.splines[s].length / 500.0f;
float ds = shape.splines[s].length / (shape.splines[s].length / ldist);
if ( ds > shape.splines[s].length )
ds = shape.splines[s].length;
int c = 0;
int k = -1;
int lk = -1;
Vector3 first = shape.splines[s].Interpolate(0.0f, shape.normalizedInterp, ref lk);
for ( float dist = ds; dist < shape.splines[s].length; dist += ds )
{
float alpha = dist / shape.splines[s].length;
Vector3 pos = shape.splines[s].Interpolate(alpha, shape.normalizedInterp, ref k);
if ( (c & 1) == 1 )
Gizmos.color = shape.col1 * modcol;
else
Gizmos.color = shape.col2 * modcol;
if ( k != lk )
{
for ( lk = lk + 1; lk <= k; lk++ )
{
Gizmos.DrawLine(tm.MultiplyPoint(first), tm.MultiplyPoint(shape.splines[s].knots[lk].p));
first = shape.splines[s].knots[lk].p;
}
}
lk = k;
Gizmos.DrawLine(tm.MultiplyPoint(first), tm.MultiplyPoint(pos));
c++;
first = pos;
}
if ( (c & 1) == 1 )
Gizmos.color = shape.col1 * modcol;
else
Gizmos.color = shape.col2 * modcol;
Vector3 lastpos;
if ( shape.splines[s].closed )
lastpos = shape.splines[s].Interpolate(0.0f, shape.normalizedInterp, ref k);
else
lastpos = shape.splines[s].Interpolate(1.0f, shape.normalizedInterp, ref k);
Gizmos.DrawLine(tm.MultiplyPoint(first), tm.MultiplyPoint(lastpos));
}
}
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:79,代码来源:MegaShapeEditor.cs
示例17: RenderGizmo
static void RenderGizmo(MegaShape shape, GizmoType gizmoType)
{
if ( (gizmoType & GizmoType.Active) != 0 && Selection.activeObject == shape.gameObject )
{
if ( shape.splines == null || shape.splines.Count == 0 )
return;
DrawGizmos(shape, new Color(1.0f, 1.0f, 1.0f, 1.0f));
Color col = Color.yellow;
col.a = 0.5f;
Gizmos.color = col; //Color.yellow;
CursorPos = shape.InterpCurve3D(shape.selcurve, shape.CursorPercent * 0.01f, true);
Gizmos.DrawSphere(shape.transform.TransformPoint(CursorPos), shape.KnotSize * 0.01f);
Handles.color = Color.white;
if ( shape.handleType == MegaHandleType.Free )
{
int s = shape.selcurve;
{
for ( int p = 0; p < shape.splines[s].knots.Count; p++ )
{
if ( shape.drawKnots ) //&& s == shape.selcurve )
{
Gizmos.color = Color.green;
Gizmos.DrawSphere(shape.transform.TransformPoint(shape.splines[s].knots[p].p), shape.KnotSize * 0.01f);
}
if ( shape.drawHandles )
{
Gizmos.color = Color.red;
Gizmos.DrawSphere(shape.transform.TransformPoint(shape.splines[s].knots[p].invec), shape.KnotSize * 0.01f);
Gizmos.DrawSphere(shape.transform.TransformPoint(shape.splines[s].knots[p].outvec), shape.KnotSize * 0.01f);
}
}
}
}
}
else
DrawGizmos(shape, new Color(1.0f, 1.0f, 1.0f, 0.25f));
if ( Camera.current )
{
Vector3 vis = Camera.current.WorldToScreenPoint(shape.transform.position);
if ( vis.z > 0.0f )
{
Gizmos.DrawIcon(shape.transform.position, "MegaSpherify icon.png", false);
Handles.Label(shape.transform.position, " " + shape.name);
}
}
}
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:51,代码来源:MegaShapeEditor.cs
示例18: PosHandles
Vector3 PosHandles(MegaShape shape, Vector3 pos, Quaternion q)
{
switch ( shape.handleType )
{
case MegaHandleType.Position:
pos = Handles.PositionHandle(pos, q);
break;
case MegaHandleType.Free:
pos = Handles.FreeMoveHandle(pos, q, shape.KnotSize * 0.01f, Vector3.zero, Handles.CircleCap);
break;
}
return pos;
}
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:15,代码来源:MegaShapeEditor.cs
示例19: PosHandlesSnap
Vector3 PosHandlesSnap(MegaShape shape, Vector3 pos, Quaternion q)
{
switch ( shape.handleType )
{
case MegaHandleType.Position:
pos = Handles.PositionHandle(pos, q);
break;
case MegaHandleType.Free:
pos = Handles.FreeMoveHandle(pos, q, shape.KnotSize * 0.01f, Vector3.zero, Handles.CircleCap);
break;
}
if ( shape.usesnap )
{
if ( shape.snap.x != 0.0f )
pos.x = (int)(pos.x / shape.snap.x) * shape.snap.x;
if ( shape.snap.y != 0.0f )
pos.y = (int)(pos.y / shape.snap.y) * shape.snap.y;
if ( shape.snap.z != 0.0f )
pos.z = (int)(pos.z / shape.snap.z) * shape.snap.z;
}
return pos;
}
开发者ID:Gounemond,项目名称:BretarisDemo,代码行数:27,代码来源:MegaShapeEditor.cs
示例20: ParseCircle
void ParseCircle(MegaXMLNode node, MegaShape shape)
{
MegaSpline spline = GetSpline(shape);
float cx = 0.0f;
float cy = 0.0f;
float r = 0.0f;
for ( int i = 0; i < node.values.Count; i++ )
{
MegaXMLValue val = node.values[i];
switch ( val.name )
{
case "cx": cx = float.Parse(val.value); break;
case "cy": cy = float.Parse(val.value); break;
case "r": r = float.Parse(val.value); break;
}
}
float vector = CIRCLE_VECTOR_LENGTH * r;
spline.knots.Clear();
for ( int ix = 0; ix < 4; ++ix )
{
float angle = (Mathf.PI * 2.0f) * (float)ix / (float)4;
float sinfac = Mathf.Sin(angle);
float cosfac = Mathf.Cos(angle);
Vector3 p = new Vector3((cosfac * r) + cx, 0.0f, (sinfac * r) + cy);
Vector3 rotvec = new Vector3(sinfac * vector, 0.0f, -cosfac * vector);
//spline.AddKnot(p, p + rotvec, p - rotvec);
AddKnot(spline, p, p + rotvec, p - rotvec, shape.axis);
}
spline.closed = true;
}
开发者ID:jsr2k1,项目名称:gato-book-test,代码行数:36,代码来源:MegaShapeSVG.cs
注:本文中的MegaShape类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论