示例#1
0
	Vector2I GUIInputCaret::getCaretPosition(const Vector2I& offset) const
	{
		if(mNumChars > 0 && isDescValid())
		{
			UINT32 curPos = 0;
			UINT32 numLines = getNumLines();

			for(UINT32 i = 0; i < numLines; i++)
			{
				const GUIInputLineDesc& lineDesc = getLineDesc(i);

				if(mCaretPos == curPos)
				{
					// Caret is on line start
					return Vector2I(offset.x, lineDesc.getLineYStart() + getTextOffset().y);
				}

				curPos += lineDesc.getEndChar(false) - lineDesc.getStartChar() + 1; // + 1 for special line start position
			}

			UINT32 charIdx = getCharIdxAtCaretPos();
			if(charIdx > 0)
				charIdx -= 1;			

			charIdx = std::min((UINT32)(mNumChars - 1), charIdx);

			Rect2I charRect = getCharRect(charIdx);
			UINT32 lineIdx = getLineForChar(charIdx);
			UINT32 yOffset = getLineDesc(lineIdx).getLineYStart() + getTextOffset().y;

			return Vector2I(charRect.x + charRect.width, yOffset);
		}

		return offset;
	}
示例#2
0
	Vector2I Sprite::getAnchorOffset(SpriteAnchor anchor, UINT32 width, UINT32 height)
	{
		switch(anchor)
		{
		case SA_TopLeft:
			return -Vector2I(0, 0);
		case SA_TopCenter:
			return -Vector2I(width / 2, 0);
		case SA_TopRight:
			return -Vector2I(width, 0);
		case SA_MiddleLeft:
			return -Vector2I(0, height / 2);
		case SA_MiddleCenter:
			return -Vector2I(width / 2, height / 2);
		case SA_MiddleRight:
			return -Vector2I(width, height / 2);
		case SA_BottomLeft:
			return -Vector2I(0, height);
		case SA_BottomCenter:
			return -Vector2I(width / 2, height);
		case SA_BottomRight:
			return -Vector2I(width, height);
		}

		return Vector2I();
	}
示例#3
0
 Vector2I get_opposite_edge(const Vector3I& f, size_t v) {
     if (f[0] == v) {
         return Vector2I(f[1], f[2]);
     } else if (f[1] == v) {
         return Vector2I(f[2], f[0]);
     } else if (f[2] == v) {
         return Vector2I(f[0], f[1]);
     } else {
         std::stringstream err_msg;
         err_msg << "Vertex " << v << " does not belong to triangle ("
             << f.transpose() << ")";
         throw RuntimeError(err_msg.str());
     }
 }
	Vector2I ScriptSceneHandles::wrapCursorToWindow() const
	{
		if (mParentWidget == nullptr)
			return Vector2I();

		SPtr<RenderWindow> parentWindow = mParentWidget->getParentWindow()->getRenderWindow();

		Vector2I windowPos = parentWindow->screenToWindowPos(Cursor::instance().getScreenPosition());
		const RenderWindowProperties& rwProps = parentWindow->getProperties();

		INT32 maxWidth = std::max(0, (INT32)rwProps.width - 1);
		INT32 maxHeight = std::max(0, (INT32)rwProps.height - 1);

		Vector2I offset;
		if (windowPos.x <= 0)
			offset.x = maxWidth;
		else if (windowPos.x >= maxWidth)
			offset.x = -maxWidth;

		if (windowPos.y <= 0)
			offset.y = maxHeight;
		else if (windowPos.y >= maxHeight)
			offset.y = -maxHeight;

		windowPos += offset;

		Vector2I wrappedScreenPos = parentWindow->windowToScreenPos(windowPos);
		Cursor::instance().setScreenPosition(wrappedScreenPos);

		return offset;
	}
	bool ScriptEditorWindow::internal_isPointerHovering(ScriptEditorWindow* thisPtr)
	{
		if (!thisPtr->isDestroyed())
		{
			EditorWidgetBase* widget = thisPtr->getEditorWidget();
			EditorWindowBase* window = widget->getParentWindow();
			if (window == nullptr)
				return false;

			SPtr<RenderWindow> renderWindow = window->getRenderWindow();

			Vector2I pointerPos = gInput().getPointerPosition();
			if(Platform::isPointOverWindow(*renderWindow, pointerPos))
			{
				Rect2I bounds = thisPtr->getEditorWidget()->getBounds();
				Vector2I screenPos = widget->widgetToScreenPos(Vector2I(0, 0));

				bounds.x = screenPos.x;
				bounds.y = screenPos.y;

				return bounds.contains(pointerPos);
			}
		}

		return false;
	}
