Jump to content

gord0

Members
  • Content count

    36
  • Joined

  • Last visited

  • Days Won

    2

gord0 last won the day on March 18 2018

gord0 had the most liked content!

About gord0

  • Rank
    Advanced Member
  1. gord0

    Runtime assistance

    Is is possible to see the source code of FaceWithTriangle(int[], out pb_Face) ? It's blowing up in there even when there aren't null faces.
  2. gord0

    Runtime assistance

    New oddity I'm dealing with now... how is it possible for a pb_Object's faces to become null even though the object visibly has all of it's faces (cube)? I'm not removing/deleting faces. for (int jFace = 0; jFace < _ourPBCube.faces.Length; jFace++) { if (_ourPBCube.faces[jFace]==null) { Debug.LogWarning("EGADS!!!"); } }
  3. gord0

    Runtime assistance

    Turns out, due to unknown sorcery, that the first 6 values in msh.triangles were being removed. So then I manually replaced them and the face reappeared, but was removed again any time I changed anything in the geometry. So I just manually made a new face and appended it to the mesh and set it's vertices to be the same as the missing face. This fix stuck, so that's that I guess.
  4. gord0

    Runtime assistance

    No, it would be wonderful if there was though lol
  5. gord0

    Runtime assistance

    Will let you know on Monday.
  6. gord0

    Runtime assistance

    Well of course because people love changing things, the whole input style has changed. The want to be able to just place nodes and have the "corridors" just connect the nodes. Which is fine, but it also means a lot of how I was doing things has changed. Have you ever had a face just disappear after an extrusion? In this case, not even the face I had extruded.
  7. gord0

    Runtime assistance

    I think I'm golden now. Thanks for all your help! : ]
  8. gord0

    Runtime assistance

    One more thing. When using AppendFace() is there a way to make the face physically stay where it was before appending. It seems to always go to the origin of the pbo that I attach it to. I then have to move the vertices manually with offsets depending where I intended to attach it. Which was fine until I realized that if the pbo is rotated at all it throws everything out of whack.
  9. gord0

    Runtime assistance

    It is working! I still have to make some adjustments so that it works on all axis but 4 of the 6 are working. I'll let you know if I have any more questions/troubles. : ]
  10. gord0

    Runtime assistance

    Cheers, will try this out in the morning. : ]
  11. gord0

    Runtime assistance

    protected void DrawCustomPlane() { if (Input.GetMouseButtonUp(0)) //they let go of the button, lets get outta here { _customExtruding = false; _meoc.RelinquishNonAxisMovement = false; _specifiedFaceSelect = true; CommenceModifications(); return; } if (!Input.GetKey(KeyCode.LeftControl)) { return; } //they're not holding left control, so let's chill if (_customExtruderPlane==null) //if our plane is null { _ray = _cam.ScreenPointToRay(Input.mousePosition); //let's fire a ray to see if we can fix that if (Physics.Raycast(_ray, out _hit, Mathf.Infinity, _lm)) //if we hit something { if (_hit.collider.gameObject.GetComponent<pb_Object>()==null) { return; } //forget it, not pb object Vector3[] verts = new Vector3[6] //we'll start with all the vertices zero'd out { Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero, Vector3.zero }; int[] indices = new int[verts.Length]; //define our indices for (int iVert=0; iVert<verts.Length; iVert++) { indices[iVert] = iVert; } //.. //now we can make the plane _customExtruderPlane = pb_Object.CreateInstanceWithVerticesFaces(verts, new pb_Face[] { new pb_Face(indices) }); _customExtruderPlane.SetFaceMaterial(_customExtruderPlane.faces, PreviewMaterial); _customExtruderPlane.ToMesh(); _customExtruderPlane.Refresh(); //move it just a little in front of whatever the ray hit so we can see it proper _customExtruderPlane.gameObject.transform.position = _hit.point + (_hit.normal * 0.1f); _customExtruderPlane.gameObject.transform.forward = _hit.normal; } } if (_customExtruderPlane==null) { return; } //i guess we missed else //lets move our vertices according to mouse movement { /* verts[0] -- upper left corner verts[0] -- upper left corner verts[1,3] -- lower left corner verts[2,3] -- lower left corner verts[2,5] -- upper right corner verts[1,4] -- upper right corner verts[4] -- lower right corner verts[5] -- lower righ corner 0 --- 2,5 0 --- 1,4 | | | | | | | | | | | | 1,3 --- 4 2,3 --- 5 */ _ray = _cam.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(_ray, out _hit, Mathf.Infinity, _lm)) //fire ray from the mouse { if (_hit.collider.gameObject.GetComponent<pb_Object>() == null) { return; } //forget it, not pb object _customPlaneMarker.position = _hit.point; //place our marker at the hit point _customPlaneMarker.parent = _customExtruderPlane.gameObject.transform; //child it to the plane Vector3[] verts = _customExtruderPlane.vertices; //grab verts from the plane verts[4] = _customPlaneMarker.localPosition; //place lower right corner at marker verts[4].z = verts[0].z; //copy z from upper right corner to lower left (remember plane is a little in front of hit) verts[2].x = verts[4].x; //make rest of verts form the rest of the rectangle based on 0 and 4 verts[5].x = verts[4].x; //.. verts[1].y = verts[4].y; //.. verts[3].y = verts[4].y; //.. //same as above but clockwise winding order //verts[5] = _customPlaneMarker.localPosition; //verts[5].z = verts[0].z; //verts[1].x = verts[5].x; //verts[4].x = verts[5].x; //verts[2].y = verts[5].y; //verts[3].y = verts[5].y; _customExtruderPlane.SetVertices(verts); //update the plane's vertices with our changes _customExtruderPlane.ToMesh(); //apply changes _customExtruderPlane.Refresh(); //.. _customPlaneMarker.parent = null; //unchild marker from plane } } } This is the code that allows the user to draw their own plane.
  12. gord0

    Runtime assistance

    I was hopeful but...same issue. I also tried VertexNormal just see what would happen and it's also the same. All three methods seem to turn out the same in this scenario.
  13. gord0

    Runtime assistance

    Ahhhh, I didn't even think to look there since I had been using that line as is for so long. Will give it a go in the morning!
  14. gord0

    Runtime assistance

    Alright I'm getting better results using a different approach. The new problem is, what is this diagonal plain on the inside of the "corridor"? I've used a 2 sided transparent material so you can see (it seems your attachment system is broken so I'm using external links): https://pasteboard.co/HfQ4Xja.png https://pasteboard.co/HfQ5Ahq.png This is how I'm achieving it: protected void CommenceModifications() { Vector3 facePos = FaceCenter(_currentSelection.Face, _currentSelection.PB); //get the center point of selected face Vector3 toWidget = (_widget.localPosition - facePos).normalized; //get direction from face center to widget bool behind = Mathf.Approximately(Vector3.Dot(toWidget, _localNormal), -1.0f); //determine if widget is in front or behind face if (_canExtrude) //may we extrude? { //make it so _currentSelection.PB.Extrude(new pb_Face[] { _currentSelection.Face }, ExtrudeMethod.IndividualFaces, !_specifiedFaceSelect ? Mathf.Epsilon : 0.0f); //epsilon if not custom face, otherwise 0 _currentSelection.PB.ToMesh(); _currentSelection.PB.Refresh(); if (_specifiedFaceSelect) //is this a user defined face? { //move their plane back to be flush with the actual face they want to extrude from _customExtruderPlane.gameObject.transform.position -= _customExtruderPlane.gameObject.transform.forward * 0.1f; Transform t = _customExtruderPlane.gameObject.transform; if (Mathf.Approximately(t.forward.z, 1.0f) || Mathf.Approximately(t.forward.x, 1.0f) || Mathf.Approximately(t.forward.x, -1.0f) || Mathf.Approximately(t.forward.y, 1.0f) || Mathf.Approximately(t.forward.y, -1.0f)) { _customExtruderPlane.faces[0].ReverseIndices(); } t.parent = _currentSelection.PB.gameObject.transform; Vector3[] offSetVerts = _customExtruderPlane.vertices; float xDist = Vector3.Distance(offSetVerts[0], offSetVerts[2]); float yDist = Vector3.Distance(offSetVerts[0], offSetVerts[1]); for (int iVert=0; iVert<offSetVerts.Length; iVert++) { offSetVerts[iVert] += t.localPosition; if (Mathf.Approximately(t.forward.z, -1.0f)) { offSetVerts[iVert].x += xDist; } /*if (iVert==5) //touching: 0, 2, 5 { //not touching: 1, 3, 4 Transform go = GameObject.CreatePrimitive(PrimitiveType.Sphere).transform; go.parent = _currentSelection.PB.gameObject.transform; go.localPosition = offSetVerts[iVert]; }*/ if ((iVert!=0 && iVert!=1 && iVert!=3) && (Mathf.Approximately(t.forward.x, 1.0f) || Mathf.Approximately(t.forward.x, -1.0f))) { offSetVerts[iVert].x = offSetVerts[0].x; offSetVerts[iVert].z += xDist * (Mathf.Approximately(t.forward.x, -1.0f) ? -1.0f : 1.0f); } if ((iVert!=0 && iVert!=2 && iVert!=5) && (Mathf.Approximately(t.forward.y, 1.0f) ||Mathf.Approximately(t.forward.y, -1.0f))) { offSetVerts[iVert].y = offSetVerts[0].y; offSetVerts[iVert].z += yDist * (Mathf.Approximately(t.forward.y, 1.0f) ? -1.0f : 1.0f); } } t.parent = null; pb_Face pbf=_currentSelection.PB.AppendFace(offSetVerts, new Color[1] { Color.white }, _customExtruderPlane.uv, _customExtruderPlane.faces[0]); _manualFaceSelect = true; _manualFaceSelectPBO = _currentSelection.PB; _manualFaceSelectFace = pbf; /*Debug.LogWarning("_customExtruderPlane.gameObject.transform.forward: " + _customExtruderPlane.gameObject.transform.forward);*/ if (_customExtruderPlane != null) { Destroy(_customExtruderPlane.gameObject); } } _currentSelection.PB.ToMesh(); //apply changes _currentSelection.PB.Refresh(); //.. _canExtrude = false; //no more extuding for now } if (!_specifiedFaceSelect) //if this was a not a user defined face, translate the verts based on widget pos { _currentSelection.PB.TranslateVertices( _currentSelection.Face.distinctIndices, _localNormal.normalized * (Vector3.Distance(_widget.localPosition, facePos)) * (behind ? -1.0f : 1.0f) ); _currentSelection.PB.ToMesh(); _currentSelection.PB.Refresh(); } else //otherwise { _specifiedFaceSelect = false; //we're done with the user defined face _destroyPreview = true; //destroy the preview plane _waitAFrame = true; //we should probably wait a frame before we do anything else } // Refresh will update the Collision mesh volume, face UVs as applicatble, and normal information. _currentSelection.PB.Refresh(); // this creates the selected face preview RefreshSelectedFacePreview(); Have you seen this kind of problem before?
  15. gord0

    Runtime assistance

    How are these pb_Object methods used?: AppendFace, Connect, and MergeFaces Could they be of use?
×