generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: ey tony whats the math

Previous Thread :: Next Thread 
chimmmihc is not online. chimmmihc
Joined: 24 Jul 2014
Total Posts: 2420
20 Dec 2015 12:18 PM
ey tony whats the math to convert 3d position to a 2d screenspace position?
Report Abuse
cgjnm is not online. cgjnm
Joined: 22 Dec 2011
Total Posts: 2347
20 Dec 2015 12:20 PM
3D uses X,Y,Z and 2D uses X,Y so just don't include the Z value? Is this what you are asking?
Report Abuse
chimmmihc is not online. chimmmihc
Joined: 24 Jul 2014
Total Posts: 2420
20 Dec 2015 12:30 PM
oh god no.

I need to map a 3d space to a 2d screen space
Report Abuse
EgoMoose is not online. EgoMoose
Joined: 04 Feb 2009
Total Posts: 2896
20 Dec 2015 12:41 PM
Like this?

http://wiki.roblox.com/index.php?title=API:Class/Camera/WorldToScreenPoint
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
20 Dec 2015 01:24 PM
local camera = workspace.CurrentCamera; do
while not camera do
repeat until workspace.Changed:wait() == "CurrentCamera" and workspace.CurrentCamera;
camera = workspace.CurrentCamera;
end
workspace.Changed:connect(function(property)
if property == "CurrentCamera" then
camera = workspace.CurrentCamera or camera;
end
end)
repeat until(
camera.ViewportSize.magnitude > 0
or
camera.Changed:wait() == "ViewportSize"
)
end

function worldToScreen(vectorIn)
local f = camera.ViewportSize.Y/(2*math.tan(math.rad(camera.FieldOfView*.5)))
local toscreen = CFrame.new(
0, 0, 0,
f, 0, 0,
0, f, 0,
0, 0, 1
)*camera.CoordinateFrame:inverse()*vectorIn*Vector3.new(1, -1, -1)
local vectorOut = Vector3.new(toscreen.X, toscreen.Y, toscreen.Z^2)/toscreen.Z + Vector3.new(camera.ViewportSize.X/2,camera.ViewportSize.Y/2)
return vectorOut, vectorOut.Z > 0
end
print(worldToScreen(workspace.BasePlate.Position))
print(camera:WorldToScreenPoint(workspace.BasePlate.Position))
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image