// Constructors & Destructors Butter::Butter(double x, double y, double z, float width, float height) { _width = width; _height = height; $setDrag(DRAG); setAABB(width/2, -width/2, height/2, -height/2); setPosition(x, y, z); }
// Constructors & Destructors Orange::Orange() { // Start managing this orange _id = ID_GENERATOR++; _orangeMap[_id] = this; setAABB(2, -2, 2, -2); $setDeadly(true); // Start with a random movement speed _incrementSpeed(); // Wait for a random time before spawning _die(); }
attacker::attacker(Floekr2T::trace& trace, int velocity, int HP, Floekr2T::animation& animation) :trace(trace), velocity(velocity), HP(HP), animation(animation) { currentPoint = 0; live = true; //起始位置为路径起始点 position = trace.getStartup(); ////默认宽高为第一张起始帧动画宽高 //width = animation.pictures[0].width; //height = animation.pictures[0].height; ////默认AABB //aabb.min = position; //aabb.max.x = position.x + width; //aabb.max.y = position.y + height; //默认没有偏移 setAABB(0, 0, animation.width, animation.height); }
// Constructors & Destructors Cheerio::Cheerio(double x, double y, double z) { setAABB(0.05, -0.05, 0.05, -0.05); $setDrag(DRAG); setPosition(x, y, z); }
// The patch segment is an array of points that will be used as a canopy patch at the end of a branch or where // a canopy is defined. To create the patch we need to know what the drop angle will be. This is calculated based on the established // grammar drop angle along with the fulcrum calculation for the tree. The patch will not be flat but will be perturbed from the plane in // a random way based on a given weight factor for perturbation. void Canopy::growPatchSegment(treeNode *rootOfTree, BranchBase *pCanopyBranch,aabb TreeBoundingBox, LevelDetail *grammar, V3 startHeading) { theOverseer = observer::Instance(); //int cwidth =9; //int cheight =9; //float m_widthStep =1; //float m_heightStep =1.25; rootOfTree->tree->m_CanopyCount++; V3 root(rootOfTree->pbranch->segments[0].m_tipPointList[0]); V3 CanopySegmentRoot(pCanopyBranch->tipPoint);// canopySegmentRoot V3 CanopyTop(root); CanopyTop.y = root.y + TreeBoundingBox.yMax; V3 CanopyFulcrum(CanopyTop); CanopyFulcrum.y = CanopyFulcrum.y * 0.57f; // 4/7 if(pCanopyBranch->tipPoint.y < CanopyFulcrum.y){ CanopyFulcrum.y = pCanopyBranch->tipPoint.y * 0.714f;// 5/7 } V3 CanopyHeading = CanopySegmentRoot-CanopyFulcrum; CanopyHeading.Normalize(); V3 CanopyArbitrary(CanopySegmentRoot-root); CanopyArbitrary.Normalize(); V3 Left = CrossProduct(CanopyArbitrary,CanopyHeading); V3 Right = CrossProduct(CanopyHeading,CanopyArbitrary); Left.Normalize(); Right.Normalize(); V3 Down = CrossProduct(Left,CanopyHeading); V3 Up = CrossProduct(CanopyHeading,Left); float perturbFactor = grammar->perturbFactor; V3 perturb = CanopyHeading; Down.Normalize(); Up.Normalize(); Basis.iAxis = Right * (((float)m_width)/2) * m_widthStep; Basis.jAxis = CanopyHeading; Basis.kAxis = Down * (((float)m_height)/2) * m_heightStep; int shift = -((int)floor(m_width/2.0f)); float nudge =0.0f; for(int j=0;j<m_height;j++){ for(int i=0;i<m_width;i++){ nudge = theOverseer->randf(-(perturbFactor),(perturbFactor)); perturb = perturb * nudge; V3 tcb = pCanopyBranch->tipPoint + ((i+shift)*m_widthStep)* Left + (j*m_heightStep)*Down; V3 *cb; if(!(j==0&&i==(m_width/2))){ tcb = tcb + perturb; cb = new V3(tcb); }else{ cb = new V3(tcb); } m_Canopy.push_back(cb); perturb = CanopyHeading; } } theOverseer = observer::Instance(); m_startIndex = theOverseer->DXRS->CurrentIndex; m_startVertex = theOverseer->DXRS->CurrentVIndex; m_AABB = setAABB(); theOverseer->DXRS->CurrentIndex = theOverseer->DXRS->CurrentIndex + ((m_height-1)*(m_width-1)*12); // 6 per quad per side = 12 theOverseer->DXRS->CurrentVIndex = theOverseer->DXRS->CurrentVIndex + ( m_height*m_width*2); // two sides = 2 m_burning = false; }
// Constructors & Destructors Car::Car(double x, double y, double z, SpotLight* pLeftHeadlight, SpotLight* pRightHeadlight) : _pLeftHeadlight(pLeftHeadlight), _pRightHeadlight(pRightHeadlight) { setAABB(0.6, -0.6, 0.6, -0.6); setPosition(x, y, z); }