Created
September 23, 2019 06:20
-
-
Save Realitian/56e0cc4d5526f34ea6f8d71b98de90eb to your computer and use it in GitHub Desktop.
Convert WorldSpaceCoordinate To ScreenSpaceCoordinate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| flagScreenPos = projectionMatrix * modelViewMatrix * pos3dWSC; | |
| float sx = flagScreenPos.x/flagScreenPos.w; | |
| float sy = flagScreenPos.y/flagScreenPos.w; | |
| float lx = (1 + sx)/2.0 * view.bounds.size.width; | |
| float ly = (1 - sy)/2.0 * view.bounds.size.height; | |
| if ( !isnan(lx) && !isnan(ly) ){ | |
| dispatch_async(dispatch_get_global_queue(0, 0), ^{ | |
| dispatch_async(dispatch_get_main_queue(), ^{ | |
| CGRect frame = self.label.frame; | |
| self.label.text = @"text"; | |
| frame.origin.x=lx - 10; | |
| frame.origin.y=ly - 10; | |
| frame.size.width = 200; | |
| frame.size.height = 50; | |
| self.label.frame= frame; | |
| }); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment