public void Group(object sender, EventArgs e) { if (_selectedObjs.Count > 1) { //需要排序,否则绘图的先后顺序会发生改变 int[] indexA = new int[_selectedObjs.Count]; for (int i = 0; i < indexA.Length; i++) { indexA[i] = Objs.IndexOf(_selectedObjs[i]); } Array.Sort(indexA); List <IDrawObj> groupL = indexA.Select(t => Objs[t]).ToList(); DrawGroup group = new DrawGroup(groupL); _nameManager.CreateName(group); group.Layer = DefaultLayer; group.LoadInitializationEvent(); foreach (IDrawObj obj in _selectedObjs) { Objs.Remove(obj); } Objs.Insert(indexA[0], group); _selectedObjs.Clear(); if (group.CanSelect()) { _selectedObjs.Add(group); } _controlPoint.ChangeSelectObj(_selectedObjs); Container.Invalidate(); } }
public IDrawObj CreateDrawObj(DrawType type) { //todo add control IDrawObj obj; switch (type) { case DrawType.Group: obj = new DrawGroup(); break; case DrawType.Combine: obj = new DrawCombine(); break; case DrawType.Rect: obj = new DrawRect(); break; case DrawType.Ellipse: obj = new DrawEllipse(); break; case DrawType.Text: obj = new DrawText(); break; case DrawType.StraightLine: obj = new DrawStraightLine(); break; case DrawType.FoldLine: obj = new DrawFoldLine(); break; case DrawType.Bezier: obj = new DrawBezier(); break; case DrawType.Polygon: obj = new DrawPolygon(); break; case DrawType.ClosedBezier: obj = new DrawClosedBezier(); break; default: return(null); } return(obj); }
public void RemoveName(IDrawObj obj) { _nameDict.Remove(obj.Name); if (obj.Type == DrawType.Group) { DrawGroup group = (DrawGroup)obj; foreach (IDrawObj o in group.ObjList) { RemoveName(o); } } }
/// <summary> /// 改变名称,用于控件粘贴 /// </summary> /// <param name="obj"></param> public void ChangeName(IDrawObj obj) { CreateName(obj); //drawgoup if (obj.Type == DrawType.Group) { DrawGroup group = (DrawGroup)obj; foreach (IDrawObj o in group.ObjList) { ChangeName(o); } } }
private void AddName(IDrawObj obj) { if (!string.IsNullOrWhiteSpace(obj.Name)) { _nameDict.Add(obj.Name, null); } if (obj.Type == DrawType.Group) { DrawGroup group = (DrawGroup)obj; foreach (IDrawObj o in group.ObjList) { AddName(o); } } }
/// <summary> /// 创建并加载点云 /// </summary> /// <returns></returns> IRenderModelPoint CreatePointCloud() { //准备容器 IModel model = new ResourceFactory().CreateModel(); IDrawGroup drawGroup = new DrawGroup(); IDrawPrimitive drawPrimitive = new DrawPrimitive(); IFloatArray verList = new FloatArray(); //点集 IUInt32Array colorList = new UInt32Array(); //点色 //点坐标 float x = 3.3f, y = 4.4f, z = 5.5f; //点色 byte a = 128, r = 255, g = 255, b = 255; uint col = (uint)(b | g << 8 | r << 16 | a << 24); //argb => uint for (int i = 0; i < 10; i++) { verList.Append(x); verList.Append(y); verList.Append(z); colorList.Append(col); } //塞入容器 drawPrimitive.VertexArray = verList; drawPrimitive.ColorArray = colorList; drawPrimitive.Material.EnableBlend = false; //关闭融合 drawPrimitive.Material.EnableLight = false; //关闭光照 drawPrimitive.PrimitiveMode = gviPrimitiveMode.gviPrimitiveModeLineList; //设置绘制模式为点 drawGroup.AddPrimitive(drawPrimitive); //塞入渲染组 model.AddGroup(drawGroup); //塞入model axRenderControl.ObjectManager.AddModel("modelName", model); //塞入三维对象,与modelPoint通过名称匹配 //创建modelPoint,用于索引模型 IModelPoint mp = (IModelPoint) new GeometryFactory().CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ); mp.SpatialCRS = (SpatialCRS)CRSFactory.CreateFromWKT("wkt"); //设置坐标系 mp.ModelEnvelope = model.Envelope; // 排除不显示BUG mp.SetCoords(3.3, 4.4, 5.5, 0, 0); mp.ModelName = "modelName"; //匹配模型 return(axRenderControl.ObjectManager.CreateRenderModelPoint(mp, null, Guid.Empty)); //创建完成 }
/// <summary> /// User clicked on a different SPR2 or DGRP chunk. /// </summary> private void LstSPR2s_SelectedValueChanged(object sender, EventArgs e) { if (RdiSPR.Checked) { m_CurrentSPR = m_CurrentArchive.SPRs[LstSPR2s.SelectedIndex]; PictCurrentFrame.Image = m_CurrentSPR.GetFrame(0).BitmapData.BitMap; m_CurrentSPRFrame = 0; } else if (RdiSpr2.Checked) { m_CurrentSPR2 = m_CurrentArchive.SPR2s[LstSPR2s.SelectedIndex]; PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(0).BitmapData.BitMap; m_CurrentSPR2Frame = 0; } else if (RdiDgrp.Checked) { m_CurrentGroup = m_CurrentArchive.DrawGroups[LstSPR2s.SelectedIndex]; PictCurrentFrame.Image = m_CurrentGroup.GetImage(0).CompiledBitmap; m_CurrentGroupFrame = 0; } }
public void UnGroup(object sender, EventArgs e) { DrawGroup group = null; foreach (IDrawObj obj in _selectedObjs) { if (obj.Type != DrawType.Group) { continue; } group = (DrawGroup)obj; group.Ungroup(); int index = Objs.IndexOf(group); Objs.Remove(group); Objs.InsertRange(index, group.ObjList); } if (group != null) { //去除锁定的控件 int count = group.ObjList.Count; for (int i = count - 1; i >= 0; i--) { IDrawObj obj = group.ObjList[i]; if (!group.ObjList[i].CanSelect()) { group.ObjList.Remove(obj); } } _selectedObjs.Clear(); _selectedObjs.AddRange(group.ObjList); _controlPoint.ChangeSelectObj(_selectedObjs); Container.Invalidate(); } }
/// <summary> /// User clicked on the list of sprites. /// </summary> private void LstSPR2s_Click(object sender, EventArgs e) { if (m_CurrentArchive != null) { if (RdiSPR.Checked) { string Caption = (string)LstSPR2s.SelectedItem; int ID = 0; string Name = ""; if (Caption.Contains("ID: ")) { ID = int.Parse(Caption.Replace("ID: ", "")); } else { Name = Caption.Replace("Name: ", ""); } foreach (SPRParser Sprite in m_CurrentArchive.SPRs) { if (ID != 0) { if (Sprite.ID == ID) { m_CurrentSPR = Sprite; PictCurrentFrame.Image = m_CurrentSPR.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap; break; } } else { if (Sprite.NameString == Name) { m_CurrentSPR = Sprite; PictCurrentFrame.Image = m_CurrentSPR.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap; break; } } } } else if (RdiSpr2.Checked) { string Caption = (string)LstSPR2s.SelectedItem; int ID = 0; string Name = ""; if (Caption.Contains("ID: ")) { ID = int.Parse(Caption.Replace("ID: ", "")); } else { Name = Caption.Replace("Name: ", ""); } foreach (SPR2Parser Sprite in m_CurrentArchive.SPR2s) { if (ID != 0) { if (Sprite.ID == ID) { m_CurrentSPR2 = Sprite; PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap; break; } } else { if (Sprite.NameString == Name) { m_CurrentSPR2 = Sprite; PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap; break; } } } } else if (RdiStr.Checked) { if (m_CurrentArchive.StringTables.Count > 0) { string Str = (string)LstSPR2s.SelectedItem; Str = Str.Replace("String: ", ""); Str = Str.Replace("String2: ", ""); MessageBox.Show(Str); } } else if (RdiBhavs.Checked) { if (m_CurrentArchive.BHAVs.Count > 0) { BHAVEdit Editor = new BHAVEdit(m_CurrentArchive, m_CurrentArchive.BHAVs[LstSPR2s.SelectedIndex]); Editor.Show(); } } else if (RdiDgrp.Checked) { string Caption = (string)LstSPR2s.SelectedItem; int ID = 0; string Name = ""; if (Caption.Contains("ID: ")) { ID = int.Parse(Caption.Replace("ID: ", "")); } else { Name = Caption.Replace("Name: ", ""); } foreach (DrawGroup DGRP in m_CurrentArchive.DrawGroups) { if (ID != 0) { if (DGRP.ID == ID) { m_CurrentGroup = DGRP; if (m_CurrentGroupFrame < m_CurrentGroup.ImageCount) { PictCurrentFrame.Image = m_CurrentGroup.GetImage(m_CurrentGroupFrame).CompiledBitmap; } else { m_CurrentGroupFrame = m_CurrentGroup.ImageCount - 1; PictCurrentFrame.Image = m_CurrentGroup.GetImage(m_CurrentGroupFrame).CompiledBitmap; } break; } } else { if (DGRP.NameString == Name) { m_CurrentGroup = DGRP; if (m_CurrentGroupFrame < m_CurrentGroup.ImageCount) { PictCurrentFrame.Image = m_CurrentGroup.GetImage(m_CurrentGroupFrame).CompiledBitmap; } else { m_CurrentGroupFrame = m_CurrentGroup.ImageCount - 1; PictCurrentFrame.Image = m_CurrentGroup.GetImage(m_CurrentGroupFrame).CompiledBitmap; } break; } } } } } }
/// <summary> /// User clicked on the button to view the next frame in a SPR2 or DGRP chunk. /// </summary> private void BtnNextFrame_Click(object sender, EventArgs e) { if (m_CurrentArchive != null) { if (RdiSPR.Checked) { m_CurrentSPRFrame++; if (m_CurrentArchive.SPRs.Count > 0) { if (m_CurrentSPRFrame < m_CurrentSPR.FrameCount) { if (m_CurrentSPR.FrameCount > 0) { PictCurrentFrame.Image = m_CurrentSPR.GetFrame(m_CurrentSPRFrame).BitmapData.BitMap; } else if (m_CurrentSPR2Frame < 0) { m_CurrentSPRFrame = 0; } } else if (m_CurrentSPRFrame > m_CurrentSPR.FrameCount) { m_CurrentSPRFrame = (int)m_CurrentSPR.FrameCount - 1; } } } else if (RdiSpr2.Checked) { m_CurrentSPR2Frame++; if (!ChkZBuffer.Checked) { if (m_CurrentArchive.SPR2s.Count > 0) { if (m_CurrentSPR2Frame < m_CurrentSPR2.FrameCount) { if (m_CurrentSPR2.FrameCount > 0) { PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap; } else if (m_CurrentSPR2Frame < 0) { m_CurrentSPR2Frame = 0; } } else if (m_CurrentSPR2Frame < 0) { m_CurrentSPR2Frame = 0; } else if (m_CurrentSPR2Frame > m_CurrentSPR2.FrameCount) { m_CurrentSPR2Frame = (int)m_CurrentSPR2.FrameCount - 1; } } } else { if (m_CurrentArchive.SPR2s.Count > 0) { if (m_CurrentSPR2Frame < m_CurrentSPR2.FrameCount) { if (m_CurrentSPR2.FrameCount > 0) { if (m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).HasZBuffer) { PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).ZBuffer.BitMap; } else { PictCurrentFrame.Image = m_CurrentSPR2.GetFrame(m_CurrentSPR2Frame).BitmapData.BitMap; } } else if (m_CurrentSPR2Frame < 0) { m_CurrentSPR2Frame = 0; } } else if (m_CurrentSPR2Frame < 0) { m_CurrentSPR2Frame = 0; } else if (m_CurrentSPR2Frame > m_CurrentSPR2.FrameCount) { m_CurrentSPR2Frame = (int)m_CurrentSPR2.FrameCount - 1; } } } } else if (RdiDgrp.Checked) { m_CurrentGroupFrame++; if (m_CurrentArchive.DrawGroups.Count > 0) { if (m_CurrentGroup == null) { if (LstSPR2s.SelectedIndex < m_CurrentArchive.DrawGroups.Count) { m_CurrentGroup = m_CurrentArchive.DrawGroups[LstSPR2s.SelectedIndex]; } else { m_CurrentGroup = m_CurrentArchive.DrawGroups[m_CurrentArchive.DrawGroups.Count - 1]; } } if (m_CurrentGroupFrame < m_CurrentGroup.ImageCount && m_CurrentGroup.ImageCount > 0) { PictCurrentFrame.Image = m_CurrentGroup.GetImage(m_CurrentGroupFrame).CompiledBitmap; } else if (m_CurrentGroupFrame < 0) { m_CurrentGroupFrame = 0; } } else if (m_CurrentGroupFrame < 0) { m_CurrentGroupFrame = 0; } else if (m_CurrentGroupFrame > m_CurrentGroup.ImageCount) { m_CurrentGroupFrame = (int)m_CurrentGroup.ImageCount - 1; } } } }
public void Add(DrawGroup group) { this.Models.Add(group); }
public void ProcessDGRPs() { List<IffChunk> DGRPs = new List<IffChunk>(); foreach (IffChunk Chunk in m_Chunks) { if (Chunk.Type == "DGRP") DGRPs.Add(Chunk); } foreach (IffChunk Chunk in DGRPs) { BinaryReader ChunkReader = new BinaryReader(new MemoryStream(Chunk.Data)); DrawGroup DGRP = new DrawGroup(); DGRP.Version = ChunkReader.ReadInt16(); if (DGRP.Version == 20000 || DGRP.Version == 20001) { DGRP.Count = Convert.ToInt32(ChunkReader.ReadBytes(2)); for (int i = 0; i < DGRP.Count; i++) { DGRPImg Img = new DGRPImg(); Img.SpriteInfoCount = Convert.ToInt32(ChunkReader.ReadBytes(2)); Img.DirFlags = ChunkReader.ReadByte(); Img.ZoomFactor = ChunkReader.ReadByte(); for (int j = 0; j < Img.SpriteInfoCount; j++) { SpriteInfo SInfo = new SpriteInfo(); SInfo.Tag = ChunkReader.ReadInt16(); SInfo.SprID = Convert.ToInt32(ChunkReader.ReadBytes(2)); SInfo.SprFrame = Convert.ToInt32(ChunkReader.ReadBytes(2)); SInfo.Flags = Convert.ToInt32(ChunkReader.ReadBytes(2)); SInfo.PixelX = Convert.ToInt32(ChunkReader.ReadBytes(2)); SInfo.PixelY = Convert.ToInt32(ChunkReader.ReadBytes(2)); if (DGRP.Version == 20001) SInfo.ZOffset = ChunkReader.ReadInt32(); SInfo.Sprite = new SPR2(); IffChunk TmpChunk = new IffChunk(); foreach (IffChunk C in m_Chunks) { if (C.TypeNum == SInfo.SprID) { if (C.Type == "SPR2") { TmpChunk = C; break; } } } BinaryReader SpriteReader = new BinaryReader(new MemoryStream(TmpChunk.Data)); SInfo.Sprite.Version1 = SpriteReader.ReadInt16(); if (SInfo.Sprite.Version1 == 0) SInfo.Sprite.Version2 = ReadBigShort(SpriteReader); else SInfo.Sprite.Version2 = SpriteReader.ReadInt16(); SInfo.Sprite.FrameCount = SpriteReader.ReadInt32(); SInfo.Sprite.PaletteID = SpriteReader.ReadInt32(); SInfo.Sprite.OffsetTable = new int[SInfo.Sprite.FrameCount]; for (int k = 0; k < SInfo.Sprite.FrameCount; k++) SInfo.Sprite.OffsetTable[k] = SpriteReader.ReadInt32(); for (int k = 0; k < SInfo.Sprite.FrameCount; k++) { SpriteFrame Frame = new SpriteFrame(); Frame.Width = SpriteReader.ReadInt16(); Frame.Height = SpriteReader.ReadInt16(); Frame.Flags = SpriteReader.ReadInt16(); Frame.Unknown = SpriteReader.ReadInt16(); Frame.PaletteID = SpriteReader.ReadInt16(); Frame.TransparentPixel = SpriteReader.ReadInt16(); Frame.XPos = SpriteReader.ReadInt16(); Frame.YPos = SpriteReader.ReadInt16(); BinaryWriter SpriteWriter = new BinaryWriter(Frame.SpriteData); for (int l = 0; l <= Frame.Height; l++) { SpriteWriter.Write(SpriteReader.ReadBytes(2)); SpriteWriter.Write(SpriteReader.ReadBytes(Frame.Width)); } SInfo.Sprite.AddFrame(Frame); SpriteWriter.Close(); } SpriteReader.Close(); //Each SPR2 resource contains a reference to a PALT chunk/resource. SInfo.Sprite.Pal = new Palette(); foreach (IffChunk C in m_Chunks) { if (C.TypeNum == SInfo.Sprite.PaletteID) { //Guess what? The typenumber of each chunk is //NOT unique, so you have to check on type as //well! if (C.Type == "PALT") { TmpChunk = C; break; } } } BinaryReader PaltReader = new BinaryReader(new MemoryStream(TmpChunk.Data)); SInfo.Sprite.Pal.AlwaysOne = PaltReader.ReadInt32(); SInfo.Sprite.Pal.Always256 = PaltReader.ReadInt32(); PaltReader.ReadBytes(8); //The PALT header has 8 additional bytes of 0. SInfo.Sprite.Pal.RGBTable = new Palette.RGB[SInfo.Sprite.Pal.Always256]; for (int l = 0; l < SInfo.Sprite.Pal.Always256; l++) { SInfo.Sprite.Pal.RGBTable[l] = new Palette.RGB(); SInfo.Sprite.Pal.RGBTable[l].Red = PaltReader.ReadByte(); SInfo.Sprite.Pal.RGBTable[l].Green = PaltReader.ReadByte(); SInfo.Sprite.Pal.RGBTable[l].Blue = PaltReader.ReadByte(); } PaltReader.Close(); Img.AddSpriteInfo(SInfo); } DGRP.AddImage(Img); } } else if (DGRP.Version == 20003 || DGRP.Version == 20004) { DGRP.Count = ChunkReader.ReadInt32(); for (int i = 0; i < DGRP.Count; i++) { DGRPImg Img = new DGRPImg(); Img.DirFlags = ChunkReader.ReadInt32(); Img.ZoomFactor = ChunkReader.ReadInt32(); Img.SpriteInfoCount = ChunkReader.ReadInt32(); //Each DrawGroup Image contains a number of SpriteInfo resources. for (int j = 0; j < Img.SpriteInfoCount; j++) { SpriteInfo SInfo = new SpriteInfo(); SInfo.SprID = ChunkReader.ReadInt32(); SInfo.SprFrame = ChunkReader.ReadInt32(); SInfo.PixelX = ChunkReader.ReadInt32(); SInfo.PixelY = ChunkReader.ReadInt32(); SInfo.ZOffset = ChunkReader.ReadInt32(); SInfo.Flags = ChunkReader.ReadInt32(); SInfo.XOffset = ChunkReader.ReadInt32(); SInfo.YOffset = ChunkReader.ReadInt32(); //Each SpriteInfo resource contains a reference to a SPR2 chunk/resource. SInfo.Sprite = new SPR2(); IffChunk TmpChunk = new IffChunk(); foreach (IffChunk C in m_Chunks) { if (C.TypeNum == SInfo.SprID) { //Guess what? The typenumber of each chunk is //NOT unique, so you have to check on type as //well! if (C.Type == "SPR2") { TmpChunk = C; break; } } } BinaryReader SpriteReader = new BinaryReader(new MemoryStream(TmpChunk.Data)); SInfo.Sprite.Version1 = SpriteReader.ReadInt16(); if (SInfo.Sprite.Version1 == 0) SInfo.Sprite.Version2 = ReadBigShort(SpriteReader); else SInfo.Sprite.Version2 = SpriteReader.ReadInt16(); SInfo.Sprite.FrameCount = SpriteReader.ReadInt32(); SInfo.Sprite.PaletteID = SpriteReader.ReadInt32(); SInfo.Sprite.OffsetTable = new int[SInfo.Sprite.FrameCount]; for (int k = 0; k < SInfo.Sprite.FrameCount; k++) SInfo.Sprite.OffsetTable[k] = SpriteReader.ReadInt32(); for (int k = 0; k < SInfo.Sprite.FrameCount; k++) { SpriteFrame Frame = new SpriteFrame(); Frame.Width = ReadBigShort(SpriteReader); MessageBox.Show("Frame.Width: " + Frame.Width.ToString()); Frame.Height = ReadBigShort(SpriteReader); MessageBox.Show("Frame.Height: " + Frame.Height.ToString()); Frame.Flags = SpriteReader.ReadInt16(); Frame.Unknown = ReadBigShort(SpriteReader); MessageBox.Show("Unknown: " + Frame.Unknown.ToString()); Frame.PaletteID = SpriteReader.ReadInt16(); Frame.TransparentPixel = SpriteReader.ReadInt16(); Frame.XPos = SpriteReader.ReadInt16(); Frame.YPos = SpriteReader.ReadInt16(); BinaryWriter SpriteWriter = new BinaryWriter(Frame.SpriteData); for (int l = 0; l <= Frame.Height; l++) { SpriteWriter.Write(SpriteReader.ReadBytes(2)); SpriteWriter.Write(SpriteReader.ReadBytes(Frame.Width)); } SInfo.Sprite.AddFrame(Frame); SpriteWriter.Close(); } SpriteReader.Close(); //Each SPR2 resource contains a reference to a PALT chunk/resource. SInfo.Sprite.Pal = new Palette(); foreach (IffChunk C in m_Chunks) { if (C.TypeNum == SInfo.Sprite.PaletteID) { //Guess what? The typenumber of each chunk is //NOT unique, so you have to check on type as //well! if (C.Type == "PALT") { TmpChunk = C; break; } } } BinaryReader PaltReader = new BinaryReader(new MemoryStream(TmpChunk.Data)); SInfo.Sprite.Pal.AlwaysOne = PaltReader.ReadInt32(); SInfo.Sprite.Pal.Always256 = PaltReader.ReadInt32(); PaltReader.ReadBytes(8); //The PALT header has 8 additional bytes of 0. SInfo.Sprite.Pal.RGBTable = new Palette.RGB[SInfo.Sprite.Pal.Always256]; for (int l = 0; l < SInfo.Sprite.Pal.Always256; l++) { SInfo.Sprite.Pal.RGBTable[l] = new Palette.RGB(); SInfo.Sprite.Pal.RGBTable[l].Red = PaltReader.ReadByte(); SInfo.Sprite.Pal.RGBTable[l].Green = PaltReader.ReadByte(); SInfo.Sprite.Pal.RGBTable[l].Blue = PaltReader.ReadByte(); } PaltReader.Close(); Img.AddSpriteInfo(SInfo); } DGRP.AddImage(Img); } } m_DGRPs.Add(DGRP); } }
/// <summary> /// 参数化建模 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDriveModel_Click(object sender, System.EventArgs e) { try { if (polyline != null) { center = polyline.Envelope.Center; IModelPoint mp = new GeometryFactory().CreateGeometry(gviGeometryType.gviGeometryModelPoint, gviVertexAttribute.gviVertexAttributeZ) as IModelPoint; mp.SpatialCRS = datasetCRS; mp.Position = center; IModel model = new ResourceFactory().CreateModel(); IDrawGroup group = new DrawGroup(); IDrawPrimitive primitive = new DrawPrimitive(); IDrawMaterial material = new DrawMaterial(); material.TextureName = (strMediaPath + @"\shp\road\textrure.jpg"); material.CullMode = gviCullFaceMode.gviCullNone; material.WrapModeS = gviTextureWrapMode.gviTextureWrapRepeat; material.WrapModeT = gviTextureWrapMode.gviTextureWrapRepeat; IFloatArray va = new FloatArray(); IFloatArray ta = new FloatArray(); // 逐点外扩 for (int i = 0; i < polyline.PointCount; i++) { #region 单独处理最后一个点 if (i == polyline.PointCount - 1) { curPoint = polyline.GetPoint(i); vecCurPos = curPoint.Position; // 最后一个点重用最后的方向向量 vecTarget = vecDirect.CrossProduct(vecZ); vecTarget.Normalize(); vecTarget.MultiplyByScalar(width / 2); vecP = vecCurPos.Add(vecTarget); vecTarget.MultiplyByScalar(-1); vecQ = vecCurPos.Add(vecTarget); // 设置外扩点 P = curPoint.Clone() as IPoint; P.Position = vecP; Q = curPoint.Clone() as IPoint; Q.Position = vecQ; // 把点坐标加进顶点数组 va.Append((float)(vecP.X - center.X)); va.Append((float)(vecP.Y - center.Y)); va.Append((float)(vecP.Z - center.Z)); va.Append((float)(vecQ.X - center.X)); va.Append((float)(vecQ.Y - center.Y)); va.Append((float)(vecQ.Z - center.Z)); // 加纹理坐标 ta.Append(0); //P点纹理 if (i == 0) { lastV = 0.0; } else { lastV = lastV + length / 10; //v方向上每隔10米重复一次 } ta.Append((float)lastV); ta.Append(1); //Q点纹理 ta.Append((float)lastV); { ISimplePointSymbol ps = new SimplePointSymbol(); ps.FillColor = System.Drawing.Color.Yellow; ps.Size = 5; rPointToDelList.Add(this.axRenderControl1.ObjectManager.CreateRenderPoint(P, ps, rootId)); rPointToDelList.Add(this.axRenderControl1.ObjectManager.CreateRenderPoint(Q, ps, rootId)); } break; } #endregion // 当不是最后一个点时: curPoint = polyline.GetPoint(i); nextPoint = polyline.GetPoint(i + 1); vecCurPos = curPoint.Position; vecNextPos = nextPoint.Position; // 运算 vecNextPos.MultiplyByScalar(-1); vecDirect = vecCurPos.Add(vecNextPos); //方向向量 vecZ.Set(0, 0, 1); vecTarget = vecDirect.CrossProduct(vecZ); vecTarget.Normalize(); vecTarget.MultiplyByScalar(width / 2); vecP = vecCurPos.Add(vecTarget); vecTarget.MultiplyByScalar(-1); vecQ = vecCurPos.Add(vecTarget); // 设置外扩点 P = curPoint.Clone() as IPoint; P.Position = vecP; Q = curPoint.Clone() as IPoint; Q.Position = vecQ; // 把点坐标加进顶点数组 va.Append((float)(vecP.X - center.X)); va.Append((float)(vecP.Y - center.Y)); va.Append((float)(vecP.Z - center.Z)); va.Append((float)(vecQ.X - center.X)); va.Append((float)(vecQ.Y - center.Y)); va.Append((float)(vecQ.Z - center.Z)); // 加纹理坐标 ta.Append(0); //P点纹理 if (i == 0) { lastV = 0.0; } else { lastV = lastV + length / 5; //v方向上每隔10米重复一次 } length = vecDirect.Length; //计算长度给奇数点用 ta.Append((float)lastV); ta.Append(1); //Q点纹理 ta.Append((float)lastV); { ISimplePointSymbol ps = new SimplePointSymbol(); ps.FillColor = System.Drawing.Color.Yellow; ps.Size = 5; rPointToDelList.Add(this.axRenderControl1.ObjectManager.CreateRenderPoint(P, ps, rootId)); rPointToDelList.Add(this.axRenderControl1.ObjectManager.CreateRenderPoint(Q, ps, rootId)); } } // 计算索引坐标 IUInt16Array ia = new UInt16Array(); for (int i = 0; i < va.Length / 6 - 1; i++) { ia.Append((ushort)(2 * i)); ia.Append((ushort)(2 * i + 1)); ia.Append((ushort)(2 * i + 2)); ia.Append((ushort)(2 * i + 1)); ia.Append((ushort)(2 * i + 3)); ia.Append((ushort)(2 * i + 2)); } primitive.VertexArray = va; primitive.TexcoordArray = ta; primitive.IndexArray = ia; primitive.Material = material; group.AddPrimitive(primitive); model.AddGroup(group); // 在内存中临时存储模型 string modelName = fid.ToString(); this.axRenderControl1.ObjectManager.AddModel(modelName, model); mp.ModelName = modelName; mp.ModelEnvelope = model.Envelope; // 可视化临时模型 IRenderModelPoint rmp = this.axRenderControl1.ObjectManager.CreateRenderModelPoint(mp, null, rootId); rmp.MaxVisibleDistance = 100000; rmp.MouseSelectMask = gviViewportMask.gviViewNone; rModelpointToDelList.Add(rmp); } } catch (System.Exception ex) { if (ex.GetType().Name.Equals("UnauthorizedAccessException")) { MessageBox.Show("需要标准runtime授权"); } else { MessageBox.Show(ex.Message); } } }
public void ProcessDGRPs() { List <IffChunk> DGRPs = new List <IffChunk>(); foreach (IffChunk Chunk in m_Chunks) { if (Chunk.Type == "DGRP") { DGRPs.Add(Chunk); } } foreach (IffChunk Chunk in DGRPs) { BinaryReader ChunkReader = new BinaryReader(new MemoryStream(Chunk.Data)); DrawGroup DGRP = new DrawGroup(); DGRP.Version = ChunkReader.ReadInt16(); if (DGRP.Version == 20000 || DGRP.Version == 20001) { DGRP.Count = Convert.ToInt32(ChunkReader.ReadBytes(2)); for (int i = 0; i < DGRP.Count; i++) { DGRPImg Img = new DGRPImg(); Img.SpriteInfoCount = Convert.ToInt32(ChunkReader.ReadBytes(2)); Img.DirFlags = ChunkReader.ReadByte(); Img.ZoomFactor = ChunkReader.ReadByte(); for (int j = 0; j < Img.SpriteInfoCount; j++) { SpriteInfo SInfo = new SpriteInfo(); SInfo.Tag = ChunkReader.ReadInt16(); SInfo.SprID = Convert.ToInt32(ChunkReader.ReadBytes(2)); SInfo.SprFrame = Convert.ToInt32(ChunkReader.ReadBytes(2)); SInfo.Flags = Convert.ToInt32(ChunkReader.ReadBytes(2)); SInfo.PixelX = Convert.ToInt32(ChunkReader.ReadBytes(2)); SInfo.PixelY = Convert.ToInt32(ChunkReader.ReadBytes(2)); if (DGRP.Version == 20001) { SInfo.ZOffset = ChunkReader.ReadInt32(); } SInfo.Sprite = new SPR2(); IffChunk TmpChunk = new IffChunk(); foreach (IffChunk C in m_Chunks) { if (C.TypeNum == SInfo.SprID) { if (C.Type == "SPR2") { TmpChunk = C; break; } } } BinaryReader SpriteReader = new BinaryReader(new MemoryStream(TmpChunk.Data)); SInfo.Sprite.Version1 = SpriteReader.ReadInt16(); if (SInfo.Sprite.Version1 == 0) { SInfo.Sprite.Version2 = ReadBigShort(SpriteReader); } else { SInfo.Sprite.Version2 = SpriteReader.ReadInt16(); } SInfo.Sprite.FrameCount = SpriteReader.ReadInt32(); SInfo.Sprite.PaletteID = SpriteReader.ReadInt32(); SInfo.Sprite.OffsetTable = new int[SInfo.Sprite.FrameCount]; for (int k = 0; k < SInfo.Sprite.FrameCount; k++) { SInfo.Sprite.OffsetTable[k] = SpriteReader.ReadInt32(); } for (int k = 0; k < SInfo.Sprite.FrameCount; k++) { SpriteFrame Frame = new SpriteFrame(); Frame.Width = SpriteReader.ReadInt16(); Frame.Height = SpriteReader.ReadInt16(); Frame.Flags = SpriteReader.ReadInt16(); Frame.Unknown = SpriteReader.ReadInt16(); Frame.PaletteID = SpriteReader.ReadInt16(); Frame.TransparentPixel = SpriteReader.ReadInt16(); Frame.XPos = SpriteReader.ReadInt16(); Frame.YPos = SpriteReader.ReadInt16(); BinaryWriter SpriteWriter = new BinaryWriter(Frame.SpriteData); for (int l = 0; l <= Frame.Height; l++) { SpriteWriter.Write(SpriteReader.ReadBytes(2)); SpriteWriter.Write(SpriteReader.ReadBytes(Frame.Width)); } SInfo.Sprite.AddFrame(Frame); SpriteWriter.Close(); } SpriteReader.Close(); //Each SPR2 resource contains a reference to a PALT chunk/resource. SInfo.Sprite.Pal = new Palette(); foreach (IffChunk C in m_Chunks) { if (C.TypeNum == SInfo.Sprite.PaletteID) { //Guess what? The typenumber of each chunk is //NOT unique, so you have to check on type as //well! if (C.Type == "PALT") { TmpChunk = C; break; } } } BinaryReader PaltReader = new BinaryReader(new MemoryStream(TmpChunk.Data)); SInfo.Sprite.Pal.AlwaysOne = PaltReader.ReadInt32(); SInfo.Sprite.Pal.Always256 = PaltReader.ReadInt32(); PaltReader.ReadBytes(8); //The PALT header has 8 additional bytes of 0. SInfo.Sprite.Pal.RGBTable = new Palette.RGB[SInfo.Sprite.Pal.Always256]; for (int l = 0; l < SInfo.Sprite.Pal.Always256; l++) { SInfo.Sprite.Pal.RGBTable[l] = new Palette.RGB(); SInfo.Sprite.Pal.RGBTable[l].Red = PaltReader.ReadByte(); SInfo.Sprite.Pal.RGBTable[l].Green = PaltReader.ReadByte(); SInfo.Sprite.Pal.RGBTable[l].Blue = PaltReader.ReadByte(); } PaltReader.Close(); Img.AddSpriteInfo(SInfo); } DGRP.AddImage(Img); } } else if (DGRP.Version == 20003 || DGRP.Version == 20004) { DGRP.Count = ChunkReader.ReadInt32(); for (int i = 0; i < DGRP.Count; i++) { DGRPImg Img = new DGRPImg(); Img.DirFlags = ChunkReader.ReadInt32(); Img.ZoomFactor = ChunkReader.ReadInt32(); Img.SpriteInfoCount = ChunkReader.ReadInt32(); //Each DrawGroup Image contains a number of SpriteInfo resources. for (int j = 0; j < Img.SpriteInfoCount; j++) { SpriteInfo SInfo = new SpriteInfo(); SInfo.SprID = ChunkReader.ReadInt32(); SInfo.SprFrame = ChunkReader.ReadInt32(); SInfo.PixelX = ChunkReader.ReadInt32(); SInfo.PixelY = ChunkReader.ReadInt32(); SInfo.ZOffset = ChunkReader.ReadInt32(); SInfo.Flags = ChunkReader.ReadInt32(); SInfo.XOffset = ChunkReader.ReadInt32(); SInfo.YOffset = ChunkReader.ReadInt32(); //Each SpriteInfo resource contains a reference to a SPR2 chunk/resource. SInfo.Sprite = new SPR2(); IffChunk TmpChunk = new IffChunk(); foreach (IffChunk C in m_Chunks) { if (C.TypeNum == SInfo.SprID) { //Guess what? The typenumber of each chunk is //NOT unique, so you have to check on type as //well! if (C.Type == "SPR2") { TmpChunk = C; break; } } } BinaryReader SpriteReader = new BinaryReader(new MemoryStream(TmpChunk.Data)); SInfo.Sprite.Version1 = SpriteReader.ReadInt16(); if (SInfo.Sprite.Version1 == 0) { SInfo.Sprite.Version2 = ReadBigShort(SpriteReader); } else { SInfo.Sprite.Version2 = SpriteReader.ReadInt16(); } SInfo.Sprite.FrameCount = SpriteReader.ReadInt32(); SInfo.Sprite.PaletteID = SpriteReader.ReadInt32(); SInfo.Sprite.OffsetTable = new int[SInfo.Sprite.FrameCount]; for (int k = 0; k < SInfo.Sprite.FrameCount; k++) { SInfo.Sprite.OffsetTable[k] = SpriteReader.ReadInt32(); } for (int k = 0; k < SInfo.Sprite.FrameCount; k++) { SpriteFrame Frame = new SpriteFrame(); Frame.Width = ReadBigShort(SpriteReader); MessageBox.Show("Frame.Width: " + Frame.Width.ToString()); Frame.Height = ReadBigShort(SpriteReader); MessageBox.Show("Frame.Height: " + Frame.Height.ToString()); Frame.Flags = SpriteReader.ReadInt16(); Frame.Unknown = ReadBigShort(SpriteReader); MessageBox.Show("Unknown: " + Frame.Unknown.ToString()); Frame.PaletteID = SpriteReader.ReadInt16(); Frame.TransparentPixel = SpriteReader.ReadInt16(); Frame.XPos = SpriteReader.ReadInt16(); Frame.YPos = SpriteReader.ReadInt16(); BinaryWriter SpriteWriter = new BinaryWriter(Frame.SpriteData); for (int l = 0; l <= Frame.Height; l++) { SpriteWriter.Write(SpriteReader.ReadBytes(2)); SpriteWriter.Write(SpriteReader.ReadBytes(Frame.Width)); } SInfo.Sprite.AddFrame(Frame); SpriteWriter.Close(); } SpriteReader.Close(); //Each SPR2 resource contains a reference to a PALT chunk/resource. SInfo.Sprite.Pal = new Palette(); foreach (IffChunk C in m_Chunks) { if (C.TypeNum == SInfo.Sprite.PaletteID) { //Guess what? The typenumber of each chunk is //NOT unique, so you have to check on type as //well! if (C.Type == "PALT") { TmpChunk = C; break; } } } BinaryReader PaltReader = new BinaryReader(new MemoryStream(TmpChunk.Data)); SInfo.Sprite.Pal.AlwaysOne = PaltReader.ReadInt32(); SInfo.Sprite.Pal.Always256 = PaltReader.ReadInt32(); PaltReader.ReadBytes(8); //The PALT header has 8 additional bytes of 0. SInfo.Sprite.Pal.RGBTable = new Palette.RGB[SInfo.Sprite.Pal.Always256]; for (int l = 0; l < SInfo.Sprite.Pal.Always256; l++) { SInfo.Sprite.Pal.RGBTable[l] = new Palette.RGB(); SInfo.Sprite.Pal.RGBTable[l].Red = PaltReader.ReadByte(); SInfo.Sprite.Pal.RGBTable[l].Green = PaltReader.ReadByte(); SInfo.Sprite.Pal.RGBTable[l].Blue = PaltReader.ReadByte(); } PaltReader.Close(); Img.AddSpriteInfo(SInfo); } DGRP.AddImage(Img); } } m_DGRPs.Add(DGRP); } }
public static bool IsShadowInteractable(DrawGroup model) { return((model.Flags & ModelFlags.CastsShadows) == ModelFlags.CastsShadows || (model.Flags & ModelFlags.ReceivesShadows) == ModelFlags.ReceivesShadows); }
public static bool IsDiffuse(DrawGroup model) { return((model.Flags & ModelFlags.Diffuse) == ModelFlags.Diffuse); }
public static bool IsSkybox(DrawGroup model) { return((model.Flags & ModelFlags.IsSkybox) == ModelFlags.IsSkybox); }
public static bool IsTransparent(DrawGroup model) { return((model.Flags & ModelFlags.IsTransparent) == ModelFlags.IsTransparent); }
public static bool IsDebugviz(DrawGroup model) { return((model.Flags & ModelFlags.DebugViz) == ModelFlags.DebugViz); }
public static bool IsWireframe(DrawGroup model) { return((model.Flags & ModelFlags.Wireframe) == ModelFlags.Wireframe); }
private IModel CreateModel(float lenght, float width, float height, uint color) { IModel model = new ResourceFactory().CreateModel(); IDrawGroup group = new DrawGroup(); IDrawPrimitive primitive = new DrawPrimitive(); IFloatArray vertexArray = new FloatArray(); IFloatArray textureArray = new FloatArray(); IUInt32Array colorArray = new UInt32Array(); #region //顶点数组3个为一组(三角面1) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(0.0f); //顶点数组3个为一组(三角面2) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); //顶点数组3个为一组(三角面3) vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); //顶点数组3个为一组(三角面4) vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); //顶点数组3个为一组(三角面5) vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); //顶点数组3个为一组(三角面6) vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); //顶点数组3个为一组(三角面7) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); //顶点数组3个为一组(三角面8) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); //顶点数组3个为一组(三角面9) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); //顶点数组3个为一组(三角面10) vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(lenght); //顶点数组3个为一组(三角面11) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); //顶点数组3个为一组(三角面12) vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(lenght); vertexArray.Append(0.0f); vertexArray.Append(0.0f); vertexArray.Append(lenght); #endregion #region //颜色数组1个为一组 colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); colorArray.Append(color); #endregion #region //纹理数组2个为一组 textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); textureArray.Append(1.0f); textureArray.Append(0.0f); textureArray.Append(1.0f); #endregion primitive.ColorArray = colorArray; primitive.TexcoordArray = textureArray; primitive.VertexArray = vertexArray; IDrawMaterial material = new DrawMaterial(); material.EnableLight = true; primitive.Material = material; group.AddPrimitive(primitive); //光照效果,跟法向有关 group.ComputeNormal(); model.AddGroup(group); return(model); }
public override void Update(double timestep) { if (inputStore.WasPressed(Keys.F2)) { enabledLayers ^= RenderLayers.Normal; } if (inputStore.WasPressed(Keys.F3)) { enabledLayers ^= RenderLayers.Debug; } if (inputStore.WasPressed(Keys.F4)) { enabledLayers ^= RenderLayers.Collision; } if (inputStore.WasPressed(Keys.F5)) { enabledLayers ^= RenderLayers.Scripting; } var entities = this.world.Scene.Entities.Values; foreach (var entity in entities) { var rootTransform = Matrix4x4.Identity; if (entity.TryGetChild <TransformComponent>(out var transform)) { rootTransform = transform.TransformationMatrix; } var renderModels = entity.GetChildren <RenderModelComponent>(); for (int j = 0; j < renderModels.Length; j++) { var renderModel = renderModels[j]; if ((renderModel.RenderModel.RenderLayer & this.enabledLayers) == 0) { continue; } var localTransform = renderModel.RenderModel.CreateTransformationMatrix(); var finalTransform = Matrix4x4.Multiply(localTransform, rootTransform); if (renderModel.DrawCommands == null) { graphics.UploadModel(renderModel.RenderModel, out var commands); renderModel.UpdateDrawCommands(commands); } // BUG: If a model should be rendered by multiple shaders, (ie diffuse + wireframe) we'll need to // submit a draw group with unique draw command instances per shader. This is because the // shader uniform handle is stored on the draw commands. Alternatively, we could perhaps // move the shader uniform handle to the draw group and submit same commands with different // wrapping DrawGroup instances // If we get rid of rendering a single item in multiple shaders, this wouldn't be a problem DrawGroup group = new DrawGroup() { DrawCommands = renderModel.DrawCommands, Transform = finalTransform, Flags = renderModel.RenderModel.Flags }; renderList.Add(group); } if (entity.TryGetChild <PointLightEmitterComponent>(out var pointLight)) { renderList.Add(new PointLight() { Position = pointLight.Light.Position + rootTransform.Translation, Color = pointLight.Light.Color, Radius = pointLight.Light.Radius }); } } }