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,
}));

实现效果

相关推荐
向宇it7 小时前
【从零开始入门unity游戏开发之——C#篇25】C#面向对象动态多态——virtual、override 和 base 关键字、抽象类和抽象方法
java·开发语言·unity·c#·游戏引擎
向宇it8 小时前
【从零开始入门unity游戏开发之——C#篇24】C#面向对象继承——万物之父(object)、装箱和拆箱、sealed 密封类
java·开发语言·unity·c#·游戏引擎
坐井观老天13 小时前
在C#中使用资源保存图像和文本和其他数据并在运行时加载
开发语言·c#
pchmi15 小时前
C# OpenCV机器视觉:模板匹配
opencv·c#·机器视觉
黄油饼卷咖喱鸡就味增汤拌孜然羊肉炒饭17 小时前
C#都可以找哪些工作?
开发语言·c#
boligongzhu19 小时前
Dalsa线阵CCD相机使用开发手册
c#
向宇it1 天前
【从零开始入门unity游戏开发之——C#篇23】C#面向对象继承——`as`类型转化和`is`类型检查、向上转型和向下转型、里氏替换原则(LSP)
java·开发语言·unity·c#·游戏引擎·里氏替换原则
sukalot1 天前
windows C#-命名实参和可选实参(下)
windows·c#
小码编匠1 天前
.NET 下 RabbitMQ 队列、死信队列、延时队列及小应用
后端·c#·.net