找回密码
 点一下
查看: 927|回复: 0

关于helanmouse的随机地形

[复制链接]
发表于 2010-5-19 18:41:24 | 显示全部楼层 |阅读模式
随机森林,看懂了里面的T,没看懂J
貌似是创建了之后 再删除树木
原帖在这http://bbs.islga.org/read-htm-tid-21019-keyword-%CB%E6%BB%FA%CA%F7%C1%D6.html
   想知道如何实现   
因为对J是很清楚,所以想要那位高手说明一下哪个变量代表什么,里面的算法等等
代码如下,最后一段时自己摸索写的 PS: 只是学习,望得到 helanmouse 的允许
function CreateForestRoad takes integer waypoint1, integer waypoint2 returns nothing
local real d = 0
local real rad = 0
local real i = 0
local real j = 0
local real ran = 0
local location rp = null
if waypoint1 < udg_treewaypointnumber and waypoint2 <= udg_treewaypointnumber then
//创建起点
call RemoveTreesInCircle(udg_treewaypoint[waypoint1], GetRandomReal(udg_gForestWaypointRadius/2,udg_gForestWaypointRadius))
//创建终点
call RemoveTreesInCircle(udg_treewaypoint[waypoint2], GetRandomReal(udg_gForestWaypointRadius/2,udg_gForestWaypointRadius))
//创建道路
set d = DistanceBetweenPoints(udg_treewaypoint[waypoint1], udg_treewaypoint[waypoint2]) //两点间距
set rad = Atan2(GetLocationY(udg_treewaypoint[waypoint2]) - GetLocationY(udg_treewaypoint[waypoint1]), GetLocationX(udg_treewaypoint[waypoint2]) - GetLocationX(udg_treewaypoint[waypoint1]))
set ran = GetRandomInt(1,3)
loop
set j = Sin( i/d * 2 * udg_pi*ran) * udg_gForestRoadRadius * 2
set rp = LocationFromAxisXY(GetLocationX(udg_treewaypoint[waypoint1])+Cos(rad)*i, GetLocationY(udg_treewaypoint[waypoint1])+Sin(rad)*i, rad, j)
call RemoveTreesInCircle(rp, GetRandomReal(0.5,1) * udg_gForestRoadRadius)
set i = i + udg_gForestRoadStep
call RemoveLocation(rp)
exitwhen i > d
endloop
endif
endfunction

function InitTrig_SuiJiDiXingRoad takes nothing returns nothing
    set gg_trg_SuiJiDiXingRoad = CreateTrigger(  )
    call TriggerAddAction( gg_trg_SuiJiDiXingRoad, function Trig_SuiJiDiXingRoad_Actions )
endfunction


在线等
您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-11-25 17:59 , Processed in 0.047478 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表