Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SoTextureCubeMap incorrect UV mapping #563

@captain0xff

Description

@captain0xff

SoTextureCubeMap seems to map the textures incorrectly. I tried setting the filenames field with 6 images and also the image* fields individually but in both cases the textures look distorted. Texture mapping a SoCube with a single SoTexture2 seems to work fine.

With SoTextureCubeMap:
Image

With SoTexture2:
Image

Here is some code for reference:

auto get_cubemap_filenames() {
	const static char *filenames[] = {
		"right.jpg", "left.jpg",
		"top.jpg", "bottom.jpg",
		"front.jpg", "back.jpg"
	};

	return filenames;
}

void add_cube(SoSeparator *root) {
	auto cube_separator = new SoSeparator;
	auto ts = new SoTranslation;
	ts->translation = {2, 0, 0};
	cube_separator->addChild(ts);

	SoInput::addDirectoryFirst("../assets/skybox");

	// SoTexture2 *texture = new SoTexture2;
	// texture->filename = "back.jpg";
	// cube_separator->addChild(texture);

	auto cube_map = new SoTextureCubeMap;
	cube_map->filenames.setValues(0, 6, get_cubemap_filenames());
	cube_separator->addChild(cube_map);

	auto cube = new SoCube;
	cube->width = 1.0f;
	cube->height = 1.0f;
	cube->depth = 1.0f;
	cube_separator->addChild(cube);

	root->addChild(cube_separator);
}

I am on debian linux and using the latest version of coin from github. I first created a discussion about this here as I wasn't sure if this is a bug or wrong usage of the api from my side.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions