iGeo icon indicating copy to clipboard operation
iGeo copied to clipboard

IGeo with P3D

Open co-ord opened this issue 4 years ago • 0 comments

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

co-ord avatar Oct 12 '19 11:10 co-ord