Jump to content

gord0

Members
  • Content count

    36
  • Joined

  • Last visited

  • Days Won

    2

Reputation Activity

  1. Like
    gord0 reacted to karl in Runtime assistance   
    Any errors in the console?
  2. Like
    gord0 reacted to karl in Runtime assistance   
    AppendFace will always assume vertices are in local coordinates. To account for rotation, you can use the functions "TransformPoint" and "InverseTransformPoint"  in the Transform class to translate from one object's local coordinates to another.
  3. Like
    gord0 reacted to karl in Runtime assistance   
    The problem stems from how you're creating that initial face. The gist of it is that for the moment it assumes any triangle edge with unique vertex positions are perimeter edges. So when you extrude, ProBuilder thinks that the face you're extruding from is actually two faces. To fix this, just use 4 vertex positions instead of 6. Ex:
    /** * Vertex positions for a quad are laid out like this. Note that positions 0 & 3 are reused. * * 2-----3 * | | * | | * 0-----1 * */ Vector3[] verts = new Vector3[4] { new Vector3(-1, -1f, 0f), new Vector3( 1, -1f, 0f), new Vector3(-1, 1f, 0f), new Vector3( 1, 1f, 0f), }; /** * Quad is two tris: * * 2←-------3 * |↖ ↘ ↑ * | ↖ ↘ | * ↓ ↖ ↘| * 0-------→1 */ var face = new pb_Face(new int[6] { 0, 1, 2, 1, 3, 2 }); face.material = pb_Constant.DefaultMaterial; var pb = pb_Object.CreateInstanceWithVerticesFaces(verts, new pb_Face[] { face }); pb.ToMesh(); pb.Refresh();  
  4. Like
    gord0 reacted to karl in Runtime assistance   
    Yup, your only problem is the ExtrudeMethod being used. You want `ExtrudeMethod.FaceNormal`, not InvdividualFaces.
    _currentSelection.PB.Extrude(new pb_Face[] { _currentSelection.Face },                              ExtrudeMethod.FaceNormal,                              !_specifiedFaceSelect ? Mathf.Epsilon : 0.0f); //epsilon if not custom face, otherwise 0  
  5. Like
    gord0 reacted to karl in Runtime assistance   
    Yeah, these things have moved around quite a bit since that was written. Math was moved into Core, and I think the shape gen class is now just pb_ShapeGenerator.
  6. Like
    gord0 reacted to karl in Runtime assistance   
    Yes, but you'd end up with two faces sandwiched next to each other. If that works for you, it would be fine to use use that approach.
    I also just remembered that I did a very similar thing for an article a few years ago. I can't find the article, but the example code is here.
    https://github.com/karl-/pipedreams
  7. Like
    gord0 reacted to karl in Runtime assistance   
    Can you condense the code to the specific problem area? It would be much easier for me to help pick out the issue.
    Yes, you can merge meshes using the MeshOps namespace.
  8. Like
    gord0 got a reaction from karl in Runtime assistance   
    Ahhh. Nice. So what I'm going to do now is work on a way for the user to just draw the preview plane on a face (perhaps by holding a kb key and dragging the mouse). Then I can do as you've explained above. Instead of sizing the preview plane to match the face, I'll scale/position the face to match the preview plane. : ]
  9. Like
    gord0 reacted to karl in Runtime assistance   
    You just extrude with no distance, then scale the face inward, then extrude again. Here's a gif showing what I mean.

  10. Like
    gord0 reacted to karl in Runtime assistance   
    You're almost there, it's just missing a few parts. In psuedo-code, it should look like this:
    if (mouseDrag) { if (!wasDragging) { pb.Extrude(faces) pb.ToMesh(); pb.Refresh(); wasDragging = true; } pb.TranslateVertices(...); pb.Refresh(); }  
  11. Like
    gord0 reacted to karl in Runtime assistance   
    It looks like so far you've just translated faces along their normal. To create branches, you need to extrude the face prior to translating. So using the RuntimeEdit example, you'd add
    currentSelection.pb.Extrude(new pb_Face[] { currentSelection.face }, ExtrudeMethod.IndividualFaces, Mathf.Epsilon); prior to translating the vertices. That creates new segments that you can then branch off however you'd like.
  12. Like
    gord0 reacted to karl in Runtime assistance   
    You'll need to include the ProBuilder2.MeshOperations namespace.
  13. Haha
    gord0 got a reaction from karl in Runtime assistance   
    Cheers. It's a snow day for me so I won't be able to try this until tomorrow...unless that's a snow day too. I'll let you know how it works out. : ]
×