示例#6
0
	Vector2I GUIHelper::calcOptimalContentsSize(const String& text, const GUIElementStyle& style, const 
		GUIDimensions& dimensions)
	{
		UINT32 wordWrapWidth = 0;

		if(style.wordWrap)
			wordWrapWidth = dimensions.maxWidth;

		UINT32 contentWidth = style.margins.left + style.margins.right + style.contentOffset.left + style.contentOffset.right;
		UINT32 contentHeight = style.margins.top + style.margins.bottom + style.contentOffset.top + style.contentOffset.bottom;

		if(style.font != nullptr && !text.empty())
		{
			bs_frame_mark();

			const U32String utf32text = UTF8::toUTF32(text);
			TextData<FrameAlloc> textData(utf32text, style.font, style.fontSize, wordWrapWidth, 0, style.wordWrap);

			contentWidth += textData.getWidth();
			contentHeight += textData.getNumLines() * textData.getLineHeight(); 

			bs_frame_clear();
		}

		return Vector2I(contentWidth, contentHeight);
	}
示例#7
0
    std::vector<VectorI> enumerate(const VectorI& repetitions) {
        std::vector<VectorI> result;
        const size_t dim = repetitions.size();
        if (dim == 2) {
            for (size_t i=0; i<repetitions[0]; i++) {
                for (size_t j=0; j<repetitions[1]; j++) {
                    result.push_back(Vector2I(i,j));
                }
            }
        } else if (dim == 3) {
            for (size_t i=0; i<repetitions[0]; i++) {
                for (size_t j=0; j<repetitions[1]; j++) {
                    for (size_t k=0; k<repetitions[2]; k++) {
                        result.push_back(Vector3I(i,j,k));
                    }
                }
            }
        } else {
            std::stringstream err_msg;
            err_msg << "Unsupported dim: " << dim;
            throw NotImplementedError(err_msg.str());
        }

        return result;
    }
	Vector2I ScriptSceneHandles::wrapCursorToWindow() const
	{
		if (mParentWidget == nullptr)
			return Vector2I();

		SPtr<RenderWindow> parentWindow = mParentWidget->getParentWindow()->getRenderWindow();

		Vector2I screenPos = Cursor::instance().getScreenPosition();
		Vector2I windowPos = parentWindow->screenToWindowPos(screenPos);
		const RenderWindowProperties& rwProps = parentWindow->getProperties();

		INT32 maxWidth = std::max(0, (INT32)rwProps.width - 1);
		INT32 maxHeight = std::max(0, (INT32)rwProps.height - 1);

		Vector2I offset;
		if (windowPos.x <= 0)
			offset.x = maxWidth;
		else if (windowPos.x >= maxWidth)
			offset.x = -maxWidth;

		if (windowPos.y <= 0)
			offset.y = maxHeight;
		else if (windowPos.y >= maxHeight)
			offset.y = -maxHeight;

		windowPos += offset;

		Vector2I wrappedScreenPos = parentWindow->windowToScreenPos(windowPos);

		// This check is important for macOS, where continuously setting the position will freeze the cursor in place
		if(wrappedScreenPos != screenPos)
			Cursor::instance().setScreenPosition(wrappedScreenPos);

		return offset;
	}
