GetScreenToWorldRay() and GetScreenToWorldRayEx() added
This commit is contained in:
parent
52954882a0
commit
7275646a1d
2 changed files with 43 additions and 1 deletions
|
@ -104,6 +104,8 @@ var setShaderValueMatrix func(shader uintptr, locIndex int32, mat uintptr)
|
|||
var setShaderValueTexture func(shader uintptr, locIndex int32, texture uintptr)
|
||||
var unloadShader func(shader uintptr)
|
||||
var getMouseRay func(ray uintptr, mousePosition uintptr, camera uintptr)
|
||||
var getScreenToWorldRay func(ray uintptr, position uintptr, camera uintptr)
|
||||
var getScreenToWorldRayEx func(ray uintptr, position uintptr, camera uintptr, width, height int32)
|
||||
var getCameraMatrix func(mat uintptr, camera uintptr)
|
||||
var getCameraMatrix2D func(mat uintptr, camera uintptr)
|
||||
var getWorldToScreen func(position uintptr, camera uintptr) uintptr
|
||||
|
@ -602,6 +604,8 @@ func init() {
|
|||
purego.RegisterLibFunc(&setShaderValueTexture, raylibDll, "SetShaderValueTexture")
|
||||
purego.RegisterLibFunc(&unloadShader, raylibDll, "UnloadShader")
|
||||
purego.RegisterLibFunc(&getMouseRay, raylibDll, "GetMouseRay")
|
||||
purego.RegisterLibFunc(&getScreenToWorldRay, raylibDll, "GetScreenToWorldRay")
|
||||
purego.RegisterLibFunc(&getScreenToWorldRayEx, raylibDll, "GetScreenToWorldRayEx")
|
||||
purego.RegisterLibFunc(&getCameraMatrix, raylibDll, "GetCameraMatrix")
|
||||
purego.RegisterLibFunc(&getCameraMatrix2D, raylibDll, "GetCameraMatrix2D")
|
||||
purego.RegisterLibFunc(&getWorldToScreen, raylibDll, "GetWorldToScreen")
|
||||
|
@ -1475,12 +1479,28 @@ func UnloadShader(shader Shader) {
|
|||
}
|
||||
|
||||
// GetMouseRay - Get a ray trace from mouse position
|
||||
//
|
||||
// Deprecated: Use [GetScreenToWorldRay] instead.
|
||||
func GetMouseRay(mousePosition Vector2, camera Camera) Ray {
|
||||
var ray Ray
|
||||
getMouseRay(uintptr(unsafe.Pointer(&ray)), *(*uintptr)(unsafe.Pointer(&mousePosition)), uintptr(unsafe.Pointer(&camera)))
|
||||
return ray
|
||||
}
|
||||
|
||||
// GetScreenToWorldRay - Get a ray trace from screen position (i.e mouse)
|
||||
func GetScreenToWorldRay(position Vector2, camera Camera) Ray {
|
||||
var ray Ray
|
||||
getScreenToWorldRay(uintptr(unsafe.Pointer(&ray)), *(*uintptr)(unsafe.Pointer(&position)), uintptr(unsafe.Pointer(&camera)))
|
||||
return ray
|
||||
}
|
||||
|
||||
// GetScreenToWorldRayEx - Get a ray trace from screen position (i.e mouse) in a viewport
|
||||
func GetScreenToWorldRayEx(position Vector2, camera Camera, width, height int32) Ray {
|
||||
var ray Ray
|
||||
getScreenToWorldRayEx(uintptr(unsafe.Pointer(&ray)), *(*uintptr)(unsafe.Pointer(&position)), uintptr(unsafe.Pointer(&camera)), width, height)
|
||||
return ray
|
||||
}
|
||||
|
||||
// GetCameraMatrix - Get camera transform matrix (view matrix)
|
||||
func GetCameraMatrix(camera Camera) Matrix {
|
||||
var mat Matrix
|
||||
|
|
|
@ -626,7 +626,9 @@ func UnloadShader(shader Shader) {
|
|||
C.UnloadShader(*cshader)
|
||||
}
|
||||
|
||||
// GetMouseRay - Returns a ray trace from mouse position
|
||||
// GetMouseRay - Get a ray trace from mouse position
|
||||
//
|
||||
// Deprecated: Use [GetScreenToWorldRay] instead.
|
||||
func GetMouseRay(mousePosition Vector2, camera Camera) Ray {
|
||||
cmousePosition := mousePosition.cptr()
|
||||
ccamera := camera.cptr()
|
||||
|
@ -635,6 +637,26 @@ func GetMouseRay(mousePosition Vector2, camera Camera) Ray {
|
|||
return v
|
||||
}
|
||||
|
||||
// GetScreenToWorldRay - Get a ray trace from screen position (i.e mouse)
|
||||
func GetScreenToWorldRay(position Vector2, camera Camera) Ray {
|
||||
cposition := position.cptr()
|
||||
ccamera := camera.cptr()
|
||||
ret := C.GetMouseRay(*cposition, *ccamera)
|
||||
v := newRayFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
}
|
||||
|
||||
// GetScreenToWorldRayEx - Get a ray trace from screen position (i.e mouse) in a viewport
|
||||
func GetScreenToWorldRayEx(position Vector2, camera Camera, width, height int32) Ray {
|
||||
cposition := position.cptr()
|
||||
ccamera := camera.cptr()
|
||||
cwidth := (C.int)(width)
|
||||
cheight := (C.int)(height)
|
||||
ret := C.GetMouseRay(*cposition, *ccamera, cwidth, cheight)
|
||||
v := newRayFromPointer(unsafe.Pointer(&ret))
|
||||
return v
|
||||
}
|
||||
|
||||
// GetCameraMatrix - Returns camera transform matrix (view matrix)
|
||||
func GetCameraMatrix(camera Camera) Matrix {
|
||||
ccamera := camera.cptr()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue