public void UpdateParticleSubState(float elaspe) { if (SubStates != null) { var effector = Effector.Get(false); for (int i = 0; i < SubStates.Length; i++) { if (CurLiveTime <= FireDelay) { continue; } unsafe { CGfxParticleState **pStates; int num = 0; CGfxParticleSubState.SDK_GfxParticleSubState_GetParticles(SubStates[i].CoreObject, &pStates, &num); if (num > 0) { //宏图处理粒子状态变更 effector.OnParticleStateTick(this, pStates, num, i, SubStates[i], elaspe, i); } } //这里处理SubState里面的粒子如果死亡,移除状态 CGfxParticleSubState.SDK_GfxParticleSubState_Simulate(SubStates[i].CoreObject, elaspe); if (TrailNode != null) { TrailNode.Clear(); } if (SubStates[i].MacrossNode != null) { effector.ParticleData.ParticleSystem = this; effector.ParticleData.ParticleSubState = SubStates[i]; effector.ParticleData.ParticleEmitterShape = SubStates[i].Shape; SubStates[i].MacrossNode.Update(elaspe, effector.ParticleData); } var TransformNode = SubStates[i].TransformNode; if (TransformNode != null) { float tick = 0; if (TransformNode.Loop) { tick = ((EngineNS.CEngine.Instance.EngineTimeSecond - TransformNode.StartTick) % TransformNode.Duration) / TransformNode.Duration; } else { tick = MathHelper.FClamp((EngineNS.CEngine.Instance.EngineTimeSecond - TransformNode.StartTick) / TransformNode.Duration, 0f, 1f); } SubStates[i].TransformNode.SetMatrix(tick); } } } }
private void UpdateTrailNodes(float elapsed) { for (int i = 1; i < trailNodeCount; i++) { TrailNode tn = trailNodes[i]; // Calculate spring force Vector2 stretch = tn.Position - trailNodes[i - 1].Position; Vector2 force = -TrailStiffness * stretch - TrailDamping * tn.Velocity; // Apply acceleration Vector2 acceleration = force / TrailNodeMass; tn.Velocity += acceleration * elapsed; // Apply velocity tn.Position += tn.Velocity * elapsed; trailNodes[i] = tn; } }
public override void Draw(GameTime gameTime) { //spriteBatch.Begin SpriteBlendMode.AlphaBlend); //spriteBatch.Begin(0, BlendState.AlphaBlend); spriteBatch.Begin(); //First we draw all the trail nodes using the border color //we need to draw them slightly larger, so the border is left visible //later, when we draw the actual nodes //adjust the StartScale and EndScale to take into consideration the border float borderStartScale = StartScale + BorderSize / cursorTexture.Width; float borderEndScale = EndScale + BorderSize / cursorTexture.Width; //draw all nodes with the new scales for (int i = 0; i < trailNodeCount; i++) { TrailNode node = trailNodes[i]; float lerpFactor = (float)i / (float)(trailNodeCount - 1); lerpFactor = (float)Math.Pow(lerpFactor, LerpExponent); float scale = MathHelper.Lerp(borderStartScale, borderEndScale, lerpFactor); //draw using the Border Color spriteBatch.Draw(cursorTexture, node.Position, null, BorderColor, 0.0f, textureCenter, scale, SpriteEffects.None, 0.0f); } //Next, we draw all the nodes normally, using the Fill Color //Because before we drew them larger, after we draw them at //their normal size, a border will remain visible. for (int i = 0; i < trailNodeCount; i++) { TrailNode node = trailNodes[i]; float lerpFactor = (float)i / (float)(trailNodeCount - 1); lerpFactor = (float)Math.Pow(lerpFactor, LerpExponent); float scale = MathHelper.Lerp(StartScale, EndScale, lerpFactor); //draw using the fill color spriteBatch.Draw(cursorTexture, node.Position, null, FillColor, 0.0f, textureCenter, scale, SpriteEffects.None, 0.0f); } spriteBatch.End(); }
protected override void PrepareBranch(UnitClause unit) { TrailNode node = new TrailNode(unit.Index, 0); trail.Add(node); unsatisfiable = false; existsNonUnitClauses = false; UnitPropagate(unit); if (unsatisfiable) { return; } satisfiable = !existsNonUnitClauses && CheckPolarity(); if (satisfiable) { return; } unsatisfiable = AllAssigned(); }
private bool CDCL() { RunInitialUnitPropagation(); UnitClause decision; while (true) { // if count > 0 -> get decision, prepare if (trail.Count > 0) { TrailNode last = PopTrail; PrepareBranch(new UnitClause(last.Variable)); } // if (unsatisfiable) { if (variables.CheckPointLevel == 0) { return(false); } // analyze conflict // addclause // bacjump continue; } if (satisfiable) { return(true); } // make decision decision = new UnitClause(heuristic.GetVariableToBranchOn()); // false first decision.Value *= -1; } }
public unsafe void DealDeathParticles() { unsafe { CGfxParticle **ppParticles; int num; GetDeathParticles(&ppParticles, &num); //处理粒子死亡 for (int i = 0; i < num; i++) { if (TrailNode != null) { TrailNode.DealDeathParticle(ref *ppParticles[i]); } if (TriggerNodes.Count > 0) { for (int j = 0; j < TriggerNodes.Count; j++) { TriggerNodes[j].TriggerDeathEvent(ref ppParticles[i]->FinalPose); } } Effector.Get(false).DoParticleDead(this, ref *ppParticles[i]); ppParticles[i]->Tag = null; } } //if (SubParticleSystems != null) //{ // for (int i = 0; i < SubParticleSystems.Count; i++) // { // SubParticleSystems[i].DealDeathParticles(); // } //} }
private void InitializeTreeView() { StockNode treeNode1; foreach (string entry in this.theme.Keys) { if (entry.ToUpper().EndsWith("GRAPH")) { GraphNode treeNode = new GraphNode(entry, this.graphMenuStrip, Color.White, Color.LightGray, true, Color.LightGray, GraphChartMode.BarChart); if (entry.ToUpper().Contains("VOLUME")) { treeNode.ImageKey = "VH"; treeNode.SelectedImageKey = "VH"; } this.treeView1.Nodes.Add(treeNode); foreach (string line in this.theme[entry]) { try { string[] fields = line.Split('|'); switch (fields[0].ToUpper()) { case "GRAPH": string[] colorItem = fields[1].Split(':'); treeNode.GraphBackgroundColor = Color.FromArgb(int.Parse(colorItem[0]), int.Parse(colorItem[1]), int.Parse(colorItem[2]), int.Parse(colorItem[3])); colorItem = fields[2].Split(':'); treeNode.GraphTextBackgroundColor = Color.FromArgb(int.Parse(colorItem[0]), int.Parse(colorItem[1]), int.Parse(colorItem[2]), int.Parse(colorItem[3])); treeNode.GraphShowGrid = bool.Parse(fields[3]); colorItem = fields[4].Split(':'); treeNode.GraphGridColor = Color.FromArgb(int.Parse(colorItem[0]), int.Parse(colorItem[1]), int.Parse(colorItem[2]), int.Parse(colorItem[3])); treeNode.GraphMode = (GraphChartMode)Enum.Parse(typeof(GraphChartMode), fields[5]); if (treeNode.Text.ToUpper() == "CLOSEGRAPH") { if (fields.Length >= 7) { treeNode.SecondaryPen = GraphCurveType.PenFromString(fields[6]); } else { treeNode.SecondaryPen = new Pen(Color.DarkGoldenrod, 1); } } break; case "DATA": if (treeNode.Text.ToUpper() == "CLOSEGRAPH") { if (fields[1] == "CLOSE") { treeNode1 = new CurveNode(fields[1], null, GraphCurveType.PenFromString(fields[2]), bool.Parse(fields[3])); treeNode.Nodes.Add(treeNode1); } else { if (bool.Parse(fields[3])) // Normaly Other than close is not visible... { treeNode1 = new CurveNode(fields[1], null, GraphCurveType.PenFromString(fields[2]), bool.Parse(fields[3])); treeNode.Nodes.Add(treeNode1); } } } else { if (fields[1] != "VOLUME" && bool.Parse(fields[3])) // Normaly Other than close is not visible... { treeNode1 = new CurveNode(fields[1], null, GraphCurveType.PenFromString(fields[2]), bool.Parse(fields[3])); treeNode.Nodes.Add(treeNode1); } } break; case "INDICATOR": { IStockIndicator stockIndicator = (IStockIndicator)StockViewableItemsManager.GetViewableItem(line); treeNode1 = new IndicatorNode(stockIndicator.Name, this.indicatorMenuStrip, stockIndicator); for (int i = 0; i < stockIndicator.SeriesCount; i++) { CurveNode curveNode = new CurveNode(stockIndicator.SerieNames[i], null, stockIndicator.SeriePens[i], true, stockIndicator.SerieVisibility[i]); treeNode1.Nodes.Add(curveNode); curveNode.ImageKey = treeNode1.ImageKey; curveNode.SelectedImageKey = treeNode1.SelectedImageKey; } treeNode.Nodes.Add(treeNode1); } break; case "PAINTBAR": { IStockPaintBar stockPaintBar = (IStockPaintBar)StockViewableItemsManager.GetViewableItem(line); treeNode1 = new PaintBarsNode(stockPaintBar.Name, this.indicatorMenuStrip, stockPaintBar); for (int i = 0; i < stockPaintBar.SeriesCount; i++) { CurveNode curveNode = new CurveNode(stockPaintBar.SerieNames[i], null, stockPaintBar.SeriePens[i], true, stockPaintBar.SerieVisibility[i]); treeNode1.Nodes.Add(curveNode); curveNode.ImageKey = treeNode1.ImageKey; curveNode.SelectedImageKey = treeNode1.SelectedImageKey; } treeNode.Nodes.Add(treeNode1); } break; case "TRAILSTOP": { IStockTrailStop stockTrailStop = (IStockTrailStop)StockViewableItemsManager.GetViewableItem(line); treeNode1 = new TrailStopsNode(stockTrailStop.Name, this.indicatorMenuStrip, stockTrailStop); for (int i = 0; i < stockTrailStop.SeriesCount; i++) { CurveNode curveNode = new CurveNode(stockTrailStop.SerieNames[i], null, stockTrailStop.SeriePens[i], false, true); treeNode1.Nodes.Add(curveNode); curveNode.ImageKey = treeNode1.ImageKey; curveNode.SelectedImageKey = treeNode1.SelectedImageKey; } treeNode.Nodes.Add(treeNode1); } break; case "DECORATOR": { IStockDecorator stockDecorator = (IStockDecorator)StockViewableItemsManager.GetViewableItem(line); treeNode1 = new DecoratorNode(stockDecorator.Name, this.indicatorMenuStrip, stockDecorator); for (int i = 0; i < stockDecorator.SeriesCount; i++) { treeNode1.Nodes.Add(new CurveNode(stockDecorator.SerieNames[i], null, stockDecorator.SeriePens[i], true, stockDecorator.SerieVisibility[i])); } for (int i = 0; i < stockDecorator.EventCount; i++) { treeNode1.Nodes.Add(new EventNode(stockDecorator.EventNames[i], null, stockDecorator.EventPens[i], true, stockDecorator.EventVisibility[i])); } foreach (TreeNode childNode in treeNode.Nodes) { if (childNode.Text == stockDecorator.DecoratedItem) { childNode.Nodes.Add(treeNode1); break; } } } break; case "TRAIL": { IStockTrail stockTrail = (IStockTrail)StockViewableItemsManager.GetViewableItem(line); treeNode1 = new TrailNode(stockTrail.Name, this.indicatorMenuStrip, stockTrail); for (int i = 0; i < stockTrail.SeriesCount; i++) { treeNode1.Nodes.Add(new CurveNode(stockTrail.SerieNames[i], null, stockTrail.SeriePens[i], true, true)); } foreach (TreeNode childNode in treeNode.Nodes) { if (childNode.Text == stockTrail.TrailedItem) { childNode.Nodes.Add(treeNode1); break; } } } break; case "LINE": treeNode.Nodes.Add(new LineNode("LINE_" + fields[1], this.indicatorMenuStrip, GraphCurveType.PenFromString(fields[2]), float.Parse(fields[1]))); break; default: continue; } } catch (System.Exception e) { StockLog.Write(e); } } } } foreach (TreeNode node in this.treeView1.Nodes) { node.Expand(); } this.treeView1.SelectedNode = treeView1.Nodes[0]; }
void addTrailToolStripMenuItem_Click(object sender, System.EventArgs e) { AddTrailDlg addDlg; StockNode treeNode = (StockNode)this.treeView1.SelectedNode; switch (treeNode.Text) { case "CloseGraph": return; case "VolumeGraph": return; default: addDlg = new AddTrailDlg(); break; } if (addDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { StockNode stockNode = (StockNode)this.treeView1.SelectedNode; if (stockNode.Type == NodeType.Trail) return; IStockTrail stockTrail = StockTrailManager.CreateTrail(addDlg.TrailName, stockNode.Name); if (stockTrail == null) { return; } if (stockTrail.DisplayTarget != IndicatorDisplayTarget.PriceIndicator) { // Only one trail per graph (except data serie) (multiple ema, BB, ....) int index = 0; bool found = false; foreach (StockNode node in stockNode.Nodes) { if (node.Type == NodeType.Trail) { found = true; break; } index++; } if (found) { stockNode.Nodes.RemoveAt(index); } } StockNode trailNode = new TrailNode(stockTrail.Name, this.indicatorMenuStrip, stockTrail); stockNode.Nodes.Add(trailNode); int i = 0; foreach (string curveName in stockTrail.SerieNames) { trailNode.Nodes.Add(new CurveNode(curveName, null, stockTrail.SeriePens[i], true)); i++; } this.treeView1.SelectedNode = trailNode; trailNode.Expand(); } }