public bool IsAffectedByLight(CModel model) { BoundingSphere lightSphere = new BoundingSphere(Transform.Position, Range); BoundingBox meshBox = new BoundingBox(model.AABoxMin, model.AABoxMin); return(lightSphere.Intersects(meshBox)); }
public SimulationManager(GraphicsDevice device, ContentManager content) { if (Instance != null) { throw new InvalidOperationException("Cannot create more than once instance of the simulation manager."); } Instance = this; _sb = new SpriteBatch(device); _blankTex = new Texture2D(device, 1, 1); _blankTex.SetData(new Color[] { Color.White }); _device = device; _world = new WorldModel(device, (int)Constants.WorldSize.X / 10); _uavModel = new CModel(device, content.Load <Model>("UAV")); _tankModel = new CModel(device, content.Load <Model>("tank")); _missModel = new CModel(device, content.Load <Model>("sphere_missile")); _cone = new ConeModel(device); _ring = new RingModel(device, Constants.TankFiringRange / 10, 1); _font = content.Load <SpriteFont>("debugfont"); _lRect = new Rectangle(0, 0, 130, 70); Simulation = new Simulation(); _entityFollow = new EntityFollowBehavior(); }
/// <summary> /// 查询一行记录 /// </summary> /// <param name="filter">过滤器</param> /// <returns>返回单条数据</returns> public CModel GetModel(ModelFilter filter) { string sql = filter.ExecuteSql.ToString(); CModel model = null; try { SqlDataReader reader = SqlRequest.GetReader(sql, filter.GetParams()); while (reader.Read()) { model = new CModel(filter.TableName); foreach (var field in filter.Fields) { model[field] = reader[field]; } } reader.Close(); return(model); } catch (Exception ex) { throw ex; } }
/// <summary> /// Creates new chase camera with default target model /// </summary> /// <param name="graphicsDevice"></param> /// <param name="model"></param> public ChaseCamera(GraphicsDevice graphicsDevice, CModel model) : base(graphicsDevice) { Model = model; PositionOffset = new Vector3(model.Position.X, model.Position.Y, Model.Position.Z + 1500); TargetOffset = new Vector3(Model.Position.X, Model.Position.Y + 200, Model.Position.Z); RelativeCameraRotation = Vector3.Zero; }
public bool TriggerTrap(int[] explorerPosition) { if (Position[0] != explorerPosition[0] || Position[1] != explorerPosition[1]) { return(false); } if (PlayScene.Random.Next(1, 3) == 1) { #if DEBUG Main.InsertLog("Explorer: Agrrrr!!!"); #endif SoundController.PlaySound(PlayContentHolder.Instance.SoundRock); rock = new CModel(PlayContentHolder.Instance.ModelRock, new Vector3(Position[1] * 10 + 5, 36, Position[0] * 10 + 5)); _state = TrapState.Rock; _parent.Explorer.Shock(); timeline = 90; } else { #if DEBUG Main.InsertLog("Explorer: Aaaaa...."); #endif SoundController.PlaySound(PlayContentHolder.Instance.SoundPit); _state = TrapState.Hole; _parent.Floor.HideMesh(Position[0] * _parent.MazeSize + Position[1]); _parent.Explorer.Fall(); } return(true); }
/// <summary> /// 根据主键获取一行记录 /// </summary> /// <param name="table"></param> /// <param name="key"></param> /// <returns></returns> public CModel GetModelByKey(string table, object key) { CModel m_table = new CModel(table); string sql = SqlSplice.GetSelect(m_table, key); CModel model = null; try { SqlDataReader reader = SqlRequest.GetReader(sql, SqlSplice.SqlParams.ToArray()); while (reader.Read()) { model = new CModel(table); foreach (var field in model.Fields) { model[field] = reader[field]; } } return(model); } catch (Exception ex) { throw new Exception("根据主键查询一行记录出错了", ex); } }
public static void Main(String[] args) { if (args.Length == 0) { Console.WriteLine("Need one argument, copasi file"); Environment.Exit(1); } CDataModel dataModel = CRootContainer.addDatamodel(); if (!dataModel.loadModel(args[0])) { Console.WriteLine("Could not open file"); Console.WriteLine(CCopasiMessage.getAllMessageText()); Environment.Exit(1); } CModel model = dataModel.getModel(); ModelParameterSetVectorN sets = model.getModelParameterSets(); // if we don't have one, create one if (sets.size() == 0) { CModelParameterSet newSet = new CModelParameterSet("Current State", model); newSet.createFromModel(); printParameterSet(newSet); sets.add(newSet); } // interrogate the exiting parameter sets printExistingParametersets(model.getModelParameterSets()); }
public Trap(int[] position, PlayScene parent) { _parent = parent; trap = new CModel(PlayContentHolder.Instance.ModelTrap, new Vector3(position[1] * 10 + 5, 0.02f, position[0] * 10 + 5)); Position = position; }
public CModelRenderNode(object outer, CModel model) : base(outer) { m_model = model; m_bounds.center = m_model.AABoxCenter; m_bounds.extent = (m_model.AABoxMax - m_model.AABoxMin) / 2; IsFullyLoaded = true; }
/// <summary> /// 删除多行记录 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="models"></param> public void DeleteModels <T>(List <T> models) { if (models.Count <= 0) { return; } List <CModel> cmodels = new List <CModel>(); foreach (var model in models) { CModel cmodel = null; cmodel = JsonConverter.ModelToCModel <T>(model); if (cmodel == null) { throw new Exception("实体对象为空"); } cmodels.Add(cmodel); } if (cmodels.Count <= 0) { return; } DeleteModels(cmodels); }
protected override void LoadContent() { base.LoadContent(); // Load the models _uavModel = new CModel(GraphicsDevice, Content.Load <Model>("UAV")); _tankModel = new CModel(GraphicsDevice, Content.Load <Model>("tank")); }
public void SetInit() { skinnedModel.Position.Y = -15; tile = new CModel( PlayContentHolder.Instance.ModelTile[parent.IsDarkness ? 2 : (position[0] * parent.MazeSize + position[1]) % 2], skinnedModel.Position ); }
public M8ViewModel(CModel cModel, IEventAggregator ea) { MyCModel = cModel; _ea = ea; _ea.GetEvent <LanguageChangeEvent>().Subscribe(ChangedLang); //TabItemのHeaderになる言葉を多言語設定の為Resoucesから取り出す Title = CModel.GetLocalizedValue <string>("TITLEM8"); }
/// <summary> /// 获取Sql参数 /// </summary> /// <param name="model"></param> /// <returns></returns> public static SqlParameter[] GetSqlParams(CModel model) { foreach (var field in model.Fields) { SqlParams.Add(new SqlParameter($"@{field}", model[field])); } return(SqlParams.ToArray()); }
public Setups(object sender) { InitializeComponent(); Model = (CModel)sender; List<string> temp=new List<string>(); foreach (string str in Model.gridsToLook) temp.Add(str); textBox1.Lines = temp.ToArray(); }
public SoundModel(CModel _commondata, IEventAggregator _ea) { ea = _ea; commondata = _commondata; InitPlotModelRT(); InitPlotModelFFT(); InitPlotModelSpectrogram(); }
public static void Main(String[] args) { // create a new datamodel CDataModel dataModel = CRootContainer.addDatamodel(); if (args.Length != 1) { Console.WriteLine("Need one argument: SBML | CPS filename."); Environment.Exit(1); } String filename = args[0]; try { String ext = System.IO.Path.GetExtension(filename); if (ext.Trim().ToLowerInvariant().EndsWith("xml")) { // load the model without progress report dataModel.importSBML(filename); } else { // load the model without progress report dataModel.loadModel(filename); } } catch { Console.WriteLine("Error while loading the model from file named \"" + filename + "\"."); Environment.Exit(1); } try { CModel model = dataModel.getModel(); int numAnnotations = model.getNumUnsupportedAnnotations(); Console.WriteLine("The model has: " + numAnnotations + " unsupported annotations."); if (numAnnotations == 0) { Console.WriteLine("adding custom annotation"); // we don't have an annotation, so lets add one if (!model.addUnsupportedAnnotation("http://myannotation.org", "<test xmlns='http://myannotation.org' value='blaaaahaaa'/>")) { Console.WriteLine("couldn't set annotation: "); Console.WriteLine(CCopasiMessage.getAllMessageText()); } } Console.WriteLine("The name of the first is: " + model.getUnsupportedAnnotationName(0)); Console.WriteLine("The raw xml of the first is: " + model.getUnsupportedAnnotation(0)); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); } }
public MAViewModel(CModel commonModel, IEventAggregator ea, IRegionManager regionManager) { MyCModel = commonModel; _ea = ea; _ea.GetEvent <LanguageChangeEvent>().Subscribe(ChangedLang); //TabItemのHeaderになる言葉を多言語設定の為Resoucesから取り出す Title = CModel.GetLocalizedValue <string>("TITLEMA"); _regionManager = regionManager; }
/// <summary> /// 实体转CModel /// </summary> /// <typeparam name="T"></typeparam> /// <param name="t"></param> /// <returns></returns> public static CModel ModelToCModel <T>(T t) { CModel model = null; string str_json = ObjectToJson <T>(t); model = JsonToCModel <T>(str_json); return(model); }
private void ReadTextureMapBlock(EndianBinaryReader reader, CModel currentModel) { currentModel.TextureMapCount = reader.ReadInt32(); for (int i = 0; i < currentModel.TextureMapCount; i++) { float tU = reader.ReadSingle(); float tV = reader.ReadSingle(); _models._vertexTextureMap.Add(new Vector2(tU, tV)); } }
private void ReadFaceMaterialsBlock(EndianBinaryReader reader, CModel currentModel) { int nbrFaceMaterials = reader.ReadInt32(); int bytesPerEntry = reader.ReadInt32(); for (int i = 0; i < nbrFaceMaterials; i++) { int matIndex = reader.ReadInt16() - 1; //-1 because it is 1-based currentModel.Polygons[i].MaterialIndex = matIndex; } }
private void ReadVertexBlock(EndianBinaryReader reader, CModel currentModel) { currentModel.VertexBaseIndex = _models._vertexPositions.Count; currentModel.VertexCount = reader.ReadInt32(); for (int i = 0; i < currentModel.VertexCount; i++) { Vector3 vertex = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); _models._vertexPositions.Add(vertex); } }
private void ReadMaterialsBlock(EndianBinaryReader reader, CModel currentModel) { currentModel.MaterialNames = new List <string>(); int nbrMaterials = reader.ReadInt32(); for (int i = 0; i < nbrMaterials; i++) { string material = ReadNullTerminatedString(reader); currentModel.MaterialNames.Add(material); } }
public void RiseUpDone() { tile = null; if (PlayScene.Random.Next(1, 3) == 1) { Dance(); } else { Spin(); } }
public void UpdateClient(CModel model) { try { SqlDataAccess sql = new SqlDataAccess(); sql.SaveData("dbo.spClientsUpdate", model, "WMData"); } catch (Exception ex) { throw new InvalidDataException($"UpdateClient(CPostModel model) coundn't update data.(model.PhoneNumber = {model.PhoneNumber})", ex); } }
public MainWindowViewModel(CModel commondata, IEventAggregator ea) { _ea = ea; MyCommonData = commondata; LocalizeDictionary.Instance.SetCurrentThreadCulture = true; LocalizeDictionary.Instance.Culture = new CultureInfo(System.Globalization.CultureInfo.CurrentCulture.Name); //LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfo("ja-JP"); Title = CModel.GetLocalizedValue <string>("TITLE"); _ea.GetEvent <LanguageChangeEvent>().Subscribe(ChangedLang); _ea.GetEvent <MessageSentEvent>().Subscribe(SetMessage); //Trace.WriteLine("main"); }
public Export(object sender, object model) { MF = (Main_Form)sender; Model = (CModel)model; InitializeComponent(); foreach (CModel.DProperty prop in Model.Props) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dataGridView1); row.Cells[0].Value = prop.Name; row.Cells[1].Value = prop.Name + "_out.txt"; dataGridView1.Rows.Add(row); } }
/// <summary> /// 实体集合转CModel集合 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="objs"></param> /// <returns></returns> public static List <CModel> ModelToCModels <T>(List <T> objs) { List <CModel> cmodels = null; foreach (var obj in objs) { CModel cmodel = ModelToCModel <T>(obj); cmodels.Add(cmodel); } return(cmodels); }
/// <summary> /// CModel转实体 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="model"></param> /// <returns></returns> public static T CModelToModel <T>(CModel model) { string json = JsonSerializer(model.FieldsValue); //object m_obj = JsonConverter.JsonDeserialize(json); json = json.Replace(",\"Value\"", string.Empty); json = json.Replace("\"Key\":", string.Empty); json = json.Replace("{", string.Empty); json = json.Replace("}", string.Empty); json = json.Replace("[", "{"); json = json.Replace("]", "}"); return(JsonDeserialize <T>(json)); }
/// <summary> /// 查询多行记录 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="filter">过滤器</param> /// <returns></returns> public List <T> GetModels <T>(ModelFilter filter) { Type type = typeof(T); string sql = filter.ExecuteSql.ToString(); List <CModel> models = new List <CModel>(); try { SqlDataReader reader = SqlRequest.GetReader(sql, filter.Params.ToArray()); while (reader.Read()) { CModel model = new CModel(type); foreach (var field in model.Fields) { model[field] = reader[field]; } models.Add(model); } reader.Close(); List <T> m_objs = new List <T>(); if (models.Count <= 0) { return(m_objs); } foreach (var model in models) { T m_obj = JsonConverter.CModelToModel <T>(model); m_objs.Add(m_obj); } return(m_objs); } catch (Exception ex) { throw new Exception("查询多行记录出错了", ex); } }
/// <summary> /// 返回删除语句 /// </summary> /// <param name="model">实体</param> /// <returns></returns> public static string GetDelete(CModel model) { SqlParamsClear(); StringBuilder sql = new StringBuilder(); sql.Append($" DELETE FROM {model.TableName} "); sql.Append($" WHERE {model.KeyName}=@{model.KeyName}"); SqlParams.Add(new SqlParameter($"@{model.KeyName}", model.KeyValue)); InitSql = sql.ToString(); return(sql.ToString()); }
private void init_View_YK(CModel tpl) { int iPos = 0; int iCount = 0; foreach (var t in tpl.lst_Table_YK.Values) { dgv_YK.RowCount += 1; iPos = 0; dgv_YK.Rows[iCount].Cells[iPos++].Value = t.Id; dgv_YK.Rows[iCount].Cells[iPos++].Value = t.GroupName; dgv_YK.Rows[iCount].Cells[iPos++].Value = t.ItemName; dgv_YK.Rows[iCount].Cells[iPos++].Value = t.DataType; dgv_YK.Rows[iCount].Cells[iPos++].Value = getHex(t.Addr); iCount += 1; } }
/// <summary> /// Gets the SBML identifier. /// </summary> /// <returns> /// The SBML identifier. /// </returns> /// <param name='model'> /// Model. /// </param> /// <param name='channel'> /// Channel. /// </param> /// <param name='type'> /// Type. /// </param> /// <param name='name'> /// Name. /// </param> static string GetSBMLId(CModel model, CPlotDataChannelSpec channel, out VariableType type, out string name) { var path = channel.getString(); var last = path.Substring(path.LastIndexOf(",", StringComparison.Ordinal) + 1); var first = path.Substring(0, path.LastIndexOf(",", StringComparison.Ordinal)); type = VariableType.Unknown; name = "unknown"; if (last.EndsWith("Rate") || last.EndsWith("ParticleNumber")) return null; if (model.getCN().getString() == first) { type = VariableType.Time; name = "Time"; return "time"; } for (int i = 0; i < model.getMetabolites().size(); i++) { var current = model.getMetabolite((uint)i); if (current.getCN().getString() == first) { type = VariableType.Species; name = current.getObjectDisplayName(); return current.getSBMLId(); } } for (int i = 0; i < model.getCompartments().size(); i++) { var current = model.getCompartment((uint)i); if (current.getCN().getString() == first) { type = VariableType.Compartment; name = current.getObjectDisplayName(); return current.getSBMLId(); } } for (int i = 0; i < model.getModelValues().size(); i++) { var current = model.getModelValue((uint)i); if (current.getCN().getString() == first) { type = VariableType.Parameter; name = current.getObjectDisplayName(); return current.getSBMLId(); } } for (int i = 0; i < model.getReactions().size(); i++) { var current = model.getReaction((uint)i); if (current.getCN().getString() == first) { type = VariableType.Reaction; name = current.getObjectDisplayName(); return current.getSBMLId(); } } return null; }
private void ReadMaterialsBlock(EndianBinaryReader reader, CModel currentModel) { currentModel.MaterialNames = new List<string>(); int nbrMaterials = reader.ReadInt32(); for (int i = 0; i < nbrMaterials; i++) { string material = ReadNullTerminatedString(reader); currentModel.MaterialNames.Add(material); } }
private void ReadPolygonBlock(EndianBinaryReader reader, CModel model) { model.Polygons = new List<Polygon>(); int polygonCount = reader.ReadInt32(); for (int i = 0; i < polygonCount; i++) { UInt16 v1 = reader.ReadUInt16(); UInt16 v2 = reader.ReadUInt16(); UInt16 v3 = reader.ReadUInt16(); byte unk1 = reader.ReadByte(); byte unk2 = reader.ReadByte(); byte unk3 = reader.ReadByte(); Polygon polygon = new Polygon(v1, v2, v3); polygon.CalculateNormal(_models._vertexPositions, model.VertexBaseIndex); model.Polygons.Add(polygon); } }
public DatFile(string filename, bool deformMainModel) { if (filename.EndsWith(".ACT", StringComparison.InvariantCultureIgnoreCase)) filename = filename.ToUpper().Replace(".ACT", ".DAT"); //fix up some 3rd party vehicle weirdness CModel currentModel = null; Stream file = OpenDataFile(filename); if (!Exists) return; EndianBinaryReader reader = new EndianBinaryReader(EndianBitConverter.Big, file); while (true) { int type = reader.ReadInt32(); int size = 0; if (type != (int)BlockType.Null) size = reader.ReadInt32(); switch (type) { case (int)BlockType.Null: break; case (int)BlockType.ModelName: reader.Seek(2, SeekOrigin.Current); string name = ReadNullTerminatedString(reader); if (deformMainModel && Path.GetFileNameWithoutExtension(name).Equals(Path.GetFileNameWithoutExtension(filename), StringComparison.InvariantCultureIgnoreCase)) currentModel = new CDeformableModel(); else currentModel = new CModel(); currentModel.Name = name; _models.Add(currentModel); break; case (int)BlockType.Vertices: ReadVertexBlock(reader, currentModel); break; case (int)BlockType.Faces: ReadPolygonBlock(reader, currentModel); break; case (int)BlockType.TextureCoords: ReadTextureMapBlock(reader, currentModel); break; case (int)BlockType.Materials: ReadMaterialsBlock(reader, currentModel); break; case (int)BlockType.FaceMaterials: ReadFaceMaterialsBlock(reader, currentModel); break; default: Debug.WriteLine("Unknown section: " + type); reader.Seek(size, SeekOrigin.Current); break; } if (reader.BaseStream.Position == reader.BaseStream.Length) break; } reader.Close(); if (filename == "FAUST.DAT") { } _models.Resolve(true); }
public void device_set_discount_curve(double[] df_i, CModel model) { host_d_set_discount_curve(df_i); CArray.alloc(ref _device_ir_yi, _host_d_ir_yi.Length, EType.float_t, EMemorySpace.device, model, "device_ir_yi"); if (df_i != null) { CArray.alloc(ref _device_df_i, host_d_df_i.Length, EType.float_t, EMemorySpace.device, model, "device_df_i"); float[] fdf_i = new float[host_d_df_i.Length]; for (int i = 0; i < host_d_df_i.Length; i++) { fdf_i[i] = (float)host_d_df_i[i]; } CArray.copy(ref _device_df_i, fdf_i); } }
private void OkButton(object sender, RoutedEventArgs e) { long age = -1; long salary = -1; if (!String.IsNullOrWhiteSpace(nameBox.Text) && Int64.TryParse(ageBox.Text, out age) && Int64.TryParse(salaryBox.Text, out salary) && !String.IsNullOrWhiteSpace(phoneBox.Text)) { CModel user = new CModel { Name = nameBox.Text, Age = age, Salary = salary, Phone = phoneBox.Text }; App.dataBase.Insert(user); if (Frame.CanGoBack) Frame.GoBack(); } }