Controlls from overlay scene

Hi,

I tray to understand BGE and I got a overlay scene with some controls using replaceMesh function witch does not work as expected using this code:

(The yellow button from overlay scene did not bring back the initial mesh - Blender 2.49b)

import GameLogic as G

sceneList = G.getSceneList()
scene = sceneList[0]
obj = scene.objects["OBCube01"]

#me = obj.meshes[0]
#print me.name
	
#for sc in sceneList:
#    print sc.name

#for ob in scene.objects:
#    print ob.name
 
objName1 = "OBCube01"
objName2 = "OBCube02"

cont = G.getCurrentController()
over1  = cont.sensors[0]
click1 = cont.sensors[1]
over2  = cont.sensors[2]
click2 = cont.sensors[3]

#print over1.name
#print click1.name
#print over2.name
#print click2.name

if over2.positive and click2.positive:
	mesh1 = scene.objects[objName1].meshes[0]
#	print mesh1.name
	obj.replaceMesh(mesh1)
	
if over1.positive and click1.positive:
	mesh2 = scene.objectsInactive[objName2].meshes[0]
#	print mesh2.name
	obj.replaceMesh(mesh2)

Can somebody tell me what is wrong.

See the attachement.

Thanks,
Joseph

Attachments

ControllsOverlay.blend (169 KB)

Hello Joseph,

you have only one inactive object: Cube02.

what you are doing is:

  • clicking on yellow (why not call the object “yellow”? )-> replace the mesh of the Cube01 with the mesh of Cube 02

  • clicking on red (why not call the object “red”? )-> replace the mesh of the Cube01 with the mesh of Cube02 which was changed by the click on yellow = replace with the same mesh.

~Monster,

Thanks for your respons, but still.

Yes, I have only one Inactive object[CRed- now], and I call its the mesh with:

mesh2 = scene.objectsInactive[objName2].meshes[0]

the CYellow cube [visible one], have the mesh:

mesh1 = scene.objects[objName1].meshes[0]

and in both cases I change the mesh of object CYellow:

obj = scene.objects["OBCYellow"]
obj.replaceMesh(mesh1)
obj.replaceMesh(mesh2)

The issue I see here it should replace back the Yellow Mesh mesh1 but it does not.

I follow the same logic like if you control the replaceMesh from within the same scene (see attachment) -

The top controlls are from the same scene witch works perfectly, the bottom ones controlled with python are from overlay scene and did not work properly.

Thanks again,
Joseph

Attachments

ControllsOverlay1.blend (177 KB)

~Monster,

I get what you mean, when you call replaceMesh for an object, the old mesh is gone, and the new mesh become the current mesh.

Interesting because the replaceMesh from the Edit Object actuators can recall the initial mesh.

Joseph

But you do not reference it.

You could store a reference to the original mesh in a property or somewhere else.

~Monster,

I don’t know exactly how to do that.
Can you give me a line of code or something.

I really appreciate it.
Joseph