Giter Club home page Giter Club logo

he_mesh's People

Contributors

wblut avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

he_mesh's Issues

Issues with normalizeSelf() and setting magnitude

Dear @wblut ,

I'm having issues when normalizing vectors with Hemesh.
Looking at WB_Vector(), it seems normalizeSelf() returns the magnitude of a vector, not its normalized vector

@Override
	public double normalizeSelf() {
		final double d = getLength();
		if (WB_Epsilon.isZero(d)) {
			set(0, 0, 0);
		} else {
			set(xd() / d, yd() / d, zd() / d);
		}
		return d;
}

I believe that you're returning d on purpose here but then how do you get the normalized vector ?

Also, without a normalize function, I'm unable to set the magnitude of a vector (ideally normalizeSelf() + scaleSelf() would have worked). Does Hemesh have something similar to setMag() (Processing) or normalizeTo() (Toxiclibs) ?

Would appreciate your lights.

Regards,

will the reference document make it back to the Repo?

I discovered many different things while working with an older version of HE_Mesh through the reference document. The HTML files that had all the inner secrets.

Is it wise for me to use the older reference document for guidance, or are there so many changes that it would be wiser, and saner, not to?

(trying to figure out how to understand the multi-slice segments a bit more, to turn them into paths I can save as a SVG file or collection of Bezier curves to use in Blender, etc. The result from HE_Mesh works better than the model/plane Boolean intersection in Blender)

Iteratively adding faces or vertices to a mesh

Hi @wblut,

Congratulations for the new release !

I'm wondering, how would you add new faces or vertices to a mesh ?

Let's say I have an Icosahedron and I want to divide one of its faces into 3 new faces by inserting a new vertex at its center, would that be possible with Hemesh ?

add_library('peasycam')
add_library('hemesh')

def setup():
    size(1000, 600, P3D)
    smooth(8)
           
    global mesh, render
    mesh = HE_Mesh(HEC_Icosahedron())
    render = WB_Render(this)
    cam = PeasyCam(this, 800)

def draw():
    background('#DCDCDC')
    lights()
    
    render.drawFaces(mesh)

def keyReleased():
    # select a face at random
    # compute its center and place a new vertex
    # create 3 new faces around that new vertex
    # remove old face

Straight Skeleton

Dear @wblut,

I just found out about the straightskeleton external package and, despite all my efforts, can't seem to manage how to output the Straight Skeleton of a polygon. Would you mind providing a simple example ?

Here is my attempt so far:

#Jython2.7
add_library('hemesh')

from wblut.external.straightskeleton import * 

verts = [PVector(208, 131),PVector(213, 142),PVector(168, 141),PVector(260, 168),PVector(246, 149),PVector(277, 142),
        PVector(271, 163),PVector(302, 180),PVector(268, 173),PVector(305, 196),PVector(319, 225),PVector(367, 214),
        PVector(423, 169),PVector(471, 160),PVector(540, 208),PVector(588, 268),PVector(616, 270),PVector(644, 308),
        PVector(630, 446),PVector(647, 472),PVector(641, 459),PVector(656, 467),PVector(660, 450),PVector(646, 423),
        PVector(687, 447),PVector(666, 495),PVector(651, 495),PVector(711, 580),PVector(728, 584),PVector(714, 557),
        PVector(746, 560),PVector(735, 569),PVector(744, 617),PVector(769, 594),PVector(753, 624),PVector(771, 628),
        PVector(793, 700),PVector(842, 708),PVector(871, 759),PVector(902, 780),PVector(891, 788),PVector(871, 773),
        PVector(887, 799),PVector(947, 774),PVector(964, 782),PVector(978, 689),PVector(985, 678),PVector(990, 695),
        PVector(984, 555),PVector(868, 338),PVector(854, 294),PVector(869, 316),PVector(887, 314),PVector(892, 366),
        PVector(895, 322),PVector(805, 196),PVector(747, 61),PVector(759, 59),PVector(753, 43),PVector(691, 33),
        PVector(683, 98),PVector(661, 72),PVector(355, 83),PVector(333, 46),PVector(35, 70),PVector(70, 144),
        PVector(50, 165),PVector(77, 154),PVector(87, 125),PVector(99, 139),PVector(106, 118),PVector(122, 139),
        PVector(89, 152),PVector(169, 124)]


