- UID
- 33415
- 在线时间
- 0 小时
- 最后登录
- 2017-9-27
- 注册时间
- 2011-11-24
- 宅魂
- 992 点
- 贡献
- 400 点
- 宅币
- 3207 枚
- 灵石
- 0 块
- 元气(技能点)
- 39 点
- 活跃
- 0 ℃
- 听众
- 39
- 收听
- 0
该用户从未签到
技术宅认证程序员
苦逼,受剥削人民
- 积分
- 9783
|
发表于 2012-6-9 23:29:05
|
显示全部楼层
[mw_shl_code=csharp,true]static public List<Game1.TrDate> Generation(int xsum, int ysum, int w, int h)
{
VertexPositionNormalTexture[,] ves=new VertexPositionNormalTexture[ysum,xsum];
Vector3[,] pts = new Vector3[ysum+1, xsum+1];
List<Game1.TrDate> trdate = new List<Game1.TrDate>() ;
for (int y = 1; y < ysum+1; y++)
{
for (int x = 1; x < xsum+1; x++)
{
pts[y, x] = new Vector3(VeHelpers.RandomBetween(w / xsum * x, w / xsum * (x+1)), VeHelpers.RandomBetween(h / ysum * y, h / ysum * (y + 1)), 0);
}
pts[y, 0] = new Vector3(0, VeHelpers.RandomBetween(h / ysum * y, h / ysum * (y + 1)), 0);
}
for (int x = 0; x < xsum; x++)
{
pts[0, x] = new Vector3(VeHelpers.RandomBetween(w / xsum * x, w / xsum * (x + 1)), 0, 0);
}
for (int y = 0; y < ysum+1; y++)
{
for(int i=0;i<xsum+1;i++)
for (int j = 0; j < xsum; j++)
{
if(pts[y,i].X < pts[y,j].X)
{
float t = pts[y, i].X;
pts[y, i].X = pts[y, j].X;
pts[y, j].X = t;
}
}
}
[/mw_shl_code] |
|