BGE Textures and custom class objects #39302

Closed
opened 2014-03-20 21:47:10 +01:00 by Richard R · 14 comments

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.

**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.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @remnar

Added subscriber: @remnar

Added subscriber: @AngusHollands-4

Added subscriber: @AngusHollands-4

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

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

Added subscriber: @mahalin

Added subscriber: @mahalin

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).

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)

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)
Member

Added subscriber: @brita

Added subscriber: @brita
Member

@remnar do you have a sample file for this?

@remnar do you have a sample file for this?

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Bastien Montagne self-assigned this 2014-06-05 11:55:06 +02:00

One week without answer, closing.

One week without answer, closing.

Added subscriber: @DavidPoirier-Quinot

Added subscriber: @DavidPoirier-Quinot

Had the same issue, sample file: inherit-kx_gameObject-matID-issue.blend

Had the same issue, sample file: [inherit-kx_gameObject-matID-issue.blend](https://archive.blender.org/developer/F232989/inherit-kx_gameObject-matID-issue.blend)

Removed subscriber: @mahalin

Removed subscriber: @mahalin
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#39302
No description provided.