Code Monkey home page Code Monkey logo

toxiclibs's People

Contributors

postspectacular avatar thomaslengeling 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

toxiclibs's Issues

Add library.properties to build

As part of #1, I am manually inserting library.properties to the zipped library compilation, but would be good for this to be part of the ANT build.

Spline2D source does not include full implementation

The methods used in the examples are not in the source code posted here. Perhaps an older version is displayed here? For example, the computeVertices method of Spline2D is nowhere to be found in the code while being crucial to the class. I would appreciate the full source as I need some more details on the implementation.

I'm trying to figure out how exactly to set control points on the ends of splines to make a "spline loop". The delta array holds the control point data presumably, but I'm not exactly sure what to set as the deltas at the endpoints. This is why I need to see the implemention; it's not clear to me what the delta array holds even after looking at the data it contains.

Problem dividing face of a WETriangleMesh

Dear Toxi,

First let me thank you for this fascinating tool that is toxiclibs.

I've recently been trying to port this growth algorithm presented on the iGeo library webpage (7th sketch from top - "Finding Edges to Divide on Closed Surface") using toxiclibs but I'm having difficulties with the WETriangleMesh class.

In the following example code I'm trying to add 3 new faces on top of one of the original 4 faces of a tetrahedron mesh. The mesh vertices are connected by springs.
My problem is that the vertices of the newly added faces don't match the original tetrahedron, as if they were disconnected from the mesh (top grey 3D triangle).

It is all the more surprising that the newly added springs that share the same vertices positions DO fit the tetrahedron (top 3 red lines)

Questions:

  • I would really appreciate if you could help me find what's wrong with this example sketch
  • Would you mind suggesting a better/smarter approach to tackle the face division part ? (Interestingly enough, this set of rules is the same suggested by Andy Lomas in this paper)
add_library('toxiclibs')
add_library('peasycam')
from toxi.physics3d.behaviors import GravityBehavior3D, AttractionBehavior3D
from toxi.physics3d import VerletPhysics3D, VerletParticle3D, VerletSpring3D


def setup():
    global  physics, mesh, gfx
    perspective(60 * DEG_TO_RAD, width/float(height), 2, 6000)
    size(690, 460, P3D)
    smooth(8)
        
    cam = PeasyCam(this, 150)
    
    physics = VerletPhysics3D()
    physics.setDrag(1.1)
    physics.setWorldBounds(AABB(Vec3D(), Vec3D(width, height, height)))
    
    mesh = WETriangleMesh()
    gfx = ToxiclibsSupport(this)

            
    #Create 4 particles to form a tetrahedron        
    for i in range(4):
        p = VerletParticle3D(Vec3D.randomVector())
        physics.addParticle(p)
        physics.addBehavior(AttractionBehavior3D(p, 10, -4))
        
    #Adding springs between particles
    for p1 in physics.particles:
        for p2 in physics.particles:
            if p1 != p2:
                s = VerletSpring3D(p1, p2, 60, .1)
                physics.addSpring(s)

    #Adding faces between particles
    p1 = physics.particles.get(0)
    p2 = physics.particles.get(1)
    p3 = physics.particles.get(2)
    p4 = physics.particles.get(3)
    
    mesh.addFace(p1, p2, p3)  
    mesh.addFace(p1, p3, p4)  
    mesh.addFace(p1, p2, p4)     
    mesh.addFace(p2, p3, p4)

    
def draw():
    background(30)
    
    #Update physics
    physics.update()
    
    #Display WETriangle mesh
    noStroke()
    fill(255, 200)
    gfx.mesh(mesh)
    
    
    #Update mesh based on particles position
    for i in range(len(physics.particles)):
        if mesh.getVertexForID(i) is not None:
            mesh.getVertexForID(i).set(physics.particles.get(i))
    
        
    #Draw springs
    for i in range(len(physics.springs)):
        stroke(255, 30, 30)
        strokeWeight(1)
        line(physics.springs.get(i).a.x(), physics.springs.get(i).a.y(), physics.springs.get(i).a.z(),  
        physics.springs.get(i).b.x(), physics.springs.get(i).b.y(), physics.springs.get(i).b.z())


def keyReleased():

    f = mesh.getFaces().get(0)
    centroid = VerletParticle3D(Triangle3D(f.a, f.b, f.c).computeCentroid())
    
    a = physics.particles.get(physics.particles.index(f.a))
    b = physics.particles.get(physics.particles.index(f.b))
    c = physics.particles.get(physics.particles.index(f.c))

    CreateFaces(a, b, c, centroid)
       

    
def CreateFaces(a, b, c, n):
    
    #Add centroid to physics + set repulsive behavior
    physics.addParticle(n)
    physics.addBehavior(AttractionBehavior3D(n, 10, -4))
    
    #Attach springs between the face vertices and the centroid
    s1 = VerletSpring3D(a, n, 60, .1)
    s2 = VerletSpring3D(b, n, 60, .1)
    s3 = VerletSpring3D(c, n, 60, .1)
    
    physics.addSpring(s1)
    physics.addSpring(s2)
    physics.addSpring(s3)
    
    #Remove original face
    mesh.removeFace(mesh.getFaces().get(0))
    
    #Add faces of the newly formed tetrahedron to the mesh
    mesh.addFace(n, a, b)
    mesh.addFace(n, b, c)
    mesh.addFace(n, a, c)

Respectfully,

solub

Using the BasicNurbsSurface class

Dear toxi,

I'd like to use the BasicNurbsSurface class but haven't found a single example sketch on the web and it seems the corresponding Javadoc is missing.

Would you mind sharing a very basic example sketch demonstrating how to handle a nurb surface with toxiclibs ?

Respectfully,

solub

Overriding Voronoi Cell site position dynamically

Hi,

I would like to know if it's possible to override a voronoi cell position while the sketch is iterating without having to clear the Voronoi() class and adding new points at every frame.

I was thinking the following would do the trick but it didn't:

voronoi.getSites().get(i).set(Vec2D(p.x, p.y))

(p being a moving VerletParticle2D object)

For now I'm clearing/ appending points at each iteration but the frameRate drops very quickly after 100 moving particles displayed on the screen:

def draw():

    #Clears voronoi
    voronoi = Voronoi()
    
    for i, p in enumerate(collection):
        p.growth()
        p.display() 

        #Appending points
        voronoi.addPoint(physics.particles.get(i))

Rename `toxi.color` package due to P5 grammar rule changes

Processing v4 has updated parse grammar rules, which now are classifying color also as reserved keyword if used within a multipart, dot-separated package name and thus breaking any project which attempts to import toxi.color.*;. The P5 team seems to have marked this as working-as-intended, breaking 2 decades old existing behavior. Therefore, I will now have to rename this package to something similar and attempt to build a new release, incl. updated examples...

Proposals for the new package name are gladly accepted!

See relevant issues:

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.