def setup():
    size(1360, 840, P2D)
    background("#FFFFFF")
    strokeWeight(4)
    fill(0)
    
    # number of vertices
    N = len(verts)
    
    # corner
    corners = [Corner(p.x, p.y) for p in verts]
    
    # edges
    edges = Loop()
    for i in xrange(N):
        edges.append(Edge(corners[i], corners[(i+1)%N]))
    
    # speeds
    speeds = []
    for i in xrange(N):        
        pv = verts[(i-1)%N] #prev vertex
        cv = verts[i] #current vertex
        nv = verts[(i+1)%N] #next vertex
        s = speed(pv, cv, nv)
        speeds.append(s)
        
    # apply speed to edges
    for i, e in enumerate(edges):
        e.machine = Machine(speeds[i])

        
    out = LoopL()
    out.add(edges)

    skel = Skeleton(out, True)
    skel.skeleton()
    faces = skel.output.faces.values()
    

    faceList = []

    for face in faces:
        temp = []
        for ptgroup in face.points:
            for i, p in enumerate(ptgroup):
                temp.append(p)
        faceList.append(temp)
        
        
                
    strokeWeight(1.3)
    for face in faceList:
        for p1, p2 in zip(face, face[1:] + face[:1]):
            line(p1.x, p1.y, p2.x, p2.y)

    for i, p in enumerate(verts):
        text(i, p.x, p.y)
    
    noLoop()
    
    

    
        
def speed(pv, cv, nv):
    
    '''Returns a float.
       Computes the speed of a vertex given both its previous and next neighbors'''
            
    vec1 = PVector.sub(cv, pv).normalize()
    vec2 = PVector.sub(nv, cv).normalize()

    a = angle(vec1, vec2)
    s = 1 / sin(a*.5) #speed  
    
    return s

 
def angle(vec1, vec2):
    
    '''Returns a float.
       Computes the angle between 2 vectors'''
    
    a = PI - PVector.angleBetween(vec1, vec2) 
        
    if vec1.cross(vec2).z > 0:
        a = TWO_PI - a
        
    return a

Also please tell me if my other question about plane fitting is poorly-worded and I will do my best to reformulate it.

Your help is very valuable to me.

Respectfully

Updating a WB_KDTreeInteger without rebuilding it

Apologies for the inconvenience. I'm wondering whether it is possible or not to change a KDTree without having to rebuild it.

Basically I have an array of cells whose locations are stored in a WB_KDTreeInteger . These locations may change over time but not at the same moment (only 1 cell out of 1000 will move, one by one). Is it possible to update the entry corresponding to the cell that has moved (update the location) without having to rebuild entirely the WB_KDTreeInteger at each iteration ?

Git history is gone

Hi! Last week I noticed that the whole commit history of HE_Mesh has disappeared so I thought I would ask where did they go? :)

Thank you for the amazing HE_Mesh!

Merging different meshes into a single one

Dear @wblut ,

The title says it pretty much, I would like to merge 2 different shapes/meshes or more into one single mesh. Is it possible with Hemesh ?

I was thinking HET_MeshOp.getFurthestIntersection() or WB_GeometryOp.getIntersection3D() combined with HEM_TriSplit.splitFaceTri() could to the trick but my attempts have been unsuccessful so far.

Would really appreciate to have your lights on this.

[not issue] awesome videos in your instagram... Alternative for openframeworks?

Hey @wblut ,
you have really nice works!

I was wondering if do you think this code is portable to OF...

I have seen the OF addon:
https://github.com/neilmendoza/ofxCorkCsg, based on https://github.com/CloudCompare/cork that is a kind of:

Cork Boolean Library
Welcome to the Cork Boolean/CSG library. Cork is designed to support Boolean operations between triangle meshes.

Not sure if this is similar to what your code does, and I am not Processing use to test it easy.
So I want to ask you in two lines if do you think could describe what your code does and if it's related to this Cork or it's doing more things...

Cheers

Planes facing each other

Dear @wblut,

I would like to attach a mesh to another mesh based on face selection.

In the example below I am trying to move the mesh on the left close to the mesh on the right so as face n°6 touches face n°8 of the latter:

Annotation 2020-07-02 122858

At the moment I am applying a transformation to the mesh on the left using transformSelf combined with WB_Transform3D() but as you can see faces are not aligned:

Annotation 2020-07-02 123017

Using HE_Mesh, what would be the correct way to compute this kind of transformation while keeping the faces aligned ? (maybe using planes ?)

My code so far:

import wblut.processing.*;

HE_Mesh m1, m2;
PeasyCam cam;

WB_Render3D render;
void setup() {
  size(1000, 1000, P3D);
  perspective(60 * DEG_TO_RAD, width/float(height), 2, 6000);
  smooth(8);
  background(55); 
  render=new WB_Render3D(this);
  cam = new PeasyCam(this, 40);
  create();
}

void create() {

  m1 = new HE_Mesh(new HEC_FromOBJFile("C:/Users/solub/Desktop/m1.obj"));
  m2 = new HE_Mesh(new HEC_FromOBJFile("C:/Users/solub/Desktop/m2.obj"));
  WB_Transform3D T=new WB_Transform3D(m1.getFaceCenter(6), m1.getFaceNormal(6), m2.getFaceCenter(8), m2.getFaceNormal(8).mul(-1));
  m1.transformSelf(T);// or .applySelf(T)
}


void draw() {
  background(50);
  stroke(0);
  render.drawFaces(m1);
  render.drawFaces(m2);
}

obj files if necessary

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.