0

I am trying to load a 3d object into a program written with Ursina. I am able to load the 3d file, and I can load the textures, but they won't load together. I'm sure there is something I am misunderstanding about the 3d file as I am pretty new to using 3d files. When I load the obj file, it is the correct shape but it is just black without the texture. It looks 2d. I can load the texture on a cube, but it is not the correct shape. How can I combine the two so it shows the correct texture on the correct 3d object? This is my code:

from ursina import *


app = Ursina()

cube = Entity(model = 'toybear.obj', color = color.white, scale=(.02,.02,.02), texture='toybearcolor')
app.run()
Val P
  • 103
  • 3
Samantha Garcia
  • 490
  • 6
  • 13
  • I was not able to add the ursina tag since it is new and I don't have the reputation, but it is created based on panda3D so I tagged that. – Samantha Garcia Feb 08 '21 at 19:28

1 Answers1

1

My first thought is that you should not delcare color = color.white and texture = 'toybearcolor' at the same time. If this doesnt fix the problem, then make sure import ursina is declared above from ursina import * If the problem still consists then it must be an issue with the UV texture that you are using because besides the things mentioned above your code is fine.

EDIT: I am not an expert UV Unwrapping but if that is the problem there are a few ways to do this. If you want custom textures you have to go in to Blender and mark the seams on the model and save the texture to a .png file like this tutorial https://www.youtube.com/watch?v=xPoxqOcUzNQ&t=560s

You can also do what's called texture baking in Blender like this https://www.youtube.com/watch?v=c2ut0Trcdi0

Alternatively some times the people who make game assets leave a UV texture as a .png file in there downloads like this artist here https://opengameart.org/content/low-poly-mushrooms So always look out for those

  • How do I get an appropriate UV texture? That's what I am having a problem with. It works fine on a cube. – Samantha Garcia Feb 16 '21 at 18:41
  • Also I had already tried removing the color. It still doesn't work properly, and it actually works even with a color and a texture if its a cube. – Samantha Garcia Feb 16 '21 at 21:14
  • Wait so your using the texture for the cube on the toy bear? Does the the toy bear have the same model as the ursina base cube? – BellVirtual Feb 16 '21 at 21:27
  • I am definitely not an expert on 3d models, and I think that's the issue. I am going to modify in blender because I think that's my problem. Thank you! – Samantha Garcia Mar 19 '21 at 13:17
  • It seems to definitely be an issue with the 3d file and the file you linked worked after converting it to .obj in blender. Thanks so much! – Samantha Garcia Mar 19 '21 at 13:38