示例#9
0
文件: Tile.cpp 项目: AeroGlass/g3m
ElevationData* Tile::createElevationDataSubviewFromAncestor(Tile* ancestor) const{
  ElevationData* ed = ancestor->getElevationData();

  if (ed == NULL){
    ILogger::instance()->logError("Ancestor can't have undefined Elevation Data.");
    return NULL;
  }

  if (ed->getExtentWidth() < 1 || ed->getExtentHeight() < 1){
    ILogger::instance()->logWarning("Tile too small for ancestor elevation data.");
    return NULL;
  }

  if ((_lastElevationDataProvider != NULL) &&
      (_lastTileMeshResolutionX > 0) &&
      (_lastTileMeshResolutionY > 0)) {
//    ElevationData* subView = _lastElevationDataProvider->createSubviewOfElevationData(ed,
//                                                                                      getSector(),
//                                                                                      Vector2I(_lastTileMeshResolutionX, _lastTileMeshResolutionY));
//    return subView;

    return new SubviewElevationData(ed,
                                    //bool ownsElevationData,
                                    getSector(),
                                    Vector2I(_lastTileMeshResolutionX, _lastTileMeshResolutionY));
  }

  ILogger::instance()->logError("Can't create subview of elevation data from ancestor");
  return NULL;

}
	void GUIResourceTreeView::dropTargetDragDropped(INT32 x, INT32 y)
	{
		const GUITreeView::InteractableElement* element = findElementUnderCoord(Vector2I(x, y));

		TreeElement* treeElement = nullptr;
		if(element != nullptr)
		{
			if(element->isTreeElement())
				treeElement = element->getTreeElement();
			else
				treeElement = element->parent;
		}

		if(mDropTarget->getDropType() == OSDropType::FileList)
		{
			Vector<WString> fileList = mDropTarget->getFileList();

			mDraggedResources = bs_new<InternalDraggedResources>((UINT32)fileList.size());
			for(UINT32 i = 0; i < (UINT32)fileList.size(); i++)
				mDraggedResources->resourcePaths[i] = fileList[i];

			dragAndDropEnded(treeElement);

			bs_delete(mDraggedResources);
			mDraggedResources = nullptr;

			unselectAll();
		}

		mDragInProgress = false;
		mDropTargetDragActive = false;
		_markLayoutAsDirty();
	}
示例#11
0
    void UpdateFromMouseInput( CameraState* camera, MouseState* current_mouse_state )
    {
		/////////////////////////////
		//	MOUSE
		//	
        current_mouse_state->m_Center = getTheRenderer().GetWindowCenterInScreenCoordinates();

		POINT mouse_pos_point;
		GetCursorPos( &mouse_pos_point );
        current_mouse_state->m_PreviousPosition = current_mouse_state->m_Position;
		current_mouse_state->m_Position = Vector2I( (int)mouse_pos_point.x, (int)mouse_pos_point.y );

		current_mouse_state->m_Delta= current_mouse_state->m_Position - current_mouse_state->m_PreviousPosition;

		switch( camera->m_Type )
		{
		case kFlyCam:
			FlyCam::UpdateFromMouseInput( camera, current_mouse_state );
			break;
		case kMayaCam:
			MayaCam::UpdateFromMouseInput( (MayaCameraState*)camera, current_mouse_state );
			break;
		}

        if( current_mouse_state->m_IsDragging )
        {
            //at -1, mouse becomes hidden
            while( ShowCursor( false ) > -1 ) {}
        }
        else
        {
            //at 0, mouse becomes visible
            while( ShowCursor( true ) < 0 ) {}
        }
	}
示例#12
0
	bool OverlayGroup::load(TiXmlNode *xmlnode)
	{
		TiXmlNode *itemnode;
		TiXmlElement *itemelement;
		
		// Parse images
		itemnode = xmlnode->FirstChild("image");
		while(itemnode)
		{
			itemnode = xmlnode->IterateChildren("image", itemnode);
			if(itemnode)
			{
				itemelement = itemnode->ToElement();
				// Check for attributes
				if(!itemelement->Attribute("name"))
				{
					std::cerr << "No \"name\" found in <image>" << std::endl;
					return false;
				}
				if(!itemelement->Attribute("offset") || !itemelement->Attribute("size"))
				{
					std::cerr << "No \"offset\" and/or \"size\" found in <image>" << std::endl;
					return false;
				}
				if(!itemelement->Attribute("image-path") || !itemelement->Attribute("texture-size"))
				{
					std::cerr << "No \"image-path\" and/or \"texture-size\" found in <image>" << std::endl;
					return false;
				}
				// Instantiate new OverlayItem object
				std::string itemname = itemelement->Attribute("name");
				OverlayImage *image = new OverlayImage();
				image->setName(itemname);
				image->setSize( Vector2I(itemelement->Attribute("size")) );
				image->setOffset( Vector2I(itemelement->Attribute("offset")) );
				image->loadImage(itemelement->Attribute("image-path"),
					Vector2I(itemelement->Attribute("texture-size")));
				items[itemname] = image;
				
				// Jump to the next <image> entry
				itemnode = xmlnode->IterateChildren("image", itemnode);
			}

		}
		return true;
	}
示例#13
0
	Vector2I GUIHelper::calcOptimalContentsSize(const Vector2I& contentSize, const GUIElementStyle& style, 
		const GUIDimensions& dimensions)
	{
		UINT32 contentWidth = style.margins.left + style.margins.right + style.contentOffset.left + style.contentOffset.right;
		UINT32 contentHeight = style.margins.top + style.margins.bottom + style.contentOffset.top + style.contentOffset.bottom;

		return Vector2I(std::max((UINT32)contentSize.x, contentWidth), std::max((UINT32)contentSize.y, contentHeight));
	}
示例#14
0
	Vector2I Win32Window::windowToScreenPos(const Vector2I& windowPos) const
	{
		POINT pos;
		pos.x = windowPos.x;
		pos.y = windowPos.y;

		ClientToScreen(m->hWnd, &pos);
		return Vector2I(pos.x, pos.y);
	}
示例#15
0
	Vector2I Win32Window::screenToWindowPos(const Vector2I& screenPos) const
	{
		POINT pos;
		pos.x = screenPos.x;
		pos.y = screenPos.y;

		ScreenToClient(m->hWnd, &pos);
		return Vector2I(pos.x, pos.y);
	}
示例#16
0
	LayoutSizeRange GUIScrollArea::_calculateLayoutSizeRange() const
	{
		// I'm ignoring scroll bars here since if the content layout fits
		// then they're not needed and the range is valid. And if it doesn't
		// fit the area will get clipped anyway and including the scroll bars
		// won't change the size much, but it would complicate this method significantly.
		if (mContentLayout->_isActive())
			return mDimensions.calculateSizeRange(_getOptimalSize());

		return mDimensions.calculateSizeRange(Vector2I());
	}
