Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
After a lot of trial and error, I got the auto texturing terrains to work via the surface angle and its almost done. I have had inconsistent results calculating the surface normal angle however from possibly using this formula which may not be correct: cellAngle = atan2(Normal.X, Normal.Y) * 57.296; The vertex Normal is a vector3d with x, y & z so can anyone help me get the correct formula using all 3 ? |
||||
|
// Calculate the angle in degrees Vector3D Normal; double cellAngle = atan2(Normal.Y, Normal.X) * 57.296; // Assuming Normal.Z contains the third component Normal = Vector3D(cos(cellAngle), sin(cellAngle), Normal.Z); maybe this will at least give you an idea of how to move forward... |
||||
|
Hello Robbo and mister chatgpt user, I believe, my last attempt to calculate face normal was based on position of 3 vertex, which define it:
I'm not sure if it's working or not. I believe, I stole it from some github page. The Internet says that you can calculate the normal of surface by calculating cross product, of two vectors which lay on this surface. Let's say your vertex names are A,B, and C, you can calculate vectors AC and AB by substracting C - A and C - B correspondingly, and then calculating these two vectors cross product. Also no clue if this works or not.
|
||||
|
... actually, this was pulled up using Codeium... so that's Mr. codeium if you don't mind! |
||||
|
Thanks for the input guys, I will add this and test it out. For now, In am getting something useable at least and hopefully more accurate with this better formula above. New API's are now working during runtime: (not available in editor as CC source code doesn't include it) ccbUpdateTerrain(terrainNode); (run once first) ccbSetTerrainTexAngle(terrainNode, low, med); (0 - 90 degrees) ccbSetTerrainTexHeight(terrainNode, low, med); (0 - 1) Grab an updated version from itchio and test it out: https://robo25.itch.io/coppercube-new-apis |
|