Page MenuHome

BGE Textures and custom class objects
Closed, ArchivedPublic

Description

System Information
WIndows 7, 2.4ghz celeron cpu, 2gb ram, Geforce 8400GS

Blender Version
2.7

Short description of error
BGE Texture is not seen from a controller's object (which contains the texture) passed to a custom class, which is derived from bge.types.KX_GameObject. I don't know if this is a bug. I assumed that the custom class would inherit all the object's materials, animations, etc. that I would be able to access when creating a custom object. However after a lot of trial and error, the custom class just refuses to see the material on the object that was passed to it.

Why does this matter? I was trying to create a custom object that played a texture animation on its creation, then delete the texture on its destruction. I found that if I create a dictionary that stores the texture on the object, it works and automatically gets cleaned up when the object is destroyed. I have to use a dictionary element instead of a variable, because it wont let me create a variable on a object; though, I can do that on bge.logic. This could be a python issue which I am new to programming with.

Is there a way to play the texture video from the start on each multiple instance of the same object while in the same scene?

Though I am creating a unique variable name which stores the bge texture for each creation of the object, it still uses the same texture to swap out with. Thus, if 2 of the same objects are in the scene, the image is not being treated like a new instance and receives the same texture swap. Thus the video plays the frame from wherever it is instead from the start, because of other instances of the same object in the scene.

Event Timeline

Richard R (remnar) raised the priority of this task from to 90.
Richard R (remnar) updated the task description. (Show Details)
Richard R (remnar) edited a custom field.

The objects share materials, and textures, hence any replacement texture would (I believe) be shared among them. You could try using LibNew to create a new mesh, and see what happens then

K (mahalin) added a subscriber: K (mahalin).EditedApr 29 2014, 1:03 AM

Textures don't work on subclasses of KX_GameObject due to the way BlendType.h checks the class using strings. The problem is tp_name is returning the subclass's name instead of KX_GameObject. I think it would be better if the functionality was similar to KX_GameObject's ConvertPythonToGameObject function, which uses PyObject_TypeCheck (objects) instead of tp_name (strings).

We should really not be using strings in the engine in this manner, in the same way that we should not be looking up data by name (TODO for any developers)

Inês Almeida (brita_) lowered the priority of this task from 90 to 30.May 29 2014, 9:42 AM

@Richard R (remnar) do you have a sample file for this?

Bastien Montagne (mont29) changed the task status from Unknown Status to Unknown Status.Jun 5 2014, 11:55 AM
Bastien Montagne (mont29) claimed this task.

One week without answer, closing.

Had the same issue, sample file: