void LWOReader::ReadPTAG( UInt32 pChunkSize ) { UInt32 dataRead = 0; LWIndex index; LWIndex val; UInt32 tagType; dataRead += ReadID4( tagType ); if( tagType != ID_SURF && tagType != ID_PART && tagType != ID_SMGP ) { Skip( pChunkSize - dataRead ); return; } while( dataRead < pChunkSize ) { dataRead += ReadVX( index ); dataRead += ReadVX( val ); switch( tagType ) { case ID_SURF: GetCurrentLayer()->mPolygonList.mPolygons[index]->mSurfaceIndex = val; break; case ID_PART: GetCurrentLayer()->mPolygonList.mPolygons[index]->mPartIndex = val; break; case ID_SMGP: GetCurrentLayer()->mPolygonList.mPolygons[index]->mSmoothingGroupIndex = val; break; } } }
void LWOReader::ReadPNTS( UInt32 pChunkSize ) { UInt32 numPoints = pChunkSize / sizeof(Vector3f); LWPoint* points; GetCurrentLayer()->mPointList.mPoints = GD_NEW_ARRAY(LWPoint, numPoints, this, "Point"); GetCurrentLayer()->mPointList.mPointsCount = numPoints; points = GetCurrentLayer()->mPointList.mPoints; for( UInt32 iPoint = 0; iPoint < numPoints; iPoint++ ) ReadVEC12( points[iPoint].mPos ); }
void LWOReader::ReadPOLS( UInt32 pChunkSize ) { UInt32 dataRead = 0; UInt16 numVertex; UInt32 polygonType; LWPolygon* newPolygon; dataRead += ReadID4( polygonType ); while( dataRead < pChunkSize ) { newPolygon = GD_NEW(LWPolygon, this, "Polygon"); dataRead += ReadU2( numVertex ); newPolygon->mFlags = (0xFC00 & numVertex) >> 10; numVertex = 0x03FF & numVertex; newPolygon->mType = polygonType; newPolygon->mVertex = GD_NEW_ARRAY(LWPolygonVertex, numVertex, this, "Polygon::Vertex"); newPolygon->mVertexCount = numVertex; // Read indices and assign them to each vertex for( UInt32 iIndex = 0; iIndex < newPolygon->mVertexCount; iIndex++ ) dataRead += ReadVX( newPolygon->mVertex[iIndex].mIndex ); GetCurrentLayer()->mPolygonList.mPolygons.push_back( newPolygon ); } }
void TileMapPanel::OnPaint(wxPaintEvent& event) { wxAutoBufferedPaintDC dc(this); DoPrepareDC(dc); wxPoint minPos = GetViewStart(); int width, height; GetClientSize(&width, &height); wxPoint maxPos = minPos + wxPoint(width, height); dc.SetBrush(gd::CommonBitmapManager::Get()->transparentBg); dc.DrawRectangle(minPos.x, minPos.y, width, height); if(!m_tilemap || !m_tileset || m_tileset->IsDirty()) return; dc.SetPen(wxPen(wxColor(128, 128, 128, 255), 1)); //Determine the first and last columns and rows to draw int firstCol = std::max((int)(minPos.x / m_tileset->tileSize.x - 1), 0); int firstRow = std::max((int)(minPos.y / m_tileset->tileSize.y - 1), 0); int lastCol = std::min((int)(maxPos.x / m_tileset->tileSize.x + 1), m_tilemap->GetColumnsCount()); int lastRow = std::min((int)(maxPos.y / m_tileset->tileSize.y + 1), m_tilemap->GetRowsCount()); //Draw the tiles for(int layer = 0; m_hideUpperLayers ? layer <= GetCurrentLayer() : layer < 3; layer++) { for(int col = firstCol; col < lastCol; col++) { for(int row = firstRow; row < lastRow; row++) { if(m_tilemap->GetTile(layer, col, row) == -1) continue; dc.DrawBitmap(m_tileset->GetTileBitmap(m_tilemap->GetTile(layer, col, row)), GetPositionOfTile(col, row).x, GetPositionOfTile(col, row).y, true); } } } //Draw the rectangle (when the mode is RectangleMode) if(m_insertionMode == RectangleMode && m_isDrawingRectangle) { dc.SetBrush(wxBrush(wxColour(128, 128, 255, 128))); dc.SetPen(wxPen(wxColor(128, 128, 255, 255), 1)); wxPoint topLeftPos(GetPositionOfTile(std::min(m_beginCol, m_endCol), std::min(m_beginRow, m_endRow))); wxPoint bottomRightPos(GetPositionOfTile(std::max(m_beginCol + 1, m_endCol + 1), std::max(m_beginRow + 1, m_endRow + 1))); wxSize rectSize(bottomRightPos.x - topLeftPos.x, bottomRightPos.y - topLeftPos.y); dc.DrawRectangle(topLeftPos, rectSize); } dc.SetPen(wxPen(wxColor(128, 128, 128, 255), 1)); //Draw the grid for(int col = firstCol; col < lastCol; col++) { dc.DrawLine(col * m_tileset->tileSize.x, minPos.y, col * m_tileset->tileSize.x, maxPos.y); for(int row = firstRow; row < lastRow; row++) { dc.DrawLine(minPos.x, row * m_tileset->tileSize.y, maxPos.x, row * m_tileset->tileSize.y); } } //Draw a gray rectangle outside the map dc.SetBrush(wxColor(128, 128, 128, 255)); if(maxPos.x > (m_tilemap->GetColumnsCount() * m_tileset->tileSize.x)) { dc.DrawRectangle(m_tilemap->GetColumnsCount() * m_tileset->tileSize.x, minPos.y, maxPos.x - m_tilemap->GetColumnsCount() * m_tileset->tileSize.x, maxPos.y - minPos.y); } if(maxPos.y > (m_tilemap->GetRowsCount() * m_tileset->tileSize.y)) { dc.DrawRectangle(minPos.x, m_tilemap->GetRowsCount() * m_tileset->tileSize.y, maxPos.x - minPos.x, maxPos.y - m_tilemap->GetRowsCount() * m_tileset->tileSize.y); } }
void LWOReader::ReadVMAP( UInt32 pChunkSize, Bool pPerPoly ) { UInt32 dataRead = 0; UInt16 dimension; LWIndex vertexIndex; LWIndex polygonIndex; LWVertexMap* newVertexMap = GD_NEW(LWVertexMap, this, "VertexMap"); newVertexMap->mPerPoly = pPerPoly; dataRead += ReadID4( newVertexMap->mType ); dataRead += ReadU2( dimension ); dataRead += ReadS0( newVertexMap->mName ); while( dataRead < pChunkSize ) { dataRead += ReadVX( vertexIndex ); newVertexMap->mVertexIndex.push_back( vertexIndex ); if( pPerPoly ) { dataRead += ReadVX( polygonIndex ); newVertexMap->mPolygonIndex.push_back( polygonIndex ); } LWMapValue mapping; switch( newVertexMap->mType ) { case ID_PICK: mapping.mPick = vertexIndex; break; case ID_WGHT: dataRead += ReadF4( mapping.mWeight ); break; case ID_TXUV: dataRead += ReadF4( mapping.mUV.U ); dataRead += ReadF4( mapping.mUV.V ); break; case ID_RGB: dataRead += ReadF4( mapping.mRGB.R ); dataRead += ReadF4( mapping.mRGB.G ); dataRead += ReadF4( mapping.mRGB.B ); break; case ID_RGBA: dataRead += ReadF4( mapping.mRGBA.R ); dataRead += ReadF4( mapping.mRGBA.G ); dataRead += ReadF4( mapping.mRGBA.B ); dataRead += ReadF4( mapping.mRGBA.A ); break; case ID_MORF: case ID_SPOT: case ID_MNVW: default: dataRead += Skip( dimension * sizeof(Float) ); break; } newVertexMap->mValues.push_back( mapping ); } GetCurrentLayer()->mVertexMaps.push_back( newVertexMap ); }
void LWOReader::ReadBBOX( UInt32 /*pChunkSize*/ ) { ReadVEC12( GetCurrentLayer()->mBoundingBox.mMin ); ReadVEC12( GetCurrentLayer()->mBoundingBox.mMax ); }