首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 編程語言 >  >> Java 程式設計 >> Java 相關知識

X3D 實戰基礎講座(三):2D 幾何體、點、線與座標系統

     編輯:Java 相關知識

X3D 場景基於右手座標系 (X 右、Y 上、Z 指向用戶)。本講介紹 PointSet (點集)、IndexedLineSet (線集)、Rectangle2D (矩形)、Arc2D/Circle2D/Disk2D (弧/圓/環) 等 2D 幾何節點,及 Color/Coordinate 輔助節點用法。

座標系統與單位

  • 右手座標系,邏輯單位 (可視為 mm)
  • 座標分量用空格或逗號分隔
  • Coordinate 節點 point 字段定義頂點列表
  • Color 節點 color 字段定義顏色列表 (RGB 0-1)

PointSet:點雲渲染

PointSet代碼

Coordinate編輯對話框

四點效果

單獨指定點顏色

刪除 Appearance,在 PointSet 下添加 Color 子節點,color 長度與 point 一致。

Color節點代碼

多彩點效果

IndexedLineSet:線段集合

coordIndex:每三個數定義一線段 (起點索引、終點索引、-1 結束)。

IndexedLineSet代碼

coordIndex內容

線段效果

指定線段顏色

添加 Color 節點,colorIndex 對應 coordIndex 結構 (起點色索引、終點色索引、-1)。

帶顏色線段代碼

彩色線段效果

Rectangle2D:平面矩形

size:寬 高 (默認 2 2)。

Rectangle2D代碼

矩形效果

弧線與圓環族

  • Arc2D:圓弧,radius、startAngle/endAngle
  • ArcClose2D:封閉圓弧 (含弦)
  • Circle2D:圓周線
  • Disk2D:實心圓盤

示例代碼與效果

Arc2D代碼

Arc2D效果

ArcClose2D代碼

Circle2D代碼

Circle2D效果

Disk2D代碼

Disk2D效果

綜合效果

總結

2D 幾何體構建於 XY 平面 (Z=0),配合 Transform 可放置於 3D 空間任意位置/朝向。Coordinate/Color 分離數據與外觀,IndexedLineSet 通過索引高效定義拓撲。下一講將進入 3D 基本幾何體創建。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved