Ejemplo n.º 1
0
func (self *AircraftTest) testDataFunc(id goplanemp.PlaneId, dataType goplanemp.PlaneDataType, ref interface{}) (goplanemp.PlaneCallbackResult, *goplanemp.PlanePosition, *goplanemp.PlaneSurfaces, *goplanemp.PlaneRadar) {
	currentPlane := ref.(*csl.CslAircraft)
	switch dataType {
	case goplanemp.DataType_Position:
		posData := &goplanemp.PlanePosition{}
		posData.Lat = dataAccess.GetDoubleData(self.latDataRef)
		posData.Lon = dataAccess.GetDoubleData(self.lonDataRef)
		posData.Elevation = dataAccess.GetDoubleData(self.elevDataRef) + 25.0 //25 Fuß höher damit es gut zu sehen ist
		posData.Heading = 0.0
		posData.Pitch = 0.0
		posData.Roll = 0.0
		posData.Label = fmt.Sprintf("%v - %v - %v", currentPlane.Icao, currentPlane.Airline, currentPlane.Livery)
		return goplanemp.Data_NewData, posData, nil, nil
	case goplanemp.DataType_Surfaces:
		surfaceData := &goplanemp.PlaneSurfaces{}
		surfaceData.Lights = goplanemp.LightStatus{}
		surfaceData.Lights.BeaconLights = true
		surfaceData.Lights.LandingLights = true
		surfaceData.Lights.NavLights = true
		surfaceData.Lights.StrobeLights = true
		surfaceData.Lights.FlashPattern = goplanemp.LightsPattern_Default
		return goplanemp.Data_NewData, nil, surfaceData, nil
	case goplanemp.DataType_Radar:
		return goplanemp.Data_Unavailable, nil, nil, nil
	}
	return goplanemp.Data_Unavailable, nil, nil, nil
}
Ejemplo n.º 2
0
func (self *DefaultRenderer) Render(isBlend, renderAircraftLabels bool, aircrafts []*goplanemp.Plane, ref interface{}) {
	var startTime time.Time
	if self.configuration.EnableRenderStatistics {
		startTime = time.Now()
	}
	self.totalPlanes = len(aircrafts)
	self.obj7Planes, self.obj8Planes = 0, 0
	now := processing.GetCycleNumber()
	cameraPos := camera.XPLMReadCameraPosition()
	cameraZoom := cameraPos.Zoom
	maxDist := dataAccess.GetFloatData(self.visDataRef)
	labelDist := float32(math.Min(float64(maxDist), MAX_LABEL_DIST)) * cameraZoom
	fullPlaneDist := cameraZoom * (5280.0 / 3.2) * self.configuration.FullDistance * 0.6213712
	cullInfo := newCullInfo()
	if now%self.configuration.CalculationMod == 0 {
		self.renderPlanes.Clear()
		userAircraftAlt := dataAccess.GetDoubleData(self.altitudeDataRef) / FtToMeters
		for _, plane := range aircrafts {
			//neue Liste erzeugen
			if plane.CslAircraft.CslType == csl.CSL_TYPE_OBJ7 && plane.CslAircraft.ObjInfo == nil {
				//es wurde kein Objekt für ein OBJ7-Flugzeug geladen --> aktuelles Flugzeug ignorieren
				continue
			}
			if plane.UpdateData(now, goplanemp.DataType_Position) == goplanemp.Data_Unavailable {
				//keine Positionsdaten vorhanden --> aktuelles Flugzeug ignorieren
				continue
			}
			//Entfernung des Flugzeugs bestimmen
			x64, y64, z64 := graphics.WorldToLocal(plane.PositionData.Lat, plane.PositionData.Lon, plane.PositionData.Elevation*FtToMeters)
			x, y, z := float32(x64), float32(y64), float32(z64)

			//prüfen ob das Flugzeug angezeigt werden soll
			cull, distance := self.isCulling(plane, cullInfo, x, y, z, maxDist)
			//Flugzeug ist außerhalb des TCAS-Bereichs --> ignorieren
			if distance > MAX_TCAS_DIST {
				continue
			}
			plane.RenderFull = distance < fullPlaneDist
			if !cull {
				self.renderPlanes.AddPlane(self.buildPlaneToRender(plane, x, y, z, distance, userAircraftAlt, now))
			}
		}
	}

	//und Flugzeuge zeichen
	obj7Planes, obj8Planes := self.renderPlanes.GetPlanes()
	if len(obj7Planes) > 0 {
		if isBlend {
			// Durchlauf 1 - OBJ7-Flugzeuge
			// Blend for solid OBJ7s?  YES!  First, in HDR mode, they DO NOT draw to the gbuffer properly -
			// they splat their livery into the normal map, which is terrifying and stupid.  Then they are also
			// pre-lit...the net result is surprisingly not much worse than regular rendering considering how many
			// bad things have happened, but for all I know we're getting NaNs somewhere.
			//
			// Blending isn't going to hurt things in NON-HDR because our rendering is so stupid for old objs - there's
			// pretty much never translucency so we aren't going to get Z-order fails.  So f--- it...always draw blend.<

			for _, current := range obj7Planes {
				if current.dist > fullPlaneDist {
					//max. Entfernung wurde erreicht --> aktuelles Flugzeug nicht zeichnen
					continue
				}
				self.drawObj7Model(current)
				self.obj7Planes++
			}
			// Durchlauf 2- OBJ7-Lichter
			fov := dataAccess.GetFloatData(self.fovDataRef)
			self.beginObj7LightDrawing()
			for _, current := range obj7Planes {
				if !self.configuration.UseObj8Lights || current.dist > fullPlaneDist {
					self.drawObj7Lights(current, fov, cameraPos)
				}
			}
		} else {
			if self.configuration.UseObj8Lights {
				for _, current := range obj7Planes {
					if current.dist <= fullPlaneDist {
						self.drawObj8Lights(current)
					}
				}
			}
		}
	}

	//Durchlauf 3 - OBJ8-Flugzeuge zeichnen
	if len(obj8Planes) > 0 {

		if isBlend {
			for _, plane := range obj8Planes {
				currentAircraft = plane.plane
				self.drawObj8Tanslucent(plane)
			}
		} else {
			for _, plane := range obj8Planes {
				currentAircraft = plane.plane
				self.drawObj8Solid(plane)
			}
		}
		self.obj8Planes = len(obj8Planes)
	}
	// Durchlauf 4 - Beschriftungen zeichnen
	if isBlend && renderAircraftLabels {
		self.drawPlaneLabels(self.renderPlanes, cullInfo, labelDist)
	}
	if self.configuration.EnableRenderStatistics {
		self.drawTime = time.Now().Sub(startTime).Seconds() / 1000.0
	}
}