Example #1
0
	void ColorGrid::HandleNodes(bool bStatus)
	{
		PaletteIndex cbPrevColor;
		PaletteIndex cbRandomColor;

		for(int i = 0; i < m_nSelectedNodesSize; i++)
		{
			if(m_pSelectedNodes[i]->isCaptured() && bStatus)
			{
				cbPrevColor = m_pSelectedNodes[i]->getPaletteIndex();
				cbRandomColor = my_utility::random(m_nColors);
				
				while(cbPrevColor == cbRandomColor)
					cbRandomColor = my_utility::random(m_nColors);
				
				m_pSelectedNodes[i]->setColor(cbRandomColor);
				m_pSelectedNodes[i]->uncapture();
				m_nCapturedNodes--;
				// Add the node's new color back to the tally
				m_uncaptured_count.tally(m_pSelectedNodes[i]->getPaletteIndex());
			}
			else if(bStatus)
			{
				m_pSelectedNodes[i]->capture();
				m_nCapturedNodes++;
				// Remove the node from the count
				m_uncaptured_count.tally(m_pSelectedNodes[i]->getPaletteIndex(),-1);
			}
		}

		ClearPoints(0);
	}
Example #2
0
	void ColorGrid::ccTouchEnded(cocos2d::CCTouch* touch, cocos2d::CCEvent* event)
	{
		cocos2d::CCPoint touchLocation = touch->getLocation();

		if(!IsFull())
			ClearPoints(0);
	}
Example #3
0
void wxPolygonShape::Create(wxList *the_points)
{
	ClearPoints();

	if (!the_points)
	{
		m_originalPoints = new wxList;
		m_points = new wxList;
	}
	else
	{
		m_originalPoints = the_points;

		// Duplicate the list of points
		m_points = new wxList;

		wxNode *node = the_points->GetFirst();
		while (node)
		{
			wxRealPoint *point = (wxRealPoint *)node->GetData();
			wxRealPoint *new_point = new wxRealPoint(point->x, point->y);
			m_points->Append((wxObject *) new_point);
			node = node->GetNext();
		}
		CalculateBoundingBox();
		m_originalWidth = m_boundWidth;
		m_originalHeight = m_boundHeight;
		SetDefaultRegionSize();
	}
}
Example #4
0
	bool ColorGrid::CheckList(unsigned int nIndex)
	{
		for(int i = 0; i < m_nSelectedNodesSize; i++)
		{
			if(nIndex == m_pSelectedNodeNumbers[i] && m_pSelectedNodes[i] != 0)
			{
				m_nSelectedNodesSize = i + 1;
				ClearPoints(m_nSelectedNodesSize);
				return false;
			}
		}

		return true;
	}
Example #5
0
int DBrush::BuildPoints()
{
    ClearPoints();

    if(faceList.size() <= 3)	// if less than 3 faces, there can be no points
        return 0;					// with only 3 faces u can't have a bounded soild

    for(list<DPlane *>::const_iterator p1=faceList.begin(); p1!=faceList.end(); p1++)
    {
        list<DPlane *>::const_iterator p2=p1;
        for(p2++; p2!=faceList.end(); p2++)
        {
            list<DPlane *>::const_iterator p3=p2;
            for(p3++; p3!=faceList.end(); p3++)
            {
                vec3_t pnt;
                if((*p1)->PlaneIntersection(*p2, *p3, pnt))
                {
                    int pos = PointPosition(pnt);

                    if(pos == POINT_IN_BRUSH)
                    {   // ???? shouldn't happen here
                        Sys_Printf("ERROR:: Build Brush Points: Point IN brush!!!\n");
                    }
                    else if(pos == POINT_ON_BRUSH)
                    {   // normal point
                        if(!HasPoint(pnt))
                            AddPoint(pnt);
                        /*						else
                        							Sys_Printf("Duplicate Point Found, pyramids ahoy!!!!!\n");*/
                        // point lies on more that 3 planes
                    }

                    // otherwise point is removed due to another plane..

                    // Sys_Printf("(%f, %f, %f)\n", pnt[0], pnt[1], pnt[2]);
                }
            }
        }
    }

#ifdef _DEBUG
//	Sys_Printf("%i points on brush\n", pointList.size());
#endif

    return pointList.size();
}
Example #6
0
	bool ColorGrid::Reset()
	{
		if(!m_pNodes)
			return init();

		ClearPoints(0);
		m_uncaptured_count.resetAll();

		for(int i = 0; i < m_nNodes; ++i)
		{
			m_pNodes[i].uncapture();
			m_pNodes[i].setColor(my_utility::random(m_nColors));
			m_uncaptured_count.tally(m_pNodes[i].getPaletteIndex());
		}

		m_nCapturedNodes = 0;

		RandomCapture(m_nInitCapturePercent);
		
		return true;
	}
Example #7
0
void DBrush::LoadFromBrush(scene::Node* brush, bool textured)
{
    ClearFaces();
    ClearPoints();

#if 0
    for(int i = g_FuncTable.m_pfnGetFaceCount(brush)-1; i >= 0 ; i--)
    {   // running backwards so i dont have to use the count function each time (OPT)
        _QERFaceData* faceData = g_FuncTable.m_pfnGetFaceData(brush, i);

        if(faceData == NULL)
            DoMessageBox("Null pointer returned", "WARNING!", MB_OK);

        if(textured)
            AddFace(faceData->m_v1, faceData->m_v2, faceData->m_v3, faceData);
        else
            AddFace(faceData->m_v1, faceData->m_v2, faceData->m_v3, NULL);
    }
#endif

    QER_brush = brush;
}
Example #8
0
	bool ColorGrid::ccTouchBegan(cocos2d::CCTouch* touch, cocos2d::CCEvent* event)
	{
		cocos2d::CCPoint touchLocation = touch->getLocation();
		
		ClearPoints(0);

		if (m_cbBounds.containsPoint(touchLocation))
		{
			for(int i = 0; i < m_nNodes; i++)
			{
				if(m_pNodes[i].isOnSprite(touchLocation))
				{
					m_pNodes[i].select();
					m_pSelectedNodes[m_nSelectedNodesSize] = &m_pNodes[i];
					m_cbSequenceColors[m_nSelectedNodesSize] = m_pNodes[i].getPaletteIndex();
					m_pSelectedNodeNumbers[m_nSelectedNodesSize] = i;
					m_nSelectedNodesSize = 1;
					return true;
				}
			}
		}

		return true;
	}
Example #9
0
wxPolygonShape::~wxPolygonShape()
{
	ClearPoints();
}
Example #10
0
DBrush::~DBrush()
{
    ClearFaces();
    ClearPoints();
}
void KMeans::IterateOnce()
{
	ClearPoints();
	DistributePointsToClusters();
	RecalculateCenters();
}