Horde3D

Next-Generation Graphics Engine
It is currently 24.11.2024, 11:30

All times are UTC + 1 hour




Post new topic Reply to topic  [ 11 posts ] 
Author Message
PostPosted: 09.06.2019, 16:32 
Offline

Joined: 08.03.2018, 12:00
Posts: 23
I've made a model programmatically using this:
Code:
H3DRes bbRes = h3dAddResource(H3DResTypes::Material, ("billboards/" + img + ".xml").c_str(), 0);
h3dutLoadResourcesFromDisk("assets");

H3DRes geo = h3dFindResource(H3DResTypes::Geometry, "models/button.geo");
H3DNode n = h3dAddModelNode(scene, (name + "MODEL").c_str(), geo);
h3dAddMeshNode(n, (std::string{name} + "MESH").c_str(), bbRes, 0, h3dGetResParamI(geo, H3DGeoRes::GeometryElem, 0, H3DGeoRes::GeoIndexCountI), 0, h3dGetResParamI(geo, H3DGeoRes::GeometryElem, 0, H3DGeoRes::GeoVertexCountI));

Before I used the above, I also tried generating the geometry myself, but in both cases, h3dutPickNode never returned the node, but what was behind it. It only seems to pick scenegraphs that were loaded with h3dAddResource.

I have checked, and no, the flags for the node were 0, so there was no NoRayQuery flag.


Top
 Profile  
Reply with quote  
PostPosted: 10.06.2019, 11:03 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Hello. At a quick glance, it seems that AABB was not correctly generated for the model. I'll look into it today, when I have time.


Top
 Profile  
Reply with quote  
PostPosted: 10.06.2019, 16:06 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Yep, it seems that the problem is in AABB not correctly updated when mesh is added. It is only updated during scene graph update, which happens during h3dRender. So, you have the following choices:
1) Postpone ray casting till next frame
2) Add SceneManager::updateNodes() in h3dAddMeshNode(). The problem with this approach is that whole scene graph would be updated on mesh adding.
3) Add SceneNode::updateTree() in ModelNode::update() in if( flags & ModelUpdateFlags::Geometry ) section. The problem with this approach is that model node and it children would be updated on each morphing animation. Don't know if it matters for you and how it will affect performance, but this is probably the way to go, if the first approach is not feasible for you.

UPDATE: probably the way to go is to add another parameter to ModelUpdateFlags, something like ModelUpdateFlags::ChildNodes, that calls update tree. That way you can control the number of updates that should be done. For example, you can add several meshes and then update only once via h3dUpdateModel().


Top
 Profile  
Reply with quote  
PostPosted: 12.06.2019, 20:56 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
I've added the functionality and pull requested it to develop branch. Please tell if it suits your needs or not.


Top
 Profile  
Reply with quote  
PostPosted: 25.06.2019, 10:22 
Offline

Joined: 08.03.2018, 12:00
Posts: 23
Very truly sorry for the wait, my mind has been filled with tasks recently, I'll give it a quick test ASAP.


Top
 Profile  
Reply with quote  
PostPosted: 25.06.2019, 11:14 
Offline

Joined: 08.03.2018, 12:00
Posts: 23
I'm not sure if I'm just being stupid but it seems like it just ignores the model for rendering.
Code:
H3DNode n = h3dAddModelNode(H3DRootNode, "MODEL", geo);
h3dAddMeshNode(n, "MESH", material, 0, h3dGetResParamI(geo, H3DGeoRes::GeometryElem, 0, H3DGeoRes::GeoIndexCountI), 0, h3dGetResParamI(geo, H3DGeoRes::GeometryElem, 0, H3DGeoRes::GeoVertexCountI));

I tested the same geometry and material file by loading a scenegraph and that did render.


Top
 Profile  
Reply with quote  
PostPosted: 25.06.2019, 11:46 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
If you use standard material and do not provide normals during creation of the geometry then mesh can be rendered incorrectly during light computing. But, if you load the same geometry and it works, then it is rather strange.
Do you see your procedurally added mesh in debug mode?


Top
 Profile  
Reply with quote  
PostPosted: 25.06.2019, 21:39 
Offline

Joined: 08.03.2018, 12:00
Posts: 23
Irdis wrote:
If you use standard material and do not provide normals during creation of the geometry then mesh can be rendered incorrectly during light computing. But, if you load the same geometry and it works, then it is rather strange.
Do you see your procedurally added mesh in debug mode?


If I enable DebugViewMode, not even the wireframe is shown. Though if I load via scenegraphs then everything's fine.


Top
 Profile  
Reply with quote  
PostPosted: 25.06.2019, 21:45 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Can you provide a minimal working example of this behaviour? It seems that something is not correctly initialized during procedural creation of the mesh.


Top
 Profile  
Reply with quote  
PostPosted: 26.06.2019, 08:09 
Offline

Joined: 08.03.2018, 12:00
Posts: 23
Irdis wrote:
Can you provide a minimal working example of this behaviour? It seems that something is not correctly initialized during procedural creation of the mesh.


Attached. Sorry it's SDL2 again, I did it with GLFW first but I couldn't get it to work on my system.


Attachments:
minimal.zip [34.15 KiB]
Downloaded 1075 times
Top
 Profile  
Reply with quote  
PostPosted: 26.06.2019, 20:28 
Offline

Joined: 17.11.2009, 17:00
Posts: 205
Location: Russia, Moscow
Got the sample working correctly.
What version of horde are you using? If you are using the develop branch but not the latest commit then the problem is in the old Horde3D.h file.
h3dAddMeshNode function was changed to receive another parameter that specifies how to draw the vertices (as triangles, points, lines or patches).
So, with the Horde.h file that was provided with minimal sample you ended up passing incorrect parameters to h3dAddMeshNode, that's why there was nothing on screen.
Oh, you should also notice that vertex count should be subtracted with 1 when mesh is added. GetResParams returns 24 vertices, and as you start from 0 you should send 23 as the last vertex.

Correct function call:
h3dAddMeshNode(n, "MESH", material, H3DMeshPrimType::TriangleList, 0, h3dGetResParamI(geo, H3DGeoRes::GeometryElem, 0, H3DGeoRes::GeoIndexCountI), 0, h3dGetResParamI(geo, H3DGeoRes::GeometryElem, 0, H3DGeoRes::GeoVertexCountI) - 1);


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group