public override void setPoint(MPoint pnt) { if (mGeometry != null) { mGeometry[index()] = new MVector(pnt); } }
public override void connectToDependNode(MObject node) { // Find the rotate and rotatePivot plugs on the node. These plugs will // be attached either directly or indirectly to the manip values on the // rotate manip. // MFnDependencyNode nodeFn = new MFnDependencyNode(node); MPlug rPlug = nodeFn.findPlug("rotate"); MPlug rcPlug = nodeFn.findPlug("rotatePivot"); // If the translate pivot exists, it will be used to move the state manip // to a convenient location. // MPlug tPlug = nodeFn.findPlug("translate"); // To avoid having the object jump back to the default rotation when the // manipulator is first used, extract the existing rotation from the node // and set it as the initial rotation on the manipulator. // MEulerRotation existingRotation = new MEulerRotation(vectorPlugValue(rPlug)); MVector existingTranslation = new MVector(vectorPlugValue(tPlug)); // // The following code configures default settings for the rotate // manipulator. // MFnRotateManip rotateManip = new MFnRotateManip(fRotateManip); rotateManip.setInitialRotation(existingRotation); rotateManip.setRotateMode(MFnRotateManip.RotateMode.kObjectSpace); rotateManip.displayWithNode(node); // Add a callback function to be called when the rotation value changes // //rotatePlugIndex = addManipToPlugConversionCallback( rPlug, (manipToPlugConversionCallback)&exampleRotateManip::rotationChangedCallback ); ManipToPlugConverion[rPlug] = rotationChangedCallback; // get the index of plug rotatePlugIndex = this[rPlug]; // Create a direct (1-1) connection to the rotation center plug // rotateManip.connectToRotationCenterPlug(rcPlug); // Place the state manip at a distance of 2.0 units away from the object // along the X-axis. // MFnStateManip stateManip = new MFnStateManip(fStateManip); MVector delta = new MVector(2, 0, 0); stateManip.setTranslation(existingTranslation + delta, MSpace.Space.kTransform); finishAddingManips(); base.connectToDependNode(node); }
void Process() { if (input.Input.Data == null || input2.Input.Data == null || input3.Input.Data == null) { return; } object from = input.Input.Data; object to = input.Input.Data; float delta = (float)input.Input.Data; if (from is float && to is MVector) { MVector f = new MVector((float)from, (float)from, (float)from, (float)from); MVector r = MVector.Lerp(f, (MVector)to, delta); output.Data = r; output.Changed(); } else if (from is float && to is float) { float r = Utils.Lerp((float)from, (float)to, delta); output.Data = r; output.Changed(); } else if (from is MVector && to is float) { MVector f = new MVector((float)from, (float)from, (float)from, (float)from); MVector r = MVector.Lerp((MVector)from, f, delta); output.Data = r; output.Changed(); } else if (from is MVector && to is MVector) { output.Data = MVector.Lerp((MVector)from, (MVector)to, delta); output.Changed(); } else { output.Data = 0; output.Changed(); } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
public override void TryAndProcess() { NodeInput input = Inputs[1]; NodeInput input2 = Inputs[2]; if (!input.IsValid || !input2.IsValid) { return; } NodeType t1 = input.Reference.Type; NodeType t2 = input2.Reference.Type; try { if ((t1 == NodeType.Float2 || t1 == NodeType.Float3 || t1 == NodeType.Float4) && (t2 == NodeType.Float2 || t2 == NodeType.Float3 || t2 == NodeType.Float4)) { MVector v1 = (MVector)input.Data; MVector v2 = (MVector)input2.Data; output.Data = v1 / v2; } else if ((t1 == NodeType.Float2 || t1 == NodeType.Float3 || t1 == NodeType.Float4) && t2 == NodeType.Float) { MVector v1 = (MVector)input.Data; float v2 = input2.Data.ToFloat(); output.Data = v1 / v2; } else if (t1 == NodeType.Float && (t2 == NodeType.Float2 || t2 == NodeType.Float3 || t2 == NodeType.Float4)) { float v1 = input.Data.ToFloat(); MVector v2 = (MVector)input2.Data; output.Data = v1 / v2; } else if (t1 == NodeType.Float && t2 == NodeType.Float) { float v1 = input.Data.ToFloat(); float v2 = input2.Data.ToFloat(); output.Data = v1 / (v2 + float.Epsilon); } result = output.Data?.ToString(); UpdateOutputType(); } catch (Exception e) { Log.Error(e); } }
public bool setPlane(MPoint pointOnPlane, MVector normalToPlane) { MVector _normalToPlane = new MVector(normalToPlane); _normalToPlane.normalize(); // Calculate a,b,c,d based on input a = _normalToPlane.x; b = _normalToPlane.y; c = _normalToPlane.z; d = -(a * pointOnPlane.x + b * pointOnPlane.y + c * pointOnPlane.z); return true; }
public static void ConvertToLAB(ref MVector v) { Vector3 xyz = ConvertRGBToXYZ(ref v); float yfunc = LABFunc(xyz.Y / LabYn); float L = 116 * yfunc - 16; float a = 500 * (LABFunc(xyz.X / LabXn) - yfunc); float b = 200 * (yfunc - LABFunc(xyz.Z / LabZn)); v.X = L; v.Y = a; v.Z = b; }
void Process() { if (input.Input.Data == null) { return; } object o = input.Input.Data; if (o is float || o is int) { float v = (float)o; output.Data = (float)Math.Floor(v); if (Outputs.Count > 0) { Outputs[0].Changed(); } } else if (o is MVector) { MVector v = (MVector)o; MVector d = new MVector(); d.X = (float)Math.Floor(v.X); d.Y = (float)Math.Floor(v.Y); d.Z = (float)Math.Floor(v.Z); d.W = (float)Math.Floor(v.W); output.Data = d; if (Outputs.Count > 0) { Outputs[0].Changed(); } } else { output.Data = 0; if (Outputs.Count > 0) { Outputs[0].Changed(); } } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
public void Write(BinaryWriter bw, int nameOffset) { if (!this.IsLegacy) { bw.Write(this.Flags); bw.Write(this.ID); bw.Write(this.ParentID); bw.Write((ushort)0); bw.Write(this.Hash); bw.Write(this.Radius); WriteLocal(); WriteInverseGlobal(); bw.Write(nameOffset - (int)bw.BaseStream.Position); } void WriteLocal() { MVector translation = this.Local.getTranslation(MSpace.Space.kTransform); double rotationX = 0; double rotationY = 0; double rotationZ = 0; double rotationW = 0; this.Local.getRotationQuaternion(ref rotationX, ref rotationY, ref rotationZ, ref rotationW, MSpace.Space.kTransform); double[] scale = new double[3]; this.Local.getScale(scale, MSpace.Space.kTransform); //Who the f**k designed this stupid API new Vector3((float)translation.x, (float)translation.y, (float)translation.z).Write(bw); new Vector3((float)scale[0], (float)scale[1], (float)scale[2]).Write(bw); new Quaternion((float)rotationX, (float)rotationY, (float)rotationZ, (float)rotationW).Write(bw); } void WriteInverseGlobal() { MVector translation = this.InverseGlobal.getTranslation(MSpace.Space.kWorld); double rotationX = 0; double rotationY = 0; double rotationZ = 0; double rotationW = 0; this.InverseGlobal.getRotationQuaternion(ref rotationX, ref rotationY, ref rotationZ, ref rotationW, MSpace.Space.kWorld); double[] scale = new double[3]; this.InverseGlobal.getScale(scale, MSpace.Space.kWorld); //Who the f**k designed this stupid API new Vector3((float)translation.x, (float)translation.y, (float)translation.z).Write(bw); new Vector3((float)scale[0], (float)scale[1], (float)scale[2]).Write(bw); new Quaternion((float)rotationX, (float)rotationY, (float)rotationZ, (float)rotationW).Write(bw); } }
public TriangleMeshAdapater(MFnMesh mesh) { MIntArray indices = new MIntArray(); MIntArray triangleCounts = new MIntArray(); MPointArray points = new MPointArray(); mesh.getTriangles(triangleCounts, indices); mesh.getPoints(points); // Get the triangle indices Indices = new Int32Collection((int)indices.length); for (int i = 0; i < indices.length; ++i) { Indices.Add(indices[i]); } // Get the control points (vertices) Points = new Point3DCollection((int)points.length); for (int i = 0; i < (int)points.length; ++i) { MPoint pt = points[i]; Points.Add(new Point3D(pt.x, pt.y, pt.z)); } // Get the number of triangle faces and polygon faces Debug.Assert(indices.length % 3 == 0); int triFaces = (int)indices.length / 3; int polyFaces = mesh.numPolygons; // We have normals per polygon, we want one per triangle. Normals = new Vector3DCollection(triFaces); int nCurrentTriangle = 0; // Iterate over each polygon for (int i = 0; i < polyFaces; ++i) { // Get the polygon normal var maya_normal = new MVector(); mesh.getPolygonNormal((int)i, maya_normal); System.Windows.Media.Media3D.Vector3D normal = new System.Windows.Media.Media3D.Vector3D(maya_normal.x, maya_normal.y, maya_normal.z); // Iterate over each tri in the current polygon int nTrisAtFace = triangleCounts[i]; for (int j = 0; j < nTrisAtFace; ++j) { Debug.Assert(nCurrentTriangle < triFaces); Normals.Add(normal); nCurrentTriangle++; } } Debug.Assert(nCurrentTriangle == triFaces); }
void Process() { if (input.Input.Data == null || input2.Input.Data == null || input3.Input.Data == null) { return; } object from = input.Input.Data; object to = input2.Input.Data; float delta = Convert.ToSingle(input3.Input.Data); if ((from is float || from is double || from is int || from is long) && to is MVector) { float vt = Convert.ToSingle(from); MVector f = new MVector(vt, vt, vt, vt); MVector r = MVector.Lerp(f, (MVector)to, delta); output.Data = r; } else if ((from is float || from is double || from is int || from is long) && (to is float || to is double || to is int || to is long)) { float r = Utils.Lerp(Convert.ToSingle(from), Convert.ToSingle(to), delta); output.Data = r; } else if (from is MVector && (to is float || to is double || to is int || to is long)) { float vt = Convert.ToSingle(to); MVector f = new MVector(vt, vt, vt, vt); MVector r = MVector.Lerp((MVector)from, f, delta); output.Data = r; } else if (from is MVector && to is MVector) { output.Data = MVector.Lerp((MVector)from, (MVector)to, delta); } else { output.Data = 0; } result = output.Data.ToString(); if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
void Process() { if (input.Input.Data == null) { return; } MVector v = (MVector)input.Input.Data; output.Data = v.X; output2.Data = v.Y; output3.Data = v.Z; }
public override void applySpringLaw(double stiffness, double damping, double restLength, double endMass1, double endMass2, MVector endP1, MVector endP2, MVector endV1, MVector endV2, MVector forceV1, MVector forceV2) { MVector distV = endP1 - endP2; double L = distV.length; distV.normalize(); double F = factor * (L - restLength); forceV1 = - F * distV; forceV2 = - forceV1; return; }
public bool setPlane(MPoint pointOnPlane, MVector normalToPlane) { MVector _normalToPlane = new MVector(normalToPlane); _normalToPlane.normalize(); // Calculate a,b,c,d based on input a = _normalToPlane.x; b = _normalToPlane.y; c = _normalToPlane.z; d = -(a * pointOnPlane.x + b * pointOnPlane.y + c * pointOnPlane.z); return(true); }
public ColorSelect(PropertyInfo p, object owner) { InitializeComponent(); property = p; propertyOwner = owner; MVector m = (MVector)p.GetValue(owner); current = m; c = D.Color.FromArgb((int)(current.W * 255), (int)(current.X * 255), (int)(current.Y * 255), (int)(current.Z * 255)); SelectColor.Background = new SolidColorBrush(Color.FromArgb(c.A, c.R, c.G, c.B)); }
public static void ConvertLABToRGB(ref MVector v) { float x = LabXn * InvLABFunc((v.X + 16) / 116 + v.Y / 500); float y = LabYn * InvLABFunc((v.X + 16) / 116); float z = LabZn * InvLABFunc((v.X + 16) / 116 - v.Z / 200); Vector3 xyz = new Vector3(x, y, z); MVector rgb = ConvertXYZtoRGB(ref xyz); v.X = rgb.X; v.Y = rgb.Y; v.Z = rgb.Z; }
public override void TryAndProcess() { if (!input.IsValid || !input2.IsValid || !input3.IsValid) { return; } NodeType t = input.Reference.Type; NodeType t2 = input2.Reference.Type; float delta = input3.Data.ToFloat(); try { if (t == NodeType.Float && t2 == NodeType.Float) { float v1 = input.Data.ToFloat(); float v2 = input2.Data.ToFloat(); output.Data = Utils.Lerp(v1, v2, delta); } else if ((t == NodeType.Float2 || t == NodeType.Float3 || t == NodeType.Float4) && (t2 == NodeType.Float2 || t2 == NodeType.Float3 || t2 == NodeType.Float4)) { MVector v1 = (MVector)input.Data; MVector v2 = (MVector)input2.Data; output.Data = MVector.Lerp(v1, v2, delta); } else if (t == NodeType.Float && (t2 == NodeType.Float2 || t2 == NodeType.Float3 || t2 == NodeType.Float4)) { float f = input.Data.ToFloat(); MVector v1 = new MVector(f, f, f, f); MVector v2 = (MVector)input2.Data; output.Data = MVector.Lerp(v1, v2, delta); } else if ((t == NodeType.Float2 || t == NodeType.Float3 || t == NodeType.Float4) && t2 == NodeType.Float) { float f = input2.Data.ToFloat(); MVector v2 = new MVector(f, f, f, f); MVector v1 = (MVector)input.Data; output.Data = MVector.Lerp(v1, v2, delta); } result = output.Data?.ToString(); } catch (Exception e) { } UpdateOutputType(); }
void AddHandle(Point p, MVector c, bool updateProperty = false) { GradientHandle h = new GradientHandle(); h.Position = (float)Math.Min(1, Math.Max(0, (p.X / (HandleHolder.ActualWidth - 4)))); h.SetColor(c); h.MouseDown += H_MouseDown; h.OnColorChanged += H_OnColorChanged; handles.Add(h); HandleHolder.Children.Add(h); Canvas.SetLeft(h, h.Position * (HandleHolder.ActualWidth - 4)); UpdateGradientPreview(updateProperty); }
public VectorSlider(PropertyInfo prop, object owner, float min = 0, float max = 1, NodeType type = NodeType.Float4) { InitializeComponent(); property = prop; propertyOwner = owner; this.min = min; this.max = max; switch (type) { case NodeType.Float2: ZView.Visibility = Visibility.Collapsed; WView.Visibility = Visibility.Collapsed; break; case NodeType.Float3: ZView.Visibility = Visibility.Visible; WView.Visibility = Visibility.Collapsed; break; case NodeType.Float4: ZView.Visibility = Visibility.Visible; WView.Visibility = Visibility.Visible; break; } object b = prop.GetValue(owner); if (b == null) { pc = new PropertyContainer(new MVector()); } else { MVector vec = (MVector)b; pc = new PropertyContainer(vec); } pc.OnUpdate += Pc_OnUpdate; var xprop = pc.GetType().GetProperty("XProp"); var yprop = pc.GetType().GetProperty("YProp"); var zprop = pc.GetType().GetProperty("ZProp"); var wprop = pc.GetType().GetProperty("WProp"); XValue.Set(min, max, xprop, pc); YValue.Set(min, max, yprop, pc); ZValue.Set(min, max, zprop, pc); WValue.Set(min, max, wprop, pc); }
public TriangleMeshAdapater(MFnMesh mesh) { MIntArray indices = new MIntArray(); MIntArray triangleCounts = new MIntArray(); MPointArray points = new MPointArray(); mesh.getTriangles(triangleCounts, indices); mesh.getPoints(points); // Get the triangle indices Indices = new Int32Collection((int)indices.length); for (int i = 0; i < indices.length; ++i) Indices.Add(indices[i]); // Get the control points (vertices) Points = new Point3DCollection((int)points.length); for (int i = 0; i < (int)points.length; ++i) { MPoint pt = points[i]; Points.Add(new Point3D(pt.x, pt.y, pt.z)); } // Get the number of triangle faces and polygon faces Debug.Assert(indices.length % 3 == 0); int triFaces = (int)indices.length / 3; int polyFaces = mesh.numPolygons; // We have normals per polygon, we want one per triangle. Normals = new Vector3DCollection(triFaces); int nCurrentTriangle = 0; // Iterate over each polygon for (int i = 0; i < polyFaces; ++i) { // Get the polygon normal var maya_normal = new MVector(); mesh.getPolygonNormal((int)i, maya_normal); System.Windows.Media.Media3D.Vector3D normal = new System.Windows.Media.Media3D.Vector3D(maya_normal.x, maya_normal.y, maya_normal.z); // Iterate over each tri in the current polygon int nTrisAtFace = triangleCounts[i]; for (int j = 0; j < nTrisAtFace; ++j) { Debug.Assert(nCurrentTriangle < triFaces); Normals.Add(normal); nCurrentTriangle++; } } Debug.Assert(nCurrentTriangle == triFaces); }
private void GetParams() { pangle = angle; pscaleX = this.scale.X; pscaleY = this.scale.Y; pxoffset = offset.X; pyoffset = offset.Y; if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "XOffset")) { pxoffset = Convert.ToSingle(ParentGraph.GetParameterValue(Id, "XOffset")); } if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "YOffset")) { pyoffset = Convert.ToSingle(ParentGraph.GetParameterValue(Id, "YOffset")); } if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Offset")) { MVector v = ParentGraph.GetParameterValue <MVector>(Id, "Offset"); pxoffset = v.X; pyoffset = v.Y; } if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "ScaleX")) { pscaleX = Convert.ToSingle(ParentGraph.GetParameterValue(Id, "ScaleX")); } if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "ScaleY")) { pscaleY = Convert.ToSingle(ParentGraph.GetParameterValue(Id, "ScaleY")); } if (parentGraph != null && ParentGraph.HasParameterValue(Id, "Scale")) { MVector v = ParentGraph.GetParameterValue <MVector>(Id, "Scale"); pscaleX = v.X; pscaleY = v.Y; } if (ParentGraph != null && ParentGraph.HasParameterValue(Id, "Angle")) { pangle = Convert.ToSingle(ParentGraph.GetParameterValue(Id, "Angle")); } }
public override void applySpringLaw(double stiffness, double damping, double restLength, double endMass1, double endMass2, MVector endP1, MVector endP2, MVector endV1, MVector endV2, MVector forceV1, MVector forceV2) { MVector distV = endP1 - endP2; double L = distV.length; distV.normalize(); double F = factor * (L - restLength); forceV1 = -F * distV; forceV2 = -forceV1; return; }
public override void FromJson(string data) { TextNodeData d = JsonConvert.DeserializeObject <TextNodeData>(data); SetBaseNodeDate(d); text = d.text; fontSize = d.fontSize; fontFamily = d.fontFamily; style = (FontStyle)d.style; rotation = d.rotation; scale = new MVector(d.scaleX, d.scaleY); position = new MVector(d.positionX, d.positionY); alignment = (TextAlignment)d.alignment; spacing = d.spacing; }
public void Reset() { position.X = 0; position.Y = 2; position.Z = 2; position.W = 0; color = new MVector(1, 1, 1, 1); power = 1; if (OnLightingUpdated != null) { OnLightingUpdated.Invoke(this); } }
public VectorInput(PropertyInfo prop, object owner, NodeType type = NodeType.Float4, NumberInputType ntype = NumberInputType.Float) { InitializeComponent(); property = prop; propertyOwner = owner; switch (type) { case NodeType.Float2: ZPos.Visibility = Visibility.Collapsed; WPos.Visibility = Visibility.Collapsed; break; case NodeType.Float3: ZPos.Visibility = Visibility.Visible; WPos.Visibility = Visibility.Collapsed; break; case NodeType.Float4: ZPos.Visibility = Visibility.Visible; WPos.Visibility = Visibility.Visible; break; } object b = prop.GetValue(owner); if (b == null) { pc = new VectorPropertyContainer(new MVector()); } else { MVector vec = (MVector)b; pc = new VectorPropertyContainer(vec); } pc.OnUpdate += Pc_OnUpdate; var xprop = pc.GetType().GetProperty("XProp"); var yprop = pc.GetType().GetProperty("YProp"); var zprop = pc.GetType().GetProperty("ZProp"); var wprop = pc.GetType().GetProperty("WProp"); XPos.Set(ntype, pc, xprop); YPos.Set(ntype, pc, yprop); ZPos.Set(ntype, pc, zprop); WPos.Set(ntype, pc, wprop); }
public override void FromJson(string data) { MeshDepthNodeData d = JsonConvert.DeserializeObject <MeshDepthNodeData>(data); SetBaseNodeDate(d); path = d.path; Resource = d.resource; relativePath = d.relativePath; position = new MVector(d.translateX, d.translateY, d.translateZ); scale = new MVector(d.scaleX, d.scaleY, d.scaleZ); rotation = new MVector(d.rotationX, d.rotationY, d.rotationZ); cameraZoom = d.cameraZoom; }
void Process() { if (input.Input.Data == null) { return; } if (!(input.Input.Data is MVector)) { return; } MVector v = (MVector)input.Input.Data; output.Data = v.X; output2.Data = v.Y; }
void AddHandle(System.Windows.Point p, MVector c, bool updateProperty = false) { GradientHandle h = new GradientHandle(); h.HorizontalAlignment = HorizontalAlignment.Left; h.VerticalAlignment = VerticalAlignment.Top; h.Position = (float)Math.Min(1, Math.Max(0, ((p.X + HANDLE_HALF_WIDTH) / HandleHolder.ActualWidth))); h.SetColor(c); h.MouseDown += H_MouseDown; h.OnColorChanged += H_OnColorChanged; handles.Add(h); HandleHolder.Children.Add(h); Canvas.SetLeft(h, h.Position * HandleHolder.ActualWidth - HANDLE_HALF_WIDTH); UpdateGradientPreview(updateProperty); }
void Process() { if (input.Input.Data == null) { return; } object o = input.Input.Data; if (o is float || o is int) { float v = (float)o; output.Data = v * -1; if (Outputs.Count > 0) { Outputs[0].Changed(); } } else if (o is MVector) { MVector v = (MVector)o; output.Data = v * -1; if (Outputs.Count > 0) { Outputs[0].Changed(); } } else { output.Data = 0; if (Outputs.Count > 0) { Outputs[0].Changed(); } } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
void Process() { object o = input.Input.Data; if (o is float || o is int) { float v = (float)o; Updated(); output.Data = (float)Math.Sqrt(v); if (Outputs.Count > 0) { Outputs[0].Changed(); } } else if (o is MVector) { MVector m = (MVector)o; m.X = (float)Math.Sqrt(m.X); m.Y = (float)Math.Sqrt(m.Y); m.Z = (float)Math.Sqrt(m.Z); m.W = (float)Math.Sqrt(m.W); output.Data = m; if (Outputs.Count > 0) { Outputs[0].Changed(); } } else { output.Data = 0; if (Outputs.Count > 0) { Outputs[0].Changed(); } } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
public bool intersect(MPoint linePoint, MVector lineDirection, ref MPoint intersectPoint) { double denominator = a * lineDirection.x + b * lineDirection.y + c * lineDirection.z; // Verify that the vector and the plane are not parallel. if (denominator < .00001) { return(false); } double t = -(d + a * linePoint.x + b * linePoint.y + c * linePoint.z) / denominator; // Calculate the intersection point. intersectPoint = linePoint + t * lineDirection; return(true); }
void Process() { if (input.Input.Data == null || input2.Input.Data == null) { return; } float seed = 0; if (ParentGraph != null) { seed = ParentGraph.RandomSeed; } object o = input.Input.Data; object o2 = input2.Input.Data; if (o is MVector && (o2 is float || o2 is int || o2 is double)) { MVector v = (MVector)o + seed; MVector v2 = new MVector(rand(ref v), Convert.ToSingle(o2)) + seed; output.Data = rand(ref v2); if (Outputs.Count > 0) { Outputs[0].Changed(); } } else { output.Data = 0; if (Outputs.Count > 0) { Outputs[0].Changed(); } } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
public override void TryAndProcess() { if (!input.IsValid) { return; } try { MVector v = (MVector)input.Data; output.Data = v.Normalized; result = output.Data?.ToString(); } catch (Exception e) { } UpdateOutputType(); }
public static MDagPath AddRPIKPole(MDagPath middleDagPath = null) { if (middleDagPath == null) { middleDagPath = BasicFunc.GetSelectedDagPath(0); if (middleDagPath == null) { Debug.Log("please select middle joint"); return(null); } } MDagPath rootDagPath = new MDagPath(), endDagPath = new MDagPath(); MFnIkJoint middleJoint = new MFnIkJoint(middleDagPath); if (middleJoint.parentCount > 0) { MDagPath.getAPathTo(middleJoint.parent(0), rootDagPath); MFnIkJoint rootJoint = new MFnIkJoint(rootDagPath); if (middleJoint.childCount > 0) { MDagPath.getAPathTo(middleJoint.child(0), endDagPath); MFnIkJoint endJoint = new MFnIkJoint(endDagPath); MVector rootPos = rootJoint.getTranslation(MSpace.Space.kWorld); MVector middlePos = middleJoint.getTranslation(MSpace.Space.kWorld); MVector endPos = endJoint.getTranslation(MSpace.Space.kWorld); //double len0 = (middlePos - rootPos).length; //double len1 = (endPos - middlePos).length; MVector fitLinePos = (rootPos + endPos) * 0.5; MVector direct_pole = middlePos - fitLinePos; MVector direct_fitLine = rootPos - endPos; MVector direct_projectPolePos = BasicFunc.VerticalProject(direct_pole, direct_fitLine).normal; //MVector nmPos = (rootPos * len0 + endPos * len1) * (1 / (len0 + len1)); float factor = (float)((rootPos - endPos).length / 3); MVector polePos = factor * direct_projectPolePos + middlePos; string locName = "loc_" + rootJoint.name + "_" + endJoint.name; return(BasicFunc.CreateLocator(polePos, locName)); } } return(null); }
public bool intersect(MPoint linePoint, MVector lineDirection, ref MPoint intersectPoint) { double denominator = a * lineDirection.x + b * lineDirection.y + c * lineDirection.z; // Verify that the vector and the plane are not parallel. if (denominator < .00001) { return false; } double t = -(d + a * linePoint.x + b * linePoint.y + c * linePoint.z) / denominator; // Calculate the intersection point. intersectPoint = linePoint + t * lineDirection; return true; }
public override void TryAndProcess() { if (!input.IsValid) { return; } try { MVector v = (MVector)input.Data; output.Data = v.Length; result = output.Data?.ToString(); } catch (Exception e) { } }
void Process() { object d1 = Inputs[1].Input.Data; object d2 = Inputs[2].Input.Data; if (d1 == null || d2 == null) { return; } var t1 = Inputs[1].Input.Type; var t2 = Inputs[2].Input.Type; if ((t1 == NodeType.Float2 && t2 == NodeType.Float2) || (t1 == NodeType.Float3 && t2 == NodeType.Float3) || (t1 == NodeType.Float4 && t2 == NodeType.Float4)) { MVector f1 = (MVector)d1; MVector f2 = (MVector)d2; output.Data = (f1 - f2).Length; if (Outputs.Count > 0) { Outputs[0].Changed(); } } else { output.Data = 0; if (Outputs.Count > 0) { Outputs[0].Changed(); } } if (ParentGraph != null) { FunctionGraph g = (FunctionGraph)ParentGraph; if (g != null && g.OutputNode == this) { g.Result = output.Data; } } }
public lineManip() { plane = new planeMath(); mousePointGlName = new MPoint(); // Setup the plane with a point on the // plane along with a normal MPoint pointOnPlane = lineGeometry.topPoint(); // Normal = cross product of two vectors on the plane MVector _topPoint = new MVector(lineGeometry.topPoint()); MVector _bottomPoint = new MVector(lineGeometry.bottomPoint()); MVector _otherPoint = new MVector(lineGeometry.otherPoint()); MVector normalToPlane = (_topPoint - _otherPoint).crossProduct(_otherPoint - _bottomPoint); // Necessary to normalize normalToPlane.normalize(); // Plane defined by a point and a normal plane.setPlane( pointOnPlane, normalToPlane ); }
// This function is a utility that can be used to extract vector values from // plugs. // private MVector vectorPlugValue(MPlug plug) { if (plug.numChildren == 3) { double x, y, z; MPlug rx = plug.child(0); MPlug ry = plug.child(1); MPlug rz = plug.child(2); x = rx.asDouble(); y = ry.asDouble(); z = rz.asDouble(); MVector result = new MVector(x, y, z); return result; } else { MGlobal.displayError("Expected 3 children for plug " + plug.name); MVector result = new MVector(0, 0, 0); return result; } }
override public void doIt(MArgList args) { MSyntax syntax = new MSyntax(); syntax.addArg(MSyntax.MArgType.kDouble); syntax.addArg(MSyntax.MArgType.kDouble); syntax.addArg(MSyntax.MArgType.kDouble); MArgDatabase argData = new MArgDatabase(syntax, args); MVector vector = MVector.xAxis ; if ( args.length == 1 ) { vector.x =args.asDouble (0) ; } else if ( args.length == 2 ) { vector.x =args.asDouble (0) ; vector.y =args.asDouble (1) ; } else if ( args.length == 3 ) { uint i =0 ; vector = args.asVector(ref i); } __delta = vector; __action (MoveToolAction.kDoIt) ; return; }
private string MVectorToString(MVector vector) { string str = string.Format("(%f, %f, %f)", vector.x, vector.y, vector.z); return str; }
private void computeMeshData() { foreach( MayaMesh mesh in allMeshes ) { // Get the Maya mesh MFnMesh mayaMesh = new MFnMesh(mesh.mayaObjectPath); // Does the maya mesh have UVs? MStringArray uvSetNames = new MStringArray(); mayaMesh.getUVSetNames(uvSetNames); bool hasUvs = (uvSetNames.length > 0) && (mayaMesh.numUVs(uvSetNames[0]) > 0); // Iterate through all of the vertices and build the data. MItMeshFaceVertex it = new MItMeshFaceVertex(mesh.mayaObjectPath); while( !it.isDone ) { // Create a new vertex and populate its data. Vertex vert = new Vertex(); // Get the local position relative to the world origin. MPoint mayaPos = it.position(MSpace.Space.kObject); vert.position = new Vector3((float)mayaPos.x, (float)mayaPos.y, (float)mayaPos.z); //vert.position = new Vector3((float)mayaPos.x - mesh.sourceXForm.mayaWorldPosition.x, //(float)mayaPos.y - mesh.sourceXForm.mayaWorldPosition.y, //(float)mayaPos.z - mesh.sourceXForm.mayaWorldPosition.z); // Get the normal. MVector mayaNrm = new MVector(); it.getNormal(mayaNrm, MSpace.Space.kObject); vert.normal = new Vector3((float)mayaNrm.x, (float)mayaNrm.y, (float)mayaNrm.z); // Texcoords. if( hasUvs && it.hasUVsProperty ) { float[] mayaUvs = new float[2]; it.getUV(mayaUvs, uvSetNames[0]); vert.texcoord = new Vector2(mayaUvs[0], mayaUvs[1]); } // Append the vertex. mesh.vertices.Add(vert); it.next(); } // Get all index data. MIntArray mia1 = new MIntArray(); MIntArray mia2 = new MIntArray(); mayaMesh.getTriangleOffsets(mia1, mia2); foreach( int idx in mia2 ) { mesh.indices.Add((uint)idx); } } }
// // Description // // This function takes an input surface of type kMeshData and converts // the geometry into this nodes attributes. // Returns false if nothing is connected. // public bool computeInputMesh(MPlug plug, MDataBlock datablock, MPointArray vertices, MIntArray counts, MIntArray connects, MVectorArray normals, apiMeshGeomUV uvs) { // Get the input subdiv // MDataHandle inputData = datablock.inputValue( inputMesh ); MObject surf = inputData.asMesh; // Check if anything is connected // MObject thisObj = thisMObject(); MPlug surfPlug = new MPlug( thisObj, inputMesh ); if ( !surfPlug.isConnected ) { datablock.setClean( plug ); return false; } // Extract the mesh data // MFnMesh surfFn = new MFnMesh(surf); surfFn.getPoints( vertices, MSpace.Space.kObject ); // Check to see if we have UVs to copy. // bool hasUVs = surfFn.numUVsProperty > 0; surfFn.getUVs( uvs.ucoord, uvs.vcoord ); for ( int i=0; i<surfFn.numPolygons; i++ ) { MIntArray polyVerts = new MIntArray(); surfFn.getPolygonVertices( i, polyVerts ); int pvc = (int)polyVerts.length; counts.append( pvc ); int uvId; for ( int v=0; v<pvc; v++ ) { if ( hasUVs ) { surfFn.getPolygonUVid( i, v, out uvId ); uvs.faceVertexIndex.append( uvId ); } connects.append( polyVerts[v] ); } } for ( int n=0; n<(int)vertices.length; n++ ) { MVector normal = new MVector(); surfFn.getVertexNormal( n, normal ); normals.append( normal ); } return true; }
// // Description: // // Bounding box drawing routine // // Arguments: // // request - request to be drawn // view - view to draw into // public void drawBoundingBox( MDrawRequest request, M3dView view ) { // Get the surface shape MPxSurfaceShape shape = (MPxSurfaceShape)surfaceShape; if ( shape == null ) return; // Get the bounding box MBoundingBox box = shape.boundingBox(); float w = (float) box.width; float h = (float) box.height; float d = (float) box.depth; view.beginGL(); // Below we just two sides and then connect // the edges together MPoint minVertex = box.min; // Draw first side OpenGL.glBegin(OpenGL.GL_LINE_LOOP); MPoint vertex = minVertex; OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]); OpenGL.glVertex3f((float)vertex[0] + w, (float)vertex[1], (float)vertex[2]); OpenGL.glVertex3f((float)vertex[0] + w, (float)vertex[1] + h, (float)vertex[2]); OpenGL.glVertex3f((float)vertex[0], (float)vertex[1] + h, (float)vertex[2]); OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]); OpenGL.glEnd(); // Draw second side MVector sideFactor = new MVector(0, 0, d); MPoint vertex2 = minVertex.plus( sideFactor ); OpenGL.glBegin(OpenGL.GL_LINE_LOOP); OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1], (float)vertex2[2]); OpenGL.glVertex3f((float)vertex2[0] + w, (float)vertex2[1], (float)vertex2[2]); OpenGL.glVertex3f((float)vertex2[0] + w, (float)vertex2[1] + h, (float)vertex2[2]); OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1] + h, (float)vertex2[2]); OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1], (float)vertex2[2]); OpenGL.glEnd(); // Connect the edges together OpenGL.glBegin(OpenGL.GL_LINES); OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1], (float)vertex2[2]); OpenGL.glVertex3f((float)vertex[0], (float)vertex[1], (float)vertex[2]); OpenGL.glVertex3f((float)vertex2[0] + w, (float)vertex2[1], (float)vertex2[2]); OpenGL.glVertex3f((float)vertex[0] + w, (float)vertex[1], (float)vertex[2]); OpenGL.glVertex3f((float)vertex2[0] + w, (float)vertex2[1] + h, (float)vertex2[2]); OpenGL.glVertex3f((float)vertex[0] + w, (float)vertex[1] + h, (float)vertex[2]); OpenGL.glVertex3f((float)vertex2[0], (float)vertex2[1] + h, (float)vertex2[2]); OpenGL.glVertex3f((float)vertex[0], (float)vertex[1] + h, (float)vertex[2]); OpenGL.glEnd(); view.endGL(); }
public override MMatrix asMatrix(double percent) { MPxTransformationMatrix m = new MPxTransformationMatrix(this); // Apply the percentage to the matrix components MVector trans = m.translation(); trans *= percent; m.translateTo( trans ); MPoint rotatePivotTrans = m.rotatePivot(); rotatePivotTrans = rotatePivotTrans * percent; m.setRotatePivot( rotatePivotTrans ); MPoint scalePivotTrans = new MPoint(m.scalePivotTranslation()); scalePivotTrans = scalePivotTrans * percent; m.setScalePivotTranslation( new MVector(scalePivotTrans)); // Apply the percentage to the rotate value. Same // as above + the percentage gets applied MQuaternion quat = rotation(); DegreeRadianConverter conv = new DegreeRadianConverter(); double newTheta = conv.degreesToRadians( getRockInX() ); quat.setToXAxis( newTheta ); m.rotateBy( quat ); MEulerRotation eulRotate = m.eulerRotation(); m.rotateTo( eulRotate.multiply(percent), MSpace.Space.kTransform); // Apply the percentage to the scale MVector s = new MVector(scale(MSpace.Space.kTransform)); s.x = 1.0 + (s.x - 1.0)*percent; s.y = 1.0 + (s.y - 1.0)*percent; s.z = 1.0 + (s.z - 1.0)*percent; m.scaleTo(s, MSpace.Space.kTransform); return m.asMatrix(); }
public moveCmd() { commandString = "moveToolCmdCSharp"; __delta =new MVector () ; }
private void doSimpleSolver() // // Solve single joint in the x-y plane // // - first it calculates the angle between the handle and the end-effector. // - then it determines which way to rotate the joint. // { // Get the handle and create a function set for it // MIkHandleGroup handle_group = handleGroup; if (null == handle_group) { throw new System.InvalidOperationException("invalid handle group."); } MObject handle = handle_group.handle( 0 ); MDagPath handlePath = MDagPath.getAPathTo( handle ); MFnIkHandle fnHandle = new MFnIkHandle( handlePath ); // Get the position of the end_effector // MDagPath end_effector = new MDagPath(); fnHandle.getEffector(end_effector); MFnTransform tran = new MFnTransform( end_effector ); MPoint effector_position = tran.rotatePivot( MSpace.Space.kWorld ); // Get the position of the handle // MPoint handle_position = fnHandle.rotatePivot( MSpace.Space.kWorld ); // Get the start joint position // MDagPath start_joint = new MDagPath(); fnHandle.getStartJoint( start_joint ); MFnTransform start_transform = new MFnTransform( start_joint ); MPoint start_position = start_transform.rotatePivot( MSpace.Space.kWorld ); // Calculate the rotation angle // MVector v1 = start_position.minus( effector_position ); MVector v2 = start_position.minus( handle_position ); double angle = v1.angle( v2 ); // -------- Figure out which way to rotate -------- // // define two vectors U and V as follows // U = EndEffector(E) - StartJoint(S) // N = Normal to U passing through EndEffector // // Clip handle_position to half-plane U to determine the region it // lies in. Use the region to determine the rotation direction. // // U // ^ Region Rotation // | B // (E)---N A C-C-W // A | B C-W // | B // | // (S) // double rot = 0.0; // Rotation about Z-axis // U and N define a half-plane to clip the handle against // MVector U = effector_position.minus( start_position ); U.normalize(); // Get a normal to U // MVector zAxis = new MVector( 0.0, 0.0, 1.0 ); MVector N = U.crossProduct( zAxis ); // Cross product N.normalize(); // P is the handle position vector // MVector P = handle_position.minus( effector_position ); // Determine the rotation direction // double PdotN = P[0]*N[0] + P[1]*N[1]; if ( PdotN < 0 ) { // counter-clockwise rot = angle; } else { // clockwise rot = -1.0 * angle; } // get and set the Joint Angles // MDoubleArray jointAngles = new MDoubleArray(); getJointAngles( jointAngles ); jointAngles.set( jointAngles[0] + rot, 0 ); setJointAngles( jointAngles ); }
public override void readDoubleVectorArray(MVectorArray array, uint arraySize) { Trace.Assert(myCurrentChanelNode != null); XmlNode doubleVectorArrayNode = myCurrentChanelNode.SelectSingleNode(doubleVectorArrayTag); XmlNodeList valueNodeList = doubleVectorArrayNode.SelectNodes("value"); uint i = 0; array.clear(); array.length = arraySize; foreach (XmlNode valueNode in valueNodeList) { XmlNode xNode = valueNode.SelectSingleNode("x"); double valueX = Convert.ToDouble(xNode.InnerText); XmlNode yNode = valueNode.SelectSingleNode("y"); double valuey = Convert.ToDouble(yNode.InnerText); XmlNode zNode = valueNode.SelectSingleNode("z"); double valuez = Convert.ToDouble(zNode.InnerText); MVector v = new MVector(valueX, valuey, valuez); array.set(v, i); i++; } return; }
public void updateDragInformation() { // Find the mouse point in local space MPoint localMousePoint = new MPoint(); MVector localMouseDirection = new MVector(); try { mouseRay(localMousePoint, localMouseDirection); } catch (System.Exception) { return; } // Find the intersection of the mouse point with the // manip plane MPoint mouseIntersectionWithManipPlane = new MPoint(); if (!plane.intersect(localMousePoint, localMouseDirection, ref mouseIntersectionWithManipPlane)) return; mousePointGlName.assign(mouseIntersectionWithManipPlane); uint active = 0; try { glActiveName(ref active); } catch (System.Exception) { return; } if (active == lineName && active != 0) { lineMath line = new lineMath(); // bool rightLine = true; if (affectTranslate) rightLine = false; // Find a vector on the plane MPoint a = lineGeometry.topPoint(rightLine); MPoint b = lineGeometry.bottomPoint(rightLine); MVector vab = a.minus(b); // Define line with a point and a vector on the plane line.setLine(a, vab); MPoint cpt = new MPoint(); // Find the closest point so that we can get the // delta change of the mouse in local space if (line.closestPoint(mousePointGlName, ref cpt)) { mousePointGlName.x -= cpt.x; mousePointGlName.y -= cpt.y; mousePointGlName.z -= cpt.z; } } }
public bool setLine(MPoint linePoint, MVector lineDirection) { point.assign(linePoint); direction.assign(lineDirection); direction.normalize(); return true; }
// Support the move tools normal/u/v mode (components) // public override bool vertexOffsetDirection( MObject component, MVectorArray direction, MVertexOffsetMode mode, bool normalize ) // // Description // // Returns offsets for the given components to be used my the // move tool in normal/u/v mode. // // Arguments // // component - components to calculate offsets for // direction - array of offsets to be filled // mode - the type of offset to be calculated // normalize - specifies whether the offsets should be normalized // // Returns // // true if the offsets could be calculated, false otherwise // { bool offsetOkay = false ; MFnSingleIndexedComponent fnComp = new MFnSingleIndexedComponent( component ); if ( component.apiType != MFn.Type.kMeshVertComponent ) { return false; } offsetOkay = true ; apiMeshGeom geomPtr = meshGeom(); if ( null == geomPtr ) { return false; } // For each vertex add the appropriate offset // int count = fnComp.elementCount; for ( int idx=0; idx<count; idx++ ) { MVector normal = geomPtr.normals[ fnComp.element(idx) ]; if( mode == MVertexOffsetMode.kNormal ) { if( normalize ) normal.normalize() ; direction.append( normal ); } else { // Construct an orthonormal basis from the normal // uAxis, and vAxis are the new vectors. // MVector uAxis = new MVector(); MVector vAxis = new MVector(); uint i, j, k; double a; normal.normalize(); i = 0; a = Math.Abs( normal[0] ); if ( a < Math.Abs(normal[1]) ) { i = 1; a = Math.Abs(normal[1]); } if ( a < Math.Abs(normal[2]) ) { i = 2; } j = (i+1)%3; k = (j+1)%3; a = Math.Sqrt(normal[i]*normal[i] + normal[j]*normal[j]); uAxis[i] = -normal[j]/a; uAxis[j] = normal[i]/a; uAxis[k] = 0.0; vAxis = normal.crossProduct( uAxis ); if ( mode == MVertexOffsetMode.kUTangent || mode == MVertexOffsetMode.kUVNTriad ) { if( normalize ) uAxis.normalize() ; direction.append( uAxis ); } if ( mode == MVertexOffsetMode.kVTangent || mode == MVertexOffsetMode.kUVNTriad ) { if( normalize ) vAxis.normalize() ; direction.append( vAxis ); } if ( mode == MVertexOffsetMode.kUVNTriad ) { if( normalize ) normal.normalize() ; direction.append( normal ); } } } return offsetOkay; }
public override void doDrag(MEvent eventArg) { base.doDrag (eventArg) ; // If we are not in selecting mode (i.e. an object has been selected) // then do the translation. if ( !_isSelecting () ) { eventArg.getPosition (ref endPos_x, ref endPos_y) ; MPoint endW =new MPoint () ; MPoint startW =new MPoint () ; MVector vec =new MVector () ; view.viewToWorld (startPos_x, startPos_y, startW, vec) ; view.viewToWorld (endPos_x, endPos_y, endW, vec) ; downButton =eventArg.mouseButton; // We reset the the move vector each time a drag event occurs // and then recalculate it based on the start position. cmd.undoIt () ; switch ( currWin ) { case 0: // TOP switch ( downButton ) { case MEvent.MouseButtonType.kMiddleMouse: cmd.setVector (endW.x - startW.x, 0.0, 0.0) ; break ; case MEvent.MouseButtonType.kLeftMouse: default: cmd.setVector (endW.x - startW.x, 0.0, endW.z - startW.z) ; break ; } break ; case 1: // FRONT switch ( downButton ) { case MEvent.MouseButtonType.kMiddleMouse: cmd.setVector (endW.x - startW.x, 0.0, 0.0) ; break ; case MEvent.MouseButtonType.kLeftMouse: default: cmd.setVector (endW.x - startW.x, endW.y - startW.y, 0.0) ; break ; } break ; case 2: //SIDE switch ( downButton ) { case MEvent.MouseButtonType.kMiddleMouse: cmd.setVector (0.0, 0.0, endW.z - startW.z) ; break ; case MEvent.MouseButtonType.kLeftMouse: default: cmd.setVector (0.0, endW.y - startW.y, endW.z - startW.z) ; break ; } break ; default: case 3: // PERSP break; } cmd.redoIt () ; view.refresh (true,false) ; } }
// // Description // // Returns offsets for the given components to be used my the // move tool in normal/u/v mode. // // Arguments // // component - components to calculate offsets for // direction - array of offsets to be filled // mode - the type of offset to be calculated // normalize - specifies whether the offsets should be normalized // // Returns // // true if the offsets could be calculated, false otherwise // // Support the move tools normal/u/v mode (components) // public override bool vertexOffsetDirection( MObject component, MVectorArray direction, MVertexOffsetMode mode, bool normalize) { bool offsetOkay = false ; MFnSingleIndexedComponent fnComp = new MFnSingleIndexedComponent( component ); if ( component.apiType != MFn.Type.kMeshVertComponent ) { return false; } offsetOkay = true ; apiMeshGeom geomPtr = meshGeom(); if ( null == geomPtr ) { return false; } // For each vertex add the appropriate offset // int count = fnComp.elementCount; for ( int idx=0; idx<count; idx++ ) { MVector normal = geomPtr.normals[ fnComp.element(idx) ]; if( mode == MVertexOffsetMode.kNormal ) { if( normalize ) normal.normalize() ; direction.append( normal ); } else { // Construct an orthonormal basis from the normal // uAxis, and vAxis are the new vectors. // MVector uAxis = new MVector(); MVector vAxis = new MVector(); uint i, j, k; double a; normal.normalize(); i = 0; a = Math.Abs( normal[0] ); if ( a < Math.Abs(normal[1]) ) { i = 1; a = Math.Abs(normal[1]); } if ( a < Math.Abs(normal[2]) ) { i = 2; } j = (i+1)%3; k = (j+1)%3; a = Math.Sqrt(normal[i]*normal[i] + normal[j]*normal[j]); uAxis[i] = -normal[j]/a; uAxis[j] = normal[i]/a; uAxis[k] = 0.0; vAxis = normal.crossProduct( uAxis ); if ( mode == MVertexOffsetMode.kUTangent || mode == MVertexOffsetMode.kUVNTriad ) { if( normalize ) uAxis.normalize() ; direction.append( uAxis ); } if ( mode == MVertexOffsetMode.kVTangent || mode == MVertexOffsetMode.kUVNTriad ) { if( normalize ) vAxis.normalize() ; direction.append( vAxis ); } if ( mode == MVertexOffsetMode.kUVNTriad ) { if( normalize ) normal.normalize() ; direction.append( normal ); } } } return offsetOkay; }
// // Description // // If the shape has history, apply any tweaks (offsets) made // to the control points. // public void applyTweaks(MDataBlock datablock, apiMeshGeom meshGeom) { MArrayDataHandle cpHandle = datablock.inputArrayValue( mControlPoints ); // Loop through the component list and transform each vertex. // uint elemCount = cpHandle.elementCount(); for ( uint idx=0; idx<elemCount; idx++ ) { int elemIndex = (int)cpHandle.elementIndex(); MDataHandle pntHandle = cpHandle.outputValue(); double[] pnt = pntHandle.Double3; MVector offset = new MVector(pnt[0], pnt[1], pnt[2]); // Apply the tweaks to the output surface // MPoint oldPnt = meshGeom.vertices[elemIndex]; oldPnt = oldPnt.plus( offset ); cpHandle.next(); } return; }
public lineMath() { point = new MPoint(); direction = new MVector(); }