コード例 #1
0
ファイル: Building.cpp プロジェクト: HEShuang/BuildUP
Surface* Building::extrude_lod3(double hFloor, double lenHasWin, double lenUnit) const
{
    Surface* bldg = extrude_envelope();
    for(int i=0;i<bldg->getNumChildren();++i)
    {
        if(bldg->getChild(i)->getType()==SurfaceType::Wall)
        {
            Wall* wall = (Wall*)(bldg->getChild(i));
            wall->splitFloor(hFloor);
            double lWall = wall->getLength();
            if(lWall>lenHasWin || std::abs(lWall-lenHasWin)<0.001)
            {
                for(int j=0;j<wall->getNumChildren();++j)
                {
                    Floor* floor = (Floor*)(wall->getChild(j));
                    floor->splitUnit(lenUnit);
                    for(int k=0;k<floor->getNumChildren();++k)
                    {
                        Unit* unit = (Unit*)(floor->getChild(k));
                        if(j==0 && k%5 == 0 && unit->getLength()>3)
                        {
                            unit->insertDoor(unit->getLength()/3,unit->getHeight()*2/3);
                            continue;
                        }

                        if(unit->getLength()>1)
                            unit->insertWindow(unit->getLength()/3,unit->getHeight()/3);
                    }
                }
            }

        }
    }
    return bldg;
}
コード例 #2
0
ファイル: bomberman.cpp プロジェクト: maryamhashemi/bomberman
bool Bomberman::collision(Wall wall)
{
        if(y + width <= wall.getY())
                return 0;
        if(x + length <= wall.getX())
                return 0;
        if(y >= wall.getY() + wall.getWidth())
                return 0;
        if(x >= wall.getX() + wall.getLength())
                return 0;
        return 1;   
}
コード例 #3
0
bool collisionCarWall(Car& car, Wall& wall, glm::mat4 carMatrix) {
    //can't collide if they are too far apart
    if (!collisionCircleCircle(car.getCenter(), carRadius, wall.getCenter(), wall.getLength()/2 + 1)) { //not very wide, and too lazy to do more percise math
        return false;
    }
    
    glm::mat4 wallMatrix = wall.getMatrix();
    
    glm::vec4 carUR = carMatrix * glm::vec4(0.5,1.0,0.0,1.0);
    glm::vec4 carLR = carMatrix * glm::vec4(0.5,-1.0,0.0,1.0);
    glm::vec4 carLL = carMatrix * glm::vec4(-0.5,-1.0,0.0,1.0);
    glm::vec4 carUL = carMatrix * glm::vec4(-0.5,1.0,0.0,1.0);
    
    glm::vec4 wallUR = wallMatrix * glm::vec4(1.0,0.2,0.0,1.0);
    glm::vec4 wallLR = wallMatrix * glm::vec4(1.0,-0.2,0.0,1.0);
    glm::vec4 wallLL = wallMatrix * glm::vec4(-1.0,-0.2,0.0,1.0);
    glm::vec4 wallUL = wallMatrix * glm::vec4(-1.0,0.2,0.0,1.0);
    
    return collisionRectSAT(carUR, carLR, carLL, carUL,
       wallUR, wallLR, wallLL, wallUL);

}