STK Components 二次开发-地面站传感器

上一篇我们说了创建地面站,那么这次我们在地面站添加一些特效。

  1. 创建地面站
cs 复制代码
var locationPoint1 = new PointCartographic(m_earth, new Cartographic(Trig.DegreesToRadians(117.17066), Trig.DegreesToRadians(31.84056), 240.359));
m_facility = new Platform
{
	Name = "DMZ",
	LocationPoint = locationPoint1,
	// Orient the facility using East-North-Up (ENU) axes.
	OrientationAxes = new AxesEastNorthUp(m_earth, locationPoint1),
};

// Set the identifier for the facility in the CZML document. 
m_facility.Extensions.Add(new IdentifierExtension("DSS"));

// Configure a glTF model for the facility.
m_facility.Extensions.Add(new ModelGraphicsExtension(new ModelGraphics
{
	// Link to a binary glTF file.
	Model = new CesiumResource(GetModelUri("facility.glb"), CesiumResourceBehavior.LinkTo),
	RunAnimations = false,
	HeightReference = CesiumHeightReference.ClampToGround,
}));

// Configure label for AGI HQ.
m_facility.Extensions.Add(new LabelGraphicsExtension(new LabelGraphics
{
	Text = m_facility.Name,
	FillColor = Color.White,
	Font = new ConstantCesiumProperty<string>("20px"),
	// Only show label when camera is far enough from the satellite,
	// to avoid visually clashing with the model.
	DistanceDisplayCondition = new Bounds(1000.0, double.MaxValue),
	HeightReference = CesiumHeightReference.ClampToGround,
}));

2.创建传感器

cs 复制代码
// Define the location of the facility using cartographic coordinates.
var locationPoint = new PointCartographic(m_earth, new Cartographic(Trig.DegreesToRadians(117.17066), Trig.DegreesToRadians(31.84056), 272.359));

m_sensorDome = new Platform
{
	Name = "Sensor Dome",
	LocationPoint = locationPoint,
	OrientationAxes = new AxesEastNorthUp(m_earth, locationPoint),
};

// Set the identifier for the facility in the CZML document. 
m_sensorDome.Extensions.Add(new IdentifierExtension("SensorDome"));

// Define the sensor geometry.
var dome = new ComplexConic();
dome.SetHalfAngles(0.0, Math.PI);
dome.SetClockAngles(0.0, Math.PI * 2);
dome.Radius = 10000.0;
m_sensorDome.Extensions.Add(new FieldOfViewExtension(dome));

// Configure graphical display of the sensor dome.
m_sensorDome.Extensions.Add(new FieldOfViewGraphicsExtension(new SensorFieldOfViewGraphics
{
	//遮罩线颜色
	DomeSurfaceMaterial = new GridMaterialGraphics
	{
		Color = Color.Transparent,
		CellAlpha = 0.0,
	},

	EllipsoidHorizonSurfaceMaterial = new SolidColorMaterialGraphics
	{
		Color = Color.YellowGreen,
	},
	//贴地透明色
	EllipsoidSurfaceMaterial = new SolidColorMaterialGraphics
	{
		Color = Color.Transparent,
	},
	EnvironmentIntersectionColor = new ConstantCesiumProperty<Color>(Color.Red),

	EnvironmentOcclusionMaterial = new SolidColorMaterialGraphics
	{
		Color = Color.Green,
	},
	IntersectionColor = new ConstantCesiumProperty<Color>(Color.Transparent),//贴地轮廓
	LateralSurfaceMaterial = new SolidColorMaterialGraphics
	{
		Color =  Color.Red,
	},

   

	EnvironmentConstraint =true,
	ViewshedOccludedColor = new ConstantCesiumProperty<Color>(Color.Red),
	ViewshedVisibleColor = new ConstantCesiumProperty<Color>(Color.Red)
}));

// Define a rotating axes.
var rotatingAxes = new AxesLinearRate
{
	ReferenceAxes = new AxesEastNorthUp(m_earth, locationPoint),
	ReferenceEpoch = m_epoch,
	InitialRotation = UnitQuaternion.Identity,
	SpinAxis = UnitCartesian.UnitZ,
	InitialRotationalVelocity = Trig.DegreesToRadians(5.0), // 5 degrees per second
	RotationalAcceleration = 0.0,
};

// Define a rotation around X.
UnitQuaternion quaternion = new UnitQuaternion(new AngleAxisRotation(Math.PI / 3.0, UnitCartesian.UnitX));
// Define an angular offset for the rotating axes.
var rotatedOffsetAxes = new AxesFixedOffset(rotatingAxes, quaternion);

m_rotatingSensor = new Platform
{
	Name = "Rotating Sensor",
	LocationPoint = locationPoint,
	OrientationAxes = rotatedOffsetAxes
};

// Set the identifier for the sensor in the CZML document. 
m_rotatingSensor.Extensions.Add(new IdentifierExtension("RotatingSensor"));

// Define the sensor geometry.
m_rotatingSensor.Extensions.Add(new FieldOfViewExtension(new RectangularPyramid
{
	XHalfAngle = Trig.DegreesToRadians(30),
	YHalfAngle = Trig.DegreesToRadians(30),
	Radius = 10000.0,
}));

// Configure graphical display of the sensor.
m_rotatingSensor.Extensions.Add(new FieldOfViewGraphicsExtension(new SensorFieldOfViewGraphics
{
	DomeSurfaceMaterial = new GridMaterialGraphics
	{
		Color = Color.Green,
		CellAlpha = 0.5,
	},
	LateralSurfaceMaterial = new GridMaterialGraphics
	{
		Color = Color.Pink,
		CellAlpha = 0.5,
	},
	IntersectionColor = Color.White,
	ShowIntersection = true,
	ShowEllipsoidHorizonSurfaces = true,
}));

实现效果

相关推荐
__water2 小时前
『功能项目』回调函数处理死亡【54】
c#·回调函数·unity引擎
__water2 小时前
『功能项目』眩晕图标显示【52】
c#·unity引擎·动画事件
__water3 小时前
『功能项目』第二职业法师的平A【57】
c#·unity引擎·魔法球伤害传递
__water5 小时前
『功能项目』战士的伤害型技能【45】
c#·unity引擎·战士职业伤害型技能
君莫愁。6 小时前
【Unity】检测鼠标点击位置是否有2D对象
unity·c#·游戏引擎
Lingbug7 小时前
.Net日志组件之NLog的使用和配置
后端·c#·.net·.netcore
咩咩觉主7 小时前
Unity实战案例全解析:PVZ 植物卡片状态分析
unity·c#·游戏引擎
Echo_Lee07 小时前
C#与Python脚本使用共享内存通信
开发语言·python·c#
__water14 小时前
『功能项目』QFrameWork框架重构OnGUI【63】
c#·unity引擎·重构背包框架
Crazy Struggle14 小时前
C# + WPF 音频播放器 界面优雅,体验良好
c#·wpf·音频播放器·本地播放器