how about this,
i use 2 object as line to simulate a rotated hand fan.
if you collect this 3d coords you can create a new triangle mesh in world space.
(its not a real 3d line)
// Light Rays
// MR 17.12.2017
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 )
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 )
//some random objects
for i=1 to 100
sphere=CreateObjectSphere(1.0,40,40)
SetObjectPosition(sphere,MyRandom(),MyRandom(),MyRandom())
if GetObjDistance(0,0,0,getobjectx(sphere),getobjecty(sphere),getobjectz(sphere))<1.0 then DeleteObject(sphere)
cube=CreateObjectBox(1,1,1)
SetObjectPosition(cube,MyRandom(),MyRandom(),MyRandom())
if GetObjDistance(0,0,0,getobjectx(cube),getobjecty(cube),getobjectz(cube))<1.0 then DeleteObject(cube)
next
//camera side view from x
SetCameraPosition(1,10,0,0)
SetCameraLookAt(1,0,0,0,0)
//Start End Ray Objects
startobj=CreateObjectSphere(0.25,8,8)
endobj=CreateObjectSphere(0.25,8,8)
FixObjectToObject(endobj,startobj)
MoveObjectLocalZ(endobj,10)
local w as float
local a as integer
do
//turn
RotateObjectLocalY(startobj,45.0 / 60.0)
//Memory Original
ox#=GetObjectAngleX(startobj)
oy#=GetObjectAngleY(startobj)
oz#=GetObjectAngleZ(startobj)
//Start Ray
sx#=GetObjectWorldX(startobj)
sy#=GetObjectWorldY(startobj)
sz#=GetObjectWorldZ(startobj)
//90 Rays
for w = -45 to 45
SetObjectRotation(startobj,w,GetObjectAngleY(startobj),GetObjectAngleZ(startobj))
//End Ray
tx#=GetObjectWorldX(endobj)
ty#=GetObjectWorldY(endobj)
tz#=GetObjectWorldZ(endobj)
a=ObjectRayCast(0,sx#,sy#,sz#,tx#,ty#,tz#)
if a>0
//world positions of collision
x#=GetObjectRayCastX(0)
y#=GetObjectRayCastY(0)
z#=GetObjectRayCastZ(0)
DrawLine3D(sx#,sy#,sz#,x#,y#,z#)
endif
next
//Back to original
SetObjectRotation(startobj,ox#,oy#,oz#)
Print( ScreenFPS() )
Sync()
loop
end
Function DrawLine3D(x1 as float,y1 as float,z1 as float,x2 as float,y2 as float,z2 as float)
col = MakeColor(255,255,0)
local sx1 as float
local sy1 as float
local sx2 as float
local sy2 as float
sx1=GetScreenXFrom3D ( x1, y1, z1 )
sy1=GetScreenYFrom3D ( x1, y1, z1 )
sx2=GetScreenXFrom3D ( x2, y2, z2 )
sy2=GetScreenYFrom3D ( x2, y2, z2 )
DrawLine(sx1,sy1,sx2,sy2,col,col)
EndFunction
Function MyRandom()
local f as float
f = Random2(-8,8)
EndFunction f
Function GetObjDistance(x1 as float,y1 as float,z1 as float,x2 as float,y2 as float,z2 as float)
local d as float
local v1 as Integer
local v2 as Integer
v1=CreateVector3(x1,y1,z1)
v2=CreateVector3(x2,y2,z2)
d=GetVector3Distance(v1,v2)
DeleteVector3(v1)
DeleteVector3(v2)
EndFunction d
AGK (Steam) V2017.09.25 : Windows 10 Pro 64 Bit : AMD (17.11.4) Radeon R7 265 : Mac mini OS High Sierra (10.13)