Ejemplo n.º 1
0
Vector3 getCurrentSelectionCenter() {
	// Construct a walker to traverse the selection
	BoundsAccumulator walker;
	GlobalSelectionSystem().foreachSelected(walker);

	return vector3_snapped(walker.getBounds().getOrigin());
}
Ejemplo n.º 2
0
bool Region_cameraValid()
{
  Vector3 vOrig(vector3_snapped(Camera_getOrigin(*g_pParentWnd->GetCamWnd())));

  for (int i=0 ; i<3 ; i++)
  {
    if (vOrig[i] > region_maxs[i] || vOrig[i] < region_mins[i])
    {
      return false;
    }
  }
  return true;
}
Ejemplo n.º 3
0
void PasteToCamera (void)
{
	CamWnd& camwnd = *g_pParentWnd->GetCamWnd();
	GlobalSelectionSystem().setSelectedAll(false);

	UndoableCommand undo("pasteToCamera");

	Selection_Paste();

	// Work out the delta
	Vector3 mid = selection::algorithm::getCurrentSelectionCenter();
	Vector3 delta = vector3_snapped(camwnd.getCameraOrigin(), GlobalGrid().getGridSize()) - mid;

	// Move to camera
	GlobalSelectionSystem().translateSelected(delta);
}
Ejemplo n.º 4
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;
}