-- Init function called from K3dEngine during initialization -- Warning -- Don't delete this function -- Function must exist function Init() print("Loading map ./maps/test/add_ray_map.lua") K3d_LoadMap("./maps/test/add_ray_map.lua") InitScene() end -- Update function called from K3dEngine during update scene -- Warning -- Don't delete this function -- Function must exist function Update() UpdateScene() if K3d_CheckKeyboardKey("Esc") then -- Load new script and delete this script -- This function must be called as last function in this script -- else engine shut down in next funcion -- because next function doesn`t exist in new script K3d_LoadNewScript("./scripts/main_menu_script.lua") end end -- Delete function called from K3dEngine during delete scene -- Warning -- Don't delete this function -- Function must exist function Delete() print("Delete() function called") end -- Global variables g_iRayId = -1 g_iLineId = -1 -- Init scene in scene initialization function InitScene() -- Your some scene initialization print("InitScene() function called") g_iRayId = K3d_GetObject("Ray", ObjType.iRayObj) print("g_iRayId =", g_iRayId) if g_iRayId == -1 then print("Ray doesn`t exists.") return false end g_iLineId = K3d_GetObject("RayLine", ObjType.iLineObj) print("g_iLineId =", g_iLineId) if g_iLineId == -1 then print("Line doesn`t exists.") return false end K3d_Hide(g_iLineId, ObjType.iLineObj, false); end -- Update scene in avery frame function UpdateScene() -- Your some scene updates K3d_Print("K3dEngine 0.1") K3d_Print("Testing K3d_GetObject, K3d_SetLine, K3d_GetRayOrigDir, K3d_Hide scripts") local x_orig,y_orig,z_orig,x_dir,y_dir, z_dir -- Get ray origin and direction and set to the line for visualize ray x_orig,y_orig,z_orig,x_dir,y_dir,z_dir = K3d_GetRayOrigDir(g_iRayId) K3d_SetLine(g_iLineId, x_orig,y_orig,z_orig,x_dir,y_dir,z_dir) end