public override List <Meshable> ExecuteShape(ShapeObject so) { float d = ((ParameterGroup)paramGroups["Position"]).parameters[0].Value; int axis = (int)((ParameterGroup)paramGroups["Axis"]).parameters[0].Value; //get scale Vector3 scale = new Vector3(1, 1, 1); scale[axis] = d; Vector3[] vects = so.Vects; Vector3 origin = so.transform.position; //get the splited meshables Meshable mb = so.meshable; Meshable scaledMb = mb.Scale(scale, vects, origin, true); //TODO: just scale the bbox scaledMb.bbox = BoundingBox.CreateFromPoints(scaledMb.vertices, so.meshable.bbox); //outMeshables.Add(scaledMb); List <Meshable> outs = new List <Meshable>(); outs.Add(scaledMb); AssignNames(outs); //AssignNames(outMeshables.ToArray()); return(outs); //Rule.Execute() will take care of the outMeshables }
public override List <Meshable> ExecuteShape(ShapeObject so) { float dx = ((ParameterGroup)paramGroups["SizeAddition"]).parameters[0].Value; float dy = ((ParameterGroup)paramGroups["SizeAddition"]).parameters[1].Value; float dz = ((ParameterGroup)paramGroups["SizeAddition"]).parameters[2].Value; //get Size Vector3 size = new Vector3(dx, dy, dz); if (randRange.HasValue) { float min = randRange.Value[0]; float max = randRange.Value[1]; for (int i = 0; i < 3; i++) { size[i] = size[i] * (1 + Random.Range(min, max)); } } if (size.z > size.x) { size.x = size.z; } Vector3 scale = new Vector3(1, 1, 1); Vector3 soSize = so.transform.localScale; for (int i = 0; i < 3; i++) { scale[i] = 1 + (size[i] / soSize[i]); } Vector3[] vects = so.Vects; Vector3 origin = so.transform.position; //get the splited meshables Meshable mb = so.meshable; Meshable scaledMb = mb.Scale(scale, vects, origin, true); //TODO: just scale the bbox scaledMb.bbox = BoundingBox.CreateFromPoints(scaledMb.vertices, so.meshable.bbox); //outMeshables.Add(scaledMb); List <Meshable> outs = new List <Meshable>(); outs.Add(scaledMb); AssignNames(outs); //AssignNames(outMeshables.ToArray()); return(outs); //Rule.Execute() will take care of the outMeshables }
public override List <Meshable> ExecuteShape(ShapeObject so) { float dx = ((ParameterGroup)paramGroups["Scale"]).parameters[0].Value; float dy = ((ParameterGroup)paramGroups["Scale"]).parameters[1].Value; float dz = ((ParameterGroup)paramGroups["Scale"]).parameters[2].Value; //round to divisible by 4 float h = so.Size[1] * dy; h -= h % 4; dy = h / so.Size[1]; Vector3 scale = new Vector3(dx, dy, dz); if (randRange.HasValue) { float min = randRange.Value[0]; float max = randRange.Value[1]; for (int i = 0; i < 3; i++) { scale[i] = scale[i] * (1 + Random.Range(min, max)); } } Vector3[] vects = so.Vects; Vector3 origin = so.transform.position; if (alignment.HasValue) { origin = so.meshable.bbox.GetOriginFromAlignment(alignment.Value); } //get the splited meshables Meshable mb = so.meshable; Meshable scaledMb = mb.Scale(scale, vects, origin, true); //TODO: just scale the bbox scaledMb.bbox = BoundingBox.CreateFromPoints(scaledMb.vertices, so.meshable.bbox); //outMeshables.Add(scaledMb); List <Meshable> outs = new List <Meshable>(); outs.Add(scaledMb); AssignNames(outs); //AssignNames(outMeshables.ToArray()); return(outs); //Rule.Execute() will take care of the outMeshables }
public static void ScaleForm(Meshable mb, Vector3 scale, Alignment?alignment = null) { Vector3 org = mb.bbox.GetOriginFromAlignment(alignment); mb.Scale(scale, mb.bbox.vects, org, false); }