You are not logged in.

1

Saturday, September 13th 2014, 4:41pm

Random start view in autotour

Hi everyone,

I'm new to the forum.

I'm trying to do something that should be simple, but is not yet working out.

I have two scenes set to autotour using the timer by Sudarchikov Andrey to switch from one to the other


I would like to get a random value for the hlookat (and vlookat) each time one scene reloads.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<krpano onstart="loadscene(0);timer.start(autotour,12);">       <events name="autotour" keep="true"        onxmlcomplete="autotour.reset();"        onmousedown="autotour.pause();"        onmouseup="autotour.reset();"        autotour="            if(autorotate.enabled,                add(sceneindex,scene[get(xml.scene)].index,1);                if(sceneindex == scene.count, set(sceneindex,0); );                loadscene(get(sceneindex),null,merge,blend(0.7));            );        "    />
    <include url="timer.xml" />
    <autorotate waittime="0" enabled="true"/>
	<krpano idletime="2.0" />	<events onidle="mul(h,random,360);mul(v,random,90);mul(f,random,90);sub(h,180);sub(v,45);add(f,45);oninterrupt(break);lookto(get(h),get(v),get(f),smooth(5,2,50));wait(2.0);" />
			<scene name="01" title="01" onstart="" thumburl="panos/01.tiles/thumb.jpg" lat="" lng="" heading="">
		<view hlookat="0" vlookat="0" fovtype="MFOV" fov="120" maxpixelzoom="2.0" fovmin="70" fovmax="140" limitview="auto" />
		<preview url="panos/01.tiles/preview.jpg" />
		<image>			<cube url="panos/01.tiles/pano_%s.jpg" />			<mobile>				<cube url="panos/01.tiles/mobile_%s.jpg" />			</mobile>		</image>
			</scene>
	<scene name="02" title="02" onstart="" thumburl="panos/02.tiles/thumb.jpg" lat="" lng="" heading="">
		<view hlookat="100" vlookat="0" fovtype="MFOV" fov="120" maxpixelzoom="2.0" fovmin="70" fovmax="140" limitview="auto" />
		<preview url="panos/02.tiles/preview.jpg" />
		<image>			<cube url="panos/02.tiles/pano_%s.jpg" />			<mobile>				<cube url="panos/02.tiles/mobile_%s.jpg" />			</mobile>		</image>
		
	</scene>


Any suggestion?

2

Thursday, September 18th 2014, 6:42pm

Hi,

e.g. add this after the loadscene() call:

Source code

1
2
3
4
mul(view.hlookat, random, 360);
sub(view.hlookat, -180);
mul(view.vlookat, random, 180);
sub(view.vlookat, -90);
This will generate random values in the range -180 to +180 for hlookat and -90 to +90 for vlookat.

But it might be more sense-full to use narrow ranges for vlookat to avoid with starting looking directly at the sky or the floor, e.g. use:

Source code

1
2
mul(view.vlookat, random, 60);
sub(view.vlookat, -30);
to use a range from -30 to +30.

Best regards,
Klaus

Similar threads