示例#1
0
//Liefert die aktuellen Daten entsprechend des Übergebenen Datentyp für das gewünschte Flugzeug zurück.
//Alle anderen Zeiger sind nil. Zusätzlich liefert die Methode das Alter der Daten und den Rückgabewert des Callback-Moduls zurück
func (self *MultiplayerManager) GetPlaneData(id PlaneId, dataType PlaneDataType) (int, PlaneCallbackResult, *PlanePosition, *PlaneSurfaces, *PlaneRadar) {
	plane, index := self.getPlane(id)
	if index == -1 {
		return -1, Data_Unavailable, nil, nil, nil
	}
	now := processing.GetCycleNumber()
	callbackResult := plane.UpdateData(now, dataType)
	switch dataType {
	case DataType_Position:
		return plane.positionDataAge, callbackResult, plane.PositionData, nil, nil
	case DataType_Surfaces:
		return plane.surfacesDataAge, callbackResult, nil, plane.SurfacesData, nil
	case DataType_Radar:
		return plane.radarDataAge, callbackResult, nil, nil, plane.RadarData
	default:
		return -1, Data_Unavailable, nil, nil, nil
	}
}
示例#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
	}
}