Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IGeo with P3D #23

Open
co-ord opened this issue Oct 12, 2019 · 0 comments
Open

IGeo with P3D #23

co-ord opened this issue Oct 12, 2019 · 0 comments

Comments

@co-ord
Copy link

co-ord commented Oct 12, 2019

Dear @sghr ,

I would like to use some of the classes of IGeo with the P3D renderer in draw(), is that possible ?

For instance, could I turn this sketch (IG.GL with Python mode)...:

add_library('igeo')

def setup():
    size(1000,600,IG.GL)
    
    for i in xrange(25):
        MyBoid(IRand.pt(-300,-300,0,300,300,0), IRand.pt(-10,-10,-20,10,10,-20))

    curl = ICompoundField().target(MyBoid)
    attr = ICompoundField().target(MyBoid)

    for i in xrange(10):
        pt = IRand.pt(-100,-100,-800,100,100,-100)
        curl.add(IPointCurlField(pt, IVec(0,0,-1)).intensity(20))
        attr.add(IAttractor(pt).intensity(20))
  
    IGravity(0,0,-2)
        


class MyBoid(IBoidTrajectory):
    def __init__(self, p, v):
        super(MyBoid, self).__init__(p, v)
        self.alignment(0, 0)
        self.cohesion(2, 40)
        self.separation(4, 50)
        self.fric(0.01)

... into something like this (P3D with draw()):

add_library('igeo')

def setup():
    size(1000,600,P3D)
    
    global boids
    
    boids = [] #appending MyBoid object to a list
    for i in xrange(25):
        b = MyBoid(IRand.pt(-300,-300,0,300,300,0), IRand.pt(-10,-10,-20,10,10,-20))
        boids.append(b)

    curl = ICompoundField().target(boids) #???? or something equivalent
    attr = ICompoundField().target(boids) #???? or something equivalent

    for i in xrange(10):
        pt = IRand.pt(-100,-100,-800,100,100,-100)
        curl.add(IPointCurlField(pt, IVec(0,0,-1)).intensity(20))
        attr.add(IAttractor(pt).intensity(20))
  
    IGravity(0,0,-2)
    
    
    
def draw():
    background(255)
    
    for b in boids:
        b.update() #???? or something equivalent
        point(b.pos().x(), b.pos().y(), b.pos().z()) 



class MyBoid(IBoidTrajectory):
    def __init__(self, p, v):
        super(MyBoid, self).__init__(p, v)
        self.alignment(0, 0)
        self.cohesion(2, 40)
        self.separation(4, 50)
        self.fric(0.01)

Respectfully,

solub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant