private void TransformObjAccordActor(MObject obj, MActor actor) { Transform actorTrans = actor.transform; //get the position of the actor within the world Vector2 actorVpPos = WorldToMap(actorTrans.position); //and it's map coordinates Vector2 objCoord = actorVpPos - currentCenterCoord; //if mask either doesn't exist or exists and the actor is in the visible area of the mask //also cut out actors outside of visible area of the view float xPos = (actorVpPos.x + rTrans.rect.width / 2 - currentCenterCoord.x) / rTrans.rect.width; float yPos = (actorVpPos.y + rTrans.rect.height / 2 - currentCenterCoord.y) / rTrans.rect.height; bool isVisible = false; if (xPos <= 1.0f && xPos >= 0.0f && yPos <= 1.0f && yPos >= 0.0f) isVisible = IsWithinMaskTex(new Vector2(xPos, yPos)); obj.UpdateObject(orientation, objCoord, actorTrans.forward, isVisible, currentCenterCoord, mObjectDefaultSize, CalculateZoomScaleRatio(), isScalingMObjects, isZoomingSmoothly, smoothZoomSpeed); }
private void TransformObjAccordActor(MObject obj, MActor actor) { Transform actorTrans = actor.transform; //object's map coordinates Vector2 actorCoord = WorldToMap(actorTrans.position); Vector2 objCoord = actorCoord - currentCenterCoord; //calculate the position within the mask and check if it is within the mask Rect locRect = rTrans.rect; float xPos = (actorCoord.x + locRect.width / 2 - currentCenterCoord.x) / locRect.width; float yPos = (actorCoord.y + locRect.height / 2 - currentCenterCoord.y) / locRect.height; bool isVisible = false; if (xPos <= 1.0f && xPos >= 0.0f && yPos <= 1.0f && yPos >= 0.0f) isVisible = IsWithinMaskTex(new Vector2(xPos, yPos)); obj.UpdateObject(orientation, objCoord, actorTrans.forward, isVisible, currentCenterCoord, mObjectDefaultSize, CalculateZoomScaleRatio(), isScalingMObjects, isZoomingSmoothly, smoothZoomSpeed); }