vegBOX

i started with the vegBOX , it should generate grass (not weed) and bushes (with weed). the bushes are done and reacting on wind and light source. but i will wait a bit (figuring out pigs or pearls).

so here a reduced version of the grass.

http://ditus.piranho.de/tests/grass.png
http://ditus.piranho.de/tests/grass.egg

'''
Created on 08.08.2009

@author: dirk hochegger
'''
import direct.directbase.DirectStart
from direct.showbase.DirectObject import DirectObject
from pandac.PandaModules import Point3,Vec3,Vec4
from pandac.PandaModules import MouseWatcher
from direct.directtools.DirectGeometry import LineNodePath 
import os,math,random,operator 

base.disableMouse()
base.setBackgroundColor(Vec4(0.0,0.0,0.0,1.0))
class grass(DirectObject):
    '''
    classdocs
    '''
    def __init__(self):
        self.speed = 2
        self.steps= 50
        self.drawGRASS()
        self.camera()
    def drawGRASS(self):
        texture = loader.loadTexture("grass.png")
        self.grassPLANE = {}
        z = 0
        color = 0
        for p in range(self.steps):
            z+=.001
            color += .02
            self.grassPLANE[p] = loader.loadModel("grass")
            self.grassPLANE[p].reparentTo(render)
            self.grassPLANE[p].setZ(z)
            self.grassPLANE[p].setBin("fixed", p)
            self.grassPLANE[p].setDepthTest(False)
            self.grassPLANE[p].setDepthWrite(False)
            self.grassPLANE[p].setScale(2,2,2)
            self.grassPLANE[p].setColor(0,color,0,1)
            self.grassPLANE[p].setTexture(texture,1)
        taskMgr.add(self.transform,"trans")
        return self.grassPLANE
    def camera(self):
        base.camera.setPos(0,-4,2)
        bas = self.grassPLANE[0].getY()- base.camera.getY()
        heigth = self.grassPLANE[0].getZ()-base.camera.getZ()
        angle = math.sin(heigth/bas)
        angle = math.degrees(angle)
        base.camera.setHpr(0,angle,0)
    def transform(self,task):
        t = self.speed*task.time
        for p in range(self.steps):
            self.grassPLANE[p].setX(p*math.sin(t)/720)
            self.grassPLANE[p].setY(p*math.cos(t)/720)
        return task.cont
     
g = grass()
run()

Very nice! But it looks a lot better if I add:

self.grassPLANE[p].setTransparency(True)

thanks pro :slight_smile: , dont you use the mesh out of my link? if you use your own geo, then you have to add what pro wrote.

but a good point, so if you dont have a alpha texture assigned to your mesh, panda doesnt do this automatical if you assigne a texture with alpha later on. so you need to “setTransperancy” …

I did use yours. Maybe it’s related to the fact that it references a texture called “…/textures/counts/zero.png” which doesn’t exist for me.

:blush: that could be right, sorry
its fixed yet.