基于Skyline的TerraExplorer6.1实现选中对象的高亮显示

如何在三维场景中实现对选中对象的高亮显示,在很久以前大家可能觉得实现起来比较麻烦,但现在在Skyline在TEPro6.1中,ITerrainObject61类增加了Tint属性,所有继承自ITerrainObject61的对象都可以通过这个属性,来实现选中状态的高亮。

具体实现过程,请参考下面代码:

 

  1  <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
  2 
  3  < html  xmlns ="http://www.w3.org/1999/xhtml" >
  4  < head >
  5      < title ></ title >
  6       < script  type  = "text/javascript"  language  = "javascript" >
  7            function  Test1() {
  8                var  SGWorld  =  CreateSGObj();
  9                var  location  =  SGWorld.Creator.CreateLocationHere();
 10                var  purl  =  toAbspath( " data/747.xpc " );
 11                var  pos  =  location.Position;
 12               pos.Yaw  =   0 ;
 13               pos.Pitch  =   0 ;
 14               pos.Roll  =   0 ;
 15                var  gid  =   0 ;
 16                var  pModel  =  SGWorld.Creator.CreateModel(pos, purl, 0 , 1 );
 17               pModel.ScaleX  =   100 ;
 18               pModel.ScaleY  =   100 ;
 19               pModel.ScaleZ  =   100 ;
 20               pModel.TreeItem.Name  =   " 模型 " ;
 21               SGWorld.Creator.DeleteObject(location.ID);
 22           }
 23 
 24            function  Test2() {
 25                var  SGWorld  =  CreateSGObj();
 26                var  ItemID  =  SGWorld.ProjectTree.FindItem( " 模型 " );
 27                if  (ItemID  >   0 ) {
 28                    var  obj  =  SGWorld.ProjectTree.GetObject(ItemID);
 29                   obj.Terrain.Tint.abgrColor  =   0x0000ff ;
 30                   obj.Terrain.Tint.SetAlpha( 0.8 );                
 31               }
 32           }
 33            function  Test3() {
 34                var  SGWorld  =  CreateSGObj();
 35                var  ItemID  =  SGWorld.ProjectTree.FindItem( " 模型 " );
 36                if  (ItemID  >   0 ) {
 37                    var  obj  =  SGWorld.ProjectTree.GetObject(ItemID);
 38                   obj.Terrain.Tint.abgrColor  =   0x0000ff ;
 39                   obj.Terrain.Tint.SetAlpha( 0 );
 40               }
 41           }
 42 
 43            /*   
 44           功能:   创建sgworld对象
 45           备注:   赵贺 2011.04.01.
 46            */
 47 
 48            function  CreateSGObj() {
 49                var  obj  =  $( " sgworld " );
 50                if  (obj  ==   null ) {
 51                   obj  =  document.createElement( ' object ' );
 52                   document.body.appendChild(obj);
 53                   obj.name  =   " sgworld " ;
 54                   obj.id  =   " sgworld " ;
 55                   obj.classid  =   " CLSID:3a4f91b1-65a8-11d5-85c1-0001023952c1 " ;
 56               }
 57                return  obj;
 58           }
 59            function  $(id) {
 60                return  window.document.getElementById(id);
 61           }
 62 
 63            function  toAbspath(src) {
 64                var  abspath  =   function  () {
 65                    var  abspath  =   "" ;
 66                    try  {
 67                       abspath  =  unescape(window.location.href);
 68                   }
 69                    catch  (e) {
 70                       abspath  =  unescape( this .__location);
 71                   }
 72                    //  Remove query String 
 73                    var  index  =  abspath.indexOf( " ? " );
 74                    if  (index  >   0 ) abspath  =  abspath.substr( 0 , index  -   1 );
 75 
 76                   index  =  abspath.lastIndexOf( " / " );
 77                    var  index2  =  abspath.lastIndexOf( " \\ " );
 78 
 79                   index  =  (index  >  index2)  ?  index : index2;
 80                    if  (index  <=   0 return  abspath;
 81 
 82                   abspath  =  abspath.substring( 0 , index);
 83 
 84                    if  (abspath.substring( 0 1 ==   " / " ) abspath  =  abspath.slice( 1 );
 85 
 86                    var  re  =   / file:\/\/\/ / gi;
 87                    if  (abspath.match(re)  !=   null ) abspath  =  abspath.replace(re,  "" );  //  if this is indeed a local file, we strip the "file://" prefix from it.    
 88 
 89                    return  (abspath);
 90 
 91               }
 92 
 93                var  re  =   / ^http:\/\/|^ftp:\/\/|^file:\/\/|^https:\/\/ / gi;
 94                if  (src.match(re)  ==   null ) {
 95                    if  (src.indexOf( " [TE Application Data] " !=   0 )
 96                        return  abspath()  +   ' / '   +  src;
 97               }
 98                else  {
 99                    //  if this is indeed a local file, we strip the "file://" prefix from it.    
100                   re  =   / file:\/\/\/ / gi;
101                    if  (src.match(re)  !=   null )
102                       src  =  src.replace(re,  "" );
103                    else  {
104                       re  =   / file:\/\/ / gi;
105                        if  (src.match(re)  !=   null ) src  =  src.replace(re,  "" );
106                   }
107               }
108 
109                return  src;
110 
111           }
112           </ script >
113  </ head >
114  < body >
115  < table  style ="margin: 0px; border: 0px;" >
116          < tr >
117              < td  colspan  = "4" >
118                  < input  id ="Button1"  type ="button"  value ="创建模型"  onclick ="Test1()"   />
119                  < input  id ="Button2"  type ="button"  value ="选择模型"  onclick ="Test2()"   />
120                  < input  id ="Button3"  type ="button"  value ="选择模型"  onclick ="Test3()"   />
121              </ td >
122          </ tr >
123          < tr >
124              < td  colspan  = "4" >
125               <!--  <object id="TerraExplorerInformationWindow" style="height: 550px; width:280px;" classid="CLSID:3a4f9193-65a8-11d5-85c1-0001023952c1">
126                  </object> -->
127              </ td >
128          </ tr >
129      </ table >
130  </ body >
131  </ html >

 

转载于:https://www.cnblogs.com/yitianhe/archive/2012/09/07/2675405.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值