Sie sind nicht angemeldet.

mds

Fortgeschrittener

  • »mds« ist der Autor dieses Themas

Beiträge: 152

Wohnort: Athens, GA

Beruf: Designer

  • Nachricht senden

1

Montag, 18. April 2011, 16:26

How to condense <scene/> code

Checking to see if anyone has come up with a simple solution to condense the scene code. There seems to be an awful lot unnecessary redundancy. Wondering if the below code can be wrapped in a function, then when writing scene code it could be something like <action>loadAnyScene(VARIABLE)</action>

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<scene name="scene_"+"VARIABLE" title="VARIABLE" onstart="" thumburl="panos/VARIABLE.tiles/thumb.jpg">
	<view hlookat="0" vlookat="0" fovtype="MFOV" fov="120" maxpixelzoom="1.0" fovmin="60" fovmax="120" />
	<preview url="panos/VARIABLE.tiles/preview.jpg" />
	<image>
		<left  url="panos/VARIABLE.tiles/pano_l.jpg" />
		<front url="panos/VARIABLE.tiles/pano_f.jpg" />
		<right url="panos/VARIABLE.tiles/pano_r.jpg" />
		<back  url="panos/VARIABLE.tiles/pano_b.jpg" />
		<up    url="panos/VARIABLE.tiles/pano_u.jpg" />
		<down  url="panos/VARIABLE.tiles/pano_d.jpg" />
		<mobile>
			<left  url="panos/VARIABLE.tiles/mobile_l.jpg" />
			<front url="panos/VARIABLE.tiles/mobile_f.jpg" />
			<right url="panos/VARIABLE.tiles/mobile_r.jpg" />
			<back  url="panos/VARIABLE.tiles/mobile_b.jpg" />
			<up    url="panos/VARIABLE.tiles/mobile_u.jpg" />
			<down  url="panos/VARIABLE.tiles/mobile_d.jpg" />
		</mobile>
		<tablet>
			<left  url="panos/VARIABLE/tablet_l.jpg" />
			<front url="panos/VARIABLE/tablet_f.jpg" />
			<right url="panos/VARIABLE/tablet_r.jpg" />
			<back  url="panos/VARIABLE/tablet_b.jpg" />
			<up    url="panos/VARIABLE/tablet_u.jpg" />
			<down  url="panos/VARIABLE/tablet_d.jpg" />
		</tablet>
	</image>
</scene>



Thoughts?? *question*
Say "Hi!" on twitter

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

2

Montag, 18. April 2011, 16:40

At first I thought, kinda stupid.
How large can an xml file be, in comparison to image that is until I looked at my own project of 1600 lines and 94 K!

So ignoring the fact that something can be done in direct relation to your post, are there any no-nos for xml compression?
Trimming all tabs, double line breaks and more than one white space cut off 5 k!
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

mds

Fortgeschrittener

  • »mds« ist der Autor dieses Themas

Beiträge: 152

Wohnort: Athens, GA

Beruf: Designer

  • Nachricht senden

3

Montag, 18. April 2011, 16:55

I'm not so much worried about file size compared to code cleanliness. If I've got 20 scenes in one tour, that's a lot of code to scroll through when adding hotspots, etc. Would be much nicer, cleaner, and compact if most of the scene code could be compressed into a function without duplicating so much of it.

Anyone have any ideas?
Say "Hi!" on twitter

4

Montag, 18. April 2011, 16:57

94k is nothing. Most people have high speed internet now and 94k is nothing. 10 years ago when 94k would choke a dialup modem this might be something to worry about. My starting xml is 152k and over 4500 lines of code.

mds

Fortgeschrittener

  • »mds« ist der Autor dieses Themas

Beiträge: 152

Wohnort: Athens, GA

Beruf: Designer

  • Nachricht senden

5

Montag, 18. April 2011, 17:01

Again, not worried about file size here. Just looking for a way to clean up redundant code. *tongue*
Say "Hi!" on twitter

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

6

Montag, 18. April 2011, 17:09

Oh right, well then thats where asp or php comes in.
You can program everything through arrays, or a database and loop all your scenes and content.
Otherwise, i don't know how anyone can troubleshoot all that material quickly.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

mds

Fortgeschrittener

  • »mds« ist der Autor dieses Themas

Beiträge: 152

Wohnort: Athens, GA

Beruf: Designer

  • Nachricht senden

7

Montag, 18. April 2011, 17:13

