Sie sind nicht angemeldet.

1

Donnerstag, 16. Februar 2023, 14:12

Object - texture change ?

Hi firends,

now other quetion about 3D model.

is possible to change texture for 3D model dynamicaly ?

Thanks

kme

Fortgeschrittener

Beiträge: 310

Wohnort: Belgium

Beruf: Long time coder, product manager and 3D enthousiast

  • Nachricht senden

2

Donnerstag, 16. Februar 2023, 14:14

How about creating 2 scenes each with the same object but with different skin? And then swap scenes?

kme

Fortgeschrittener

Beiträge: 310

Wohnort: Belgium

Beruf: Long time coder, product manager and 3D enthousiast

  • Nachricht senden

3

Donnerstag, 16. Februar 2023, 14:37

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
	<scene name="scene1" autoload="true">
		<image>
			<sphere url="texture.jpg" />
			<depthmap url="model.obj" hittest="true" rendermode="3dmodel" scale="100" textured="true" waitforload="true" center="0,0,0" axis="+x+y+z"/> 
		</image>
	</scene>
	<scene name="scene2" >
		<image>
			<sphere url="texture-2.jpg" />
			<depthmap url="model.obj" hittest="true" rendermode="3dmodel" scale="100" textured="true" waitforload="true" center="0,0,0" axis="+x+y+z"/> 
		</image>
	</scene>
	
	<style name="button" type="text" css="text-align:center;" padding="4 8" mergedalpha="false" bgborder="0 0xFFFFFF 1" bgroundedge="1" bgshadow="0 1 4 0x000000 1.0" ondown="set(bgcolor, 0xDDDDDD);" onup="set(bgcolor, 0xFFFFFF);" />
	<layer name="changescenebutton" style="button" keep="true" html="Switch Texture"  width="80" align="bottom" y="50" onclick="changetexture();" />
	
	
	<action name="changetexture" >
		loadscene(scene2, null, MERGE|KEEPVIEW, BLEND(0.5));
	</action>

kme

Fortgeschrittener

Beiträge: 310

Wohnort: Belgium

Beruf: Long time coder, product manager and 3D enthousiast

  • Nachricht senden

5

Donnerstag, 16. Februar 2023, 16:27

Oooh, nice one @indexofrefraction !

Tested this and also works:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
	<scene name="scene1" autoload="true">
		<image>
			<sphere url="texture.jpg" />
			<depthmap url="model.obj" hittest="true" rendermode="3dmodel" scale="100" textured="true" waitforload="true" center="0,0,0" axis="+x+y+z"/> 
		</image>
	</scene>
	
	<style name="button" type="text" css="text-align:center;" padding="4 8" mergedalpha="false" bgborder="0 0xFFFFFF 1" bgroundedge="1" bgshadow="0 1 4 0x000000 1.0" ondown="set(bgcolor, 0xDDDDDD);" onup="set(bgcolor, 0xFFFFFF);" />
	<layer name="changescenebutton" style="button" keep="true" html="Switch Texture"  width="80" align="bottom" y="50" onclick="changetexture();" />
	
	
	<action name="changetexture" >
		<!-- loadscene(scene2, null, MERGE|KEEPVIEW, BLEND(0.5)); -->
		image.reset();
		set(image.sphere.url, 'texture-2.jpg');
		set(image.depthmap.url, "model.obj");
		set(image.depthmap.rendermode, "3dmodel");
		set(image.depthmap.scale, "100");
		
		loadpanoimage(MERGE|KEEPVIEW, BLEND(0.5));
	</action>

6

Donnerstag, 16. Februar 2023, 17:23

*thumbsup*
loadpanoimage() is pretty new, i think it came with 1.20.11