Jump to content

Slastraf

Developers
  • Posts

    705
  • Joined

  • Last visited

Everything posted by Slastraf

  1. I Instantiate a loaded model like this worldGenerator->terrainChunk = Model::Load("Models/terrain_Plane.mdl"); ... c->chunkModel = (Model*)terrainChunk->Instance(); then I applied some previously tested code on the surface of the model like this: Surface* surface = c->chunkModel->GetSurface(0); for(int i = 0; i<surface->CountVertices(); i++) { Vec3 xy = surface->GetVertexPosition(i); float height = (rand()%(3)); if(i==surface->CountVertices()*0.5) { height = -100*(rand()%(3)); cout<<"Offset height:"<<height; } if(i==0)cout<<"height at: "<<height<<endl; surface->SetVertexPosition(i, xy+Vec3(0,height*.1,0)); } surface->Update(); c->chunkModel->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB); For every vertex, I set a randomly generated position. This is simplified to show the issue. All the generated model chunks are the same. A good guess would be that LE copies an already Instantiated model over, and overwrites all changes of the current one to all previous ones, or somehow ignores changes otherwise. I put a screnshot of the console and two images showing duplicate chunks. There are 9 chunks and each of them looks the same. How to fix this behaviour ?
  2. Most .mdl files have a hierarchy similar to this STATIC_MESH (< no surface) - OBJECT THING (< with surface) The surface count in the latter case will be zero, even if there is a surface in the OBJECT THING The workaround is to collapse the whole thing in the model editor. It would be nice if getsurface will check the first child for surface too if the top level doesn't have one because it is exported like this in most modeling software.
  3. I generate new vertices, traingles for every new mesh completely new. Agreeably this takes long. To copy it over and iterate all verts to put them on the generated position could be much faster. The chunks don't have that many verts so it takes less than a few frames. How to access mesh information ?
  4. I have coded a basic terrain generator which takes a perlin noise and builds a mesh from that. The problem is this is an expensive task for real time. So I put the whole function which calculates the chunks in a second thread which is handled in the game loop. This has not helped much with the performance, as I am using Leadwerks functions inside the thread which still accesses the game world and makes it freeze for a split second. Is there any way to calculate the mesh in a different thread and then "load" it into the world ? An explanatory video below. Thanks LE.mp4
  5. I cant wait and implement my own infinite perlin noise based terrain in c++. The blog is coming, need to just finish up some AI stuff and then can write about the prototype.
  6. That pointed me in the right direction. I made everything into one model, it still lagged, then I also made only one surface and then I got acceptable performance. Still it should not lag in the first place. The code looks like this and now I can proceed. void generateTest(){ // std::random_device rd; // std::uint32_t seed = rd(); //const siv::PerlinNoise perlin(seed); Surface* surface = NULL; Model* model = NULL; model = Model::Create(); model->SetColor(1.0, 0.0, 1.0); surface = model->AddSurface(); for(int i = 0; i<1000; i++) { surface->AddVertex(0.5, 0, 0.5, 0, 0, 1); surface->AddVertex(0.5, 0, -0.5, 0, 0, 1); surface->AddVertex(-0.5, 0, 0.5, 0, 0, 1); surface->AddVertex(-0.5, 0, -0.5, 0, 0, 1); surface->AddTriangle(0, 1, 2); surface->AddTriangle(1, 2, 3); surface->Update(); model->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB); } }
  7. void generateTest(){ //const siv::PerlinNoise perlin(seed); Surface* surface = NULL; Model* model = NULL; for(int i = 0; i<1000; i++) { model = Model::Create(); model->SetColor(1.0, 0.0, 1.0); surface = model->AddSurface(); surface->AddVertex(0.5, 0, 0.5, 0, 0, 1); surface->AddVertex(0.5, 0, -0.5, 0, 0, 1); surface->AddVertex(-0.5, 0, 0.5, 0, 0, 1); surface->AddVertex(-0.5, 0, -0.5, 0, 0, 1); surface->AddTriangle(0, 1, 2); surface->AddTriangle(1, 2, 3); surface->Update(); model->UpdateAABB(Entity::LocalAABB | Entity::GlobalAABB); } } Hello after I wanted to make a mesh generation algorithm I found out that I get a lot of lag when trying to have a small amount of vertex (<10k) in the scene If you run the test example above, it will make the game run at 2 fps or less. It does not max out my ram / gpu at all. I guess it has to do with memory leaks because I did not delete surface and model pointer. Then I tried to do the latter but it made different errors. 2021-04-09 18-23-58.mp4
  8. I dont want to add my libs in :/SteamLibrary/steamapps/common/Leadwerks\Include but in the project files somewhere.
  9. Hello, what is happening ? Please see the video. 1102370169_2021-04-0811-18-04.mp4
  10. I am trying to implement this and the more I look into it the harder the math gets. Hats off I cant do it but is so crucial in a game engine and has been done in LE before. https://www.ultraengine.com/community/blogs/entry/94-ik-animation/
  11. And this whole thing makes me stuck at my project right now because there really is no alternative
  12. Sorry to bother so much, yes the original post was about selection Nodes, but my post from 19 hours ago was to reset the whole tree (and it worked prior but not anymore). Regardless, both things need to work. There shou.ld be ->SetParent(NULL) to remove 1 item and also tree->root->SetParent(NULL) or an equivalent tree->root->ClearNodes() (exists but throws error currently) which resets the whole tree.
  13. That is good and I have implemented a similar thing, but what if you want to remove all nodes from the tree ? You could select an item and delete it, but in an other case I want to reset the whole tree. For example you have 10 different users and for each user there is a list of items and you want the tree to display all items of the selected user. This requires for the entire tree to refresh and rebuild. This functionality does not work anymore because a few days ago you could take the node which you iterated the tree with (like my example above) and set its parent to null and the tree would hide. This does not work anymore. Can you provide an example for reseting the tree ?
  14. How to use it ? Yesterday it seemed to work by setting subnode->SetParent(nullptr); then it would hide the whole tree but today I get an error. I made code to reproduce it, can replace lines 74-76 in the default project main. auto tree2 = CreateTreeView(border, border, 280, subpanel3->ClientSize().y - border * 2, subpanel3, TREEVIEW_DRAGANDDROP | TREEVIEW_DRAGINSERT); tree2->SetLayout(1, 0, 1, 1); auto subnode2 = tree2->root->AddNode("Node 1"); for (int n = 1; n < 10; ++n) { subnode2->AddNode("Subnode " + String(n)); } //error here subnode2->SetParent(nullptr); BTW, also happens with SetParent(NULL);
×
×
  • Create New...