void ParticleSystem::Load( const std::string & texpath, const std::string & texname, int anisotropy, ContentManager & content) { TextureInfo texinfo; texinfo.anisotropy = anisotropy; content.load(texture, texpath, texname, texinfo); draw = GetDrawlist(node).insert(Drawable()); Drawable & drawref = GetDrawlist(node).get(draw); drawref.SetDrawEnable(false); drawref.SetVertArray(&varrays[cur_varray]); drawref.SetTextures(texture->GetID()); drawref.SetCull(false, false); }
void ParticleSystem::SyncGraphics() { if (max_particles == 0) return; Drawable & drawref = GetDrawlist(node).get(draw); drawref.SetVertArray(&varrays[cur_varray]); drawref.SetDrawEnable(varrays[cur_varray].GetNumFaces()); cur_varray = (cur_varray + 1) % 2; }
void CAR::UpdateGraphics() { if (!bodynode.valid()) return; assert(dynamics.GetNumBodies() == topnode.Nodes()); unsigned int i = 0; keyed_container<SCENENODE> & childlist = topnode.GetNodelist(); for (keyed_container<SCENENODE>::iterator ni = childlist.begin(); ni != childlist.end(); ++ni, ++i) { MATHVECTOR<float, 3> pos = ToMathVector<float>(dynamics.GetPosition(i)); QUATERNION<float> rot = ToMathQuaternion<float>(dynamics.GetOrientation(i)); ni->GetTransform().SetTranslation(pos); ni->GetTransform().SetRotation(rot); } // brake/reverse lights SCENENODE & bodynoderef = topnode.GetNode(bodynode); for (std::list<LIGHT>::iterator i = lights.begin(); i != lights.end(); i++) { SCENENODE & node = bodynoderef.GetNode(i->node); DRAWABLE & draw = GetDrawlist(node, OMNI).get(i->draw); draw.SetDrawEnable(applied_brakes > 0); } if (brakelights.valid()) { GetDrawlist(bodynoderef, EMISSIVE).get(brakelights).SetDrawEnable(applied_brakes > 0); } if (reverselights.valid()) { GetDrawlist(bodynoderef, EMISSIVE).get(reverselights).SetDrawEnable(GetGear() < 0); } // steering if (steernode.valid()) { SCENENODE & steernoderef = bodynoderef.GetNode(steernode); steernoderef.GetTransform().SetRotation(steer_rotation); } }
bool CAR::LoadLight( const PTree & cfg, ContentManager & content, std::ostream & error_output) { float radius; std::string radiusstr; MATHVECTOR<float, 3> pos(0), col(0); if (!cfg.get("position", pos, error_output)) return false; if (!cfg.get("color", col, error_output)) return false; if (!cfg.get("radius", radius, error_output)) return false; cfg.get("radius", radiusstr); lights.push_back(LIGHT()); SCENENODE & bodynoderef = topnode.GetNode(bodynode); lights.back().node = bodynoderef.AddNode(); SCENENODE & node = bodynoderef.GetNode(lights.back().node); node.GetTransform().SetTranslation(MATHVECTOR<float,3>(pos[0], pos[1], pos[2])); std::tr1::shared_ptr<MODEL> mesh; if (!content.get("", "cube"+radiusstr, mesh)) { VERTEXARRAY varray; varray.SetToUnitCube(); varray.Scale(radius, radius, radius); content.load("", "cube"+radiusstr, varray, mesh); } models.push_back(mesh); keyed_container <DRAWABLE> & dlist = GetDrawlist(node, OMNI); lights.back().draw = dlist.insert(DRAWABLE()); DRAWABLE & draw = dlist.get(lights.back().draw); draw.SetColor(col[0], col[1], col[2]); draw.SetModel(*mesh); draw.SetCull(true, true); draw.SetDrawEnable(false); return true; }