示例#17
0
	void TextSprite::getAlignmentOffsets(const TextDataBase& textData,
		UINT32 width, UINT32 height, TextHorzAlign horzAlign, TextVertAlign vertAlign, Vector2I* output)
	{
		UINT32 numLines = textData.getNumLines();
		UINT32 curHeight = 0;
		for(UINT32 i = 0; i < numLines; i++)
		{
			const TextDataBase::TextLine& line = textData.getLine(i);
			curHeight += line.getYOffset();
		}

		// Calc vertical alignment offset
		UINT32 vertDiff = std::max(0U, height - curHeight);
		UINT32 vertOffset = 0;
		switch(vertAlign)
		{
		case TVA_Top:
			vertOffset = 0;
			break;
		case TVA_Bottom:
			vertOffset = std::max(0, (INT32)vertDiff);
			break;
		case TVA_Center:
			vertOffset = std::max(0, (INT32)vertDiff) / 2;
			break;
		}

		// Calc horizontal alignment offset
		UINT32 curY = 0;
		for(UINT32 i = 0; i < numLines; i++)
		{
			const TextDataBase::TextLine& line = textData.getLine(i);

			UINT32 horzOffset = 0;
			switch(horzAlign)
			{
			case THA_Left:
				horzOffset = 0;
				break;
			case THA_Right:
				horzOffset = std::max(0, (INT32)(width - line.getWidth()));
				break;
			case THA_Center:
				horzOffset = std::max(0, (INT32)(width - line.getWidth())) / 2;
				break;
			}

			output[i] = Vector2I(horzOffset, vertOffset + curY);
			curY += line.getYOffset();
		}
	}
示例#18
0
	void GuichanFont::drawString(gcn::Graphics *graphics,
		const std::string& text, int x, int y)
	{
		const gcn::ClipRectangle &top = graphics->getCurrentClipArea();
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
		glEnable(GL_BLEND);
		glEnable(GL_TEXTURE_2D);
		font->renderRaw(text, Vector2I(x + top.xOffset, y + top.yOffset));
		glDisable(GL_TEXTURE_2D);
		glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
		gcn::Color color = graphics->getColor();
		if (color.a == 255)
			glDisable(GL_BLEND);
	}
	void ScriptContextMenu::internal_Open(ScriptContextMenu* instance, Vector2I* position, ScriptGUILayout* layoutPtr)
	{
		GUIElementBase* layout = layoutPtr->getGUIElement();

		GUIWidget* widget = layout->_getParentWidget();
		if (widget == nullptr)
			return;

		Rect2I bounds = layout->getGlobalBounds();
		Vector2I windowPosition = *position + Vector2I(bounds.x, bounds.y);

		SPtr<GUIContextMenu> contextMenu = instance->getInternal();
		contextMenu->open(windowPosition, *widget);
	}
示例#20
0
	HRESULT __stdcall Win32DropTarget::DragLeave()
	{
		{
			Lock lock(mSync);

			mQueuedDropOps.push_back(DropTargetOp(DropOpType::Leave, Vector2I()));

			DropTargetOp& op = mQueuedDropOps.back();
			op.dataType = DropOpDataType::FileList;
			op.mFileList = mFileLists.back();
		}

		return S_OK;
	}
示例#21
0
	Rect2I GUIElement::getCachedContentClipRect() const
	{
		Rect2I contentBounds = getCachedContentBounds();
		
		// Transform into element space so we can clip it using the element clip rectangle
		Vector2I offsetDiff = Vector2I(contentBounds.x - mLayoutData.area.x, contentBounds.y - mLayoutData.area.y);
		Rect2I contentClipRect(offsetDiff.x, offsetDiff.y, contentBounds.width, contentBounds.height);
		contentClipRect.clip(mLayoutData.getLocalClipRect());

		// Transform into content sprite space
		contentClipRect.x -= offsetDiff.x;
		contentClipRect.y -= offsetDiff.y;

		return contentClipRect;
	}
	Vector2I GUIButtonBase::_getOptimalSize() const
	{
		UINT32 imageWidth = 0;
		UINT32 imageHeight = 0;

		const HSpriteTexture& activeTex = getActiveTexture();
		if(SpriteTexture::checkIsLoaded(activeTex))
		{
			imageWidth = activeTex->getWidth();
			imageHeight = activeTex->getHeight();
		}

		Vector2I contentSize = GUIHelper::calcOptimalContentsSize(mContent, *_getStyle(), _getDimensions(), mActiveState);
		UINT32 contentWidth = std::max(imageWidth, (UINT32)contentSize.x);
		UINT32 contentHeight = std::max(imageHeight, (UINT32)contentSize.y);

		return Vector2I(contentWidth, contentHeight);
	}
