/// <summary> /// Fly to the given center with zooming out to given resolution and in again /// </summary> /// <param name="center">MPoint to fly to</param> /// <param name="maxResolution">Maximum resolution to zoom out</param> /// <param name="duration">Duration for animation in milliseconds.</param> public void FlyTo(MPoint center, double maxResolution, long duration = 500) { var animationEntries = FlyToAnimation.Create(_viewport, center, maxResolution, duration); AddFinalAction(animationEntries, () => OnNavigated(ChangeType.Discrete)); _viewport.SetAnimations(animationEntries); }
public void MBox_CorrectLeftCornerWidthHeightLength_MBoxReturned() { // arrange float width = 100, length = (float)58.3, height = 50; var expectedVertices = GetVertices(width, length, height); var expectedFacets = GetFacets(expectedVertices); MPoint leftFaceCorner = new MPoint((float)21.5, (float)45.39, 4); // act MBox actualBox = new MBox(leftFaceCorner, length, width, height); // assert CompareLogic compareLogic = new CompareLogic(); var vericesComparsionResult = compareLogic.Compare(expectedVertices, actualBox.Vertices); var facetsComparsionResult = compareLogic.Compare(expectedFacets, actualBox.Facets); Assert.IsTrue(vericesComparsionResult.AreEqual); Assert.IsTrue(facetsComparsionResult.AreEqual); Assert.AreEqual(width, actualBox.Width); Assert.AreEqual(length, actualBox.Length); Assert.AreEqual(height, actualBox.Height); }
public Point ToScrPoint(MPoint mapPoint) { double x = mapPoint.X / ratio - offsetX; double y = this.Height - (mapPoint.Y / ratio + offsetY); return(new Point(x, y)); }
public override void setPoint(MPoint pnt) { if (mGeometry != null) { mGeometry[index()] = new MVector(pnt); } }
/// <summary> /// 根据最后一个分子,以及分支数量,划分支线 /// </summary> /// <param name="right_x"></param> /// <param name="center_y"></param> /// <param name="num"></param> private void WriteBranchLine(double right_x, double center_y, List <double> listHigh, MDocument md) { //水平线部分 MPoint p1 = new MPoint(right_x + SpanceX * (0.5 - SpaceLineScale / 2), center_y); MPoint p2 = new MPoint(right_x + SpanceX * 0.5, center_y); MRectangle arrow1 = new MRectangle(p1, p2); md.addObject(arrow1);; //划竖直线 double topy = -9999999; double bottomy = 9999999; foreach (var item in listHigh) { topy = topy < item ? item : topy; bottomy = bottomy > item ? item : bottomy; } MPoint p3 = new MPoint(right_x + SpanceX * 0.5, topy); MPoint p4 = new MPoint(right_x + SpanceX * 0.5, bottomy); MRectangle arrow2 = new MRectangle(p3, p4); md.addObject(arrow2); //根据传入的高度记录划水平分支线 foreach (double high in listHigh) { MPoint p5 = new MPoint(right_x + SpanceX * 0.5, high); MPoint p6 = new MPoint(right_x + SpanceX * (0.5 + SpaceLineScale / 2), high); MRectangle arrow3 = new MRectangle(p5, p6); md.addObject(arrow3); } }
public bool setLine(MPoint linePoint, MVector lineDirection) { point.assign(linePoint); direction.assign(lineDirection); direction.normalize(); return(true); }
public void ResetCamera() { //<PerspectiveCamera UpDirection="0,1,0" Position="1,1,1" LookDirection="-1,-1,-1" FieldOfView="45" /> MDagPath cameraPath; try { // Try with a Maya host first cameraPath = M3dView.active3dView.Camera; } catch { // We are in standalone mode (WPF application) MSelectionList list = new MSelectionList(); list.add("persp"); cameraPath = new MDagPath(); list.getDagPath(0, cameraPath); } MFnCamera fnCamera = new MFnCamera(cameraPath); MPoint eyePoint = fnCamera.eyePoint(MSpace.Space.kWorld); MPoint centerOfInterestPoint = fnCamera.centerOfInterestPoint(MSpace.Space.kWorld); MVector direction = centerOfInterestPoint.minus(eyePoint); MVector upDirection = fnCamera.upDirection(MSpace.Space.kWorld); camera.Position = new Point3D(eyePoint.x, eyePoint.y, eyePoint.z); camera.LookDirection = new Vector3D(direction.x, direction.y, direction.z); MAngle fieldOfView = new MAngle(fnCamera.verticalFieldOfView); //verticalFieldOfView / horizontalFieldOfView camera.FieldOfView = fieldOfView.asDegrees; camera.UpDirection = new Vector3D(upDirection.x, upDirection.y, upDirection.z); camera.NearPlaneDistance = fnCamera.nearClippingPlane; camera.FarPlaneDistance = fnCamera.farClippingPlane; camera.Transform = new Transform3DGroup(); (camera.Transform as Transform3DGroup).Children.Add(new TranslateTransform3D(new Vector3D())); }
public List <MPoint> ExtraerPuntos(List <string> E2KRange) { double Xc, Yc; double Zc = 0; string PointLabel = ""; List <MPoint> mpoints = new List <MPoint>(); foreach (string E2KLine in E2KRange) { var TempPoint = E2KLine.Split(); PointLabel = TempPoint[3].Replace("\"", ""); Xc = double.Parse(TempPoint[5]); Yc = double.Parse(TempPoint[6]); if (TempPoint[7] != "") { Zc = double.Parse(TempPoint[7]); } var puntoi = new MPoint(PointLabel, Xc, Yc, Zc); mpoints.Add(puntoi); } return(mpoints); }
/// <summary> /// Zoom to a given resolution with a given point as center /// </summary> /// <param name="resolution">Resolution to zoom</param> /// <param name="centerOfZoom">Center of zoom in screen coordinates. This is the one point in the map that /// stays on the same location while zooming in. /// For instance, in mouse wheel zoom animation the position /// of the mouse pointer can be the center of zoom. Note, that the centerOfZoom is in screen coordinates not /// world coordinates, this is because this is most convenient for the main use case, zoom with the mouse /// position as center.</param> /// <param name="duration">Duration for animation in milliseconds.</param> /// <param name="easing">The easing of the animation when duration is > 0</param> public void ZoomTo(double resolution, MPoint centerOfZoom, long duration = 0, Easing?easing = default) { var(worldCenterOfZoomX, worldCenterOfZoomY) = _viewport.ScreenToWorldXY(centerOfZoom.X, centerOfZoom.Y); _viewport.SetAnimations(ZoomAroundLocationAnimation.Create(_viewport, worldCenterOfZoomX, worldCenterOfZoomY, resolution, _viewport.CenterX, _viewport.CenterY, _viewport.Resolution, duration)); OnNavigated(duration, ChangeType.Discrete); }
public List <MPoint> RasterizePolygon(MFacet polygon) { var points = new List <MPoint>(); SortVertices(polygon.Vertices); var upperRightCorner = GetMaxCoordinates(polygon.Vertices); var bottomLeftCorner = GetMinCoordinates(polygon.Vertices); for (int i = (int)bottomLeftCorner.X; i <= upperRightCorner.X; ++i) { for (int j = (int)bottomLeftCorner.Y; j <= upperRightCorner.Y; ++j) { bool inside = true; var p = new MPoint(i, j, 1); inside &= EdgeFunction(polygon.Vertices[0], polygon.Vertices[1], p); inside &= EdgeFunction(polygon.Vertices[1], polygon.Vertices[2], p); inside &= EdgeFunction(polygon.Vertices[2], polygon.Vertices[0], p); if (inside) { points.Add(p); } } } return(points); }
private void Swap(MPoint vertex0, MPoint vertex1) { var temp = vertex0; vertex0 = vertex1; vertex1 = temp; }
public MQuad(MPoint bottomLeft, MPoint topLeft, MPoint topRight, MPoint bottomRight) { BottomLeft = bottomLeft; TopLeft = topLeft; TopRight = topRight; BottomRight = bottomRight; }
private void UpdateAdjustLen() { Vector3 pos = curObj.worldToLocalMatrix.MultiplyPoint(sceneManager.rightControllerPosition); MFace f = selectedEntity[0] as MFace; MPoint p = selectedEntity[1] as MPoint; pos = f.GetVerticalPoint(p.position, pos); float relativeLen = curObj.RefEdgeRelativeLength(Vector3.Distance(p.position, pos)); pos = RevisePos(ref relativeLen, p.position, pos); activePoint.SetPosition(pos); activeTextMesh.GetComponentInChildren <TextMesh>().text = relativeLen.ToString(); activeTextMesh.transform.position = sceneManager.rightControllerPosition + MDefinitions.DEFAULT_ACTIVE_TEXT_OFFSET; if (sceneManager.camera != null) { activeTextMesh.transform.rotation = Quaternion.LookRotation((sceneManager.camera.transform.position - activeTextMesh.transform.position) * -1, Vector3.up); } if (activeEdge == null) { activeEdge = new MLinearEdge(p, activePoint); activeEdge.entityStatus = MEntity.MEntityStatus.ACTIVE; activeEdge.end.edges.Add(activeEdge); } activePoint.Render(curObj.localToWorldMatrix); if (activeEdge != null && activeEdge.IsValid()) { activeEdge.Render(curObj.localToWorldMatrix); } }
static void Main(string[] args) { var Plus = new Point2(250, 250); MPoint sun = new MPoint(new Point2(0, 0) + Plus, 100, Point2.Zero, true); MPoint planet = new MPoint(new Point2(0, -50) + Plus, 30, new Point2(1.5, 0), false); MPoint aster = new MPoint(new Point2(-100, 60) + Plus, 100, Point2.Zero, false); _w = new Space(1, WorldType.ObjectsGravity); _w.Objects.AddRange(new [] { sun, planet, aster }); _render = new RenderWindow(new VideoMode(500, 500), "Render view"); _render.Closed += (sender, eventArgs) => _render.Close(); _render.SetFramerateLimit(10); _render.SetActive(true); while (_render.IsOpen) { _render.Clear(new(0, 0, 0)); _render.DispatchEvents(); { { _w.Next(1); _w.Draw(_render, 1, false); } } _render.Display(); } }
/// <summary> /// Extract geometry (position, normal, UVs...) for a specific vertex /// </summary> /// <param name="mFnMesh"></param> /// <param name="polygonId">The polygon (face) to examine</param> /// <param name="vertexIndexGlobal">The object-relative (mesh-relative/global) vertex index</param> /// <param name="vertexIndexLocal">The face-relative (local) vertex id to examine</param> /// <param name="hasUV"></param> /// <returns></returns> private GlobalVertex ExtractVertex(MFnMesh mFnMesh, int polygonId, int vertexIndexGlobal, int vertexIndexLocal, bool hasUV) { MPoint point = new MPoint(); mFnMesh.getPoint(vertexIndexGlobal, point); MVector normal = new MVector(); mFnMesh.getFaceVertexNormal(polygonId, vertexIndexGlobal, normal); // Switch coordinate system at object level point.z *= -1; normal.z *= -1; var vertex = new GlobalVertex { BaseIndex = vertexIndexGlobal, Position = point.toArray(), Normal = normal.toArray() }; // UV if (hasUV) { float u = 0, v = 0; mFnMesh.getPolygonUV(polygonId, vertexIndexLocal, ref u, ref v); vertex.UV = new float[] { u, v }; } return(vertex); }
private void MapControl_PointerWheelChanged(object sender, PointerRoutedEventArgs e) { if (_map?.ZoomLock ?? true) { return; } if (!Viewport.HasSize) { return; } var currentPoint = e.GetCurrentPoint(this); #if __WINUI__ var mousePosition = new MPoint(currentPoint.Position.X, currentPoint.Position.Y); #else var mousePosition = new MPoint(currentPoint.RawPosition.X, currentPoint.RawPosition.Y); #endif var resolution = MouseWheelAnimation.GetResolution(currentPoint.Properties.MouseWheelDelta, _viewport, _map); // Limit target resolution before animation to avoid an animation that is stuck on the max resolution, which would cause a needless delay if (this.Map == null) { return; } resolution = Map.Limiter.LimitResolution(resolution, Viewport.Width, Viewport.Height, Map.Resolutions, Map.Extent); Navigator.ZoomTo(resolution, mousePosition, MouseWheelAnimation.Duration, MouseWheelAnimation.Easing); e.Handled = true; }
private void SetNewCoordinatesToPoint(MPoint destinationPoint, float[,] newCoordinates) { destinationPoint.X = newCoordinates[0, 0]; destinationPoint.Y = newCoordinates[1, 0]; destinationPoint.Z = newCoordinates[2, 0]; destinationPoint.W = newCoordinates[3, 0]; }
override public void deform(MDataBlock block, MItGeometry iter, MMatrix m, uint multiIndex) { MDataHandle angleData = block.inputValue(angle); MDataHandle envData = block.inputValue(envelope); double magnitude = angleData.asDouble; float env = envData.asFloat; for (; !iter.isDone; iter.next()) { MPoint pt = iter.position(); // do the twist // double ff = magnitude * pt.y * env; if (ff != 0.0) { double cct = Math.Cos(ff); double cst = Math.Sin(ff); double tt = pt.x * cct - pt.z * cst; pt.z = pt.x * cst + pt.z * cct; pt.x = tt;; } iter.setPosition(pt); } }
private void UpdateStretch() { Vector3 pos = obj.worldToLocalMatrix.MultiplyPoint(sceneManager.rightControllerPosition); MPoint a = activeEdges[0].start; MPoint b = activeEdges[0].end; MPoint c = activeEdges[1].end; float width = Vector3.Distance(a.position, b.position); Vector3 p = MHelperFunctions.VectorL2P(pos, activeEdges[0].direction, a.position); p = ReviseLength(p, width); c.SetPosition(p + b.position); if (activeFace != null && activeFace.IsValid()) { activeFace.Render(obj.localToWorldMatrix); foreach (MLinearEdge edge in activeEdges) { edge.Render(obj.localToWorldMatrix); } a.Render(obj.localToWorldMatrix); b.Render(obj.localToWorldMatrix); c.Render(obj.localToWorldMatrix); activeTextMesh.GetComponentInChildren <TextMesh>().text = "1:" + (p.magnitude / width).ToString(); activeTextMesh.transform.position = sceneManager.rightControllerPosition + MDefinitions.DEFAULT_ACTIVE_TEXT_OFFSET; if (sceneManager.camera != null) { activeTextMesh.transform.rotation = Quaternion.LookRotation((sceneManager.camera.transform.position - activeTextMesh.transform.position) * -1, Vector3.up); } } else { activeTextMesh.GetComponentInChildren <TextMesh>().text = ""; } }
public MQuad() { BottomLeft = new MPoint(); TopLeft = new MPoint(); TopRight = new MPoint(); BottomRight = new MPoint(); }
public static void CreateRelativeCurve(MSelectionList selected = null, ConstantValue.SampleType st = ConstantValue.SampleType.ObjectTrans, bool reOrder = true, bool closedArc = true, string ctlName = null) { if (selected == null) { selected = BasicFunc.GetSelectedList(); } List <MVector> positions = new List <MVector>(); switch (st) { case ConstantValue.SampleType.Vert: { MItSelectionList it_selectionList = new MItSelectionList(selected); MVector totalWeight = MVector.zero; for (; !it_selectionList.isDone; it_selectionList.next()) { MObject component = new MObject(); MDagPath item = new MDagPath(); it_selectionList.getDagPath(item, component); MItMeshVertex it_verts = new MItMeshVertex(item, component); for (; !it_verts.isDone; it_verts.next()) { //Debug.Log(it_verts.index().ToString()); MPoint point = it_verts.position(MSpace.Space.kWorld); MVector pos = new MVector(point.x, point.y, point.z); //BasicFunc.CreateLocator(pos, "vert_" + it_verts.index()); positions.Add(pos); totalWeight += pos; } } break; } case ConstantValue.SampleType.Edge: { break; } case ConstantValue.SampleType.Poly: { break; } case ConstantValue.SampleType.ObjectTrans: { foreach (MDagPath dag in selected.DagPaths()) { MFnTransform trans = new MFnTransform(dag); positions.Add(trans.getTranslation(MSpace.Space.kWorld)); } break; } } if (ctlName == null) { ctlName = "samplerCurve_00"; } CreateLoopCircleByPos(positions, reOrder, closedArc, ctlName); }
/// <summary> /// Extract ordered indices on a triangle basis /// Extract position and normal of each vertex per face /// </summary> /// <param name="mFnMesh"></param> /// <param name="vertices"></param> /// <param name="indices"></param> /// <param name="subMeshes"></param> /// <param name="optimizeVertices"></param> private void ExtractGeometry(MFnMesh mFnMesh, List <GlobalVertex> vertices, List <int> indices, List <BabylonSubMesh> subMeshes, bool optimizeVertices) { // TODO - Multimaterials: create a BabylonSubMesh per submaterial // TODO - optimizeVertices MIntArray triangleCounts = new MIntArray(); MIntArray trianglesVertices = new MIntArray(); mFnMesh.getTriangles(triangleCounts, trianglesVertices); // For each polygon of this mesh for (int polygonId = 0; polygonId < mFnMesh.numPolygons; polygonId++) { MIntArray verticesId = new MIntArray(); int nbTriangles = triangleCounts[polygonId]; // For each triangle of this polygon for (int triangleIndex = 0; triangleIndex < triangleCounts[polygonId]; triangleIndex++) { int[] triangleVertices = new int[3]; mFnMesh.getPolygonTriangleVertices(polygonId, triangleIndex, triangleVertices); // Inverse winding order var tmp = triangleVertices[1]; triangleVertices[1] = triangleVertices[2]; triangleVertices[2] = tmp; // For each vertex of this triangle (3 vertices per triangle) foreach (int vertexId in triangleVertices) { MPoint point = new MPoint(); mFnMesh.getPoint(vertexId, point); MVector normal = new MVector(); mFnMesh.getFaceVertexNormal(polygonId, vertexId, normal); var vertex = new GlobalVertex { BaseIndex = vertexId, Position = point.toArray(), Normal = normal.toArray() }; indices.Add(vertices.Count); vertices.Add(vertex); } } } // BabylonSubMesh var subMesh = new BabylonSubMesh { indexStart = 0, materialIndex = 0 }; subMeshes.Add(subMesh); subMesh.indexCount = indices.Count; subMesh.verticesStart = 0; subMesh.verticesCount = vertices.Count; }
public override bool HandleWidgetTouched(INavigator navigator, MPoint position) { var args = new HyperlinkWidgetArguments(); Touched?.Invoke(this, args); return(args.Handled); }
public static MMesh GetMMesh() { mesh = new MMesh(); MPoint center = mesh.CreatePoint(Vector3.zero); mesh.CreateSphereFace(center, 0.5f); return(mesh); }
private MPoint GetNextPoint(MPoint point1, MPoint point2) { var x = (float)Math.Round((point1.X + point2.X) / 2); var y = (float)Math.Round((point1.Y + point2.Y) / 2); var z = (float)Math.Round((point1.Z + point2.Z) / 2); return(new MPoint(x, y, z)); }
private void ClearSelectPoint() { if (selectPoint != null) { selectPoint.entityStatus = MEntity.MEntityStatus.DEFAULT; selectPoint = null; } }
public void OnEnter(StateMachine machine, IState prevState, object param) { sceneManager.rightEvents.TriggerPressed += rightTriggerPressed; sceneManager.rightEvents.GripPressed += RightGripPressed; activePoint = new MPoint(Vector3.zero); activePoint.entityStatus = MEntity.MEntityStatus.ACTIVE; curObj = null; }
public override MPoint point() { MPoint pnt; if (mGeometry != null) pnt = new MPoint(mGeometry[index()]); else pnt = new MPoint(); return pnt; }
// 获取当前屏幕鼠标位置 public static Point GetMousePoint() { MPoint mpt = new MPoint(); GetCursorPos(out mpt); Point p = new Point(mpt.X, mpt.Y); return(p); }
public CreateVerticalLineState(SceneManager sceneManager, GameObject activeTextMesh) { this.sceneManager = sceneManager; this.activeTextMesh = activeTextMesh; rightTriggerPressed = new VRTK.ControllerInteractionEventHandler(RightTriggerPressed); rightGripPressed = new VRTK.ControllerInteractionEventHandler(RightGripPressed); selectedEntity = new List <MEntity>(); activePoint = new MPoint(Vector3.zero); }
public bool closestPoint(MPoint toPoint, ref MPoint closest) { double t = direction.x * (toPoint.x - point.x) + direction.y * (toPoint.y - point.y) + direction.z * (toPoint.z - point.z); closest = point + (direction * t); return(true); }
public void UpdateTriMesh(MFnMesh fnMesh, TriMesh triMesh) { for (int i = 0; i < triMesh.Vertices.Count; i++) { MPoint pos = new MPoint(); fnMesh.getPoint(i, pos); triMesh.Vertices[i].Traits.Position.x = pos.x; triMesh.Vertices[i].Traits.Position.y = pos.y; triMesh.Vertices[i].Traits.Position.z = pos.z; } }
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 override MPoint point() // // Description // // Returns the point for the current element in the iteration. // This is used by the transform tools for positioning the // manipulator in component mode. It is also used by deformers. // { MPoint pnt = new MPoint(); if (null != meshGeometry) { pnt = meshGeometry.vertices[index()]; } return pnt; }
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 MBoundingBox boundingBox() { // Get the size // MObject thisNode = thisMObject(); MPlug plug = new MPlug( thisNode, size ); MDistance sizeVal = new MDistance(); plug.getValue( sizeVal ); double multiplier = sizeVal.asCentimeters; MPoint corner1 = new MPoint( -0.17, 0.0, -0.7 ); MPoint corner2 = new MPoint( 0.17, 0.0, 0.3 ); corner1 = corner1 * multiplier; corner2 = corner2 * multiplier; return new MBoundingBox( corner1, corner2 ); }
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 ); }
public override bool setInternalValue(MPlug plug, MDataHandle handle) { bool isOk = true; if( plug.attribute.equalEqual(mControlPoints) || plug.attribute.equalEqual(mControlValueX) || plug.attribute.equalEqual(mControlValueY) || plug.attribute.equalEqual(mControlValueZ) ) { // If there is input history then set the control points value // using the normal mechanism. In this case we are setting // the tweak or offset that will get applied to the input // history. // // If there is no input history then ignore the controlPoints // attribute and set the vertex position directly in the // cachedMesh. // if ( hasHistory() ) { verticesUpdated(); return base.setInternalValue( plug, handle ); } else { if( plug.attribute.equalEqual(mControlPoints) && !plug.isArray) { int index = (int)plug.logicalIndex; MPoint point = new MPoint(); double[] ptData = handle.Double3; point.x = ptData[0]; point.y = ptData[1]; point.z = ptData[2]; setValue( index, point ); } else if( plug.attribute.equalEqual(mControlValueX) ) { MPlug parentPlug = plug.parent; int index = (int)parentPlug.logicalIndex; setValue( index, 0, handle.asDouble ); } else if( plug.attribute.equalEqual(mControlValueY) ) { MPlug parentPlug = plug.parent; int index = (int)parentPlug.logicalIndex; setValue( index, 1, handle.asDouble ); } else if( plug.attribute.equalEqual(mControlValueZ) ) { MPlug parentPlug = plug.parent; int index = (int)parentPlug.logicalIndex; setValue( index, 2, handle.asDouble ); } } } // This inherited attribute is used to specify whether or // not this shape has history. During a file read, the shape // is created before any input history can get connected. // This attribute, also called "tweaks", provides a way to // for the shape to determine if there is input history // during file reads. // else if ( plug.attribute.equalEqual(mHasHistoryOnCreate) ) { fHasHistoryOnCreate = handle.asBool; } else { isOk = base.setInternalValue( plug, handle ); } return isOk; }
public bool value( int pntInd, ref MPoint val ) // // Description // // Helper function to return the value of a given vertex // from the cachedMesh. // { bool result = false; apiMesh nonConstThis = (apiMesh)this; apiMeshGeom meshGeom = nonConstThis.cachedGeom(); if (null != meshGeom) { MPoint point = meshGeom.vertices[pntInd]; val = point; result = true; } return result; }
public override MBoundingBox boundingBox() // // Description // // Returns the bounding box for this object. // It is a good idea not to recompute here as this funcion is called often. // { MObject thisNode = thisMObject(); MPlug c1Plug = new MPlug( thisNode, bboxCorner1 ); MPlug c2Plug = new MPlug( thisNode, bboxCorner2 ); MObject corner1Object = new MObject(); MObject corner2Object = new MObject(); c1Plug.getValue( corner1Object ); c2Plug.getValue( corner2Object ); double[] corner1 = new double[3]; double[] corner2 = new double[3]; MFnNumericData fnData = new MFnNumericData(); fnData.setObject( corner1Object ); fnData.getData(out corner1[0], out corner1[1], out corner1[2]); fnData.setObject( corner2Object ); fnData.getData(out corner2[0], out corner2[1], out corner2[2]); MPoint corner1Point = new MPoint( corner1[0], corner1[1], corner1[2] ); MPoint corner2Point = new MPoint( corner2[0], corner2[1], corner2[2] ); return new MBoundingBox( corner1Point, corner2Point ); }
public override MBoundingBox boundingBox() { MBoundingBox result = new MBoundingBox(); quadricGeom geom = this.geometry(); double r = geom.radius1; MPoint t = new MPoint(r, r, r); MPoint nt = new MPoint(-r, -r, -r); result.expand(t); result.expand(nt); r = geom.radius2; result.expand(t); result.expand(nt); r = geom.height; result.expand(t); result.expand(nt); return result; }
public bool setValue(int pntInd, MPoint val) // // Description // // Helper function to set the value of a given vertex // in the cachedMesh. // { bool result = false; apiMesh nonConstThis = (apiMesh)this; apiMeshGeom meshGeom = nonConstThis.cachedGeom(); if (null != meshGeom) { meshGeom.vertices[pntInd] = val; result = true; } verticesUpdated(); return result; }
// // Description // // Helper function to return the value of a given vertex // from the cachedMesh. // public bool value( int pntInd, ref MPoint val ) { bool result = false; apiMesh nonConstThis = (apiMesh)this; apiMeshGeom meshGeom = nonConstThis.cachedGeom(); if (null != meshGeom) { MPoint point = meshGeom.vertices[pntInd]; val = point; result = true; } return result; }
// // Description // // Returns the closest point to the given point in space. // Used for rigid bind of skin. Currently returns wrong results; // override it by implementing a closest point calculation. public override void closestPoint(MPoint toThisPoint, MPoint theClosestPoint, double tolerance) { // Iterate through the geometry to find the closest point within // the given tolerance. // apiMeshGeom geomPtr = meshGeom(); uint numVertices = geomPtr.vertices.length; for (int ii=0; ii<numVertices; ii++) { MPoint tryThisOne = geomPtr.vertices[ii]; } // Set the output point to the result (hardcode for debug just now) // theClosestPoint = geomPtr.vertices[0]; }
public bool setLine(MPoint linePoint, MVector lineDirection) { point.assign(linePoint); direction.assign(lineDirection); direction.normalize(); return true; }
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) ; } }
public bool closestPoint(MPoint toPoint, ref MPoint closest) { double t = direction.x * (toPoint.x - point.x) + direction.y * (toPoint.y - point.y) + direction.z * (toPoint.z - point.z); closest = point + (direction * t); return true; }
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 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 override void draw(M3dView view, MDagPath path, M3dView.DisplayStyle style, M3dView.DisplayStatus status) { base.draw(view, path, style, status); // view.beginGL(); //MPoint textPos = new MPoint(nodeTranslation()); MPoint textPos = new MPoint(0,0,0); String distanceText = "Two custom line manipulators"; view.drawText(distanceText, textPos, M3dView.TextPosition.kLeft); // view.endGL(); }
// // Select function. Gets called when the bbox for the object is selected. // This function just selects the object without doing any intersection tests. // /* override */ public override bool select(MSelectInfo selectInfo, MSelectionList selectionList, MPointArray worldSpaceSelectPts) { MSelectionMask priorityMask = new MSelectionMask(MSelectionMask.SelectionType.kSelectObjectsMask); MSelectionList item = new MSelectionList(); item.add(selectInfo.selectPath); MPoint xformedPt = new MPoint(); selectInfo.addSelection(item, xformedPt, selectionList, worldSpaceSelectPts, priorityMask, false); return true; }
// // Description // // Helper function to set the value of a given vertex // in the cachedMesh. // public bool setValue(int pntInd, MPoint val) { bool result = false; apiMesh nonConstThis = (apiMesh)this; apiMeshGeom meshGeom = nonConstThis.cachedGeom(); if (null != meshGeom) { meshGeom.vertices[pntInd] = val; result = true; } verticesUpdated(); return result; }
public override void tweakUsing( MMatrix mat, MObjectArray componentList, MVertexCachingMode cachingMode, MPointArray pointCache, MArrayDataHandle handle ) // // Description // // Transforms the given components. This method is used by // the move, rotate, and scale tools in component mode when the // tweaks for the shape are stored on a separate tweak node. // The bounding box has to be updated here, so do the normals and // any other attributes that depend on vertex positions. // // Arguments // mat - matrix to transform the components by // componentList - list of components to be transformed, // or an empty list to indicate the whole surface // cachingMode - how to use the supplied pointCache // pointCache - if non-null, save or restore points from this list base // on the cachingMode // handle - handle to the attribute on the tweak node where the // tweaks should be stored // { apiMeshGeom geomPtr = meshGeom(); bool savePoints = (cachingMode == MVertexCachingMode.kSavePoints); bool updatePoints = (cachingMode == MVertexCachingMode.kUpdatePoints); MArrayDataBuilder builder = handle.builder(); MPoint delta = new MPoint(); MPoint currPt = new MPoint(); MPoint newPt = new MPoint(); int i=0; uint len = componentList.length; int cacheIndex = 0; uint cacheLen = (null != pointCache) ? pointCache.length : 0; if (cachingMode == MVertexCachingMode.kRestorePoints) { // restore points from the pointCache // if (len > 0) { // traverse the component list // for ( i=0; i<len; i++ ) { MObject comp = componentList[i]; MFnSingleIndexedComponent fnComp = new MFnSingleIndexedComponent( comp ); int elemCount = fnComp.elementCount; for ( int idx=0; idx<elemCount && cacheIndex < cacheLen; idx++, cacheIndex++) { int elemIndex = fnComp.element( idx ); MDataHandle hdl = builder.addElement((uint)elemIndex); double[] pt = hdl.Double3; MPoint cachePt = pointCache[cacheIndex]; pt[0] += cachePt.x; pt[1] += cachePt.y; pt[2] += cachePt.z; hdl.Double3 = pt; } } } else { // if the component list is of zero-length, it indicates that we // should transform the entire surface // len = geomPtr.vertices.length; for ( uint idx = 0; idx < len && idx < cacheLen; ++idx ) { MDataHandle hdl = builder.addElement(idx); double[] pt = hdl.Double3; MPoint cachePt = pointCache[cacheIndex]; pt[0] += cachePt.x; pt[1] += cachePt.y; pt[2] += cachePt.z; hdl.Double3 = pt; } } } else { // Tweak the points. If savePoints is true, also save the tweaks in the // pointCache. If updatePoints is true, add the new tweaks to the existing // data in the pointCache. // if (len > 0) { for ( i=0; i<len; i++ ) { MObject comp = componentList[i]; MFnSingleIndexedComponent fnComp = new MFnSingleIndexedComponent( comp ); int elemCount = fnComp.elementCount; if (savePoints) { pointCache.sizeIncrement = (uint)elemCount; } for ( int idx=0; idx<elemCount; idx++ ) { int elemIndex = fnComp.element( idx ); MDataHandle hdl = builder.addElement((uint)elemIndex); double[] pt = hdl.Double3; currPt = newPt = geomPtr.vertices[elemIndex]; newPt.multiplyEqual( mat ); delta.x = newPt.x - currPt.x; delta.y = newPt.y - currPt.y; delta.z = newPt.z - currPt.z; pt[0] += delta.x; pt[1] += delta.y; pt[2] += delta.z; hdl.Double3 = pt; if (savePoints) { // store the points in the pointCache for undo // pointCache.append(delta*(-1.0)); } else if (updatePoints && cacheIndex < cacheLen) { MPoint cachePt = pointCache[cacheIndex]; cachePt[0] -= delta.x; cachePt[1] -= delta.y; cachePt[2] -= delta.z; cacheIndex++; } } } } else { // if the component list is of zero-length, it indicates that we // should transform the entire surface // len = geomPtr.vertices.length; if (savePoints) { pointCache.sizeIncrement = len; } for ( int idx = 0; idx < len; ++idx ) { MDataHandle hdl = builder.addElement((uint)idx); double[] pt = hdl.Double3; currPt = newPt = geomPtr.vertices[idx]; newPt.multiplyEqual( mat ); delta.x = newPt.x - currPt.x; delta.y = newPt.y - currPt.y; delta.z = newPt.z - currPt.z; pt[0] += delta.x; pt[1] += delta.y; pt[2] += delta.z; hdl.Double3 = pt; if (savePoints) { // store the points in the pointCache for undo // pointCache.append(delta*-1.0); } else if (updatePoints && idx < cacheLen) { MPoint cachePt = pointCache[idx]; cachePt[0] -= delta.x; cachePt[1] -= delta.y; cachePt[2] -= delta.z; } } } } // Set the builder into the handle. // handle.set(builder); // Tell Maya the bounding box for this object has changed // and thus "boundingBox()" needs to be called. // childChanged( MChildChanged.kBoundingBoxChanged ); }
// // Description // // Transforms the given components. This method is used by // the move, rotate, and scale tools in component mode when the // tweaks for the shape are stored on a separate tweak node. // The bounding box has to be updated here, so do the normals and // any other attributes that depend on vertex positions. // // Arguments // mat - matrix to transform the components by // componentList - list of components to be transformed, // or an empty list to indicate the whole surface // cachingMode - how to use the supplied pointCache // pointCache - if non-null, save or restore points from this list base // on the cachingMode // handle - handle to the attribute on the tweak node where the // tweaks should be stored // public override void tweakUsing( MMatrix mat, MObjectArray componentList, MVertexCachingMode cachingMode, MPointArray pointCache, MArrayDataHandle handle) { apiMeshGeom geomPtr = meshGeom(); bool savePoints = (cachingMode == MVertexCachingMode.kSavePoints); bool updatePoints = (cachingMode == MVertexCachingMode.kUpdatePoints); MArrayDataBuilder builder = handle.builder(); MPoint delta = new MPoint(); MPoint currPt = new MPoint(); MPoint newPt = new MPoint(); int i=0; uint len = componentList.length; int cacheIndex = 0; uint cacheLen = (null != pointCache) ? pointCache.length : 0; if (cachingMode == MVertexCachingMode.kRestorePoints) { // restore points from the pointCache // if (len > 0) { // traverse the component list // for ( i=0; i<len; i++ ) { MObject comp = componentList[i]; MFnSingleIndexedComponent fnComp = new MFnSingleIndexedComponent( comp ); int elemCount = fnComp.elementCount; for ( int idx=0; idx<elemCount && cacheIndex < cacheLen; idx++, cacheIndex++) { int elemIndex = fnComp.element( idx ); MDataHandle hdl = builder.addElement((uint)elemIndex); double[] pt = hdl.Double3; MPoint cachePt = pointCache[cacheIndex]; pt[0] += cachePt.x; pt[1] += cachePt.y; pt[2] += cachePt.z; hdl.Double3 = pt; } } } else { // if the component list is of zero-length, it indicates that we // should transform the entire surface // len = geomPtr.vertices.length; for ( uint idx = 0; idx < len && idx < cacheLen; ++idx ) { MDataHandle hdl = builder.addElement(idx); double[] pt = hdl.Double3; MPoint cachePt = pointCache[cacheIndex]; pt[0] += cachePt.x; pt[1] += cachePt.y; pt[2] += cachePt.z; hdl.Double3 = pt; } } } else { // Tweak the points. If savePoints is true, also save the tweaks in the // pointCache. If updatePoints is true, add the new tweaks to the existing // data in the pointCache. // if (len > 0) { for ( i=0; i<len; i++ ) { MObject comp = componentList[i]; MFnSingleIndexedComponent fnComp = new MFnSingleIndexedComponent( comp ); int elemCount = fnComp.elementCount; if (savePoints) { pointCache.sizeIncrement = (uint)elemCount; } for ( int idx=0; idx<elemCount; idx++ ) { int elemIndex = fnComp.element( idx ); MDataHandle hdl = builder.addElement((uint)elemIndex); double[] pt = hdl.Double3; currPt = newPt = geomPtr.vertices[elemIndex]; newPt.multiplyEqual( mat ); delta.x = newPt.x - currPt.x; delta.y = newPt.y - currPt.y; delta.z = newPt.z - currPt.z; pt[0] += delta.x; pt[1] += delta.y; pt[2] += delta.z; hdl.Double3 = pt; if (savePoints) { // store the points in the pointCache for undo // pointCache.append(delta*(-1.0)); } else if (updatePoints && cacheIndex < cacheLen) { MPoint cachePt = pointCache[cacheIndex]; cachePt[0] -= delta.x; cachePt[1] -= delta.y; cachePt[2] -= delta.z; cacheIndex++; } } } } else { // if the component list is of zero-length, it indicates that we // should transform the entire surface // len = geomPtr.vertices.length; if (savePoints) { pointCache.sizeIncrement = len; } for ( int idx = 0; idx < len; ++idx ) { MDataHandle hdl = builder.addElement((uint)idx); double[] pt = hdl.Double3; currPt = newPt = geomPtr.vertices[idx]; newPt.multiplyEqual( mat ); delta.x = newPt.x - currPt.x; delta.y = newPt.y - currPt.y; delta.z = newPt.z - currPt.z; pt[0] += delta.x; pt[1] += delta.y; pt[2] += delta.z; hdl.Double3 = pt; if (savePoints) { // store the points in the pointCache for undo // pointCache.append(delta*-1.0); } else if (updatePoints && idx < cacheLen) { MPoint cachePt = pointCache[idx]; cachePt[0] -= delta.x; cachePt[1] -= delta.y; cachePt[2] -= delta.z; } } } } // Set the builder into the handle. // handle.set(builder); // Tell Maya the bounding box for this object has changed // and thus "boundingBox()" needs to be called. // childChanged( MChildChanged.kBoundingBoxChanged ); }
public override void closestPoint(MPoint toThisPoint, MPoint theClosestPoint, double tolerance) // // Description // // Returns the closest point to the given point in space. // Used for rigid bind of skin. Currently returns wrong results; // override it by implementing a closest point calculation. { // Iterate through the geometry to find the closest point within // the given tolerance. // apiMeshGeom geomPtr = meshGeom(); uint numVertices = geomPtr.vertices.length; for (int ii=0; ii<numVertices; ii++) { MPoint tryThisOne = geomPtr.vertices[ii]; } // Set the output point to the result (hardcode for debug just now) // theClosestPoint = geomPtr.vertices[0]; }
// // Description // // Returns the bounding box for this object. // It is a good idea not to recompute here as this funcion is called often. // public override MBoundingBox boundingBox() { MObject thisNode = thisMObject(); MPlug c1Plug = new MPlug( thisNode, bboxCorner1 ); MPlug c2Plug = new MPlug( thisNode, bboxCorner2 ); MObject corner1Object = new MObject(); MObject corner2Object = new MObject(); c1Plug.getValue( corner1Object ); c2Plug.getValue( corner2Object ); double[] corner1 = new double[3]; double[] corner2 = new double[3]; MFnNumericData fnData = new MFnNumericData(); fnData.setObject( corner1Object ); fnData.getData(out corner1[0], out corner1[1], out corner1[2]); fnData.setObject( corner2Object ); fnData.getData(out corner2[0], out corner2[1], out corner2[2]); MPoint corner1Point = new MPoint( corner1[0], corner1[1], corner1[2] ); MPoint corner2Point = new MPoint( corner2[0], corner2[1], corner2[2] ); return new MBoundingBox( corner1Point, corner2Point ); }
public override bool getInternalValue(MPlug plug, MDataHandle result) // // Description // // Handle internal attributes. // // Attributes that require special storage, bounds checking, // or other non-standard behavior can be marked as "Internal" by // using the "MFnAttribute.setInternal" method. // // The get/setInternalValue methods will get called for internal // attributes whenever the attribute values are stored or retrieved // using getAttr/setAttr or MPlug getValue/setValue. // // The inherited attribute mControlPoints is internal and we want // its values to get stored only if there is input history. Otherwise // any changes to the vertices are stored in the cachedMesh and outputMesh // directly. // // If values are retrieved then we want the controlPoints value // returned if there is history, this will be the offset or tweak. // In the case of no history, the vertex position of the cached mesh // is returned. // { bool isOk = true; if( plug.attribute.equalEqual(mControlPoints) || plug.attribute.equalEqual(mControlValueX) || plug.attribute.equalEqual(mControlValueY) || plug.attribute.equalEqual(mControlValueZ) ) { // If there is input history then the control point value is // directly returned. This is the tweak or offset that // was applied to the vertex. // // If there is no input history then return the actual vertex // position and ignore the controlPoints attribute. // if ( hasHistory() ) { return base.getInternalValue( plug, result ); } else { double val = 0.0; if ( plug.attribute.equalEqual(mControlPoints) && !plug.isArray ) { MPoint pnt = new MPoint(); int index = (int)plug.logicalIndex; value( index, ref pnt ); result.set( pnt[0], pnt[1], pnt[2] ); } else if ( plug.attribute.equalEqual(mControlValueX) ) { MPlug parentPlug = plug.parent; int index = (int)parentPlug.logicalIndex; value( index, 0, ref val ); result.set( val ); } else if ( plug.attribute.equalEqual(mControlValueY) ) { MPlug parentPlug = plug.parent; int index = (int)parentPlug.logicalIndex; value( index, 1, ref val ); result.set( val ); } else if ( plug.attribute.equalEqual(mControlValueZ) ) { MPlug parentPlug = plug.parent; int index = (int)parentPlug.logicalIndex; value( index, 2, ref val ); result.set( val ); } } } // This inherited attribute is used to specify whether or // not this shape has history. During a file read, the shape // is created before any input history can get connected. // This attribute, also called "tweaks", provides a way to // for the shape to determine if there is input history // during file reads. // else if ( plug.attribute.equalEqual(mHasHistoryOnCreate) ) { result.set( fHasHistoryOnCreate ); } else { isOk = base.getInternalValue( plug, result ); } return isOk; }
// // Description // // Handle internal attributes. // // Attributes that require special storage, bounds checking, // or other non-standard behavior can be marked as "Internal" by // using the "MFnAttribute.setInternal" method. // // The get/setInternalValue methods will get called for internal // attributes whenever the attribute values are stored or retrieved // using getAttr/setAttr or MPlug getValue/setValue. // // The inherited attribute mControlPoints is internal and we want // its values to get stored only if there is input history. Otherwise // any changes to the vertices are stored in the cachedMesh and outputMesh // directly. // // If values are retrieved then we want the controlPoints value // returned if there is history, this will be the offset or tweak. // In the case of no history, the vertex position of the cached mesh // is returned. // public override bool getInternalValue(MPlug plug, MDataHandle result) { bool isOk = true; if( plug.attribute.equalEqual(mControlPoints) || plug.attribute.equalEqual(mControlValueX) || plug.attribute.equalEqual(mControlValueY) || plug.attribute.equalEqual(mControlValueZ) ) { // If there is input history then the control point value is // directly returned. This is the tweak or offset that // was applied to the vertex. // // If there is no input history then return the actual vertex // position and ignore the controlPoints attribute. // if ( hasHistory() ) { return base.getInternalValue( plug, result ); } else { double val = 0.0; if ( plug.attribute.equalEqual(mControlPoints) && !plug.isArray ) { MPoint pnt = new MPoint(); int index = (int)plug.logicalIndex; value( index, ref pnt ); result.set( pnt[0], pnt[1], pnt[2] ); } else if ( plug.attribute.equalEqual(mControlValueX) ) { MPlug parentPlug = plug.parent; int index = (int)parentPlug.logicalIndex; value( index, 0, ref val ); result.set( val ); } else if ( plug.attribute.equalEqual(mControlValueY) ) { MPlug parentPlug = plug.parent; int index = (int)parentPlug.logicalIndex; value( index, 1, ref val ); result.set( val ); } else if ( plug.attribute.equalEqual(mControlValueZ) ) { MPlug parentPlug = plug.parent; int index = (int)parentPlug.logicalIndex; value( index, 2, ref val ); result.set( val ); } } } // This inherited attribute is used to specify whether or // not this shape has history. During a file read, the shape // is created before any input history can get connected. // This attribute, also called "tweaks", provides a way to // for the shape to determine if there is input history // during file reads. // else if ( plug.attribute.equalEqual(mHasHistoryOnCreate) ) { result.set( fHasHistoryOnCreate ); } else { isOk = base.getInternalValue( plug, result ); } return isOk; }
public lineMath() { point = new MPoint(); direction = new MVector(); }