0

I'm trying to load low poly FPS arms I made in Blender. I gave them colors using a material that I set a color to, it appears nicely in Blender. But when I load them into Ursina, they are totally white, no color ! I clearly think the problem is the "way" I applied the color, which may be a problem for some reason or another.

Here is how I imported the file :

class Hand(Entity):
    def __init__(self):
        super().__init__(model = 'ARMS.obj',
            scale = (0.1, 0.1, 0.1),
            rotation = (0, -20, 0),
            color = color.white,
            position = (0, 2, 0))

(sorry for minimum reproductible example, would be hard to do without posting my whole code)

So yeah, it shows with the color I set in the color parameter (white to avoid affecting the colors I apply in Blender... That don't show). Does someone know how to do that please ? By this, I mean, does someone have experience loading 3D models into Ursina/an equivalent, and knows what I did wrong ? I did as well as I could, following this : https://blender.stackexchange.com/questions/75872/not-showing-colors-in-material-mode. I will join an image of the properties of my material I assigned into blender :

enter image description here

I'm really wondering how I can get my color/future textures to load into ursina !

Quantum Sushi
  • 504
  • 7
  • 23
  • I'll try this, thanks ! – Quantum Sushi Sep 20 '21 at 15:29
  • Sorry, I got confused. Ursina cannot use the .mtl file. Instead, you'll have to load it into Blender (which does happen automatically when you import the .obj mesh) and export the UV mapped texture to a PNG file. – Jan Wilamowski Sep 22 '21 at 01:16
  • Yup, that's what I saw from trying : the file was not loaded or anything... I exported the UV texture into a PNG, following a tutorial, I got the image, all good looking, but when I specified the texture as being that image in my code, the UV unwrapping seemed to be forgotten : the texture didn't load like it was supposed to, creating a kind of a mess... – Quantum Sushi Sep 24 '21 at 13:01

1 Answers1

1

OBJ models can't be loaded in with colours in ursina. What you have to do is

  1. At the top of Blender click on the Texture Paint tab
  2. On the Top Left side of the screen, you will see a button called Image.
  3. Click it, and if you already have an image loaded (which it looks like you do), click Save and Save it into your project folder
  4. In the hand class, include the texture param
class Hand(Entity):
   def __init__(self):
       super().__init__(
           model = 'ARMS.obj',
           scale = (0.1, 0.1, 0.1),
           rotation = (0, -20, 0),
           color = color.white,
           position = (0, 2, 0),
           texture = "ARMS.png"
       )

Dharman
  • 30,962
  • 25
  • 85
  • 135
mandaw2014
  • 21
  • 1
  • 2
  • I already tried this, but the UV unwrapping got somehow kinda weird ? And the texture didn't load properly... – Quantum Sushi Sep 20 '21 at 15:28
  • @QuantumSushi did you unwrap your model in blender? If not: Go into edit mode of your object in blender. Click 'UV' at the top. Then click unwrap. And also, .mtl files dont work in Ursina – mandaw2014 Sep 21 '21 at 19:14
  • I tried to export the texture as PNG, to load it into ursina, and yes I unwrapped the model, but when loading the object, the unwrapping seemed to be forgotten, and the texture loaded, but made a mess – Quantum Sushi Sep 24 '21 at 13:02