one function with a scene variable in the xml is what i'm looking for
Say "Hi!" on twitter

Beiträge: 1 857

Beruf: Virtual Tours - Photography - Krpano developer

  • Nachricht senden

8

Montag, 18. April 2011, 17:37

What about a loadxml string?
Building your scene dynamically inside that.
KRPano Developer: Portfolio ::Gigapixel Tagging Solutions - Porfolio 2 :: Facebook :: Twitter :: reddit.com/r/VirtualTour

9

Mittwoch, 19. Oktober 2011, 16:09

solution with php

Hi!

I think I found a solution to reduce the amount of code lines within the scene. This involves adding some lines of php code and renaming and calling the krpano.xml file with the name krpano.xml.php
At the beginning of the xml.php document I added the following code (edit the url lines according to the location of your saved pano-images):

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php 

function makescene($scene){

echo'	
	<preview url="../pano/'.$scene.'/preview.jpg"/>

	<image type="CUBE" multires="true" tilesize="390" progressive="false">
		<level tiledimagewidth="2483" tiledimageheight="2483">
			<left  url="../pano/'.$scene.'/l3_l_%0v_%0h.jpg" />
			<front url="../pano/'.$scene.'/l3_f_%0v_%0h.jpg" />
			<right url="../pano/'.$scene.'/l3_r_%0v_%0h.jpg" />
			<back  url="../pano/'.$scene.'/l3_b_%0v_%0h.jpg" />
			<up	   url="../pano/'.$scene.'/l3_u_%0v_%0h.jpg" />
			<down  url="../pano/'.$scene.'/l3_d_%0v_%0h.jpg" />
		</level>
		<level tiledimagewidth="1242" tiledimageheight="1242">
			<left  url="../pano/'.$scene.'/l2_l_%0v_%0h.jpg" />
			<front url="../pano/'.$scene.'/l2_f_%0v_%0h.jpg" />
			<right url="../pano/'.$scene.'/l2_r_%0v_%0h.jpg" />
			<back  url="../pano/'.$scene.'/l2_b_%0v_%0h.jpg" />
			<up	   url="../pano/'.$scene.'/l2_u_%0v_%0h.jpg" />
			<down  url="../pano/'.$scene.'/l2_d_%0v_%0h.jpg" />
		</level>
		<level tiledimagewidth="621" tiledimageheight="621">
			<left  url="../pano/'.$scene.'/l1_l_%0v_%0h.jpg" />
			<front url="../pano/'.$scene.'/l1_f_%0v_%0h.jpg" />
			<right url="../pano/'.$scene.'/l1_r_%0v_%0h.jpg" />
			<back  url="../pano/'.$scene.'/l1_b_%0v_%0h.jpg" />
			<up	   url="../pano/'.$scene.'/l1_u_%0v_%0h.jpg" />
			<down  url="../pano/'.$scene.'/l1_d_%0v_%0h.jpg" />
		</level>
		<mobile>
			<left  url="../pano/'.$scene.'/mobile_l.jpg" />
			<front url="../pano/'.$scene.'/mobile_f.jpg" />
			<right url="../pano/'.$scene.'/mobile_r.jpg" />
			<back  url="../pano/'.$scene.'/mobile_b.jpg" />
			<up	   url="../pano/'.$scene.'/mobile_u.jpg" />
			<down  url="../pano/'.$scene.'/mobile_d.jpg" />
		</mobile>
		<tablet>
			<left  url="../pano/'.$scene.'/tablet_l.jpg" />
			<front url="../pano/'.$scene.'/tablet_f.jpg" />
			<right url="../pano/'.$scene.'/tablet_r.jpg" />
			<back  url="../pano/'.$scene.'/tablet_b.jpg" />
			<up	   url="../pano/'.$scene.'/tablet_u.jpg" />
			<down  url="../pano/'.$scene.'/tablet_d.jpg" />
		</tablet>
	</image>';

}
?>


To call the function with the code snippet just add

Quellcode

1
<?php makescene(***); ?>

where *** represents the name of your panorama you want to load. Add this line in every <scene>. Of course you also have to remove the code for the preview and the image in your scenes.

I hope this helps making your scenes better editable and more lightweight!


**Edit: I realize that this won't change the size of data transferred from the server to the browser, as the functions are rendered on the server. So the xml file you get in the end will have about the same size as before…

**Edit2: And of course your server needs to have php enabled…
"Warum sind denn da alle Linien so krumm?!"