public ColorCodec(RGBAPixel[] pixels) { _srcCount = pixels.Length; _handle = GCHandle.Alloc(pixels, GCHandleType.Pinned); _pData = (RGBAPixel *)_handle.AddrOfPinnedObject(); Evaluate(); }
protected override bool OnInitialize() { base.OnInitialize(); _lighting = new List <RGBAPixel>(); fixedFlags = Data->_fixedFlags; unk2 = Data->_unk2; unk3 = Data->_unk3; unk4 = Data->_unk4; if ((fixedFlags >> 7 & 1) == 1) { _lighting.Add(Data->_lighting); } else { if (Name != "<null>") { RGBAPixel *addr = Data->lightEntries; for (int i = 0; i <= ((SCN0Node)Parent.Parent).FrameCount; i++) { _lighting.Add(*addr++); } } } return(false); }
protected void ReadColors( uint flags, uint bit, ref RGBAPixel solidColor, ref List <RGBAPixel> colors, int frameCount, VoidPtr address, ref bool constant, ref int numEntries) { colors = new List <RGBAPixel>(); if (constant = (flags & bit) != 0) { solidColor = *(RGBAPixel *)address; numEntries = 0; } else { numEntries = frameCount + 1; RGBAPixel *addr = (RGBAPixel *)(address + *(bint *)address); for (int x = 0; x < numEntries; x++) { colors.Add(*addr++); } } }
public override bool OnInitialize() { base.OnInitialize(); _colors = new List <ARGBPixel>(); fixedFlags = Data->_fixedFlags; usageFlags = Data->_flags; if ((fixedFlags >> 7 & 1) == 1) { _constant = true; _numEntries = 0; _solidColor = (ARGBPixel)Data->_lighting; } else if (Name != "<null>") { _constant = false; _numEntries = FrameCount + 1; RGBAPixel *addr = Data->lightEntries; for (int i = 0; i < _numEntries; i++) { _colors.Add((ARGBPixel)(*addr++)); } } return(false); }
public ColorCodec(RGBAPixel[] pixels) { _srcCount = pixels.Length; _handle = GCHandle.Alloc(pixels, GCHandleType.Pinned); _pData = (RGBAPixel*)_handle.AddrOfPinnedObject(); Evaluate(); }
public static unsafe GLTexture CreateBG(TKContext ctx) { GLTexture tex = new GLTexture(16, 16); tex._texId = GL.GenTexture(); GL.BindTexture(TextureTarget.Texture2D, tex._texId); int * pixelData = stackalloc int[16 * 16]; RGBAPixel *p = (RGBAPixel *)pixelData; for (int y = 0; y < 16; y++) { for (int x = 0; x < 16; x++) { *p++ = ((x & 8) == (y & 8)) ? _left : _right; } } GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Four, 16, 16, 0, PixelFormat.Rgba, PixelType.UnsignedByte, (VoidPtr)pixelData); return(tex); }
public override unsafe void Export(string outPath) { int length = 12 + (_numEntries != 0 ? _colors.Count * 4 : 4); using (FileStream stream = new FileStream(outPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None, 8, FileOptions.RandomAccess)) { stream.SetLength(length); using (FileMap map = FileMap.FromStream(stream)) { CLR0MaterialEntry *entry = (CLR0MaterialEntry *)map.Address; entry->_colorMask = _colorMask; entry->_data = 8; *((bint *)entry + 2) = _numEntries; RGBAPixel *pData = entry->Data; if (_numEntries != 0) { foreach (ARGBPixel p in _colors) { *pData++ = (RGBAPixel)p; } } else { *pData = _solidColor; } } } }
private static void WriteColors(string name, RGBAPixel *pData, int count, int set, XmlWriter writer) { bool first = true; //Position source writer.WriteStartElement("source"); writer.WriteAttributeString("id", name + "_Colors" + set.ToString()); //Array start writer.WriteStartElement("float_array"); writer.WriteAttributeString("id", name + "_ColorArr" + set.ToString()); writer.WriteAttributeString("count", (count * 4).ToString()); for (int i = 0; i < count; i++) { if (first) { first = false; } else { writer.WriteString(" "); } writer.WriteString(String.Format("{0} {1} {2} {3}", pData->R * cFactor, pData->G * cFactor, pData->B * cFactor, pData->A * cFactor)); pData++; } writer.WriteEndElement(); //int_array //Technique writer.WriteStartElement("technique_common"); writer.WriteStartElement("accessor"); writer.WriteAttributeString("source", "#" + name + "_ColorArr" + set.ToString()); writer.WriteAttributeString("count", count.ToString()); writer.WriteAttributeString("stride", "4"); writer.WriteStartElement("param"); writer.WriteAttributeString("name", "R"); writer.WriteAttributeString("type", "float"); writer.WriteEndElement(); //param writer.WriteStartElement("param"); writer.WriteAttributeString("name", "G"); writer.WriteAttributeString("type", "float"); writer.WriteEndElement(); //param writer.WriteStartElement("param"); writer.WriteAttributeString("name", "B"); writer.WriteAttributeString("type", "float"); writer.WriteEndElement(); //param writer.WriteStartElement("param"); writer.WriteAttributeString("name", "A"); writer.WriteAttributeString("type", "float"); writer.WriteEndElement(); //param writer.WriteEndElement(); //accessor writer.WriteEndElement(); //technique_common writer.WriteEndElement(); //source }
public void Dispose() { if (_handle.IsAllocated) { _handle.Free(); } _pData = null; GC.SuppressFinalize(this); }
protected override bool OnInitialize() { base.OnInitialize(); starts = new List <SCN0Keyframe>(); ends = new List <SCN0Keyframe>(); colors = new List <RGBAPixel>(); flags = (SCN0FogFlags)Data->_flags; density = Data->_density; if (Name != "<null>") { if (flags.HasFlag(SCN0FogFlags.FixedStart)) { starts.Add(new Vector3(Data->_start, 0, 0)); } else { SCN0KeyframeStruct *addr = Data->startKeyframes->Data; for (int i = 0; i < Data->startKeyframes->_numFrames; i++) { starts.Add(*addr++); } } if (flags.HasFlag(SCN0FogFlags.FixedEnd)) { ends.Add(new Vector3(Data->_end, 0, 0)); } else { SCN0KeyframeStruct *addr = Data->endKeyframes->Data; for (int i = 0; i < Data->endKeyframes->_numFrames; i++) { ends.Add(*addr++); } } if (flags.HasFlag(SCN0FogFlags.FixedColor)) { colors.Add(Data->_color); } else { RGBAPixel *addr = Data->colorEntries; for (int i = 0; i <= ((SCN0Node)Parent.Parent).FrameCount; i++) { colors.Add(*addr++); } } } return(false); }
public override bool OnInitialize() { base.OnInitialize(); _colors = new List <ARGBPixel>(); _startKeys = new KeyframeArray(FrameCount + 1); _endKeys = new KeyframeArray(FrameCount + 1); flags = (SCN0FogFlags)Data->_flags; type = Data->_type; if (Name != "<null>") { if (flags.HasFlag(SCN0FogFlags.FixedStart)) { _startKeys[0] = Data->_start; } else if (!_replaced) { DecodeFrames(_startKeys, Data->startKeyframes); } if (flags.HasFlag(SCN0FogFlags.FixedEnd)) { _endKeys[0] = Data->_end; } else if (!_replaced) { DecodeFrames(_endKeys, Data->endKeyframes); } if (flags.HasFlag(SCN0FogFlags.FixedColor)) { _constant = true; _numEntries = 0; _solidColor = (ARGBPixel)Data->_color; } else { _constant = false; _numEntries = FrameCount + 1; RGBAPixel *addr = Data->colorEntries; for (int i = 0; i <= FrameCount; i++) { _colors.Add((ARGBPixel)(*addr++)); } } } return(false); }
public override bool OnInitialize() { _colors.Clear(); _colorMask = (ARGBPixel)Header->_colorMask; if (_replaced && WorkingUncompressed.Length >= 16 && Header->_data == 8) { _numEntries = *((bint *)Header + 2); _constant = _numEntries == 0; RGBAPixel *data = Header->Data; if (_constant) { _solidColor = *data; } else { int frameCount = ((CLR0Node)Parent.Parent)._numFrames; for (int i = 0; i < frameCount; i++) { _colors.Add(i >= _numEntries ? new ARGBPixel() : (ARGBPixel)(*data++)); } _numEntries = frameCount; } } else { if (_constant) { _numEntries = 0; _solidColor = (ARGBPixel)Header->SolidColor; } else { _numEntries = ((CLR0Node)Parent.Parent)._numFrames; RGBAPixel *data = Header->Data; for (int i = 0; i < _numEntries; i++) { _colors.Add((ARGBPixel)(*data++)); } } } _name = _target.ToString(); return(false); }
public int WriteColors(ref int flags, int bit, RGBAPixel solidColor, List <RGBAPixel> colors, bool constant, int frameCount, VoidPtr valueAddr, ref VoidPtr thisMatchAddr, VoidPtr thatMatchAddr, RGBAPixel *dataAddr) { if (!constant) { flags &= ~bit; thisMatchAddr = dataAddr; if (thatMatchAddr == null) { VoidPtr start = dataAddr; *((bint *)valueAddr) = (int)dataAddr - (int)valueAddr; for (int x = 0; x <= frameCount; x++) { if (x < colors.Count) { *dataAddr++ = colors[x]; } else { *dataAddr++ = new RGBAPixel(); } } return((int)(dataAddr - start)); } else { *((bint *)valueAddr) = (int)thatMatchAddr - (int)valueAddr; return(0); } } else { flags |= bit; *((RGBAPixel *)valueAddr) = solidColor; return(0); } }
protected override bool OnInitialize() { base.OnInitialize(); _unk1 = Data->_unk1; _unk2 = Data->_unk2; _flags1 = new Bin16(Data->_flags1); _flags2 = new Bin16(Data->_flags2); _unk5 = Data->_unk5; _unk6 = Data->_unk6; _unk7 = Data->_unk7; _unk8 = Data->_unk8; _unk9 = Data->_unk9; _unk10 = Data->_unk10; _unk12 = Data->_unk12; _lighting1 = new List <RGBAPixel>(); _lighting2 = new List <RGBAPixel>(); xEnds = new List <SCN0Keyframe>(); yEnds = new List <SCN0Keyframe>(); zEnds = new List <SCN0Keyframe>(); xStarts = new List <SCN0Keyframe>(); yStarts = new List <SCN0Keyframe>(); zStarts = new List <SCN0Keyframe>(); if (Flags1[3]) { xEnds.Add(new Vector3(0, 0, Data->_vec1._x)); } else { if (Name != "<null>") { SCN0KeyframesHeader *keysHeader = Data->xEndKeyframes; SCN0KeyframeStruct * addr = keysHeader->Data; for (int i = 0; i < keysHeader->_numFrames; i++) { xEnds.Add(*addr++); } } } if (Flags1[4]) { yEnds.Add(new Vector3(0, 0, Data->_vec1._y)); } else { if (Name != "<null>") { SCN0KeyframesHeader *keysHeader = Data->yEndKeyframes; SCN0KeyframeStruct * addr = keysHeader->Data; for (int i = 0; i < keysHeader->_numFrames; i++) { yEnds.Add(*addr++); } } } if (Flags1[5]) { zEnds.Add(new Vector3(0, 0, Data->_vec1._z)); } else { if (Name != "<null>") { SCN0KeyframesHeader *keysHeader = Data->zEndKeyframes; SCN0KeyframeStruct * addr = keysHeader->Data; for (int i = 0; i < keysHeader->_numFrames; i++) { zEnds.Add(*addr++); } } } if (Flags1[6]) { _lighting1.Add(Data->_lighting1); } else { if (Name != "<null>") { RGBAPixel *addr = Data->light1Entries; for (int i = 0; i <= ((SCN0Node)Parent.Parent).FrameCount; i++) { _lighting1.Add(*addr++); } } } if (Flags1[7]) { xStarts.Add(new Vector3(0, 0, Data->_vec2._x)); } else { if (Name != "<null>") { SCN0KeyframesHeader *keysHeader = Data->xStartKeyframes; SCN0KeyframeStruct * addr = keysHeader->Data; for (int i = 0; i < keysHeader->_numFrames; i++) { xStarts.Add(*addr++); } } } if (Flags1[8]) { yStarts.Add(new Vector3(0, 0, Data->_vec2._y)); } else { if (Name != "<null>") { SCN0KeyframesHeader *keysHeader = Data->yStartKeyframes; SCN0KeyframeStruct * addr = keysHeader->Data; for (int i = 0; i < keysHeader->_numFrames; i++) { yStarts.Add(*addr++); } } } if (Flags1[9]) { zStarts.Add(new Vector3(0, 0, Data->_vec2._z)); } else { if (Name != "<null>") { SCN0KeyframesHeader *keysHeader = Data->zStartKeyframes; SCN0KeyframeStruct * addr = keysHeader->Data; for (int i = 0; i < keysHeader->_numFrames; i++) { zStarts.Add(*addr++); } } } if (Flags1[14]) { _lighting2.Add(Data->_lighting2); } else { if (Name != "<null>") { RGBAPixel *addr = Data->light2Entries; for (int i = 0; i <= ((SCN0Node)Parent.Parent).FrameCount; i++) { _lighting2.Add(*addr++); } } } return(false); }
public void Dispose() { if (_handle.IsAllocated) _handle.Free(); _pData = null; GC.SuppressFinalize(this); }
private void FinishMDL0(MDL0Node model) { Error = "There was a problem creating a default material and shader."; if (model._matList.Count == 0 && model._objList.Count != 0) { MDL0MaterialNode mat = new MDL0MaterialNode() { _name = "Default", }; (mat.ShaderNode = new MDL0ShaderNode()).AddChild(new MDL0TEVStageNode() { RasterColor = ColorSelChan.LightChannel0, AlphaSelectionD = AlphaArg.RasterAlpha, ColorSelectionD = ColorArg.RasterColor, }); model._shadGroup.AddChild(mat.ShaderNode); model._matGroup.AddChild(mat); foreach (MDL0ObjectNode obj in model._objList) { if (obj._drawCalls.Count == 0) { obj._drawCalls.Add(new DrawCall(obj)); } obj._drawCalls[0].MaterialNode = mat; } } Error = "There was a problem removing original color buffers."; //Remove original color buffers if option set if (_importOptions._ignoreColors) { if (model._objList != null && model._objList.Count != 0) { foreach (MDL0ObjectNode p in model._objList) { for (int x = 2; x < 4; x++) { if (p._manager._faceData[x] != null) { p._manager._faceData[x].Dispose(); p._manager._faceData[x] = null; } } } } } Error = "There was a problem adding default color values."; //Add color buffers if option set if (_importOptions._addClrs) { RGBAPixel pixel = _importOptions._dfltClr; //Add a color buffer to objects that don't have one if (model._objList != null && model._objList.Count != 0) { foreach (MDL0ObjectNode p in model._objList) { if (p._manager._faceData[2] == null) { RGBAPixel *pIn = (RGBAPixel *)(p._manager._faceData[2] = new UnsafeBuffer(4 * p._manager._pointCount)).Address; for (int i = 0; i < p._manager._pointCount; i++) { *pIn++ = pixel; } } } } } Error = "There was a problem initializing materials."; //Apply defaults to materials if (model._matList != null) { foreach (MDL0MaterialNode mat in model._matList) { mat._activeStages = mat.ShaderNode.Stages; if (_importOptions._mdlType == ImportOptions.MDLType.Stage) { mat._lightSetIndex = 0; mat._fogIndex = 0; } } } Error = "There was a problem remapping materials."; //Remap materials if option set if (_importOptions._rmpMats && model._matList != null && model._objList != null) { foreach (MDL0ObjectNode obj3 in model._objList) { MDL0MaterialNode mat = obj3._drawCalls[0].MaterialNode; foreach (MDL0MaterialNode m in model._matList) { if (m.Children.Count > 0 && m.Children[0] != null && mat != null && mat.Children.Count > 0 && mat.Children[0] != null && m.Children[0].Name == mat.Children[0].Name && m.C1ColorMaterialSource == mat.C1ColorMaterialSource) { obj3._drawCalls[0].MaterialNode = m; break; } } } //Remove unused materials for (int i = 0; i < model._matList.Count; i++) { if (((MDL0MaterialNode)model._matList[i])._objects.Count == 0) { model._matList.RemoveAt(i--); } } } Error = "There was a problem writing the model."; //Clean the model and then build it! if (model != null) { model.FinishImport(); } }
public ColorCodec(RGBAPixel* sPtr, int count) { _pData = sPtr; _srcCount = count; Evaluate(); }
internal void UpdateStream(int index) { _dirty[index] = false; if (_faceData[index] == null) { return; } //Set starting address byte *pOut = (byte *)_graphicsBuffer.Address; for (int i = 0; i < index; i++) { if (_faceData[i] != null) { if (i < 2) { pOut += 12; } else if (i < 4) { pOut += 4; } else { pOut += 8; } } } if (index == 0) { ushort *pIn = (ushort *)_faceData[index].Address; for (int i = 0; i < _pointCount; i++, pOut += _stride) { *(Vector3 *)pOut = _vertices[*pIn++].WeightedPosition; } } else if (index == 1) { Vector3 *pIn = (Vector3 *)_faceData[index].Address; for (int i = 0; i < _pointCount; i++, pOut += _stride) { *(Vector3 *)pOut = *pIn++; } } else if (index < 4) { RGBAPixel *pIn = (RGBAPixel *)_faceData[index].Address; for (int i = 0; i < _pointCount; i++, pOut += _stride) { *(RGBAPixel *)pOut = *pIn++; } } else { Vector2 *pIn = (Vector2 *)_faceData[index].Address; for (int i = 0; i < _pointCount; i++, pOut += _stride) { *(Vector2 *)pOut = *pIn++; } } }
public override bool OnInitialize() { base.OnInitialize(); _numEntries = new int[] { 0, 0 }; _solidColors = new RGBAPixel[2]; _constants = new bool[] { true, true }; _nonSpecLightId = Data->_nonSpecLightId; _part2Offset = Data->_part2Offset; _flags1 = Data->_fixedFlags; _flags2 = Data->_usageFlags; _enableOffset = Data->_visOffset; _distFunc = Data->_distFunc; _spotFunc = Data->_spotFunc; for (int x = 0; x < 10; x++) { SetKeys(x, new KeyframeArray(FrameCount + 1)); } FixedFlags flags = (FixedFlags)_flags1; if (Name == "<null>") { return(false); } if (!flags.HasFlag(FixedFlags.EnabledConstant)) { _entryCount = FrameCount + 1; int numBytes = _entryCount.Align(32) / 8; _data = new byte[numBytes]; Marshal.Copy((IntPtr)Data->visBitEntries, _data, 0, numBytes); } else { _entryCount = 0; _data = new byte[0]; } if (flags.HasFlag(FixedFlags.ColorConstant)) { _solidColors[0] = Data->_lightColor; } else { _constants[0] = false; _numEntries[0] = FrameCount + 1; RGBAPixel *addr = Data->lightColorEntries; for (int x = 0; x <= FrameCount; x++) { _lightColor.Add(*addr++); } } if (SpecularEnabled) { if (flags.HasFlag(FixedFlags.SpecColorConstant)) { _solidColors[1] = Data->_specularColor; } else { _constants[1] = false; _numEntries[1] = FrameCount + 1; RGBAPixel *addr = Data->specColorEntries; for (int x = 0; x <= FrameCount; x++) { _specColor.Add(*addr++); } } } bint *values = (bint *)&Data->_startPoint; int index = 0; for (int i = 0; i < 14; i++) { if (!(i == 3 || i == 7 || i == 10 || i == 12)) { DecodeFrames(GetKeys(index), &values[i], (int)_flags1, (int)_ordered[index++]); } } return(false); }
public override void OnRebuild(VoidPtr address, int length, bool force) { int count = Children.Count; CLR0Material *pMat = (CLR0Material *)(address + (_version == 4 ? CLR0v4.Size : CLR0v3.Size) + 0x18 + (count * 0x10)); int offset = Children.Count * 8; foreach (CLR0MaterialNode n in Children) { offset += n.Children.Count * 8; } RGBAPixel *pData = (RGBAPixel *)((VoidPtr)pMat + offset); ResourceGroup *group; if (_version == 4) { CLR0v4 *header = (CLR0v4 *)address; * header = new CLR0v4(length, _numFrames, count, _loop); group = header->Group; } else { CLR0v3 *header = (CLR0v3 *)address; * header = new CLR0v3(length, _numFrames, count, _loop); group = header->Group; } *group = new ResourceGroup(count); ResourceEntry *entry = group->First; foreach (CLR0MaterialNode n in Children) { (entry++)->_dataOffset = (int)pMat - (int)group; uint newFlags = 0; CLR0MaterialEntry *pMatEntry = (CLR0MaterialEntry *)((VoidPtr)pMat + 8); foreach (CLR0MaterialEntryNode e in n.Children) { newFlags |= ((uint)((1 + (e._constant ? 2 : 0)) & 3) << ((int)e._target * 2)); if (e._numEntries == 0) { *pMatEntry = new CLR0MaterialEntry((RGBAPixel)e._colorMask, (RGBAPixel)e._solidColor); } else { *pMatEntry = new CLR0MaterialEntry((RGBAPixel)e._colorMask, (int)pData - (int)((VoidPtr)pMatEntry + 4)); foreach (ARGBPixel p in e._colors) { *pData++ = (RGBAPixel)p; } } pMatEntry++; e._changed = false; } pMat->_flags = newFlags; pMat = (CLR0Material *)pMatEntry; n._changed = false; } if (_userEntries.Count > 0 && _version == 4) { CLR0v4 *header = (CLR0v4 *)address; header->UserData = pData; _userEntries.Write(pData); } }
public ColorCodec(RGBAPixel *sPtr, int count) { _pData = sPtr; _srcCount = count; Evaluate(); }
internal unsafe void Precalc(MDL0PolygonNode parent, IMatrixProvider[] nodes) { //If already calculated, and no weights, skip? bool hasNodes = parent._nodeList.Count > 0; if ((_precVertices != null) && hasNodes) { return; } Vector3[] verts, norms = null; Vector3 * vPtr = null, nPtr = null; RGBAPixel[][] colors = new RGBAPixel[2][]; Vector2[][] uvs = new Vector2[8][]; uint * ptrCache = stackalloc uint[10]; //Points verts = parent._vertexNode.Vertices; if (_precVertices == null) { _precVertices = new UnsafeBuffer(_elementCount * 12); } vPtr = (Vector3 *)_precVertices.Address; //Normals if (parent._normalNode != null) { norms = parent._normalNode.Normals; if (_precNormals == null) { _precNormals = new UnsafeBuffer(_elementCount * 12); } nPtr = (Vector3 *)_precNormals.Address; } else if (_precNormals != null) { _precNormals.Dispose(); _precNormals = null; } //Colors for (int i = 0; i < 1; i++) { if (parent._colorSet[i] != null) { colors[i] = parent._colorSet[i].Colors; if (_precColors == null) { _precColors = new UnsafeBuffer(_elementCount * 4); } ptrCache[i] = (uint)_precColors.Address; } else if (_precColors != null) { _precColors.Dispose(); _precColors = null; } } //UVs for (int i = 0; i < 8; i++) { if (parent._uvSet[i] != null) { uvs[i] = parent._uvSet[i].Points; if (_precUVs[i] == null) { _precUVs[i] = new UnsafeBuffer(_elementCount * 8); } ptrCache[i + 2] = (uint)_precUVs[i].Address; } else if (_precUVs[i] != null) { _precUVs[i].Dispose(); _precUVs[i] = null; } } int count = _vertices.Count; for (int x = 0; x < count; x++) { Vertex vert = _vertices[x]; //Vertices if (hasNodes) { *vPtr++ = nodes[vert.Weight].FrameMatrix.Multiply(verts[vert.Position]); } else { *vPtr++ = verts[vert.Position]; } //Normals if (nPtr != null) { if (hasNodes) { *nPtr++ = nodes[vert.Weight].FrameMatrix.Multiply(norms[vert.Normal]); } else { *nPtr++ = norms[vert.Normal]; } } //Colors for (int i = 0; i < 1; i++) { RGBAPixel *cPtr = (RGBAPixel *)ptrCache[i]; if (cPtr != null) { cPtr[x] = colors[i][vert.Color[i]]; } } //UVs for (int i = 0; i < 8; i++) { Vector2 *uPtr = (Vector2 *)ptrCache[i + 2]; if (uPtr != null) { uPtr[x] = uvs[i][vert.UV[i]]; } } } }