ModelData ModelDataClone(ModelData source) { ModelData dest = new ModelData(); dest.xyz = new float[source.GetXyzCount()]; for (int i = 0; i < source.GetXyzCount(); i++) { dest.xyz[i] = source.xyz[i]; } dest.uv = new float[source.GetUvCount()]; for (int i = 0; i < source.GetUvCount(); i++) { dest.uv[i] = source.uv[i]; } dest.rgba = new byte[source.GetRgbaCount()]; for (int i = 0; i < source.GetRgbaCount(); i++) { dest.rgba[i] = source.rgba[i]; } dest.indices = new int[source.GetIndicesCount()]; for (int i = 0; i < source.GetIndicesCount(); i++) { dest.indices[i] = source.indices[i]; } dest.SetVerticesCount(source.GetVerticesCount()); dest.SetIndicesCount(source.GetIndicesCount()); return(dest); }
public void AddVertex(ModelData model, float x, float y, float z, float u, float v, int color) { model.xyz[model.GetXyzCount() + 0] = x; model.xyz[model.GetXyzCount() + 1] = y; model.xyz[model.GetXyzCount() + 2] = z; model.uv[model.GetUvCount() + 0] = u; model.uv[model.GetUvCount() + 1] = v; model.rgba[model.GetRgbaCount() + 0] = Game.IntToByte(Game.ColorR(color)); model.rgba[model.GetRgbaCount() + 1] = Game.IntToByte(Game.ColorG(color)); model.rgba[model.GetRgbaCount() + 2] = Game.IntToByte(Game.ColorB(color)); model.rgba[model.GetRgbaCount() + 3] = Game.IntToByte(Game.ColorA(color)); model.verticesCount++; }
public static void AddVertex(ModelData model, float x, float y, float z, float u, float v, int color) { if (model.verticesCount >= model.verticesMax) { int xyzCount = model.GetXyzCount(); float[] xyz = new float[xyzCount * 2]; for (int i = 0; i < xyzCount; i++) { xyz[i] = model.xyz[i]; } int uvCount = model.GetUvCount(); float[] uv = new float[uvCount * 2]; for (int i = 0; i < uvCount; i++) { uv[i] = model.uv[i]; } int rgbaCount = model.GetRgbaCount(); byte[] rgba = new byte[rgbaCount * 2]; for (int i = 0; i < rgbaCount; i++) { rgba[i] = model.rgba[i]; } model.xyz = xyz; model.uv = uv; model.rgba = rgba; model.verticesMax = model.verticesMax * 2; } model.xyz[model.GetXyzCount() + 0] = x; model.xyz[model.GetXyzCount() + 1] = y; model.xyz[model.GetXyzCount() + 2] = z; model.uv[model.GetUvCount() + 0] = u; model.uv[model.GetUvCount() + 1] = v; model.rgba[model.GetRgbaCount() + 0] = Game.IntToByte(Game.ColorR(color)); model.rgba[model.GetRgbaCount() + 1] = Game.IntToByte(Game.ColorG(color)); model.rgba[model.GetRgbaCount() + 2] = Game.IntToByte(Game.ColorB(color)); model.rgba[model.GetRgbaCount() + 3] = Game.IntToByte(Game.ColorA(color)); model.verticesCount++; }
static void AddVertex(ModelData model, float x, float y, float z, float u, float v, int color) { model.xyz[model.GetXyzCount() + 0] = x; model.xyz[model.GetXyzCount() + 1] = y; model.xyz[model.GetXyzCount() + 2] = z; model.uv[model.GetUvCount() + 0] = u; model.uv[model.GetUvCount() + 1] = v; model.rgba[model.GetRgbaCount() + 0] = Game.IntToByte(Game.ColorR(color)); model.rgba[model.GetRgbaCount() + 1] = Game.IntToByte(Game.ColorG(color)); model.rgba[model.GetRgbaCount() + 2] = Game.IntToByte(Game.ColorB(color)); model.rgba[model.GetRgbaCount() + 3] = Game.IntToByte(Game.ColorA(color)); model.verticesCount++; }
ModelData ModelDataClone(ModelData source) { ModelData dest = new ModelData(); #if !CITO unchecked { #endif dest.xyz = new float[source.GetXyzCount()]; for (int i = 0; i < source.GetXyzCount(); i++) { dest.xyz[i] = source.xyz[i]; } dest.uv = new float[source.GetUvCount()]; for (int i = 0; i < source.GetUvCount(); i++) { dest.uv[i] = source.uv[i]; } dest.rgba = new byte[source.GetRgbaCount()]; for (int i = 0; i < source.GetRgbaCount(); i++) { dest.rgba[i] = source.rgba[i]; } dest.indices = new int[source.GetIndicesCount()]; for (int i = 0; i < source.GetIndicesCount(); i++) { dest.indices[i] = source.indices[i]; } dest.SetVerticesCount(source.GetVerticesCount()); dest.SetIndicesCount(source.GetIndicesCount()); #if !CITO } #endif return dest; }
public override void DrawModelData(ModelData data) { GL.EnableClientState(ArrayCap.VertexArray); GL.EnableClientState(ArrayCap.ColorArray); GL.EnableClientState(ArrayCap.TextureCoordArray); float[] dataXyz = data.getXyz(); float[] dataUv = data.getUv(); byte[] dataRgba = data.getRgba(); for (int i = 0; i < data.GetXyzCount(); i++) { xyz[i] = dataXyz[i]; } for (int i = 0; i < data.GetUvCount(); i++) { uv[i] = dataUv[i]; } if (dataRgba == null) { for (int i = 0; i < data.GetRgbaCount(); i++) { rgba[i] = 255; } } else { for (int i = 0; i < data.GetRgbaCount(); i++) { rgba[i] = dataRgba[i]; } } GL.VertexPointer(3, VertexPointerType.Float, 3 * 4, xyz); GL.ColorPointer(4, ColorPointerType.UnsignedByte, 4 * 1, rgba); GL.TexCoordPointer(2, TexCoordPointerType.Float, 2 * 4, uv); BeginMode beginmode = BeginMode.Triangles; if (data.getMode() == DrawModeEnum.Triangles) { beginmode = BeginMode.Triangles; GL.Enable(EnableCap.Texture2D); } else if (data.getMode() == DrawModeEnum.Lines) { beginmode = BeginMode.Lines; GL.Disable(EnableCap.Texture2D); } else { throw new Exception(); } int[] dataIndices = data.getIndices(); for (int i = 0; i < data.GetIndicesCount(); i++) { indices[i] = (ushort)dataIndices[i]; } GL.DrawElements(beginmode, data.GetIndicesCount(), DrawElementsType.UnsignedShort, indices); GL.DisableClientState(ArrayCap.VertexArray); GL.DisableClientState(ArrayCap.ColorArray); GL.DisableClientState(ArrayCap.TextureCoordArray); GL.Disable(EnableCap.Texture2D); }