public static void LoadData() { // default shape is sphere MyMwcObjectBuilder_VoxelHand_Sphere defaultBuilder = new MyMwcObjectBuilder_VoxelHand_Sphere(new MyMwcPositionAndOrientation(MySpectator.Orientation, Vector3.Forward, Vector3.Up), MyVoxelConstants.DEFAULT_VOXEL_HAND_SIZE, MyMwcVoxelHandModeTypeEnum.SUBTRACT); VoxelHandShape = new MyVoxelHandSphere(); ((MyVoxelHandSphere)VoxelHandShape).Init(defaultBuilder, null); m_Enabled = false; m_timeFromLastShaping = 0; m_distance = MyVoxelConstants.DEFAULT_VOXEL_HAND_DISTANCE; IsProjected = false; IsProjectedToWaypoints = false; }
public static void AddVein(MyMwcObjectBuilder_VoxelMap builder, float thickness, Vector3 position, Random rnd, MyMwcVoxelMaterialsEnum material, float veinAngleDev, int maxLevel, int level = 0) { int numSplits = 2;// rnd.Next(2, 4); List<Vector3> targets = new List<Vector3>(numSplits); float handDist = thickness * 1.5f; for (int iSplit = 0; iSplit < numSplits; iSplit++) { // Hands per line int numHands = rnd.Next(8, 12); Vector3 direction = rnd.Direction(); Vector3 target = position; for (int i = 0; i < numHands; i++) { direction = rnd.Direction(direction, veinAngleDev); target += direction * handDist; // TODO: uncomment this to see material better (shown as tunnels, not only as voxel material) //var voxelHand = new MyMwcObjectBuilder_VoxelHand_Sphere(target, thickness - 1, MyMwcVoxelHandModeTypeEnum.SUBTRACT); //voxelHand.VoxelHandMaterial = material; //builder.VoxelHandShapes.Add(voxelHand); var voxelHand2 = new MyMwcObjectBuilder_VoxelHand_Sphere(new MyMwcPositionAndOrientation(target, Vector3.Forward, Vector3.Up), thickness, MyMwcVoxelHandModeTypeEnum.SET_MATERIAL); voxelHand2.VoxelHandMaterial = material; builder.VoxelHandShapes.Add(voxelHand2); } targets.Add(target); } if (level < maxLevel) { foreach (var t in targets) { AddVein(builder, thickness * 0.7f, t, rnd, material, veinAngleDev, maxLevel, level + 1); } } }
public static void SetVoxelProperties(MyVoxelHandShapeType voxelHandShapeType, float distance, MyMwcVoxelHandModeTypeEnum modeType, MyMwcVoxelMaterialsEnum? materialEnum, bool isProjected, bool isProjectedToWaypoints) { IsProjected = isProjected; IsProjectedToWaypoints = isProjectedToWaypoints; // same shape type if (voxelHandShapeType == MyEditorVoxelHand.VoxelHandShape.GetShapeType()) { //if ((size >= MyVoxelConstants.MIN_VOXEL_HAND_SIZE) && (size <= MyVoxelConstants.MAX_VOXEL_HAND_SIZE)) { //MyEditorVoxelHand.VoxelHandShape.SetShapeSize(size); //MyEditorVoxelHand.VoxelHandShape.SetShapeSize2(size2); //MyEditorVoxelHand.VoxelHandShape.SetShapeSize3(size3); MyEditorVoxelHand.VoxelHandShape.ModeType = modeType; MyEditorVoxelHand.VoxelHandShape.Material = materialEnum; } } // another shape type else { // float newShapeSize = size; // if ((newShapeSize < MyVoxelConstants.MIN_VOXEL_HAND_SIZE) && (newShapeSize > MyVoxelConstants.MAX_VOXEL_HAND_SIZE)) float newShapeSize = MyVoxelConstants.DEFAULT_VOXEL_HAND_SIZE; MyMwcPositionAndOrientation positionAndOritentation = new MyMwcPositionAndOrientation(MySpectator.Position, Vector3.Forward, Vector3.Up); switch (voxelHandShapeType) { case MyVoxelHandShapeType.Sphere: MyMwcObjectBuilder_VoxelHand_Sphere sphereObjectBuilder = new MyMwcObjectBuilder_VoxelHand_Sphere(positionAndOritentation, newShapeSize, modeType); MyEditorVoxelHand.VoxelHandShape = new MyVoxelHandSphere(); ((MyVoxelHandSphere)MyEditorVoxelHand.VoxelHandShape).Init(sphereObjectBuilder, null); break; case MyVoxelHandShapeType.Box: MyMwcObjectBuilder_VoxelHand_Box boxObjectBuilder = new MyMwcObjectBuilder_VoxelHand_Box(positionAndOritentation, newShapeSize, modeType); MyEditorVoxelHand.VoxelHandShape = new MyVoxelHandBox(); ((MyVoxelHandBox)MyEditorVoxelHand.VoxelHandShape).Init(boxObjectBuilder, null); break; case MyVoxelHandShapeType.Cuboid: MyMwcObjectBuilder_VoxelHand_Cuboid cuboidObjectBuilder = new MyMwcObjectBuilder_VoxelHand_Cuboid(positionAndOritentation, newShapeSize, newShapeSize, newShapeSize, newShapeSize, newShapeSize, modeType); MyEditorVoxelHand.VoxelHandShape = new MyVoxelHandCuboid(); ((MyVoxelHandCuboid)MyEditorVoxelHand.VoxelHandShape).Init(cuboidObjectBuilder, null); break; case MyVoxelHandShapeType.Cylinder: MyMwcObjectBuilder_VoxelHand_Cylinder cylinderObjectBuilder = new MyMwcObjectBuilder_VoxelHand_Cylinder(positionAndOritentation, newShapeSize, newShapeSize, newShapeSize, modeType); MyEditorVoxelHand.VoxelHandShape = new MyVoxelHandCylinder(); ((MyVoxelHandCylinder)MyEditorVoxelHand.VoxelHandShape).Init(cylinderObjectBuilder, null); break; default: System.Diagnostics.Debug.Assert(false); break; } MyEditorVoxelHand.VoxelHandShape.Material = materialEnum; } if (IsProjected) { if (!MyFakes.MWBUILDER) { if ((distance >= MyVoxelConstants.MIN_PROJECTED_VOXEL_HAND_OFFSET) && (distance <= MyVoxelConstants.MAX_PROJECTED_VOXEL_HAND_OFFSET)) MyEditorVoxelHand.SetShapeDistance(distance); } } else if (IsProjectedToWaypoints) { } else { if ((distance >= MyVoxelConstants.MIN_VOXEL_HAND_DISTANCE) && (distance <= MyVoxelConstants.MAX_VOXEL_HAND_DISTANCE)) MyEditorVoxelHand.SetShapeDistance(distance); } MyEditorVoxelHand.UpdateShapePosition(); }