Пример #1
0
 public void makeEllipse(float ixradius, float iyradius, float imass)
 {
     if (geomType != GEOMTYPE.multigeom) geomType = GEOMTYPE.ellipse;
        OBJ_DESC obj = new OBJ_DESC(p);
        if (objDesc.Count != 0 && geomType == GEOMTYPE.multigeom) { obj.globalGeomType = GEOMTYPE.multigeom; obj.body = objDesc[0].body; }
        obj.makeEllipse(ixradius, iyradius, imass);
        objDesc.Add(obj);
 }
Пример #2
0
        public bool makeVerts(string texname, Vector2 wh)
        {
            if (geomType != GEOMTYPE.multigeom) geomType = GEOMTYPE.verts;

               Texture2D tex = p.Content.Load<Texture2D>("textures/" + texname);
               if (tex == null) return false;
               uint[] data = new uint[tex.Width * tex.Height];
               tex.GetData(data);
               mapCreator map = new mapCreator();
               List<Vertices> vertsList = map.getMap(data, tex.Width, tex.Height);
               if (vertsList.Count == 0) return true;

               for (int i = 0; i < vertsList.Count; ++i)
               {
            OBJ_DESC obj = new OBJ_DESC(p);
            obj.makeVerts(wh, tex);

            obj.verts = new Vertices();
            for (int j = 0; j < vertsList[i].Count; ++j)
            {
             vertsList[i][j] *= new Vector2(wh.X / (float)mesh.tex.Width, -wh.Y / (float)mesh.tex.Height);
             vertsList[i][j] -= new Vector2(wh.X / 2, -wh.Y / 2);

             obj.verts.Add(vertsList[i][j]);
            }
            obj.verts.Add(obj.verts[0]);

            Vector2 centroid = vertsList[i].GetCentroid();

            //obj.body = BodyFactory.Instance.CreatePolygonBody(p.ps, vertsList[i], OBJ_DESC.tonn);
            if (objDesc.Count != 0 && geomType == GEOMTYPE.multigeom) { obj.globalGeomType = GEOMTYPE.multigeom; obj.body = objDesc[0].body; }
            else obj.body = BodyFactory.Instance.CreatePolygonBody(p.ps, vertsList[i], OBJ_DESC.tonn);

            obj.body.IsStatic = true;
            obj.geom = GeomFactory.Instance.CreatePolygonGeom(p.ps, obj.body, vertsList[i], centroid, 0, 0.5f);
            obj.body.Position = Vector2.Zero;

            objDesc.Add(obj);
               }

               return false;
        }
Пример #3
0
 public void makeBox(float iwidth, float iheight, float imass)
 {
     if (geomType != GEOMTYPE.multigeom) geomType = GEOMTYPE.box;
        OBJ_DESC obj = new OBJ_DESC(p);
        if (objDesc.Count != 0 && geomType == GEOMTYPE.multigeom) { obj.globalGeomType = GEOMTYPE.multigeom; obj.body = objDesc[0].body; }
        obj.makeBox(iwidth, iheight, imass);
        objDesc.Add(obj);
 }