1.7.2 + materials = bug?

Ive been trying to mess around with textures for a few hours and so far nothing has worked, at all. No errors but no materials either =/

some of my code:

from direct.showbase.ShowBase import ShowBase 
from direct.showbase import DirectObject 
from direct.task import Task 
from direct.gui.OnscreenText import OnscreenText
from pandac.PandaModules import *

from math import pi, sin, cos 

hitcount = 0 
startfun = None
x = 0
direction = 1
time = 0
    
class MyApp(ShowBase): 
  
    def __init__(self): 
        ShowBase.__init__(self) 
        base.disableMouse()
        
        light = PointLight('light')
        light.setColor(VBase4(1, 1, 1, 1))
        plnp = render.attachNewNode(light)
        render.setLight(plnp)
        
        material = Material()
        material.setShininess(5.0)
        material.setAmbient(VBase4(1, 0, 0, 1))
        
        self.box = self.loader.loadModel('arrow')
        self.box.reparentTo(self.render)
        self.box.setHpr(90, 90, 0)
        self.box.setMaterial(material)
        
    	self.taskMgr.add(self.moveball, "moveball")    
        
    def moveball(self, task):
        self.box.setPos(x, 15, 0)
        global x
        global direction
        x += ((hitcount / ((time + .01)/ 60)) / 20000) * direction
        if x > 4:
        	direction = -1
        	self.box.setHpr(270, 90, 0)
        if x < -4:
        	direction = 1
        	self.box.setHpr(90, 90, 0)
        return Task.cont
      
  
class Hello(DirectObject.DirectObject): 
    
    def __init__(self): 
        self.accept('mouse1',self.hitcountfunction) 
        self.accept('mouse3',self.hitcountfunction) 
        self.accept('z',self.hitcountfunction)
        self.accept('x',self.hitcountfunction)      
        
    def hitcountfunction(self): 
        global hitcount 
        hitcount += 1 
        print hitcount
        global startfun
        print startfun
        if not startfun:
			taskMgr.add(h.cpm, "...")
			startfun = True
			print startfun
        
        
    def cpm(self, task): 
      global time
      time = task.time
      if task.time < 20:
    	task.time and \
        cpmt.setText( 
          str( 
            round( 
              (hitcount / ( task.time / 60 )) / 4, 
              2 ) ) ) 
      return task.cont 
 
         
h = Hello() 

app = MyApp() 

cpmt = OnscreenText( pos = ( 0, -.2 ), scale = .05, mayChange = True ) 

app.run()

im by no means an expert ( not even close XD) but that should work right? i also tried setEmission with no pointlight instead of setAmbient with pointlight and still no materials =/. againi get no errors but my model gets no materials lol. Any ideas?

Could you post the files needed to run that code (models, textures, …)?

sure :smiley: mediafire.com/?kv891vfaktd39x6

What is the problem exactly? What do you want to obtain?

just to add a material to the arrow.

These modifications should work:

        material = Material()
        material.setShininess(5.0)
        material.setAmbient(VBase4(1, 0, 0, 1))
        material.setDiffuse(VBase4(1, 0, 0, 1))
        
        self.box = self.loader.loadModel('arrow')
        self.box.reparentTo(self.render)
        self.box.setHpr(90, 90, 0)
        self.box.setMaterial(material,1)

I’ve only added setDiffuse and modified setMaterial.

ill give that a shot :smiley: what does the 1 do after set material? Sure enoiugh it works :smiley:

Looking at the reference, it is the priority, I’ve used it like for textures.

awesome thanks for the help :smiley: