/// <summary> /// Erzeugt ein MarkierungZustand-Objekt mit den aktuellen Daten der /// Markierung. /// </summary> internal MarkerState ErzeugeInfo() { MarkerState info = new MarkerState(colonyId, Id); info.PositionX = koordinate.X / SimulationEnvironment.PLAYGROUND_UNIT; info.PositionY = koordinate.Y / SimulationEnvironment.PLAYGROUND_UNIT; info.Radius = koordinate.Radius / SimulationEnvironment.PLAYGROUND_UNIT; info.Direction = koordinate.Richtung; return(info); }
void EnterStartState(Vector2 vp1) { if (vp1.Equals(Vector2.zero)) { _mstate = MarkerState.MARKER_INIT; txt_xa.gameObject.SetActive(false); } else { _mstate = MarkerState.MARKER_START; txt_xa.gameObject.GetComponent <RectTransform>().anchoredPosition = vp1; txt_xa.gameObject.SetActive(true); } }
public void DrawMarker(int colony, MarkerState state) { GraphicsDevice.RasterizerState = markerRasterizerState; GraphicsDevice.DepthStencilState = markerDepthStencilState; GraphicsDevice.BlendState = BlendState.AlphaBlend; //GraphicsDevice.BlendState = new BlendState() //{ // AlphaBlendFunction = BlendFunction.Add, // ColorBlendFunction = BlendFunction.Add, // AlphaSourceBlend = Blend.SourceAlpha, // ColorSourceBlend = Blend.SourceColor, // AlphaDestinationBlend = Blend.InverseSourceAlpha, // ColorDestinationBlend = Blend.InverseSourceColor, //}; Vector3 pos = new Vector3(state.PositionX - playgroundWidth, 0, -state.PositionY + playgroundHeight); Matrix matrix = Matrix.CreateTranslation(pos); matrix.M11 = matrix.M22 = matrix.M33 = state.Radius; foreach (var mesh in marker.Meshes) { foreach (BasicEffect eff in mesh.Effects) { eff.World = matrix; eff.View = camera.ViewMatrix; eff.Projection = camera.ProjectionMatrix; eff.LightingEnabled = false; eff.Alpha = 0.05f; eff.EmissiveColor = 0.33f * playerColors[state.ColonyId - 1]; eff.DiffuseColor = 0.33f * playerColors[state.ColonyId - 1]; } mesh.Draw(); } GraphicsDevice.RasterizerState = defaultRasterizerState; GraphicsDevice.DepthStencilState = defaultDepthStencilState; // draw debug if (showDebugInfo) { debugRenderer.DrawHorizontalCircle(pos, state.Radius, 16, new Color(0.33f * playerColors[state.ColonyId - 1])); } }
protected override void RequestDraw() { MainState _currentState = _state; if (_currentState != null) { Index2 cells = _currentState.Map.GetCellCount(); DrawPlayground(cells, _currentState.Map.Tiles); foreach (var item in _currentState.Items) { if (item is AnthillState) { AnthillState anthillState = item as AnthillState; DrawItem(item.Id, item.Position, anthillState.Radius, null, null, Color.Brown, null, null, null, null, null, null); } if (item is AntState) { AntState antState = item as AntState; // DrawItem(item.Id, item.Position, antState.Radius, Color.Black); } if (item is SugarState) { SugarState sugarState = item as SugarState; // DrawItem(item.Id, item.Position, sugarState.Radius, Color.White); } if (item is AppleState) { AppleState appleState = item as AppleState; // DrawItem(item.Id, item.Position, 5, Color.LightGreen); } if (item is MarkerState) { MarkerState markerState = item as MarkerState; // DrawItem(item.Id, item.Position, 10, Color.Yellow); } if (item is BugState) { // DrawItem(item.Id, item.Position, 10, Color.Blue); } } } }
void EnterFinalState(Vector2 vp2) { if (vp2.Equals(Vector2.zero)) { _mstate = MarkerState.MARKER_START; txt_xb.gameObject.SetActive(false); LineImg.gameObject.SetActive(false); RegionMarkerImg.gameObject.SetActive(false); } else { _mstate = MarkerState.MARKER_FINAL; txt_xb.gameObject.GetComponent <RectTransform>().anchoredPosition = vp2; txt_xb.gameObject.SetActive(true); if (_rEnvFSM.GetCurrentStateName() == REnvState.SegmentCUD) { UpdateLineImg(vp2, GetOrigin()); } else if (_rEnvFSM.GetCurrentStateName() == REnvState.CreateRegion) { UpdateRegionMarkerImg(vp2, GetOrigin()); } } }
/// <summary> /// Render Marker. /// </summary> /// <param name="colony">Colony-ID</param> /// <param name="state"><see cref="MarkerState"/></param> public void RenderMarker(int colony, MarkerState state) { Matrix matrix = Matrix.Translation (state.PositionX - playgroundWidth, 0, -state.PositionY + playgroundHeight); matrix.M11 = state.Radius; matrix.M22 = state.Radius; matrix.M33 = state.Radius; // Enable transperency renderDevice.RenderState.AlphaBlendEnable = true; renderDevice.RenderState.ZBufferWriteEnable = false; renderDevice.RenderState.SourceBlend = Blend.SourceAlpha; renderDevice.RenderState.DestinationBlend = Blend.InvSourceAlpha; renderDevice.Material = markerMaterials[colony]; renderDevice.Transform.World = matrix; markerMesh.DrawSubset(0); // Disable transparency renderDevice.RenderState.AlphaBlendEnable = false; renderDevice.RenderState.ZBufferWriteEnable = true; }
private void render(object sender, PaintEventArgs e) { if (Visible && renderDevice != null) { if (watch.ElapsedMilliseconds > 40) { watch.Reset(); watch.Start(); Selection selectedItem = new Selection(); // Selektionsinfos zurücksetzen selectedItem.SelectionType = SelectionType.Nothing; selectedItem.Item = null; float distanceToSelectedItem = VIEWRANGE_MAX * VIEWRANGE_MAX; renderDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.FromArgb(51, 153, 255), 1.0f, 0); renderDevice.BeginScene(); //// Falls schon ein Zustand da ist kann gezeichnet werden if (simulationState != null) { SimulationState currentState = simulationState; // Update Camera camera.Update(currentState.PlaygroundWidth, currentState.PlaygroundHeight); renderDevice.Transform.View = camera.ViewMatrix; Pickray pickray = camera.Pickray; Point mousePosition = camera.MousePosition; // render Playerground modelManager.SetPlaygroundSize(currentState.PlaygroundWidth, currentState.PlaygroundHeight); modelManager.RenderPlayground(); // render these preaty little, blue items... float distance; for (int i = 0; i < currentState.BugStates.Count; i++) { if ((distance = modelManager.RenderBug(currentState.BugStates[i], pickray, false)) > 0) { // select, if pickray collides with item if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = currentState.BugStates[i]; selectedItem.SelectionType = SelectionType.Bug; } } } // Render sugar for (int i = 0; i < currentState.SugarStates.Count; i++) { if ((distance = modelManager.RenderSugar(currentState.SugarStates[i], pickray, false)) > 0) { // select, if pickray collides with item if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = currentState.SugarStates[i]; selectedItem.SelectionType = SelectionType.Sugar; } } } // Render Fruit for (int i = 0; i < currentState.FruitStates.Count; i++) { if ((distance = modelManager.RenderFruit(currentState.FruitStates[i], pickray, false)) > 0) { // select, if pickray collides with item if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = currentState.FruitStates[i]; selectedItem.SelectionType = SelectionType.Fruit; } } } // Colony-specific stuff int count = 0; for (int teamIndex = 0; teamIndex < currentState.TeamStates.Count; teamIndex++) { for (int colonyIndex = 0; colonyIndex < currentState.TeamStates[teamIndex].ColonyStates.Count; colonyIndex++) { ColonyState colony = currentState.TeamStates[teamIndex].ColonyStates[colonyIndex]; // Ensure available materials for that colony modelManager.PrepareColony(count); // Render Anthills for (int anthillIndex = 0; anthillIndex < colony.AnthillStates.Count; anthillIndex++) { if ( (distance = modelManager.RenderAnthill( count, colony.AnthillStates[anthillIndex], pickray, false)) > 0) // select, if pickray collides with item { if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = colony.AnthillStates[anthillIndex]; selectedItem.SelectionType = SelectionType.Anthill; selectedItem.AdditionalInfo = colony.ColonyName; } } } // Render Ants for (int antIndex = 0; antIndex < colony.AntStates.Count; antIndex++) { if ( (distance = modelManager.RenderAnt( count, colony.AntStates[antIndex], pickray, false)) > 0) { // select, if pickray collides with item if (distance < distanceToSelectedItem) { distanceToSelectedItem = distance; selectedItem.Item = colony.AntStates[antIndex]; selectedItem.SelectionType = SelectionType.Ant; selectedItem.AdditionalInfo = colony.ColonyName; } } } count++; } } // Render Marker // This must happen at the end, cause of alpha-tranperency count = 0; for (int teamIndex = 0; teamIndex < currentState.TeamStates.Count; teamIndex++) { TeamState team = currentState.TeamStates[teamIndex]; for (int colonyIndex = 0; colonyIndex < team.ColonyStates.Count; colonyIndex++) { ColonyState colony = team.ColonyStates[colonyIndex]; for (int markerIndex = 0; markerIndex < colony.MarkerStates.Count; markerIndex++) { MarkerState marker = colony.MarkerStates[markerIndex]; modelManager.RenderMarker(count, marker); } count++; } } // Render Statistics in the upper left corner modelManager.RenderInfobox(currentState); // Render Info-Tag at selected item if (selectedItem.SelectionType != SelectionType.Nothing) { string line1; string line2; switch (selectedItem.SelectionType) { case SelectionType.Ant: AntState ameise = (AntState)selectedItem.Item; string name; if (!antNames.ContainsKey(ameise.Id)) { name = names[random.Next(names.Length)]; antNames.Add(ameise.Id, name); } else { name = antNames[ameise.Id]; } line1 = string.Format(Resource.HovertextAntLine1, name, selectedItem.AdditionalInfo); line2 = string.Format(Resource.HovertextAntLine2, ameise.Vitality); break; case SelectionType.Anthill: line1 = Resource.HovertextAnthillLine1; line2 = string.Format(Resource.HovertextAnthillLine2, selectedItem.AdditionalInfo); break; case SelectionType.Bug: BugState bugState = (BugState)selectedItem.Item; line1 = Resource.HovertextBugLine1; line2 = string.Format(Resource.HovertextBugLine2, bugState.Vitality); break; case SelectionType.Fruit: FruitState fruitState = (FruitState)selectedItem.Item; line1 = Resource.HovertextFruitLine1; line2 = string.Format(Resource.HovertextFruitLine2, fruitState.Amount); break; case SelectionType.Sugar: SugarState sugar = (SugarState)selectedItem.Item; line1 = Resource.HovertextSugarLine1; line2 = string.Format(Resource.HovertextSugarLine2, sugar.Amount); break; default: line1 = String.Empty; line2 = String.Empty; break; } // Text an Mausposition ausgeben if (line1 != String.Empty || line2 != String.Empty) { modelManager.RenderInfoTag(mousePosition, line1, line2); } } } renderDevice.EndScene(); renderDevice.Present(); } Application.DoEvents(); Invalidate(); } }
// Use this for initialization void Start() { markerScale = new float[]{Marker1Scale, Marker2Scale, Marker3Scale, Marker4Scale}; if(Startup.GetGeneration() == "iPad2"){ minX /= 2; maxX /= 2; minY /= 2; maxY /= 2; MaxHeightCheck /= 2; MaxFurniture = 3; } menu = GameObject.Find ("PeekARGUIObject").GetComponent<PeekGUI>(); menu.DeleteBtn += () => { mode = Mode.Delete;}; menu.CancelDelete += () => {mode = Mode.Manip;}; menu.InfoClick += () => Startup.AddWelcomeScreen(); menu.ClearBtn += () => DeleteAll(); camManager = this.GetComponent<JeffARManager>(); tplane = TouchPlane.GroundPlane(camera); camManager.Locked += () => { camState = MarkerState.Locked; }; camManager.Lost += () => { camState = MarkerState.Lost; }; }
public AccessControl(byte priority, byte state) { _priority = priority; _state = state != 0 ? MarkerState.Frame : MarkerState.Marker; }
protected new void Update() { //Debug.Log("CC AR MAN Update"); // Update StringCam's internal state base.Update(); //Debug.Log ("Running...."); // Handle detected markers uint markerCount = GetDetectedMarkerCount(); //currentMarkerCount = markerCount; for (uint i = 0; i < markerCount; i++) { //Debug.Log("ContentCentricARManager(31) - Marker Detected"); // Fetch tracker data for this marker currentMarkerInfo = GetDetectedMarkerInfo(i); //currentMarkerID = currentMarkerInfo.imageID; //Debug.Log (currentMarkerInfo.imageID); //oldColour = currentMarkerInfo.color; //Test //oldColourShare = col; //Debug.Log ("Colour Share: R:" + oldColourShare.x + " G:" + oldColourShare.y + " B:" + oldColourShare.z); col = currentMarkerInfo.color; if (currentMarkerInfo.imageID < markerObjects.Length) { //GameObject markerObj = markerObjects[currentMarkerInfo.imageID]; TargetMarker (currentMarkerInfo); //Debug.Log("goodSpotTime " + goodSpotTime); // Orient the camera according to the marker if (goodSpotTime == SpotTime) { if (state != MarkerState.Locked && Locked != null) { //Debug.Log("CCARman Locked"); Locked(); //Add Green Label // go.GetComponent<LockingLabel>().CurrentLockState("Locked"); //GameObject.Find("PeekARGUIObject").GetComponent<LockingLabel>().CurrentLockState("Locked"); state = MarkerState.Locked; } } else { //TargetRest(); //Continuous Event if (Locking != null) { Locking(); //GameObject.Find("PeekARGUIObject").GetComponent<LockingLabel>().CurrentLockState("Locking"); state = MarkerState.Locking; } } goodSpotTime += Time.deltaTime; goodSpotTime = Mathf.Clamp(goodSpotTime, 0, SpotTime); steady = (currentMarkerInfo.rotation.eulerAngles - lastRotation).magnitude < steadyTolerance && (currentMarkerInfo.position - lastPosition).magnitude < steadyTolerance/100; lastPosition = currentMarkerInfo.position; lastRotation = currentMarkerInfo.rotation.eulerAngles; break; } } //Lost the marker if (markerCount == 0) { //DOESNT ACCOUNT FOR INDIVIDUAL MARKER LOSS WITH MULTIPLE MARKERS!!! if (state != MarkerState.Lost && Lost != null) { Lost(); //Add Red Label //guiObject.GetComponent<LockingLabel>().CurrentLockState("Lost"); //GameObject.Find("PeekARGUIObject").GetComponent<LockingLabel>().CurrentLockState("Lost"); state = MarkerState.Lost; } goodSpotTime = 0; } if(state != MarkerState.Locked){ lostTime += 0.01f; } else{ lostTime = 0; } // Marker not spotted? Point camera away /*if (lastSpottedTime != Time.time) { //TargetRest(); }*/ }
public void FullFSMReset() { AllMarkersOff(); _mstate = MarkerState.MARKER_INIT; }
public void UpdateValues(MarkerState state) { Position.Value = state.position; Rotation.Value = state.rotation; Radius.Value = state.radius; }