Jump to content

Object space to world space conversion?


CrazyM
 Share

Recommended Posts

http://www.leadwerks.com/werkspace/page/api-reference/_/transform/transformpoint-r543

window = Window:Create()
context = Context:Create(window)
world = World:Create()
camera = Camera:Create()
camera:Move(0,2,6)
light = DirectionalLight:Create()
light:SetRotation(35,35,0)

model = Model:Box()
model:SetColor(0.0,0.0,1.0)
model:SetPosition(0,2,9)
model:SetRotation(45,45,0)
surface = model:GetSurface(0)
marker = Model:Box()
marker:SetScale(.05,.05,.05)
marker:SetColor(1,0,0,1)

while window:KeyDown(Key.Escape)==false do
	if window:Closed() then break end
	
	model:Turn(0,-0.2,0.5)
	localpos = surface:GetVertexPosition(0)
	globalpos = Transform:Point(localpos,model,nil)
	screenpos = camera:Project(globalpos)
	marker:SetPosition(globalpos)

	Time:Update()
	world:Update()
	world:Render()

	context:SetBlendMode(Blend.Alpha)
	context:DrawText("Local Vertex Position: "..localpos:ToString(),2,2)
	context:DrawText("Global Vertex Position: "..globalpos:ToString(),2,22)
	context:DrawText("Vert0",screenpos.x,screenpos.y)
	context:SetBlendMode(Blend.Solid)
	context:Sync(true)
end

 

post-14-0-65566200-1453465013_thumb.jpg

  • Upvote 6

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...