Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ofxAssimp vs. ofxAssimpModelLoader - normalized tex coordinates #8263

Open
dimitre opened this issue Feb 12, 2025 · 3 comments
Open

ofxAssimp vs. ofxAssimpModelLoader - normalized tex coordinates #8263

dimitre opened this issue Feb 12, 2025 · 3 comments

Comments

@dimitre
Copy link
Member

dimitre commented Feb 12, 2025

I'm porting some code from ofxAssimpModelLoader to ofxAssimp
I use to load some 3d objects and the change the texture to fit content (to simulate led panels)

I've noticed in ofxAssimpModelLoader it is using pixels coordinates, if I have a texture in original model
and with ofxAssimp the whole model is getting the top left pixel color, so I suppose it is working with normalized tex coordinates.

Is this intentional? if yes how can I change to pixel coordinates?
Thank you

cc: @NickHardeman

Image
@NickHardeman
Copy link
Contributor

Hmm, I think it's a bit more complicated in ofxAssimp since each model can have multiple textures so the default is Texture2D which is tex coords 0 -> 1.
Try importing with ImportSettings and ImportSettings. importAsTex2d as false

struct ImportSettings {
of::filesystem::path filePath;
int assimpOptimizeFlags=OFX_ASSIMP_OPTIMIZE_DEFAULT;
bool importAsTex2d = true;
bool importTextures = true;
bool importAnimations = true;
bool importMaterials = true;
bool fixInfacingNormals = false; // aiProcess_FixInfacingNormals
// bool importLights = false;
bool convertToLeftHanded = true; // aiProcess_ConvertToLeftHanded
std::vector<std::string> excludeNodesContainingStrings;
unsigned int aiFlags = 0; // ai process flags, ie. aiProcess_FixInfacingNormals
};

ImportSettings is;
is.path = "pathToModel.fbx";
is. importAsTex2d = false;
myModel->load(is);

@NickHardeman
Copy link
Contributor

Most models use normalized coordinates so the default is to load Texture2D. Maybe we could run through the mesh and determine if there are texture coords greater than 1.0 and then load ARB textures?

@dimitre
Copy link
Member Author

dimitre commented Feb 12, 2025

Great it works! thank you.
in ofxAssimpModelLoader it changed to pixel coordinates if the texture was loaded correctly. I'm not sure if it was intentional but I was used to it, so my ofFbo textures would just work there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants