2
$\begingroup$

I have made a game with mirror material using the Render To Texture script. When I hit P in Blender, it works. But when I Saved as Runtime Game and opened my runtime game file, the mirror material was black and did not work.

Why it doesn't work and how to make it work?

The result when I export game to Runtime:

Traceback (most recent call last):
  File "/opt/Blender/2.72/scripts/addons/io_export_pc2.py", line 156, in poll
    return context.active_object.type in {'MESH', 'CURVE', 'SURFACE', 'FONT'}
AttributeError: 'NoneType' object has no attribute 'type'

location: <unknown location>:-1

The code I use for mirror relfection:

######################################################
#
#    RenderToTexture.py        Blender 2.50
#
#    Tutorial for using RenderToTexture.py can be found at
#
#    www.tutorialsforblender3d.com
#
#    Released under the Creative Commons Attribution 3.0 Unported License.  
#
#    If you use this code, please include this information header.
#
######################################################

#import GameLogic
import GameLogic

# get current scene
scene = GameLogic.getCurrentScene()

# get the current controller
controller = GameLogic.getCurrentController()

# get object script is attached to
obj = controller.owner

# check to see RenderToTexture has been added
if "RenderToTexture" in obj:

    # update the texture
    obj["RenderToTexture"].refresh(True)

# if RenderToTexture hasn't been added 
else:

    # import VideoTexture module
    import VideoTexture

    # get a list of objects in the scene
    objList = scene.objects

    # get camera name being used for render to texture
    camName = obj['cam']

    # get camera object
    cam = objList[camName]

    # get the texture material ID
    matID = VideoTexture.materialID(obj, "MA" + obj['material'])

    # set the texture
    renderToTexture = VideoTexture.Texture(obj, matID)

    # get the texture image
    renderToTexture.source = VideoTexture.ImageRender(scene,cam)

    # save RenderToTexture as an object variable
    obj["RenderToTexture"] = renderToTexture
$\endgroup$
  • $\begingroup$ What modifiers? I don't use modifiers. It is not Mirror modifier, but a reflection texture(python script, that Always gets render from camera and makes that render into texture) $\endgroup$ – Adrians Netlis Dec 29 '14 at 14:00
  • $\begingroup$ If that the case, enabling True-Level-triggering should fix. $\endgroup$ – Scalia Dec 29 '14 at 16:25
  • $\begingroup$ I have enabled true level triggering. $\endgroup$ – Adrians Netlis Dec 29 '14 at 17:06
  • $\begingroup$ @AdriansNetlis Better to edit your question and put the code there. Comments don't allow newlines and are limited to 500 chars. $\endgroup$ – gandalf3 Dec 29 '14 at 20:07
  • $\begingroup$ Did as you said... $\endgroup$ – Adrians Netlis Dec 29 '14 at 20:16
1
$\begingroup$

For some reason the obj["RenderToTexture"].refresh(True) makes it not work. If I change it to obj["RenderToTexture"].refresh(False) it works also in standalone for me. Strange...

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.