void grPropagateDamage (ssgEntity* l, sgVec3 poc, sgVec3 force, int cnt) { //showEntityType (l); if (l->isAKindOf (ssgTypeBranch())) { ssgBranch* br = (ssgBranch*) l; for (int i = 0 ; i < br -> getNumKids () ; i++ ) { ssgEntity* ln = br->getKid (i); grPropagateDamage(ln, poc, force, cnt+1); } } if (l->isAKindOf (ssgTypeVtxTable())) { sgVec3* v; int Nv; ssgVtxTable* vt = (ssgVtxTable*) l; Nv = vt->getNumVertices(); vt->getVertexList ((void**) &v); tdble sigma = sgLengthVec3 (force); tdble invSigma = 5.0; for (int i=0; i<Nv; i++) { tdble r = sgDistanceSquaredVec3 (poc, v[i]); tdble f = exp(-r*invSigma)*5.0; v[i][0] += force[0]*f; v[i][1] += force[1]*f; // use sigma as a random number generator (!) v[i][2] += (force[2]+0.02*sin(2.0*r + 10.0*sigma))*f; //printf ("(%f %f %f)\n", v[i][0], v[i][1], v[i][2]); } } }
ssgVtxTableShadow::ssgVtxTableShadow ( GLenum ty, ssgVertexArray *vl, ssgNormalArray *nl, ssgTexCoordArray *tl, ssgColourArray *cl ) : ssgVtxTable( ty, vl, nl, tl, cl ) { type = ssgTypeVtxTable () ; factor=0; unit=0; }
ssgVtxTableCarlight::ssgVtxTableCarlight(ssgVertexArray *vtx, double s, sgVec3 p) { gltype = GL_TRIANGLE_STRIP; type = ssgTypeVtxTable(); size = s; on = 1; pos[0] = p[0]; pos[1] = p[1]; pos[2] = p[2]; vertices = (vtx!=NULL) ? vtx : new ssgVertexArray(); normals = new ssgNormalArray(); texcoords = new ssgTexCoordArray(); colours = new ssgColourArray(); vertices->ref(); normals->ref(); texcoords->ref(); colours->ref(); recalcBSphere(); }
ssgVtxTableSmoke:: ssgVtxTableSmoke (ssgVertexArray *shd_vtx , float initsize, int typ) { sizex = sizey = sizez = initsize; gltype = GL_TRIANGLE_STRIP; type = ssgTypeVtxTable () ; stype = typ; vertices = (shd_vtx!=NULL) ? shd_vtx : new ssgVertexArray () ; normals = new ssgNormalArray () ; texcoords = new ssgTexCoordArray () ; colours = new ssgColourArray () ; vertices -> ref () ; normals -> ref () ; texcoords -> ref () ; colours -> ref () ; cur_col[0] = cur_col[1] = cur_col[2] = 0.8; vvx = vvy = vvz = 0.0; init_alpha = 0.9; recalcBSphere () ; }