You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Sunday, March 6th 2011, 5:36pm

string and vectormath plugins

I have released two more utility plugins, and bundled my swf-based plugins as the krpano_fovplugin suite. As with my previous plugins, they are free to use and their sources are available as GPL open source.

string
Provides the following functions designed to complement txtadd provided by krpano itself:
  • txtlength(destVar, text)
    Sets destVar to the length of 'text'
  • txtchunk(destVar, text, start, length)
    Sets destVar to the substring of 'text', starting from 'start' and 'length' characters long
  • txtfind(destVar, text, find)
    Sets destVar to the position of 'find' in 'text', or -1 if the text is not found
  • txtreplace(destVar, text, find, replace, flags)
    Sets destVar to a copy of 'text', replacing 'find' with 'replace'. The optional 'flags' argument can be used to set flags for the internal regular expression pattern (and defaults to ''gi' for a global, case-insensitive replace).
vectormath
Provides the following functions:
  • sin(destVar, angle)
    Sets destVar to the sine of 'angle'
  • cos(destVar, angle)
    Sets destVar to the cosine of 'angle'
  • tan(destVar, angle)
    Sets destVar to the tangens of 'angle'
  • asin(destVar, number)
    Sets destVar to the inverse sine of 'number'
  • acos(destVar, number)
    Sets destVar to the inverse cosine of 'number'
  • atan(destVar, number)
    Sets destVar to the inverse tangent of 'number'
  • atan2(destVar, opposite, adjacent)
    Sets destVar to the inverse tangent of 'opposite'/'adjacent'
  • anglebetween(destVar, ath1, atv1, ath2, atv2)
    Sets destVar to the angle between the two vectors defined by ('ath1', 'atv1') and ('ath2', 'atv2')
  • normal(destVarH, destVarV, ath1, atv1, ath2, atv2)
    Sets destVarH and destVarV to align with the normal of the two vectors defined by ('ath1', 'atv1') and ('ath2', 'atv2')
  • rotatevector(destVarH, destVarV, ath1, atv1, ath2, atv2)
    Sets destVarH and destVarV to align with the vector ('ath1', 'atv1') after it has been rotated by ('ath2', 'atv2')

All angles are specified and returned in degrees, and axis rotations are done in the same order as krpano does them.

The string.swf and vectormath.swf files are available as part of the krpano_fovplugins package on github. See the examples folders for usage examples.

This post has been edited 2 times, last edit by "ahoeben" (Mar 15th 2011, 4:54pm)


Tuur

Master

Posts: 2,405

Location: Netherlands

Occupation: Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

2

Sunday, March 6th 2011, 5:54pm

Aldo! Master!

great stuff!

I think it would be nice to make the examples like real world examples.. just to see for dummy's.. (pictures and simple code example)
espesialy the vectormath and string ones..

I would like a tickertape plugin.. that loops the text...
i tried to fake it a bit with the textmachine and tween but that's no serious option.

Some drinks for Aldo in the krpano bar and Cafe

Cheers!
Tuur *thumbsup*

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

3

Sunday, March 6th 2011, 6:05pm

Thanks Aldo for your intelligent generosity *smile* ...
It is great to have guys like you *thumbup* .

SAlut.

Tuur

Master

Posts: 2,405

Location: Netherlands

Occupation: Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

4

Sunday, March 6th 2011, 6:06pm

yep..

got it..

GREAT!!!

Tuur *thumbsup*

Tuur

Master

Posts: 2,405

Location: Netherlands

Occupation: Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

5

Sunday, March 6th 2011, 6:15pm

only don't understand that string thing..

Tuur *thumbsup*

Tuur

Master

Posts: 2,405

Location: Netherlands

Occupation: Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

6

Sunday, March 6th 2011, 6:20pm

could i use that for the tickertape thing?

tuur *thumbsup*

7

Sunday, March 6th 2011, 6:23pm

Quoted

I think it would be nice to make the examples like real world examples..


The vectormath plugin is somewhat special purpose. If you don't understand how you would use them, you probably don't need them in the first place. But if you have ever thought "I wish I could put a hotspot exactly perpendicular to two other hotspots", then the vectormath plugin is what you need. You don't have to use this plugin, but if you need it, it is there ;-). I am not yet at liberty to share why I needed the vectormath plugin myself.

The string plugin contains krpano specific string manipulations which are missing from krpano itself. Sometimes, especially if you pull in data from different sources, you want to be able to process text a bit more. For example truncating a text to a maximum of 20 characters. The example includes the code to do just that.

This post has been edited 2 times, last edit by "ahoeben" (Mar 6th 2011, 6:39pm)


Tuur

Master

Posts: 2,405

Location: Netherlands

Occupation: Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

8

Sunday, March 6th 2011, 6:28pm

Oke thanx for the explanation!

i understand now better..
Well you can also have just fun and let people see pano's partial or totally upside down ;-)

i was thiking about that ship on the sea to give it a roll ;-)

i see what you mean with the string in the logkey..

could i use that string plugin to make sort of a tickertape thing?
also using stage width? and repeating text?

or is there a better way...

Tuur *thumbsup*

9

Sunday, March 6th 2011, 6:40pm

I guess you could use the string plugin for a ticker tape... (though I am not a fan of ticker tapes)

The following code is incomplete and entirely untested. But in theory it could work.

Source code

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
<krpano onstart="delayedcall(0.1,startticker())">
<data name="tickertape">
  Your ticker text would go here. And typically it would be quite long, or why would you want a ticker in the first place?
</data>
<plugin name="tickertext" src="textfield.swf" (... positioning and styling goes here...) />
<plugin name="string" src="string.swf" />

