public override bool Prepare(MegaModContext mc) { vWind.x = Mathf.Sin(WindDir * Mathf.Deg2Rad) * WindSpeed; vWind.y = Mathf.Cos(WindDir * Mathf.Deg2Rad) * WindSpeed; return(true); }
public override bool Prepare(MegaModContext mc) { if ( chanBank != null && chanBank.Count > 0 ) return true; return false; }
public override void DrawGizmo(MegaModContext context) { Gizmos.color = Color.yellow; Matrix4x4 gtm = Matrix4x4.identity; Vector3 pos = gizmoPos; pos.x = -pos.x; pos.y = -pos.y; pos.z = -pos.z; Vector3 scl = gizmoScale; scl.x = 1.0f - (scl.x - 1.0f); scl.y = 1.0f - (scl.y - 1.0f); gtm.SetTRS(pos, Quaternion.Euler(gizmoRot), scl); Matrix4x4 tm = Matrix4x4.identity; switch (axis) { case MegaAxis.X: MegaMatrix.RotateZ(ref tm, 90.0f * Mathf.Deg2Rad); break; case MegaAxis.Z: MegaMatrix.RotateX(ref tm, 90.0f * Mathf.Deg2Rad); break; } Gizmos.matrix = transform.localToWorldMatrix * gtm * tm; BuildMesh(); }
public override void DrawGizmo(MegaModContext context) { Gizmos.color = Color.yellow; Matrix4x4 gtm = Matrix4x4.identity; Vector3 pos = gizmoPos; pos.x = -pos.x; pos.y = -pos.y; pos.z = -pos.z; Vector3 scl = gizmoScale; scl.x = 1.0f - (scl.x - 1.0f); scl.y = 1.0f - (scl.y - 1.0f); gtm.SetTRS(pos, Quaternion.Euler(gizmoRot), scl); Gizmos.matrix = transform.localToWorldMatrix * gtm; float r1 = 0.0f; for (int i = 0; i < circles; i++) { float r = ((float)i / (float)circles) * radius; MakeCircle(t, r, r1, amp, amp2, wave, phase, dy, segments); r1 = r; } }
public override bool ModLateUpdate(MegaModContext mc) { if (!Prepare(mc)) { return(false); } if (animated) { time += Time.deltaTime * speed; } switch (LoopMode) { case MegaRepeatMode.Loop: t = Mathf.Repeat(time, maxtime); break; case MegaRepeatMode.PingPong: t = Mathf.PingPong(time, maxtime); break; case MegaRepeatMode.Clamp: t = Mathf.Clamp(time, 0.0f, maxtime); break; } alpha = t / maxtime; float val = (float)(Verts[0].points.Length - 1) * alpha; sindex = (int)val; dalpha = val - sindex; //Debug.Log("t " + t + " alpha " + alpha + " sindex " + sindex + " dalpha " + dalpha + " verts " + Verts[0].points.Length); return(true); }
public override bool Prepare(MegaModContext mc) { vWind.x = Mathf.Sin(WindDir * Mathf.Deg2Rad) * WindSpeed; vWind.y = Mathf.Cos(WindDir * Mathf.Deg2Rad) * WindSpeed; return true; }
public override bool Prepare(MegaModContext mc) { if ( normals != null ) return true; return false; }
public override bool Prepare(MegaModContext mc) { tm = Matrix4x4.identity; invtm = tm.inverse; mat = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(gizmoRot), gizmoScale); return(true); }
public override bool Prepare(MegaModContext mc) { if (SourceWarpObj != current) { current = SourceWarpObj; warp = null; } if (SourceWarpObj != null) { if (warp == null) { warp = SourceWarpObj.GetComponent <MegaWarp>(); } if (warp != null && warp.Enabled) { tm = transform.localToWorldMatrix; invtm = tm.inverse; return(warp.Prepare(decay)); } } return(false); }
public override bool Prepare(MegaModContext mc) { if (target) { tm = target.worldToLocalMatrix * transform.localToWorldMatrix; invtm = tm.inverse; //target.worldToLocalMatrix; } else { tm = transform.localToWorldMatrix; invtm = transform.worldToLocalMatrix; } oomass = 1.0f / mass; grav = gravity * 0.1f; if (!defined) { Init(mc.mod); } if (vr != null) { return(true); } return(false); }
public override bool Prepare(MegaModContext mc) { tm = Matrix4x4.identity; invtm = tm.inverse; mat = Matrix4x4.TRS(Vector3.zero, Quaternion.Euler(gizmoRot), gizmoScale); return true; }
public override void DrawGizmo(MegaModContext context) { Gizmos.color = Color.yellow; Matrix4x4 gtm = Matrix4x4.identity; Vector3 pos = gizmoPos; pos.x = -pos.x; pos.y = -pos.y; pos.z = -pos.z; Vector3 scl = gizmoScale; scl.x = 1.0f - (scl.x - 1.0f); scl.y = 1.0f - (scl.y - 1.0f); gtm.SetTRS(pos, Quaternion.Euler(gizmoRot), scl); //if ( context.sourceObj != null ) //Gizmos.matrix = context.sourceObj.transform.localToWorldMatrix * gtm; //else //Gizmos.matrix = transform.localToWorldMatrix * gtm; Gizmos.matrix = transform.localToWorldMatrix * gtm; float r1 = 0.0f; for ( int i = 0; i < circles; i++ ) { float r = ((float)i / (float)circles) * radius; MakeCircle(t, r, r1, amp, amp2, wave, phase, dy, segments); r1 = r; } }
public override void DrawGizmo(MegaModContext context) { if (!Prepare(context)) { return; } Vector3 min = context.bbox.min; Vector3 max = context.bbox.max; Matrix4x4 gtm = Matrix4x4.identity; Vector3 pos = gizmoPos; pos.x = -pos.x; pos.y = -pos.y; pos.z = -pos.z; Vector3 scl = gizmoScale; scl.x = 1.0f - (scl.x - 1.0f); scl.y = 1.0f - (scl.y - 1.0f); gtm.SetTRS(pos, Quaternion.Euler(gizmoRot), scl); if (context.mod.sourceObj != null) { Gizmos.matrix = context.mod.sourceObj.transform.localToWorldMatrix * gtm; } else { Gizmos.matrix = transform.localToWorldMatrix * gtm; } Gizmos.color = Color.yellow; corners[0] = new Vector3(min.x, min.y, min.z); corners[1] = new Vector3(min.x, max.y, min.z); corners[2] = new Vector3(max.x, max.y, min.z); corners[3] = new Vector3(max.x, min.y, min.z); corners[4] = new Vector3(min.x, min.y, max.z); corners[5] = new Vector3(min.x, max.y, max.z); corners[6] = new Vector3(max.x, max.y, max.z); corners[7] = new Vector3(max.x, min.y, max.z); DrawEdge(corners[0], corners[1]); DrawEdge(corners[1], corners[2]); DrawEdge(corners[2], corners[3]); DrawEdge(corners[3], corners[0]); DrawEdge(corners[4], corners[5]); DrawEdge(corners[5], corners[6]); DrawEdge(corners[6], corners[7]); DrawEdge(corners[7], corners[4]); DrawEdge(corners[0], corners[4]); DrawEdge(corners[1], corners[5]); DrawEdge(corners[2], corners[6]); DrawEdge(corners[3], corners[7]); ExtraGizmo(context); }
public override void DrawGizmo(MegaModContext context) { if ( ModEnabled ) { base.DrawGizmo(context); Matrix4x4 tm = gameObject.transform.localToWorldMatrix; Gizmos.matrix = tm; for ( int i = 0; i < volumes.Count; i++ ) { if ( volumes[i].enabled && volumes[i].volType == MegaVolumeType.Box ) { Gizmos.color = volumes[i].regcol; //Color.yellow; Gizmos.DrawWireCube(volumes[i].origin, volumes[i].boxsize * 2.0f); // * 0.5f); } if ( volumes[i].enabled && volumes[i].volType == MegaVolumeType.Sphere ) { Gizmos.color = volumes[i].regcol; //Color.yellow; Gizmos.DrawWireSphere(volumes[i].origin, volumes[i].radius); // * 0.5f); } } Gizmos.matrix = Matrix4x4.identity; } }
public override bool Prepare(MegaModContext mc) { if ( !roller ) return false; rpos = transform.worldToLocalMatrix.MultiplyPoint3x4(roller.position); height = rpos.y - radius; if ( offsets == null || offsets.Length != mc.mod.verts.Length ) offsets = new Vector3[mc.mod.verts.Length]; mat = Matrix4x4.identity; SetAxis(mat); tm = Matrix4x4.identity; if ( clearoffsets ) { clearoffsets = false; for ( int i = 0; i < offsets.Length; i++ ) { offsets[i] = Vector3.zero; } } if ( height < mc.bbox.Size().y ) delta = height / mc.bbox.Size().y; else delta = 1.0f; return true; }
//public override bool ModLateUpdate(Modifiers mc) public override bool ModLateUpdate(MegaModContext mc) { if ( animate ) percent += speed * Time.deltaTime; return Prepare(mc); }
public override void DrawGizmo(MegaModContext context) { base.DrawGizmo(context); Gizmos.color = Color.yellow; Gizmos.DrawWireCube(origin, size * 2.0f); }
public override bool Prepare(MegaModContext mc) { if (targets.Count > 0) { if (conformColliders.Count == 0) { return(false); } if (conformedVerts == null || conformedVerts.Length != mc.mod.verts.Length) { conformedVerts = new Vector3[mc.mod.verts.Length]; // Need to run through all the source meshes and find the vertical offset from the base offsets = new float[mc.mod.verts.Length]; last = new float[mc.mod.verts.Length]; for (int i = 0; i < mc.mod.verts.Length; i++) { offsets[i] = mc.mod.verts[i][(int)axis] - mc.bbox.min[(int)axis]; } } loctoworld = transform.localToWorldMatrix; ctm = loctoworld; cinvtm = transform.worldToLocalMatrix; //ctm.inverse; } return(true); }
public override bool ModLateUpdate(MegaModContext mc) { if ( animate ) phase += Time.deltaTime * speed; return Prepare(mc); }
public override void ExtraGizmo(MegaModContext mc) { if (doRegion) { DrawFromTo(axis, from, to, mc); } }
public override bool Prepare(MegaModContext mc) { size = bbox.Size(); amt = amount / 100.0f; return(true); }
public override bool Prepare(MegaModContext mc) { switch (EAxis) { case MegaEffectAxis.X: doX = true; doY = false; break; case MegaEffectAxis.Y: doX = false; doY = true; break; case MegaEffectAxis.XY: doX = true; doY = true; break; } mat = Matrix4x4.identity; switch (axis) { case MegaAxis.X: MegaMatrix.RotateZ(ref mat, Mathf.PI * 0.5f); l = bbox.max[0] - bbox.min[0]; break; case MegaAxis.Y: MegaMatrix.RotateX(ref mat, -Mathf.PI * 0.5f); l = bbox.max[2] - bbox.min[2]; break; case MegaAxis.Z: l = bbox.max[1] - bbox.min[1]; break; } if (l != 0.0f) { ovl = 1.0f / l; } MegaMatrix.RotateY(ref mat, Mathf.Deg2Rad * dir); SetAxis(mat); SetK(amount, crv); return(true); }
public override bool ModLateUpdate(MegaModContext mc) { int ax = (int)axis; float width = bbox.max[ax] - bbox.min[ax]; // init if (buffer1 == null) { Setup(); } // Update ripples if (swapMe) { // process the ripples for this frame processRipples(buffer1, buffer2); currentBuffer = buffer2; } else { processRipples(buffer2, buffer1); currentBuffer = buffer1; } swapMe = !swapMe; //splashAtPoint(cols / 2, rows / 2); return(Prepare(mc)); }
public override bool Prepare(MegaModContext mc) { if (wave == 0.0f) { wave = 0.000001f; } dy = Decay / 1000.0f; switch (waveaxis) { case MegaAxis.X: ix = 0; iz = 2; break; case MegaAxis.Y: ix = 1; iz = 2; break; case MegaAxis.Z: ix = 2; iz = 0; break; } return(true); }
public override void DrawGizmo(MegaModContext context) { Gizmos.color = Color.yellow; Matrix4x4 gtm = Matrix4x4.identity; Vector3 pos = gizmoPos; pos.x = -pos.x; pos.y = -pos.y; pos.z = -pos.z; Vector3 scl = gizmoScale; scl.x = 1.0f - (scl.x - 1.0f); scl.y = 1.0f - (scl.y - 1.0f); gtm.SetTRS(pos, Quaternion.Euler(gizmoRot), scl); //if ( context.sourceObj != null ) //Gizmos.matrix = context.sourceObj.transform.localToWorldMatrix * gtm; //else //Gizmos.matrix = transform.localToWorldMatrix * gtm; Gizmos.matrix = transform.localToWorldMatrix * gtm; BuildMesh(t); }
public override bool Prepare(MegaModContext mc) { mat = Matrix4x4.identity; SetAxis(mat); return true; }
public override bool Prepare(MegaModContext mc) { if (path != null) { if (curve >= path.splines.Count) { curve = 0; } usepercent = percent / 100.0f; ovlen = (1.0f / path.splines[curve].length); // * stretch; usetan = (tangent * 0.01f); mat = Matrix4x4.identity; switch (axis) { case MegaAxis.X: MegaMatrix.RotateZ(ref mat, Mathf.PI * 0.5f); break; case MegaAxis.Y: MegaMatrix.RotateX(ref mat, -Mathf.PI * 0.5f); break; case MegaAxis.Z: break; } MegaMatrix.RotateZ(ref mat, Mathf.Deg2Rad * rotate); SetAxis(mat); mat = transform.localToWorldMatrix.inverse * path.transform.localToWorldMatrix; return(true); } return(false); }
public override bool Prepare(MegaModContext mc) { mat = Matrix4x4.identity; switch (axis) { case MegaAxis.X: MegaMatrix.RotateZ(ref mat, Mathf.PI * 0.5f); break; case MegaAxis.Y: MegaMatrix.RotateX(ref mat, -Mathf.PI * 0.5f); break; case MegaAxis.Z: break; } SetAxis(mat); float xsize = bbox.max.x - bbox.min.x; float zsize = bbox.max.z - bbox.min.z; size = (xsize > zsize) ? xsize : zsize; // Get the percentage to spherify at this time per = Percent / 100.0f; return(true); }
public override bool ModLateUpdate(MegaModContext mc) { // init if (buffer1 == null || rows * cols != buffer1.Length) { Setup(); swapMe = false; currentBuffer = buffer2; return(false); } // Update ripples if (swapMe) { // process the ripples for this frame processRipples(buffer1, buffer2); currentBuffer = buffer2; } else { processRipples(buffer2, buffer1); currentBuffer = buffer2; } swapMe = !swapMe; return(Prepare(mc)); }
public override bool Prepare(MegaModContext mc) { affected.Clear(); distances.Clear(); if (offsets == null || offsets.Length != mc.mod.verts.Length) { offsets = new Vector3[mc.mod.verts.Length]; } normals = mc.mod.mesh.normals; // get current normals mat = Matrix4x4.identity; SetAxis(mat); hadahit = false; if (Input.GetMouseButton(0)) { RaycastHit hit; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.collider == gameObject.collider) { hadahit = true; relativePoint = hit.collider.transform.InverseTransformPoint(hit.point); } } } else { } return(true); }
//public override bool ModLateUpdate(Modifiers mc) public override bool ModLateUpdate(MegaModContext mc) { if (animate) { if (Application.isPlaying) { spiral += spiralspeed * Time.deltaTime; } if (Mathf.Abs(spiral) > spirallim) { if (spiral < 0.0f) { spiral = -spirallim; } else { spiral = spirallim; } spiralspeed = -spiralspeed; } if (Application.isPlaying) { gizmoRot.y += rotspeed * Time.deltaTime; gizmoRot.y = Mathf.Repeat(gizmoRot.y, 360.0f); gizmoPos += speed * Time.deltaTime; } } return(Prepare(mc)); }
public override bool ModLateUpdate(MegaModContext mc) { if (source) { if (animate) { if (Application.isPlaying) { animtime += Time.deltaTime * speed; } switch (repeatMode) { case MegaRepeatMode.Loop: animtime = Mathf.Repeat(animtime, looptime); break; case MegaRepeatMode.Clamp: animtime = Mathf.Clamp(animtime, 0.0f, looptime); break; } SetAnim(animtime); } if (dif == null) { dif = new Vector3[mc.mod.verts.Length]; } } return(Prepare(mc)); }
public override void DrawGizmo(MegaModContext context) { if (ModEnabled) { base.DrawGizmo(context); Matrix4x4 tm = gameObject.transform.localToWorldMatrix; Gizmos.matrix = tm; for (int i = 0; i < volumes.Count; i++) { if (volumes[i].enabled && volumes[i].volType == MegaVolumeType.Box) { Gizmos.color = volumes[i].regcol; //Color.yellow; Gizmos.DrawWireCube(volumes[i].origin, volumes[i].boxsize * 2.0f); // * 0.5f); } if (volumes[i].enabled && volumes[i].volType == MegaVolumeType.Sphere) { Gizmos.color = volumes[i].regcol; //Color.yellow; Gizmos.DrawWireSphere(volumes[i].origin, volumes[i].radius); // * 0.5f); } } Gizmos.matrix = Matrix4x4.identity; } }
public override bool Prepare(MegaModContext mc) { if ( wave == 0.0f ) wave = 0.000001f; dy = Decay / 1000.0f; switch ( waveaxis ) { case MegaAxis.X: ix = 0; iz = 2; break; case MegaAxis.Y: ix = 1; iz = 2; break; case MegaAxis.Z: ix = 2; iz = 0; break; } return true; }
public override bool Prepare(MegaModContext mc) { Vector3 s = LatticeSize(); for (int i = 0; i < 3; i++) { if (s[i] == 0.0f) { s[i] = 1.0f; } else { s[i] = 1.0f / s[i]; } } Vector3 c = MegaMatrix.GetTrans(ref tm); MegaMatrix.SetTrans(ref tm, c - bbox.min - Offset); MegaMatrix.Scale(ref tm, s, false); invtm = tm.inverse; return(true); }
public override bool Prepare(MegaModContext mc) { mat = Matrix4x4.identity; SetAxis(mat); return(true); }
public override bool Prepare(MegaModContext mc) { size = bbox.Size(); amt = amount / 100.0f; return true; }
public override bool Prepare(MegaModContext mc) { if (path != null) { if (curve >= path.splines.Count) { curve = 0; } usepercent = percent / 100.0f; ovlen = (1.0f / path.splines[curve].length); // * stretch; usetan = (tangent * 0.01f); //Debug.Log("PathLength " + path.splines[0].length); //path.CalcLength(0, 5); //Debug.Log("CalcPathLength " + path.splines[0].length); //return false; //if ( path.beendrawn == false ) //return false; mat = Matrix4x4.identity; switch (axis) { case MegaAxis.Z: MegaMatrix.RotateX(ref mat, -Mathf.PI * 0.5f); break; } MegaMatrix.RotateZ(ref mat, Mathf.Deg2Rad * rotate); SetAxis(mat); start = path.splines[curve].knots[0].p; Vector3 p1 = path.InterpCurve3D(0, 0.01f, path.normalizedInterp); Vector3 up = Vector3.zero; switch (axis) { case MegaAxis.X: up = Vector3.left; break; case MegaAxis.Y: up = Vector3.back; break; case MegaAxis.Z: up = Vector3.up; break; } Quaternion lrot = Quaternion.identity; if (flip) { up = -up; } lrot = Quaternion.FromToRotation(p1 - start, up); mat.SetTRS(Vector3.zero, lrot, Vector3.one); return(true); } return(false); }
public override bool Prepare(MegaModContext mc) { if (mycollider == null) { mycollider = GetComponent <Collider>(); } return(true); }
public override bool ModLateUpdate(MegaModContext mc) { if ( Animate ) Phase += Time.deltaTime * Freq; time = Phase; return Prepare(mc); }
public override bool ModLateUpdate(MegaModContext mc) { if (animate) { phase += Time.deltaTime * speed; } return(Prepare(mc)); }
//public override bool ModLateUpdate(Modifiers mc) public override bool ModLateUpdate(MegaModContext mc) { if ( animate ) { t += Time.deltaTime * Speed; phase = t; } return Prepare(mc); }
//public override bool ModLateUpdate(Modifiers mc) public override bool ModLateUpdate(MegaModContext mc) { if (animate) { percent += speed * Time.deltaTime; } return(Prepare(mc)); }
public override void DrawGizmo(MegaModContext context) { //tm = Matrix4x4.identity; //Matrix.Translate(ref tm, Offset); //invtm = tm.inverse; if ( !Prepare(context) ) return; Vector3 min = context.bbox.min; Vector3 max = context.bbox.max; //Matrix4x4 gtm = Matrix4x4.identity; //Vector3 pos = gizmoPos; //pos.x = -pos.x; //pos.y = -pos.y; //pos.z = -pos.z; //Vector3 scl = gizmoScale; //scl.x = 1.0f - (scl.x - 1.0f); //scl.y = 1.0f - (scl.y - 1.0f); //gtm.SetTRS(pos, Quaternion.Euler(gizmoRot), scl); if ( context.mod.sourceObj != null ) Gizmos.matrix = context.mod.sourceObj.transform.localToWorldMatrix; // * gtm; else Gizmos.matrix = transform.localToWorldMatrix; // * gtm; //Gizmos.color = ModCol(); //Color.yellow; corners[0] = new Vector3(min.x, min.y, min.z); corners[1] = new Vector3(min.x, max.y, min.z); corners[2] = new Vector3(max.x, max.y, min.z); corners[3] = new Vector3(max.x, min.y, min.z); corners[4] = new Vector3(min.x, min.y, max.z); corners[5] = new Vector3(min.x, max.y, max.z); corners[6] = new Vector3(max.x, max.y, max.z); corners[7] = new Vector3(max.x, min.y, max.z); DrawEdge(corners[0], corners[1]); DrawEdge(corners[1], corners[2]); DrawEdge(corners[2], corners[3]); DrawEdge(corners[3], corners[0]); DrawEdge(corners[4], corners[5]); DrawEdge(corners[5], corners[6]); DrawEdge(corners[6], corners[7]); DrawEdge(corners[7], corners[4]); DrawEdge(corners[0], corners[4]); DrawEdge(corners[1], corners[5]); DrawEdge(corners[2], corners[6]); DrawEdge(corners[3], corners[7]); ExtraGizmo(context); }
public override bool Prepare(MegaModContext mc) { mat = Matrix4x4.identity; SetAxis(mat); SetK(amount, crv, radialamount, radialcrv); Vector3 size = bbox.Size(); l = size[1]; //bbox.max[1] - bbox.min[1]; l2 = Mathf.Sqrt(size[0] * size[0] + size[2] * size[2]); return true; }
public override bool ModLateUpdate(MegaModContext mc) { if ( animate ) phase += Time.deltaTime * speed; timex = 0.1365143f + phase; timey = 1.21688f + phase; timez = 2.5564f + phase; return Prepare(mc); }
public override bool ModLateUpdate(MegaModContext mc) { if ( animate ) { float dt = Time.deltaTime; if ( dt == 0.0f ) dt = 0.01f; t += dt * Speed; phase = t; } return Prepare(mc); }
public override void DrawGizmo(MegaModContext context) { base.DrawGizmo(context); for ( int i = 0; i < curves.Count; i++ ) { if ( curves[i].enabled && curves[i].uselimits ) { Gizmos.color = curves[i].regcol; //Color.yellow; Gizmos.DrawWireCube(curves[i].origin, curves[i].boxsize); // * 0.5f); } } }
// Should use Map //public override void Modify(MegaModifiers mc) //{ // for ( int i = 0; i < verts.Length; i++ ) // { // sverts[i] = verts[i]; // } //} public override bool ModLateUpdate(MegaModContext mc) { ax = (int)axis; minx = bbox.min[ax]; width = bbox.max[ax] - bbox.min[ax]; if ( init ) { init = false; Init(); } AddWeight(); UpdateRope(); return Prepare(mc); }
public override bool ModLateUpdate(MegaModContext mc) { if ( animate ) { animtime += Time.deltaTime * speed; switch ( repeatMode ) { case MegaRepeatMode.Loop: animtime = Mathf.Repeat(animtime, looptime); break; case MegaRepeatMode.Clamp: animtime = Mathf.Clamp(animtime, 0.0f, looptime); break; } SetAnim(animtime); } return Prepare(mc); }
public override bool Prepare(MegaModContext mc) { mat = Matrix4x4.identity; MegaMatrix.RotateZ(ref mat, Mathf.Deg2Rad * dir); SetAxis(mat); dy = Decay / 1000.0f; dist = (wave / 10.0f) * 4.0f * 5.0f; //float(numSides); if ( dist == 0.0f ) dist = 1.0f; return true; }
public override bool Prepare(MegaModContext mc) { xsize = bbox.max.x - bbox.min.x; ysize = bbox.max.y - bbox.min.y; zsize = bbox.max.z - bbox.min.z; size = (xsize > ysize) ? xsize : ysize; size = (zsize > size) ? zsize : size; size /= 2.0f; cx = bbox.center.x; cy = bbox.center.y; cz = bbox.center.z; // Get the percentage to spherify at this time per = percent / 100.0f; return true; }
public override void DrawGizmo(MegaModContext context) { tm = Matrix4x4.identity; invtm = tm.inverse; if ( !Prepare(context) ) return; Vector3 min = context.bbox.min; Vector3 max = context.bbox.max; if ( context.mod.sourceObj != null ) Gizmos.matrix = context.mod.sourceObj.transform.localToWorldMatrix; else Gizmos.matrix = transform.localToWorldMatrix; corners[0] = new Vector3(min.x, min.y, min.z); corners[1] = new Vector3(min.x, max.y, min.z); corners[2] = new Vector3(max.x, max.y, min.z); corners[3] = new Vector3(max.x, min.y, min.z); corners[4] = new Vector3(min.x, min.y, max.z); corners[5] = new Vector3(min.x, max.y, max.z); corners[6] = new Vector3(max.x, max.y, max.z); corners[7] = new Vector3(max.x, min.y, max.z); DrawEdge(corners[0], corners[1]); DrawEdge(corners[1], corners[2]); DrawEdge(corners[2], corners[3]); DrawEdge(corners[3], corners[0]); DrawEdge(corners[4], corners[5]); DrawEdge(corners[5], corners[6]); DrawEdge(corners[6], corners[7]); DrawEdge(corners[7], corners[4]); DrawEdge(corners[0], corners[4]); DrawEdge(corners[1], corners[5]); DrawEdge(corners[2], corners[6]); DrawEdge(corners[3], corners[7]); ExtraGizmo(context); }
//public override bool ModLateUpdate(Modifiers mc) public override bool ModLateUpdate(MegaModContext mc) { if ( animate ) { spiral += spiralspeed * Time.deltaTime; if ( Mathf.Abs(spiral) > spirallim ) { if ( spiral < 0.0f ) spiral = -spirallim; else spiral = spirallim; spiralspeed = -spiralspeed; } gizmoRot.y += rotspeed * Time.deltaTime; gizmoRot.y = Mathf.Repeat(gizmoRot.y, 360.0f); gizmoPos += speed * Time.deltaTime; } return Prepare(mc); }
public override bool Prepare(MegaModContext mc) { Vector3 s = LatticeSize(); for ( int i = 0; i < 3; i++ ) { if ( s[i] == 0.0f ) s[i] = 1.0f; else s[i] = 1.0f / s[i]; } Vector3 c = MegaMatrix.GetTrans(ref tm); MegaMatrix.SetTrans(ref tm, c - bbox.min - Offset); MegaMatrix.Scale(ref tm, s, false); invtm = tm.inverse; return true; }
public override bool Prepare(MegaModContext mc) { mat = Matrix4x4.identity; switch ( axis ) { case MegaAxis.X: MegaMatrix.RotateZ(ref mat, Mathf.PI * 0.5f); break; case MegaAxis.Y: MegaMatrix.RotateX(ref mat, -Mathf.PI * 0.5f); break; case MegaAxis.Z: break; } SetAxis(mat); float xsize = bbox.max.x - bbox.min.x; float zsize = bbox.max.z - bbox.min.z; size = (xsize > zsize) ? xsize : zsize; // Get the percentage to spherify at this time per = Percent / 100.0f; return true; }
public override bool Prepare(MegaModContext mc) { if ( from > 0.0f ) from = 0.0f; if ( to < 0.0f ) to = 0.0f; mat = Matrix4x4.identity; switch ( axis ) { case MegaAxis.X: MegaMatrix.RotateZ(ref mat, Mathf.PI * 0.5f); break; case MegaAxis.Y: MegaMatrix.RotateX(ref mat, -Mathf.PI * 0.5f); break; case MegaAxis.Z: break; } MegaMatrix.RotateY(ref mat, Mathf.Deg2Rad * dir); SetAxis(mat); float len = 0.0f; if ( !doRegion ) { switch ( axis ) { case MegaAxis.X: len = bbox.max.x - bbox.min.x; break; case MegaAxis.Z: len = bbox.max.y - bbox.min.y; break; case MegaAxis.Y: len = bbox.max.z - bbox.min.z; break; } } else len = to - from; if ( len == 0.0f ) len = 0.000001f; amountOverLength = amount / len; return true; }
public override bool Prepare(MegaModContext mc) { if ( !roller ) return false; rpos = transform.worldToLocalMatrix.MultiplyPoint3x4(roller.position); height = rpos.y - radius; //Debug.Log("height + " + height + " rpos " + rpos); if ( offsets == null || offsets.Length != mc.mod.verts.Length ) offsets = new Vector3[mc.mod.verts.Length]; mat = Matrix4x4.identity; SetAxis(mat); tm = Matrix4x4.identity; if ( clearoffsets ) { clearoffsets = false; for ( int i = 0; i < offsets.Length; i++ ) { offsets[i] = Vector3.zero; } } //Debug.Log("size " + mc.bbox.Size()); if ( height < mc.bbox.Size().y ) { delta = height / mc.bbox.Size().y; } else delta = 1.0f; Debug.Log("delta " + delta); return true; }
public override void DrawGizmo(MegaModContext context) { if ( ModEnabled ) { base.DrawGizmo(context); Matrix4x4 tm = gameObject.transform.localToWorldMatrix; Gizmos.matrix = tm; if ( enabled && volType == MegaVolumeType.Box ) { Gizmos.color = Color.yellow; Gizmos.DrawWireCube(origin, boxsize * 2.0f); // * 0.5f); } if ( enabled && volType == MegaVolumeType.Sphere ) { Gizmos.color = Color.yellow; Gizmos.DrawWireSphere(origin, radius); // * 0.5f); } Gizmos.matrix = Matrix4x4.identity; } }