<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    悟心

    成功不是將來才有的,而是從決定去做的那一刻起,持續(xù)累積而成。 上人生的旅途罷。前途很遠,也很暗。然而不要怕。不怕的人的面前才有路。

      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      93 隨筆 :: 1 文章 :: 103 評論 :: 0 Trackbacks
      1 ------------ 變量申明 --------------------------
      2 property mySphere  --代理球
      3 property mySprite  --當前精靈
      4 property pCam   --攝像機1
      5 property pCam2  --攝像機2
      6 property scene  --場景
      7 property pSphere --球體
      8 property ground  --地面
      9 
     10 property wall  --墻壁
     11 property wall01  --墻壁1
     12 property wall02  --墻壁2
     13 property wall03  --墻壁3
     14 property wall04  --墻壁4
     15 
     16 property stair  --樓梯
     17 
     18 -------------方法、事件----------------------
     19 on beginSprite me
     20   
     21   scene = member("3d")  --設置 場景=3d 成員 
     22   scene.resetWorld()   --重置
     23   mySprite = sprite(me.spriteNum)  --設置精靈
     24   put mySprite
     25   pSphere = scene.newModelResource( "pSphere",#sphere )  --創(chuàng)建 圓球
     26   pSphere.radius = 50  --設置 圓球 半徑
     27   
     28   mySphere = scene.newModel( "pSphere",pSphere )  --將 圓球 加到 3D場景 中
     29   mySphere.translate(0,-1500,50)  --設置 球 的位置
     30   --mySp.rotate(10,0,0)
     31   
     32   --創(chuàng)建 地面,并且設置 屬性
     33   ground = scene.newModelResource("ground",#plane)
     34   ground.length = 5000
     35   ground.width = 5000
     36   ground.widthVertices = 10
     37   ground.lengthVertices = 10
     38   
     39   scene.newModel("ground",ground)  --加到 3D場景中
     40   --設置 地面 的貼圖 的比例
     41   scene.shader("defaultShader").textureTransform.scale(0.1,0.1,1)
     42   
     43   --創(chuàng)建 四面墻體
     44   wall = scene.newModelResource( "wall",#plane,#front )
     45   wall.length = 200
     46   wall.width = 5000
     47   
     48   --添加到 3D場景 中
     49   wall01 = scene.newModel("wall01",wall)
     50   wall02 = scene.newModel("wall02",wall)
     51   wall03 = scene.newModel("wall03",wall)
     52   wall04 = scene.newModel("wall04",wall)
     53   
     54   --設置4面墻的位置
     55   wall01.translate(0,-2500,100,#world)
     56   wall01.rotate(90,0,0)
     57   
     58   wall02.translate(0,2500,100,#world)
     59   wall02.rotate(-90,0,0)
     60   
     61   wall03.translate(2500,0,100,#world)
     62   wall03.rotate(90,0,90)
     63   
     64   wall04.translate(-2500,0,100,#world)
     65   wall04.rotate(90,0,-90)
     66   
     67   --創(chuàng)建樓梯
     68   stair = scene.newModelResource("stair",#box)
     69   stair.height = 60
     70   stair.width = 300
     71   stair.length = 30
     72   
     73   scene.newModel("stair",stair)
     74   scene.model("stair").translate(0,0,0)
     75   
     76   --循環(huán),輸出每一節(jié)樓梯
     77   repeat with i=1 to 20
     78     stairI=scene.newModel( "b0"&string(i),stair )
     79     stairI.translate(0,60*i,30*i)
     80   end repeat
     81   
     82   --創(chuàng)建攝像機1
     83   pCam = scene.newCamera("cam01")
     84   pCam.transform.position = mySphere.transform.position
     85   pCam.rotate(90,0,0)
     86   pCam.translate(0,50,0)
     87   
     88   --攝像機2
     89   pCam2= scene.newCamera("cam02")
     90   pCam2.transform.position = mySphere.transform.position
     91   pCam2.translate(0,-2000,2000)
     92   pCam2.rotate(45,0,0)
     93   
     94   mySprite.camera=pCam  --設置當前默認相機
     95   --mySprite.camera=pCam2
     96   
     97   --將相機綁定到 球體 中
     98   mySphere.addChild(pCam)
     99   mySphere.addChild(pCam2)
    100   
    101   --創(chuàng)建燈光
    102   lightx = scene.newLight("lightx",#point)
    103   
    104   lightx.translate(2000,1500,1000)
    105   mySphere.translate(0,0,50)   --設置球的位置
    106   
    107 end beginSprite
    108 -------------------------------------------------------------------
    109 on exitFrame me
    110   --簡單重力
    111   mySphere.translate(0,0,-50)
    112   
    113   myKeyPressed  --調用鍵盤按下事件
    114   
    115   ---模擬碰撞測試程序------
    116   -- modelsUnderRay 函數將返回關于射線經過模型的一些數據。
    117   --碰撞處理程序將對這些數據進行分析。
    118   
    119   --以 負z 為中心軸
    120   tList = scene.modelsUnderRay( mySphere.worldPosition,-mySphere.transform.zAxis,#detailed )
    121   if tList.count then
    122     me.checkGroundCollsision(tList[1])  --檢查對 地面 碰撞
    123   end if
    124   
    125   --以 正z 為中心軸
    126   tList = scene.modelsUnderRay( mySphere.worldPosition,mySphere.transform.zAxis,#detailed )
    127   if (tList.countthen
    128     me.checkForCollision(tList[1])
    129   end if   
    130   
    131   --以 正y 為中心軸 
    132   tList = scene.modelsUnderRay( mySphere.worldPosition,mySphere.transform.yAxis,#detailed )
    133   if tList.count then
    134     me.checkForCollision(tList[1])
    135   end if
    136   
    137   --以 負y 為中心軸
    138   tList = scene.modelsUnderRay( mySphere.worldPosition,-mySphere.transform.yAxis,#detailed )
    139   if tList.count then
    140     me.checkForCollision(tList[1])
    141   end if
    142   
    143   --以 正x 為中心軸
    144   tList = scene.modelsUnderRay( mySphere.worldPosition,mySphere.transform.xAxis,#detailed )  
    145   if (tList.countthen
    146     me.checkForCollision(tList[1])
    147   end if  
    148   
    149   --以 負x為 中心軸
    150   tList = scene.modelsUnderRay( mySphere.worldPosition,-mySphere.transform.xAxis,#detailed )  
    151   if (tList.countthen
    152     me.checkForCollision(tList[1])
    153   end if 
    154   
    155   go the frame
    156 end exitFrame
    157 
    158 -- 發(fā)生 與 墻壁、樓梯 碰撞  處理方法 
    159 on checkForCollision (me,thisData)
    160   
    161   thisDistance = thisData.distance  --距離、間距
    162   
    163   mySphereRadius = mySphere.resource.radius+5  --圓球半徑+5
    164   
    165   --如果當前 距離 小于 球體的半徑+25
    166   if thisDistance < mySphereRadius then
    167     
    168     tVector = thisData.isectNormal * (mySphereRadius-thisDistance)
    169     
    170     mySphere.translate(tVector,#world)  --移動 圓球
    171   end if
    172 end checkForCllision
    173 
    174 --與 地面 碰撞處理,防止“下沉”
    175 on checkGroundCollsision(me,thisData)
    176   
    177   thisDistance = thisData.distance
    178   mySphereRadius = mySphere.resource.radius+70
    179   
    180   if thisDistance < mySphereRadius then
    181     tVector = thisData.isectNormal * ( mySphereRadius-thisDistance )
    182     mySphere.translate( tVector,#world )
    183   end if
    184   
    185 end checkGroundCollsision
    186 
    187 --------鍵盤按下事件--------------
    188 on myKeyPressed 
    189   if keyPressed(126or keyPressed("w") then  --top 前進
    190     mySphere.translate(0,20,0)  --移動
    191   end if
    192   
    193   if keyPressed(125or keyPressed("s") then  --botton 后退
    194     mySphere.translate(0,-20,0)  --移動
    195   end if
    196   
    197   if keyPressed("a") then  --
    198     mySphere.translate(-10,0,0)  --移動
    199   end if
    200   
    201   if keyPressed("d") then  --
    202     mySphere.translate(10,0,0)  --移動
    203   end if
    204   
    205   if keyPressed(123then  --left
    206     mySphere.rotate(0,0,2)  --旋轉
    207   end if
    208   
    209   if keyPressed(124then
    210     mySphere.rotate(0,0,-2)  --旋轉
    211   end if
    212   
    213   if keyPressed("1") then
    214     mySprite.camera = pCam  --如果是按1,切換到1號視角
    215   end if
    216   
    217   if keyPressed("2") then
    218     mySprite.camera = pCam2  --切換2號視角
    219   end if
    220 end myKeyPressed
    221 
    posted on 2009-11-27 12:30 艾波 閱讀(351) 評論(0)  編輯  收藏 所屬分類: Other
    主站蜘蛛池模板: 免费无码不卡视频在线观看| 国内精品免费视频精选在线观看| 麻豆视频免费播放| 97亚洲熟妇自偷自拍另类图片| 久久精品免费大片国产大片| 亚洲精品国产高清嫩草影院| 免费无码国产在线观国内自拍中文字幕| 免费无码又爽又刺激高潮 | 中文字幕不卡高清免费| 久久精品国产亚洲5555| 99久久免费国产精品热| 亚洲爆乳无码一区二区三区| 无码精品一区二区三区免费视频| 亚洲综合在线观看视频| AA免费观看的1000部电影| 亚洲人成色在线观看| 国产一级高清免费观看| 一级毛片免费播放男男| 亚洲AV中文无码乱人伦下载| 99在线免费观看视频| 亚洲香蕉久久一区二区三区四区| 成人最新午夜免费视频| 国产亚洲精品美女2020久久| 久久久久亚洲AV成人网人人软件| 国色精品va在线观看免费视频| 老色鬼久久亚洲AV综合| 国产精品无码免费播放| 黄页网址在线免费观看| 亚洲人成网7777777国产| 久久成人国产精品免费软件| 亚洲人片在线观看天堂无码| 亚洲成年人啊啊aa在线观看| 免费精品99久久国产综合精品| 亚洲一区二区三区无码国产| 全部免费毛片在线| 性xxxx视频免费播放直播| 亚洲成AV人影片在线观看| 亚洲VA中文字幕不卡无码| 成人啪精品视频免费网站| 中国一级毛片免费看视频| 亚洲一区无码中文字幕乱码|