Ejemplo n.º 1
0
// create the display list at the end
void CPointfile::GenerateDisplayList()
{
  m_displaylist = glGenLists(1);

  glNewList (m_displaylist,  GL_COMPILE);

  glBegin(GL_LINE_STRIP);
	for(std::size_t i=0;i<s_num_points;i++)
	  glVertex3fv (vector3_to_array(s_pointvecs[i]));
  glEnd();
  glLineWidth (1);
	
  glEndList();
}
Ejemplo n.º 2
0
SignalHandlerResult DTreePlanter::mouseDown(const WindowVector& position, ButtonIdentifier button, ModifierFlags modifiers)
{
  if(button != c_buttonLeft)
  {
    return SIGNAL_CONTINUE_EMISSION;
  }
	VIEWTYPE vt = GlobalRadiant().XYWindow_getViewType();

	switch(vt) {
		case XY:
			break;
		case YZ:
		case XZ:
		default:
			return SIGNAL_CONTINUE_EMISSION;
	}

	Vector3 pt, vhit;

  pt = vector3_snapped(GlobalRadiant().XYWindow_windowToWorld(position), GlobalRadiant().getGridSize());

	if(FindDropPoint(vector3_to_array(pt), vector3_to_array(vhit))) {
		vhit[2] += m_offset;

		char buffer[128];
		DEntity e(m_entType);

		sprintf(buffer, "%i %i %i", (int)vhit[0], (int)vhit[1], (int)vhit[2]);
		e.AddEPair("origin", buffer);

		if(m_autoLink) {

      const scene::Path* pLastEntity = NULL;
			const scene::Path* pThisEntity = NULL;

			int entpos;
			for(int i = 0; i < 256; i++) {
				sprintf(buffer, m_linkName, i);
        pThisEntity = FindEntityFromTargetname( buffer );

				if(pThisEntity) {
					entpos = i;
					pLastEntity = pThisEntity;
				}
			}

			if(!pLastEntity) {
				sprintf(buffer, m_linkName, 0);
			} else {
				sprintf(buffer, m_linkName, entpos + 1);
			}

			e.AddEPair( "targetname", buffer );

			if(pLastEntity) {
				DEntity e2;
				e2.LoadFromEntity(pLastEntity->top(), true);
				e2.AddEPair("target", buffer);
				e2.RemoveFromRadiant();
				e2.BuildInRadiant(false);
			}

		}

		if(m_setAngles) {
			int angleYaw = (rand() % (m_maxYaw - m_minYaw + 1)) + m_minYaw;
			int anglePitch = (rand() % (m_maxPitch - m_minPitch + 1)) + m_minPitch;

			sprintf(buffer, "%i %i 0", anglePitch, angleYaw);
			e.AddEPair("angles", buffer);
		}

		if(m_numModels) {
			int treetype = rand() % m_numModels;
			e.AddEPair("model", m_trees[treetype].name);
		}

		if(m_useScale) {
			float scale = (((rand()%1000)*0.001f) * (m_maxScale - m_minScale)) + m_minScale;

			sprintf(buffer, "%f", scale );
			e.AddEPair("modelscale", buffer);
		}

		e.BuildInRadiant( false );
	}

	if(m_autoLink) {
		DoTrainPathPlot();
	}

	return SIGNAL_STOP_EMISSION;
}