I am trying to apply textures to Sprite3D objects.
I have managed to perform such by doing:
auto sprite = Sprite3D::create("mySprite.c3t");
sprite->setTexture("myTexture.png");
However, there are some Sprite3D objects with which I cannot seem to make it work.
I have analyzed the differences between the c3t files with which I can apply texture and the ones I can’t.
The only difference I can see is the c3t objects I cannot apply texture to have children in their “nodes” object:
- c3t file that works:
"materials": [
{
"id": "Material",
"ambient": [ 0.050876, 0.050876, 0.050876],
"diffuse": [ 0.800000, 0.800000, 0.800000],
"emissive": [ 0.000000, 0.000000, 0.000000],
"opacity": 0.000000,
"specular": [ 0.800000, 0.800000, 0.800000],
"shininess": 36.000000,
"textures": [
{
"id": "base_color_texture",
"filename": "Texture12x12.png",
"type": "DIFFUSE",
"wrapModeU": "REPEAT",
"wrapModeV": "REPEAT"
}
]
}
],
"nodes": [
{
"id": "M1",
"skeleton": false,
"transform": [ 99.998405, -0.000000, -0.565386, 0.000000, -0.565386, -0.000004, -99.998405, 0.000000, -0.000000, 100.000000, -0.000004, 0.000000, -35.771751, 300.000000, 0.000000, 1.000000],
"parts": [
{
"meshpartid": "Cube.007_part1",
"materialid": "Material",
"uvMapping": [[]]
}
]
}
],
- c3t file that doesn’t work:
"materials": [
{
"id": "lambert2SG",
"ambient": [ 1.000000, 1.000000, 1.000000],
"diffuse": [ 1.000000, 1.000000, 1.000000],
"emissive": [ 0.000000, 0.000000, 0.000000],
"opacity": 1.000000,
"specular": [ 0.200000, 0.200000, 0.200000],
"shininess": 20.000000,
"textures": [
{
"id": "lambert2SG",
"filename": "red_suits_texture2.png",
"type": "DIFFUSE",
"wrapModeU": "REPEAT",
"wrapModeV": "REPEAT"
}
]
}
],
"nodes": [
{
"id": "Sphere_Guy_root",
"skeleton": false,
"transform": [ 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000],
"children": [
{
"id": "circle",
"skeleton": false,
"transform": [ 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000],
"parts": [
{
"meshpartid": "shape1_part1",
"materialid": "lambert2SG",
"uvMapping": [[ 0]]
}
]
},
{
"id": "circle_ring",
"skeleton": false,
"transform": [ 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 0.000000, 1.000000],
"parts": [
{
"meshpartid": "shape2_part1",
"materialid": "lambert2SG",
"uvMapping": [[ 0]]
}
]
}
]
}
],
I have tried searching for answers on other topics in this forum and on other forums but I cannot seem to find any answers.
I have managed to change the texture of the Sprite3D object by modifying directly the file path to the texture in the c3t file but it is a workaround hat doesn’t satisfies me.
Am I missing something in the code?
Is the c3t file where I cannot apply texture to erroneous?
Thank you