harfang3d / harfang3d Goto Github PK
View Code? Open in Web Editor NEWHARFANG 3D source code public repository
Home Page: https://www.harfang3d.com
License: GNU Lesser General Public License v3.0
HARFANG 3D source code public repository
Home Page: https://www.harfang3d.com
License: GNU Lesser General Public License v3.0
Object culling seems too aggressive. In some cases, the object disappears before it completely goes out of the camera field:
It could be something that was introduced lately.
Bug between pitchs of Stereo / Spatialized sounds
A cache bug need a fix in sound system.
If Stereo source is not stopped, playing in loop mode, its pitch is not affected by Spatialized sound velocity calculations.
import harfang as hg
hg.InputInit()
hg.WindowSystemInit()
hg.AudioInit()
hg.AddAssetsFolder("assets_compiled")
width, height = 1280, 720
window = hg.RenderInit('Harfang window', width, height, hg.RF_None)
stereo_sound_ref = hg.LoadWAVSoundAsset("main_left.wav")
stereo_state = hg.StereoSourceState()
stereo_state.volume = 1
stereo_state.repeat = hg.SR_Loop
stereo_state.panning = 0
spacialized_sound_ref = hg.LoadWAVSoundAsset("turbine.wav")
spacialized_state = hg.SpatializedSourceState(hg.TranslationMat4(hg.Vec3(0, 0, 10)))
spacialized_state.vel = hg.Vec3(0, 0, -50)
spacialized_state.volume = 1
spacialized_state.repeat = hg.SR_Loop
keyboard = hg.Keyboard()
while not keyboard.Pressed(hg.K_Escape):
keyboard.Update()
dt = hg.TickClock()
dts = hg.time_to_sec_f(dt)
view_id = 0
hg.SetViewClear(view_id, hg.CF_Color | hg.CF_Depth, hg.Color.Green)
hg.SetViewRect(view_id, 0, 0, width, height)
hg.Touch(view_id)
if keyboard.Pressed(hg.K_F1):
hg.StopAllSources()
stereo_source = hg.PlayStereo(stereo_sound_ref, stereo_state)
elif keyboard.Pressed(hg.K_F2):
hg.StopAllSources()
spacialized_source = hg.PlaySpatialized(spacialized_sound_ref, spacialized_state)
hg.Frame()
hg.UpdateWindow(window)
hg.StopAllSources()
hg.RenderShutdown()
hg.DestroyWindow(window)
It is not possible to get the OpenVR working (as shown in this snippet when Harfang is running in OpenGL. It only work in DX11.
Need to fix CaptureTexture() for Python / Lua. In Python and Lua, the CaptureTexture() function don't work.
In Python, afte CaptureTexture() call, next Frame() causes program exit silently:
# Draw scene to texture
import harfang as hg
import math
hg.InputInit()
hg.WindowSystemInit()
res_x, res_y = 1024, 1024
win = hg.RenderInit('Draw Scene to Texture', res_x, res_y, hg.RF_VSync | hg.RF_MSAA8X)
hg.AddAssetsFolder("resources_compiled")
# create pipeline
pipeline = hg.CreateForwardPipeline()
res = hg.PipelineResources()
# load the scene to draw to a texture
scene = hg.Scene()
hg.LoadSceneFromAssets("materials/materials.scn", scene, res, hg.GetForwardPipelineInfo())
# create a 512x512 frame buffer to draw the scene to
tex_size = 512
picture = hg.Picture(tex_size, tex_size, hg.PF_RGBA32)
tex_color = hg.CreateTexture(tex_size, tex_size, "color_texture",hg.TF_ReadBack | hg.TF_RenderTarget | hg.TF_SamplerMinAnisotropic, hg.TF_RGBA8)
tex_color_ref = res.AddTexture("tex_rb", tex_color)
tex_depth = hg.CreateTexture(tex_size, tex_size, "depth_texture", hg.TF_RenderTarget, hg.TF_D24)
frame_buffer = hg.CreateFrameBuffer(tex_color, tex_depth, "framebuffer")
# create the cube model
vtx_layout = hg.VertexLayoutPosFloatNormUInt8TexCoord0UInt8()
cube_mdl = hg.CreateCubeModel(vtx_layout, 1, 1, 1)
cube_ref = res.AddModel('cube', cube_mdl)
# prepare the cube shader program
cube_prg = hg.LoadProgramFromAssets('shaders/texture')
# main loop
angle = 0
frame_count = 0
flag_capture_texture = False
while not hg.ReadKeyboard().Key(hg.K_Escape) and hg.IsWindowOpen(win):
dt = hg.TickClock()
angle = angle + hg.time_to_sec_f(dt)
# update scene and render to the frame buffer
scene.GetCurrentCamera().GetTransform().SetPos(hg.Vec3(0, 0, -(math.sin(angle) * 3 + 4))) # animate the scene current camera on Z
scene.Update(dt)
view_id = 0
view_id, pass_ids = hg.SubmitSceneToPipeline(view_id, scene, hg.IntRect(0, 0, 512, 512), True, pipeline, res, frame_buffer.handle)
if not flag_capture_texture and hg.ReadKeyboard().Key(hg.K_Space):
flag_capture_texture = True
frame_count_capture = hg.CaptureTexture(res, tex_color_ref, picture)
# draw a rotating cube in immediate mode using the texture the scene was rendered to
hg.SetViewPerspective(view_id, 0, 0, res_x, res_y, hg.TranslationMat4(hg.Vec3(0, 0, -1.8)))
val_uniforms = [hg.MakeUniformSetValue('color', hg.Vec4(1, 1, 1, 1))] # note: these could be moved out of the main loop but are kept here for readability
tex_uniforms = [hg.MakeUniformSetTexture('s_tex', tex_color, 0)]
hg.DrawModel(view_id, cube_mdl, cube_prg, val_uniforms, tex_uniforms, hg.TransformationMat4(hg.Vec3(0, 0, 0), hg.Vec3(angle * 0.1, angle * 0.05, angle * 0.2)))
#
frame_count = hg.Frame()
# Save captured picture:
if flag_capture_texture and frame_count_capture <= frame_count:
hg.SavePNG(picture, "captured_picture.png")
flag_capture_texture = False
hg.UpdateWindow(win)
hg.RenderShutdown()
hg.WindowSystemShutdown()
In Lua, CreateTexture() with TF_ReadBack | TF_RenderTarget causes program crash:
-- Draw scene to texture
hg = require("harfang")
hg.InputInit()
hg.WindowSystemInit()
res_x, res_y = 1024, 1024
win = hg.RenderInit('Draw Scene to Texture', res_x, res_y, hg.RF_VSync | hg.RF_MSAA8X)
hg.AddAssetsFolder("resources_compiled")
-- create pipeline
pipeline = hg.CreateForwardPipeline()
res = hg.PipelineResources()
-- load the scene to draw to a texture
scene = hg.Scene()
hg.LoadSceneFromAssets("materials/materials.scn", scene, res, hg.GetForwardPipelineInfo())
-- create a 512x512 frame buffer to draw the scene to
tex_size = 512
picture = hg.Picture(tex_size, tex_size, hg.PF_RGBA32)
tex_color = hg.CreateTexture(tex_size, tex_size, "color_texture",hg.TF_ReadBack | hg.TF_RenderTarget | hg.TF_SamplerMinAnisotropic, hg.TF_RGBA8)
tex_color_ref = res:AddTexture("tex_rb", tex_color)
tex_depth = hg.CreateTexture(tex_size, tex_size, "depth_texture", hg.TF_RenderTarget, hg.TF_D24)
frame_buffer = hg.CreateFrameBuffer(tex_color, tex_depth, "framebuffer")
-- create the cube model
vtx_layout = hg.VertexLayoutPosFloatNormUInt8TexCoord0UInt8()
cube_mdl = hg.CreateCubeModel(vtx_layout, 1, 1, 1)
cube_ref = res:AddModel('cube', cube_mdl)
-- prepare the cube shader program
cube_prg = hg.LoadProgramFromAssets('shaders/texture')
-- main loop
angle = 0
frame_count = 0
flag_capture_texture = false
while not hg.ReadKeyboard():Key(hg.K_Escape) and hg.IsWindowOpen(win) do
dt = hg.TickClock()
angle = angle + hg.time_to_sec_f(dt)
-- update scene and render to the frame buffer
scene:GetCurrentCamera():GetTransform():SetPos(hg.Vec3(0, 0, -(math.sin(angle) * 3 + 4))) -- animate the scene current camera on Z
scene:Update(dt)
view_id = 0
view_id, pass_ids = hg.SubmitSceneToPipeline(view_id, scene, hg.IntRect(0, 0, 512, 512), true, pipeline, res, frame_buffer.handle)
if not flag_capture_texture and hg.ReadKeyboard():Key(hg.K_Space) then
flag_capture_texture = true
frame_count_capture = hg.CaptureTexture(res, tex_color_ref, picture)
end
-- draw a rotating cube in immediate mode using the texture the scene was rendered to
hg.SetViewPerspective(view_id, 0, 0, res_x, res_y, hg.TranslationMat4(hg.Vec3(0, 0, -1.8)))
val_uniforms = {hg.MakeUniformSetValue('color', hg.Vec4(1, 1, 1, 1))} -- note: these could be moved out of the main loop but are kept here for readability
tex_uniforms = {hg.MakeUniformSetTexture('s_tex', tex_color, 0)}
hg.DrawModel(view_id, cube_mdl, cube_prg, val_uniforms, tex_uniforms, hg.TransformationMat4(hg.Vec3(0, 0, 0), hg.Vec3(angle * 0.1, angle * 0.05, angle * 0.2)))
--
frame_count = hg.Frame()
-- Save captured picture:
if flag_capture_texture and frame_count_capture <= frame_count then
hg.SavePNG(picture, "captured_picture.png")
flag_capture_texture = false
end
hg.UpdateWindow(win)
end
hg.RenderShutdown()
hg.WindowSystemShutdown()
Currently, HARFANG Lua5.4.4 ships with a lua53.dll:
https://github.com/harfang3d/harfang3d/blob/main/extern/lua/CMakeLists.txt#L99
Shouldn't this be renamed lua54.dll ?
Please can you add a function bool = IsVRHeaderOnHead()
, returns True
if the VR headset is on user's head.
Is it possible to build a Harfang3d project to exe or binary when using high level scripting languages (Python/Lua)?
I am picturing something similar to https://docs.panda3d.org/1.10/python/distribution/building-binaries.
If it is possible, can it be added to your documentation? Otherwise it's definitely a Feature Request that I would ask for.
Thank you! And the project looks great btw...
Describe the bug
It seems that both the cone and the capsule have their builtin models misaligned in regards to the collision shape.
Possibly this issue is related to the way Bullet physics defines the collision shape (height vs half-height, centered pivot...)
In HG3.2.3, it looks like this :
Expected behavior
Both cone & capsule should have the model aligned to the collision shape (and not the other way around!)
Bloom seems to be broken on Linux studio.
Studio version 0.8.3 but latest studio versions crash on startup on Ubuntu 22.04.
To Reproduce
Open up any scene in studio, switch to forward AAA pipeline. Crank up bloom settings. Observe a vertical banding effect. Shown here on cornel-box/main_direct.scn from sample projects.
Expected behavior
Smooth bloom without vertical banding.
Desktop:
Linux studio build 0.8.4 crashes on startup.
(From here: https://github.com/harfang3d/harfang3d/releases/download/v3.2.6/studio-0.8.4-ubuntu64.zip).
Splash screen briefly displays then it disappears, no console output.
Previous version runs fine on this machine. Ubuntu 22.04. Replicate on another Ubuntu 22.04 machine. nvidia gpu.
I tried a little debugging in gdb:
gdb ./studio
GNU gdb (Ubuntu 12.0.90-0ubuntu1) 12.0.90
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./studio...
(No debugging symbols found in ./studio)
(gdb) set follow-fork-mode child
(gdb) break exit
Breakpoint 1 at 0x5c4d0 (2 locations)
(gdb) break abort
Breakpoint 2 at 0x5c770
(gdb) break _exit
Breakpoint 3 at 0x5d320
(gdb) start
Temporary breakpoint 4 at 0xaea20
Starting program: /home/luke/harfang/studio/studio-0.8.4-ubuntu64/studio
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Temporary breakpoint 4, 0x0000555555602a20 in main ()
(gdb) continue
Continuing.
[Attaching after Thread 0x7ffff57fcac0 (LWP 332375) fork to child process 332381]
[New inferior 2 (process 332381)]
[Detaching after fork from parent process 332375]
[Inferior 1 (process 332375) detached]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
process 332381 is executing new program: /usr/bin/dash
Error in re-setting breakpoint 1: Function "exit" not defined.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Attaching after Thread 0x7ffff7d6b740 (LWP 332381) vfork to child process 332384]
[New inferior 3 (process 332384)]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Switching to Thread 0x7ffff7d6b740 (LWP 332384)]
Thread 3.1 "sh" hit Breakpoint 3, __GI__exit (status=126) at ../sysdeps/unix/sysv/linux/_exit.c:27
27 ../sysdeps/unix/sysv/linux/_exit.c: No such file or directory.
(gdb) bt
#0 __GI__exit (status=126) at ../sysdeps/unix/sysv/linux/_exit.c:27
#1 0x000055555555956f in ?? ()
#2 0x000055555556b740 in ?? ()
#3 0x000055555555cc25 in ?? ()
#4 0x000055555555d8de in ?? ()
#5 0x00005555555673ac in ?? ()
#6 0x0000555555560c00 in ?? ()
#7 0x0000555555560c00 in ?? ()
#8 0x00005555555646c2 in ?? ()
#9 0x0000555555558d36 in ?? ()
#10 0x00007ffff7d97d90 in __libc_start_call_main (main=main@entry=0x555555558ae0, argc=argc@entry=3, argv=argv@entry=0x7fffffffdcc8) at ../sysdeps/nptl/libc_start_call_main.h:58
#11 0x00007ffff7d97e40 in __libc_start_main_impl (main=0x555555558ae0, argc=3, argv=0x7fffffffdcc8, init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fffffffdcb8) at ../csu/libc-start.c:392
#12 0x0000555555558f15 in ?? ()
(gdb) list
22 in ../sysdeps/unix/sysv/linux/_exit.c
(gdb) continue
Continuing.
[Detaching vfork parent process 332381 after child exit]
[Inferior 2 (process 332381) detached]
[Inferior 3 (process 332384) exited with code 0176]
(gdb)
quit
Spotted that on pypi there's no linux wheels: https://pypi.org/simple/harfang/
But looks like they exist: https://www.harfang3d.com/releases/3.1.1/
Why not uploading them?
It is impossible to get the mouse cursor coordinates when it is outside of the main client window. This can be an issue when dealing with an application that would require the main display to occur in a VR headset while having the user working with the mouse.
Best solution would be to be able to disable the cursor when the harfang-based application is running.
Is this possible?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.