Advertisement

Question regarding planet LOD

Started by July 25, 2017 10:29 PM
0 comments, last by Toastmastern 7 years, 4 months ago

So it's been a while since I took a break from my whole creating a planet in DX11. Last time around I got stuck on fixing a nice LOD.

A week back or so I got help to find this:

https://github.com/sp4cerat/Planet-LOD

In general this is what I'm trying to recreate in DX11, he that made that planet LOD uses OpenGL but that is a minor issue and something I can solve. But I have a question regarding the code

He gets the position using this row


vec4d pos = b.var.vec4d["position"];

Which is then used further down when he sends the variable "center" into the drawing function:


 if (pos.len() < 1) pos.norm();
	world::draw(vec3d(pos.x, pos.y, pos.z));

 

Inside the draw function this happens:


draw_recursive(p3[0], p3[1], p3[2], center);

Basically the 3 vertices of the triangle and the center of details that he sent as a parameter earlier: vec3d(pos.x, pos.y, pos.z)

Now onto my real question, he does vec3d edge_center[3] = { (p1 + p2) / 2, (p2 + p3) / 2, (p3 + p1) / 2 }; to get the edge center of each edge, nothing weird there.

But this is used later on with:


vec3d d = center + edge_center;
	edge_test = d.len() > ratio_size;

edge_test is then used to evaluate if there should be a triangle drawn or if it should be split up into 3 new triangles instead. Why is it working for him? shouldn't it be like center - edge_center or something like that? Why adding them togheter? I asume here that the center is the center of details for the LOD. the position of the camera if stood on the ground of the planet and not up int he air like it is now.

Full code can be seen here:

https://github.com/sp4cerat/Planet-LOD/blob/master/src.simple/Main.cpp

If anyone would like to take a look and try to help me understand this code I would love this person. I'm running out of ideas on how to solve this in my own head, most likely twisted it one time to many up in my head :P

Thanks in advance

Toastmastern

 

 

This topic is closed to new replies.

Advertisement