<action name="startticker">
plugin[string].txtlength(tickertape_length, get(data[tickertape].content));
set(ticker_length,0);
set(ticker_offset,0);
delayedcall(0.25, tickertick);
</action>

<action name="tickertick">
plugin[string].txtchunk(chunk, get(data[tickertape].content), ticker_offset, ticker_length);
txtadd(plugin[tickertext].html, "[p]", chunk, "[/p]");

if(ticker_length LT 10,
  inc(ticker_length);
,
  if(ticker_offset LT tickertape_length,
    inc(ticker_offset);
    delayedcall(0.25, tickertick);
  )
);
</action>

Tuur

Master

Posts: 2,405

Location: Netherlands

Occupation: Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

10

Sunday, March 6th 2011, 6:56pm

mmm..

i can't get it now..
i'll try later..

Tuur *thumbsup*

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

11

Monday, March 7th 2011, 2:00am

Hi Tuur,

Here a working one (after little correction in Ahoeben's code *thumbup* ):

Source code

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
<krpano onstart="delayedcall(2,startticker())">
<data name="tickertape">
  Your ticker text would go here. And typically it would be quite long, or why would you want a ticker in the first place?
</data>
	
<plugin name="tickertext" url="%SWFPATH%/plugins/textfield.swf" 
		origin="center" 
    	width="160" height="20" 
    	x="0" y="0" 
    	html="SAlut"
    	borderwidth="1"
    	bordercolor="0xFFFFFF"
    	backgroundcolor="0xFFFFFF"
		/>
<plugin name="string" url="%SWFPATH%/plugins/string.swf" />

<action name="startticker">
plugin[string].txtlength(tickertape_length, get(data[tickertape].content));
trace('tickertape_length = ',tickertape_length);
set(ticker_length,0);
set(ticker_offset,0);
delayedcall(0.25, tickertick);
</action>

<action name="tickertick">
plugin[string].txtchunk(chunk, get(data[tickertape].content), get(ticker_offset), get(ticker_length));
trace('chunk = ',chunk);
txtadd(plugin[tickertext].html, "[p]", get(chunk), "[/p]");
trace('chunk = ',chunk);
if(ticker_length LT 30,
  inc(ticker_length);
	delayedcall(0.15, tickertick);
,
  if(ticker_offset LT tickertape_length,
	inc(ticker_offset);
	delayedcall(0.15, tickertick);
	,	
	delayedcall(5, startticker);
  );
);
</action>
</krpano>


SAlut.

Tuur

Master

Posts: 2,405

Location: Netherlands

Occupation: Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

12

Monday, March 7th 2011, 2:09am

Great!

Thanx Michel and Ahoeben!! *thumbsup* *thumbsup*

Cheers

Tuur *thumbsup*

13

Monday, March 7th 2011, 11:25am

Ah, yes... you need to use get() with the variables. Thanks michel

14

Monday, March 7th 2011, 3:38pm

By the way, I am open to suggestions if you need more text manipulation or (vector)math methods. I am also open to patches to the sources if someone feels inclined to make improvements. And finally I am open to donations ;-)

DorinDXN

Trainee

Posts: 96

Location: Timisoara, Romania

  • Send private message

15

Saturday, March 26th 2011, 2:12pm

I just become aware of this plugins collection and looks like a very good one.

Gongrats!



Dorin
www.livepanoramas.com

Tuur

Master

Posts: 2,405

Location: Netherlands

Occupation: Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

16

Wednesday, March 30th 2011, 1:28pm

Hi,
Is there an , XML , way to make à textmachine ?
That works on iPhone / pad..
So that THE NeXT syllable is coming like 0.15 seconds after THE previous one.
And Also get that with variables in textfield on mobile devices??

Tuur *thumbsup*

17

Wednesday, March 30th 2011, 2:18pm

How is what you call a "textmachine" different from a "ticker" as Michel (and I) posted above?

The plugin is only available as aswf now (so it won't work on ios devices). krpano 1.14 will bring the capability to have actual javascript plugins for the ios/html5 viewer, so then it should be possible to write versions of some of my scripting plugins that work on ios as well.

As for the "other" type of mobile devices... Android-powered devices that have Flash should already be able to use the current batch of plugins.

Tuur

Master

Posts: 2,405

Location: Netherlands

Occupation: Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

18

Wednesday, March 30th 2011, 2:23pm

He Aldo,

thanx for the answere.. i now .. there is a flash version from what i mean already... maybe this is the wrong threath to ask in..

Grtz

Tuur *thumbsup*

19

Monday, April 4th 2011, 10:10pm

The string plugin is now also available in a js version for krpanoJS:
http://fieldofview.github.com/krpano_fov…ing/plugin.html
(soon also on the official plugins page)

The vectormath plugin will follow suit (eventually).

michel

Professional

Posts: 1,153

Location: ANDORRA

Occupation: TV

  • Send private message

20

Saturday, April 9th 2011, 5:11am

Hi Ahoeben,

It seems that there is a mistake on the vectormath definition of the rotatevector() function:
  • rotatevector(destVarH, destVarV, ath1, atv1, ath2, atv2)
    Sets destVarH and destVarV to align with the vector ('ath1', 'atv1') after it has been rotated by ('ath2', 'atv2')
After reading your example code, in my understanding it should be something like:

Quoted

  • rotatevector(destVarH, destVarV, destVarR, ath1, atv1, rotate1, ath2, atv2, rotate2)
    Sets destVarH, destVarV and destVarR to align with the vector ('ath1', 'atv1', 'rotate1') after it has been rotated by ('ath2', 'atv2', 'rotate2')
Or...

SAlut.

Similar threads