本文整理汇总了C#中MegaModifiers类的典型用法代码示例。如果您正苦于以下问题:C# MegaModifiers类的具体用法?C# MegaModifiers怎么用?C# MegaModifiers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MegaModifiers类属于命名空间,在下文中一共展示了MegaModifiers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitMod
public override bool InitMod(MegaModifiers mc)
{
bsize = mc.bbox.size;
bcenter = mc.bbox.center;
Init();
return true;
}
示例2: Modify
public override void Modify(MegaModifiers mc)
{
Vector2[] uvs = mc.GetSourceUvs();
Vector2[] newuvs = mc.GetDestUvs();
if ( uvs.Length > 0 )
{
Vector3 pos = -gizmoPos;
Vector3 scl = gizmoScale;
Vector3 rot = gizmoRot;
Matrix4x4 tm1 = Matrix4x4.identity;
Vector3 p = Vector3.zero;
for ( int i = 0; i < uvs.Length; i++ )
{
p.x = uvs[i].x - Offset.x - 0.5f;
p.z = uvs[i].y - Offset.z - 0.5f;
p.y = 0.0f;
float d = Mathf.Sqrt(p.x * p.x + p.z * p.z) * spiral;
rot = new Vector3(gizmoRot.x, gizmoRot.y + d, gizmoRot.z);
tm1 = Matrix4x4.TRS(pos, Quaternion.Euler(rot), scl);
p = tm1.MultiplyPoint(p);
newuvs[i].x = p.x;
newuvs[i].y = p.z;
}
}
}
示例3: Modify
public override void Modify(MegaModifiers mc)
{
if ( conformColliders.Count > 0 )
{
int ax = (int)axis;
Vector3 hitpos = Vector3.zero;
for ( int i = 0; i < verts.Length; i++ )
{
Vector3 origin = ctm.MultiplyPoint(verts[i]);
origin.y += raystartoff;
ray.origin = origin;
ray.direction = Vector3.down;
sverts[i] = verts[i];
if ( DoRayCast(ray, ref hitpos, raydist) )
{
Vector3 lochit = cinvtm.MultiplyPoint(hitpos);
sverts[i][ax] = Mathf.Lerp(verts[i][ax], lochit[ax] + offsets[i] + offset, conformAmount);
last[i] = sverts[i][ax];
}
else
{
Vector3 ht = ray.origin;
ht.y -= raydist;
sverts[i][ax] = last[i];
}
}
}
else
verts.CopyTo(sverts, 0);
}
示例4: GetSelection
public override void GetSelection(MegaModifiers mc)
{
if ( enabled )
{
if ( modselection == null || modselection.Length != mc.verts.Length )
modselection = new float[mc.verts.Length];
if ( update )
{
update = false;
if ( mc.cols != null && mc.cols.Length > 0 )
{
int c = (int)channel;
for ( int i = 0; i < mc.verts.Length; i++ )
modselection[i] = ((mc.cols[i][c] - threshold) / (1.0f - threshold)) * weight;
}
else
{
for ( int i = 0; i < mc.verts.Length; i++ )
modselection[i] = weight;
}
}
mc.selection = modselection;
}
}
示例5: Modify
public override void Modify(MegaModifiers mc)
{
for ( int i = 0; i < verts.Length; i++ )
{
Vector3 p = tm.MultiplyPoint3x4(verts[i]);
sp.x = p.x * scale + 0.5f;
sp.y = p.y * scale + 0.5f;
sp.z = p.z * scale + 0.5f;
if ( Fractal )
{
d.x = iperlin.fBm1(sp.y, sp.z, time, rt, 2.0f, Iterations);
d.y = iperlin.fBm1(sp.x, sp.z, time, rt, 2.0f, Iterations);
d.z = iperlin.fBm1(sp.x, sp.y, time, rt, 2.0f, Iterations);
}
else
{
d.x = iperlin.Noise(sp.y, sp.z, time);
d.y = iperlin.Noise(sp.x, sp.z, time);
d.z = iperlin.Noise(sp.x, sp.y, time);
}
p.x += d.x * Strength.x;
p.y += d.y * Strength.y;
p.z += d.z * Strength.z;
sverts[i] = invtm.MultiplyPoint3x4(p);
}
}
示例6: Modify
public override void Modify(MegaModifiers mc)
{
// Copy the verts to start
verts.CopyTo(sverts, 0);
/*
int vertCount = verts.Length;
for (int i = 0; i < vertCount; i++) {
sverts[i] = verts[i];
}
*/
// Find [resolution] offsets from source to target shape
bool type = false;
int knot = 0;
float alpha = 0f;
float step = 1f / (resolution - 1);
Matrix4x4 trans = transform.worldToLocalMatrix * target.transform.localToWorldMatrix;
for ( int i = 0; i < resolution; i++ )
{
//targetOffsets[i] = trans.MultiplyPoint3x4(target.Interpolate(alpha, type, ref knot)) - sourcePositions[i];
targetOffsets[i] = trans.MultiplyPoint3x4(target.InterpCurve3D(0, alpha, type)) - sourcePositions[i];
alpha += step;
}
int wireVertCount = wireVerts.Length;
Debug.Log("Modify() moving " + wireVertCount + " verts.");
for ( int i = 0; i < wireVertCount; i++ )
{
sverts[wireVerts[i].vert] += targetOffsets[wireVerts[i].u] * wireVerts[i].w;
}
}
示例7: Start
void Start()
{
if ( source != null )
{
context = (MegaModifiers)source.GetComponent<MegaModifyObject>();
if ( context != null )
{
mods = source.GetComponents<MegaModifier>();
showmod = new bool[mods.Length];
}
gcontext = (MegaModifiers)ground.GetComponent<MegaModifyObject>();
if ( gcontext != null )
{
gmods = ground.GetComponents<MegaModifier>();
showgmod = new bool[gmods.Length];
}
}
//if ( book )
//{
//pageturn = book.GetComponent<PageTurn>();
//}
//windowRect.yMax = Screen.height - dsize;
//svh = windowRect.yMax * svd; //(float)Screen.height * 0.5f; // - dsize; //25.0f; //* 0.955f;
SizeChange();
}
示例8: Modify
public override void Modify(MegaModifiers mc)
{
for ( int i = 0; i < verts.Length; i++ )
{
Vector3 p = tm.MultiplyPoint3x4(verts[i]);
ip = p;
sp.x = p.x * scale + 0.5f; //half;
sp.z = p.z * scale + 0.5f; //half;
float dist = Mathf.Sqrt(p.x * p.x + p.z * p.z);
float dcy = Mathf.Exp(-decay * Mathf.Abs(dist));
if ( Fractal )
d.y = iperlin.fBm1(sp.x, sp.z, time, rt, 2.0f, Iterations);
else
d.y = iperlin.Noise(sp.x, sp.z, time);
p.y += d.y * Strength;
p.y = ip.y + ((p.y - ip.y) * dcy);
sverts[i] = invtm.MultiplyPoint3x4(p);
}
}
示例9: GetSelection
public override void GetSelection(MegaModifiers mc)
{
if ( ModEnabled )
{
if ( modselection == null || modselection.Length != mc.verts.Length )
modselection = new float[mc.verts.Length];
if ( update )
{
update = false;
if ( matnum < 0 )
matnum = 0;
if ( matnum >= mc.mesh.subMeshCount )
matnum = mc.mesh.subMeshCount - 1;
int[] tris = mc.mesh.GetTriangles(matnum);
for ( int i = 0; i < modselection.Length; i++ )
modselection[i] = otherweight;
for ( int i = 0; i < tris.Length; i++ )
modselection[tris[i]] = weight;
}
mc.selection = modselection;
}
}
示例10: ModStart
//void Reset()
//{
//if ( SourceWarpObj != null )
//warp = SourceWarpObj.GetComponent<Warp>();
//}
public override void ModStart(MegaModifiers mc)
{
if ( SourceWarpObj != null && SourceWarpObj != current )
{
current = SourceWarpObj;
warp = SourceWarpObj.GetComponent<MegaWarp>();
}
}
示例11: Init
// remove dups
void Init(MegaModifiers mod)
{
if ( mod.verts == null )
return;
List<int> noweights = new List<int>();
List<int> ActiveVertex = new List<int>();
int wc = (int)channel;
for ( int i = 0; i < mod.verts.Length; i++ )
{
// Dont add if we have already
if ( channel == MegaWeightChannel.None || mod.cols == null || mod.cols.Length == 0 )
{
//if ( !HavePoint(mod.verts, ActiveVertex, mod.verts[i]) )
//ActiveVertex.Add(i);
}
else
{
if ( mod.cols[i][wc] > threshold )
{
if ( !HavePoint(mod.verts, ActiveVertex, mod.verts[i]) )
ActiveVertex.Add(i);
}
else
noweights.Add(i);
}
}
notmoved = noweights.ToArray();
if ( ActiveVertex.Count > 0 )
{
vr = new VertexRubber[ActiveVertex.Count];
for ( int i = 0; i < ActiveVertex.Count; i++ )
{
int ref_index = (int)ActiveVertex[i];
float stiff = 1.0f;
if ( stiffchannel != MegaWeightChannel.None && mod.cols != null && mod.cols.Length > 0 )
{
stiff = mod.cols[ref_index][(int)stiffchannel];
}
//if ( channel != MegaWeightChannel.None && mod.cols != null && mod.cols.Length > 0 )
float intens = (mod.cols[ref_index][wc] - threshold) / (1.0f - threshold);
vr[i] = new VertexRubber(transform.TransformPoint(mod.verts[ref_index]), intens, stiff);
vr[i].indices = FindVerts(mod.verts, mod.verts[ref_index]);
}
}
else
vr = null;
defined = true;
}
示例12: Modify
public override void Modify(MegaModifiers mc)
{
for ( int i = 0; i < verts.Length; i++ )
{
Vector3 p = tm.MultiplyPoint3x4(verts[i]);
// So this mod should transform world point into local space of mod (gizmo offset if OSM, node tm if warp)
p = warp.Map(i, p);
sverts[i] = invtm.MultiplyPoint3x4(p);
}
}
示例13: GetSelection
public override void GetSelection(MegaModifiers mc)
{
if ( modselection == null || modselection.Length != mc.verts.Length )
{
modselection = new float[mc.verts.Length];
}
// we dont need to update if nothing changes
if ( useCurrentVerts )
{
for ( int i = 0; i < verts.Length; i++ )
{
float d = Vector3.Distance(origin, verts[i]) - radius;
if ( d < 0.0f )
modselection[i] = 1.0f;
else
{
float w = Mathf.Exp(-falloff * Mathf.Abs(d));
modselection[i] = w; //mc.cols[i][c];
}
}
}
else
{
for ( int i = 0; i < verts.Length; i++ )
{
float d = Vector3.Distance(origin, verts[i]) - radius;
if ( d < 0.0f )
modselection[i] = 1.0f;
else
{
float w = Mathf.Exp(-falloff * Mathf.Abs(d));
modselection[i] = w; //mc.cols[i][c];
}
}
}
//if ( weight == 1.0f )
// mc.selection = null; // Normal system
// We only need the copy if we are first mod
if ( (mc.dirtyChannels & MegaModChannel.Verts) == 0 )
{
mc.InitVertSource();
//verts.CopyTo(sverts, 0);
//mc.UpdateMesh = 1;
}
//Debug.Log("sel " + modselection.Length);
mc.selection = modselection;
}
示例14: Modify
public override void Modify(MegaModifiers mc)
{
//if ( uvs.Length == 0 )
//uvs = mc.uvs;
//if ( normals.Length == 0 )
//normals = mc.mesh.normals;
//Vector3[] verts = mc.GetSourceVerts();
//Vector3[] sverts = mc.GetDestVerts();
for ( int i = 0; i < verts.Length; i++ )
sverts[i] = Map(i, verts[i]);
}
示例15: DoWork
public override void DoWork(MegaModifiers mc, int index, int start, int end, int cores)
{
//if ( useWeights )
if ( selection != null )
{
DoWorkWeighted(mc, index, start, end, cores);
return;
}
for ( int i = start; i < end; i++ )
sverts[i] = MapMT(i, verts[i]);
}