示例#23
0
	void CEGUITextureTarget::declareRenderSize(const CEGUI::Sizef& sz)
	{
		// exit if current size is enough
		if ((m_Area.getWidth() >= sz.d_width) 
			&& (m_Area.getHeight() >= sz.d_height))
		{
			return;
		}

		CA_TRACE("CEGUITextureTarget(%p) resize %f %f\n", this, sz.d_width, sz.d_height);

		setArea(CEGUI::Rectf(m_Area.getPosition(), sz));

		CasaEngine::TextureTarget* pTexTarget = dynamic_cast<CasaEngine::TextureTarget *>(m_pRenderTarget);
		pTexTarget->Create(
			Vector2I(m_Area.getSize().d_width, m_Area.getSize().d_height), 
			CasaEngine::PixelFormat::ARGB_8888);
		m_pTexture->SetTexture(pTexTarget->GetTexture());
	}
	void GUIResourceTreeView::dropTargetDragMove(INT32 x, INT32 y)
	{
		mDragPosition = Vector2I(x, y);
		mDragInProgress = true;
		mDropTargetDragActive = true;
		_markLayoutAsDirty();

		if(mBottomScrollBounds.contains(mDragPosition))
		{
			if(mScrollState != ScrollState::Down)
				mScrollState = ScrollState::TransitioningDown;
		}
		else if(mTopScrollBounds.contains(mDragPosition))
		{
			if(mScrollState != ScrollState::Up)
				mScrollState = ScrollState::TransitioningUp;
		}
		else
			mScrollState = ScrollState::None;
	}
示例#25
0
	HRESULT __stdcall Win32DropTarget::DragOver(DWORD grfKeyState, POINTL pt, DWORD* pdwEffect)
	{
		*pdwEffect = DROPEFFECT_LINK;

		if(!mAcceptDrag)
			return S_OK;

		{
			Lock lock(mSync);

			ScreenToClient(mHWnd, (POINT *)&pt);
			mQueuedDropOps.push_back(DropTargetOp(DropOpType::DragOver, Vector2I((int)pt.x, (int)pt.y)));

			DropTargetOp& op = mQueuedDropOps.back();
			op.dataType = DropOpDataType::FileList;
			op.mFileList = mFileLists.back();
		}

		return S_OK;
	}
示例#26
0
GoogleMapsLayer::GoogleMapsLayer(const std::string& key,
                                 const TimeInterval& timeToCache,
                                 bool readExpired,
                                 int initialLevel,
                                 LayerCondition* condition) :
Layer(condition,
      "GoogleMaps",
      timeToCache,
      readExpired,
      new LayerTilesRenderParameters(Sector::fullSphere(),
                                     1,
                                     1,
                                     initialLevel,
                                     20,
                                     Vector2I(256, 256),
                                     LayerTilesRenderParameters::defaultTileMeshResolution(),
                                     true) ),
_key(key),
_sector(Sector::fullSphere())
{

}
示例#27
0
	Rect2I GUIInputCaret::getSpriteClipRect(const Rect2I& parentClipRect) const
	{
		Vector2I offset(mElement->_getLayoutData().area.x, mElement->_getLayoutData().area.y);

		Vector2I clipOffset = getSpriteOffset() - offset -
			Vector2I(mElement->_getTextInputRect().x, mElement->_getTextInputRect().y);

		Rect2I clipRect(-clipOffset.x, -clipOffset.y, mTextDesc.width, mTextDesc.height);

		Rect2I localParentCliprect = parentClipRect;

		// Move parent rect to our space
		localParentCliprect.x += mElement->_getTextInputOffset().x + clipRect.x;
		localParentCliprect.y += mElement->_getTextInputOffset().y + clipRect.y;

		// Clip our rectangle so its not larger then the parent
		clipRect.clip(localParentCliprect);

		// Increase clip size by 1, so we can fit the caret in case it is fully at the end of the text
		clipRect.width += 1;

		return clipRect;
	}
