Silence Exterminator Posted May 31 Author Share Posted May 31 3 hours ago, Bigchillghost said: It's really difficult to read your comment due to the lack of necessary punctuations and I always seem to lost focus on what you're actually trying to express. So I'm serious about this: So why did you wrote the entire normal buffer from offset 0x8050 instead of one per vertex element? file.seekp(32848); int count = 0; for (const auto& normal : normals) { if (count >= 2848) { break; // Reached the limit } for (float component : normal) { char byte = static_cast<char>((component + 1.0f) * 127.0f); // Convert float to Byte range file.write(&byte, sizeof(char)); } // #### file.seekp(0x15, ios::cur) is required here!!! 0x15 == 24 - 3 bytes for the written normal ++count; } And what's this "remainingBytes" for and why did you insert the AB 00 00 00 pattern repeatedly? // Check if we need to move to the next pattern int bytesInjected = count * 12; int remainingBytes = 32848 - 20 - bytesInjected; if (remainingBytes > 0) { file.seekp(bytesInjected, std::ios::cur); for (int i = 0; i < remainingBytes; ++i) { char patternByte = (i % 4 == 0) ? 0xAB : 0x00; file.write(&patternByte, sizeof(char)); } } The "blue" are the normal plus the tangent, the leading zero bytes might be an unused vertex color channel. Something like: uint8_t aByte = 0; file.read((char *)&aByte, 1); float toFloat = (aByte / 255.0) * 2.0 - 1.0; Not sure what you mean by that. You hard-coded the address and count but expected it to be generic? hi bro how are u thanks for replying, I was just trying to implement custom normal injection into the game from an obj file. An attempt for injection biscally to change the mesh in game. I did that successfully but normals were very badly looking in game, so i tried to inject normals from obj file but doesn't seem to work very well, but now as u provided me the code piece i can work on it and let u know, thanks again Link to comment Share on other sites More sharing options...
Engineer shak-otay Posted June 1 Engineer Share Posted June 1 (edited) On 5/24/2024 at 11:20 AM, shak-otay said: The normals might be compressed in the vertex block, 2 x DWORD, aabbccFF, 2x24= 48 bits? @roocker666: well, seems I was right with my first assumption... edit: so normals, not vertex colors. edit2: Bigchillghost made it clear that it's 8 bit normal's components (last Friday) Edited June 3 by shak-otay @ added Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now