zoukankan      html  css  js  c++  java
  • 基于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 <= 0return abspath;
     81 
     82                  abspath = abspath.substring(0, index);
     83 
     84                  if (abspath.substring(01== "/") 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; 280px;" classid="CLSID:3a4f9193-65a8-11d5-85c1-0001023952c1">
    126                 </object>-->
    127             </td>
    128         </tr>
    129     </table>
    130 </body>
    131 </html>
  • 相关阅读:
    ExtJS小技巧
    Oracle 表的行数、表占用空间大小,列的非空行数、列占用空间大小 查询
    NPM 私服
    IDEA 不编译java以外的文件
    SQL 引号中的问号在PrepareStatement 中不被看作是占位符
    Chrome 浏览器自动填表呈现淡黄色解决
    批量删除Maven 仓库未下载成功.lastupdate 的文件
    Oracle 11g 监听很慢,由于监听日志文件太大引起的问题(Windows 下)
    Hibernate 自动更新表出错 建表或添加列,提示标识符无效
    Hibernate 自动更新表出错 More than one table found in namespace
  • 原文地址:https://www.cnblogs.com/yitianhe/p/2675405.html
Copyright © 2011-2022 走看看