示例#28
0
	HRESULT __stdcall Win32DropTarget::Drop(IDataObject* pDataObj, DWORD grfKeyState, POINTL pt, DWORD* pdwEffect)
	{
		*pdwEffect = DROPEFFECT_LINK;
		mAcceptDrag = false;

		if(!isDataValid(pDataObj))
			return S_OK;

		{
			Lock lock(mSync);

			mFileLists.push_back(getFileListFromData(pDataObj));

			ScreenToClient(mHWnd, (POINT *)&pt);
			mQueuedDropOps.push_back(DropTargetOp(DropOpType::Drop, Vector2I((int)pt.x, (int)pt.y)));

			DropTargetOp& op = mQueuedDropOps.back();
			op.dataType = DropOpDataType::FileList;
			op.mFileList = mFileLists.back();
		}

		return S_OK;
	}
示例#29
0
namespace engine {
	// Mathlib.hpp
	const float Math::Pi = 3.14159265f;
	const float Math::HalfPi = 1.570796325f;
	const float Math::Epsilon = std::numeric_limits<float>::epsilon();

	// Vector2.hpp
	template<> const Vector2I Vector2I::ZERO = Vector2I(0,0);
	template<> const Vector2F Vector2F::ZERO = Vector2F(0.f, 0.f);

	// Vector3.hpp
	template<> const Vector3I Vector3I::ZERO = Vector3I(0,0,0);
	template<> const Vector3F Vector3F::ZERO = Vector3F(0.f,0.f,0.f);

	template<> const Vector3F Vector3F::UNIT_Z = Vector3F(0.f,0.f,1.f);
	template<> const Vector3F Vector3F::UNIT_X = Vector3F(1.f,0.f,0.f);
	template<> const Vector3F Vector3F::UNIT_Y = Vector3F(0.f,1.f,0.f);
	template<> const Vector3F Vector3F::NEGUNIT_Z = Vector3F(0.f,0.f,-1.f);
	template<> const Vector3F Vector3F::NEGUNIT_X = Vector3F(-1.f,0.f,0.f);
	template<> const Vector3F Vector3F::NEGUNIT_Y = Vector3F(0.f,-1.f,0.f);

	// Matrix4.hpp
	const Matrix4 Matrix4::IDENTITY = Matrix4();

	void Matrix4::SetOrientation(const Quaternion &pQuat){
		Matrix4 tempMat = pQuat.ToMatrix();
		tempMat.SetTranslation(this->GetTranslation());
		*this = tempMat;
	}

	void Matrix4::Rotate(const Quaternion &pQuat){
		Quaternion oldOrient, newOrient;
		oldOrient.FromMatrix(*this);
		newOrient = oldOrient * pQuat;
		this->SetOrientation(newOrient);
	}
}
	void ScriptSceneSelection::internal_PickObject(ScriptSceneSelection* thisPtr, Vector2I* inputPos, bool additive)
	{
		// TODO - Handle multi-selection (i.e. selection rectangle when dragging)
		HSceneObject pickedObject = ScenePicking::instance().pickClosestObject(thisPtr->mCamera, *inputPos, Vector2I(1, 1));

		if (pickedObject)
		{
			if (additive) // Append to existing selection
			{
				Vector<HSceneObject> selectedSOs = Selection::instance().getSceneObjects();

				auto iterFind = std::find_if(selectedSOs.begin(), selectedSOs.end(),
					[&](const HSceneObject& obj) { return obj == pickedObject; }
				);

				if (iterFind == selectedSOs.end())
					selectedSOs.push_back(pickedObject);

				Selection::instance().setSceneObjects(selectedSOs);
			}
			else
			{
				Vector<HSceneObject> selectedSOs = { pickedObject };

				Selection::instance().setSceneObjects(selectedSOs);
			}
		}
		else
			Selection::instance().clearSceneSelection();
	}