Archive:Vortex Visualization Development and Adding videos to the library: Difference between pages

From Official Kodi Wiki
(Difference between pages)
Jump to navigation Jump to search
 
>Cosmicr
mNo edit summary
 
Line 1: Line 1:
Vortex Visualization Development
{{Cleanup}}
{{XBMC wiki toc Inline}}
__NOEDITSECTION__
__TOC__
[[Scraper.xml|Scrapers]] are used by XBMC to retrieve data from a webpage which is used in the [[Video Library]]. To be able to utilize them you first have to "Set Content" to the source you plan to add information on.<br>


==Setting Contents==
In the [[Videos#Files View|Files View]] of the 'Videos' section of XBMC, bring up the [[Videos Navigation and Control#The Context Menu|Context Menu]]. By selecting "Set Content" one can set the type of content for the chosen directory.


== Coding your own presets and transitions for Vortex ==
The Context menu can be brought up by either the 'C' key or the 'Windows' '''Application''' key on the Keyboard or by pressing right mouse button on the appropriate item.
 
On the Mac version of XBMC, the context menu can be displayed by holding the '''Menu''' button on the Apple Remote or by pressing '''C''' on the keyboard.
=== The filetypes ===
{|
* '''*.vtx''' - preset file, the actual visualization
|
* '''*.tra''' - transition file, changes from current preset to the next preset
[[image:Set_content0.jpg|180px]]
 
| valign="top" |
=== The template ===
Different types of scrapers can be assigned to different directories, but be aware that 'TV Shows' scrapers must be assigned to a folder containing multiple TV shows ( or at least be one directory above the TV show folder itself) unless you select the ''Folder contains a single TV Show Option'', e.g.
<python>//filename - TheTransitionOrPresetFilename.Extension
<pre>
//author - your name
TV Shows
void Init()
    |----TV Show 1
{
    |      |___ TV Show 1 Media files
  //TODO: put your initializationcode here
    |
}
      ----TV Show 2
 
            |___ TV Show 2 Media files
void Render()
</pre>
{
In the above example you would assign the chosen TV Shows scraper to the ''TV Shows'' folder. Note that each TV show needs to be in its own folder for XBMC to be able to scan it into the library.
  //TODO: put your stunning graphics here
}</python>
 
=== The coding ===
If you did some coding before, go on reading. If not, get your self some knowledge with coding c/c++ and return after that.
 
==== The datatypes ====
* '''float'''
* '''int'''
* '''bool'''
* '''Texture'''
* '''Map'''
* '''VoicePrint'''
* '''Tunnel'''
 
==== The operators and math-functions ====
* '''+''' - Addition
* '''-''' - Subtraction
* '''*''' - Multiplication
* '''=''' - Equality (left side will be made same as right side)
* '''+=''' - same as left = left + right
* '''-=''' - same as left = left - right
* '''Cos(x)''' - Cosine of x in radians
* '''Sin(x)''' - Sine of x in radians
* '''Rand()''' - returns a random float between 0 and 1
* '''Pow(a,x)''' - a to the power of x
* '''Fabs(a)''' - makes float a an absolute value
 
Boolean operators
* '''>''' - returns true if left is greater than right
* '''<''' - returns true if right is greater than left
* '''>=''' - returns true if left is greater or equal to right
* '''<=''' - returns true if right is greater or equal to left
* '''==''' - returns true if right is equal to left
* '''!=''' - returns true if right is not equal to left
* '''&&''' - returns left AND right
* '''||''' - returns left OR right
 
==== The built-in VORTEX-variables ====
* '''TREBLE''' - returns the treble level (float, values between -1 and 1)
* '''MIDDLE''' - returns the middle level (float, values between -1 and 1)
* '''BASS''' - returns the bass level (float, values between -1 and 1)
* '''TIMEPASS''' - returns the time passed since the last Render()-Call (float, value in seconds)
* '''FINISHED''' - set this to true if your tranisition has finished (boolean)
 
==== The built-in VORTEX-constants ====
===== Blendmodes =====
* '''const int BLEND_OFF = 0;''' - disables Blending
* '''const int BLEND_ADD = 1;''' - adds color values
* '''const int BLEND_MOD = 2;''' - modulated blend
* '''const int BLEND_MAX = 3;''' - finalcolor is the brightest color
===== PrimitiveTypes =====
* '''const int PRIM_POINTLIST = 1;''' - vertices are rendered as individual points
* '''const int PRIM_LINELIST = 2;''' - vrtices form lines (vertex 1&2, vertex 3&4 ...)
* '''const int PRIM_LINELOOP = 3;''' - vertices form a loop (first and last vertex are connected)
* '''const int PRIM_LINESTRIP = 4;''' - vertices form a continuous line (line from 1 to 2, 2 to 3 ...)
* '''const int PRIM_TRIANGLELIST = 5;''' - vertices build triangles (1&2&3, 4&5&6 ...)
* '''const int PRIM_TRIANGLESTRIP = 6;''' - vertices build continuous triangles (1&2&3, 2&3&4, 3&4&5...)
* '''const int PRIM_TRIANGLEFAN = 7;''' - vertices build a fan of triangles (1&2&3, 1&3&4, 1&4&5...)
* '''const int PRIM_QUADLIST = 8;''' - vertices build a quad: the vertices have to be ordered clockwise (1&2&3&4, 5&6&7&8...)
* '''const int PRIM_QUADSTRIP = 9;''' - vertices build a continuous band of quads (1&2&3&4, 3&4&5&6...)
===== Fillmodes =====
* '''const int FILLMODE_SOLID = 0;''' - all trangles a rendered as filled triangles
* '''const int FILLMODE_WIREFRAME = 1;''' - only the edges of the triangles are rendered
===== StandardTextures =====
* '''const int TEXTURE_FRAMEBUFFER = 1;''' - a texture showing the current framebuffer
* '''const int TEXTURE_NEXTPRESET = 2;''' - a texture showing the next preset in action (used for transitions)
* '''const int TEXTURE_CURRPRESET = 3;''' - a texture showing the current preset in action (used for transitions)
* '''const int TEXTURE_ALBUMART = 4;''' - a texture showing the coverart of the currently playing song, if none available a default image will be used
 
==== The built-in VORTEX-functions ====
* '''GetSpec(int a)''' - returns the spectrum value at the given position
 
==== The built-in VORTEX-functions for graphics ====
* '''gfxSetTexture(Texture texture)''' - specifies the texture to be used for the next drawing calls
* '''gfxSetRenderTarget(Texture texture)''' - specifies the texture as a rendertarget (output not to screen but to the texture)
** '''gfxSetRenderTarget(Map map)''' - specifies the map as a rendertarget (output not to screen but to the map)
** '''gfxSetRenderTarget(0)''' - specifies the screen as rendertarget (default)
* '''gfxSetEnvTexture(Texture texture)''' - specifies the Texture as environment texture
* '''gfxTranslate(float x, float y, float z)''' - adds a translation to the current view transformation (see [[Vortex Visualization Development#The coordinatesystem|CoordinateSystem]])
* '''gfxRotate(float angle, float axisX, float axisY, float axisZ)''' - adds a rotation to the current view transformation (float angle (degree), float axisX,axisY,axisZ form an axis from origin to the given coordinates (the rotation axis))
* '''gfxColour(float r, float g, float b, float a)''' - set the color for the next drawing calls (RGB + Alpha)
* '''gfxCube(a,b, c, d,e,[f])''' (Using f coz I use f for something else)
* '''gfxTexCoord(float tu, float tv)''' - set the texturecoordinates for the next vertex
* '''gfxVertex(x,y,z)''' - adds a vertex to the renderingpipeline
* '''gfxSetBlendMode([[Vortex Visualization Development#Blendmodes|BLENDMODE]])''' - set the blendmode (blending is used is a pixel already has a colorvalue, and an object needs to be rendered to this position)
* '''gfxBegin([[Vortex Visualization Development#PrimitiveTypes|PRIMITIVETYPE]])''' - sets the way the following vertices should be handled, reqires a closing gfxEnd()
* '''gfxEnd()''' - tells the renderingpipeline that no more vertices should be rendered with to declared PRIMITIVETYPE
* '''gfxPushMatrix()''' - pushes the current matrix on the stack
* '''gfxPopMatrix()''' - pops the topmost matrix from the stack
* '''gfxClear(0)''' -
* '''gfxSetAspect(0)''' - sets the aspectratio of the screen
* '''gfxTexRect(float left, float right, float top, float bottom)''' - draws a rectangle to the given coordinates, the texture is drawn completely on that rectangle
* '''gfxLookAt(Cos(tn*1.23)*5,Sin(tn)*5,(tm*2)-1,Cos(tn*0.6734)*2,Sin(tn*0.2143)*2,(tm*2)+8,0,1,0 )''' - calculates a viewmatrix to point to a desired point in space
 
==== The MAP-Datatype ====
Maps are some special kind of textures. If you use them like textures without any special handling, then all youll get is some black texture. But if you render something to them using the gfxSetRenderTarget-Method you can do some very cool and unique effects.
 
The map has always a dimension of 32x24!
 
Now the Step-By-Step-Guide to Maps:
* create a new Map: <php>Map map;</php>
* set the maps values:
<php>
for (int y = 0; y < 24; y++)
{
  for (int x = 0; x < 32; x++)
  {
    map.SetValues(x, y, speedX, speedY, attR, attG, attB);
  } 
}
</php>
Here we used the SetValues-method of the map datatype. This function is where all the magic happens.
 
The x and y values only specify the position for the following values.
 
The speedX and speedY values move the pixel inside the map. if you set all speedX and speedY you'll get 24x32 little icons of what you rendered to the map. if you set them to 0 you see everything you rendered in the last frames on the texture too. So for example to move the last frames slowly to the top you have to set the speedX to 0 (you want no motion along the x axis) and the speed Y to some value other than 0.
 
The attR, attG, attB values specify how the color of the pixels change over time. For each basecolor you can specify how strong its filtering should be. If set to 0 the basecolor is filtered out, if 1 the basecolor will not be touched.
 
* render the map
<php>map.Render();</php>
Here the values you applied to the map will be used to transform the previous data in the map.
 
* set the map as rendertarget
<php>gfxSetRenderTarget(map);</php>
 
* render something to the map
<php>RenderSomeCoolGraphicsHere();</php>
 
* change the rendertarget to default
<php>gfxSetRenderTarget(NULL);</php>
 
* do something with the map
Now you can do something with the map. For example you can just put it on a rectangle and render it to screen.
 
== The graphics basics ==
=== The coordinatesystem ===
The coordinate system used by vortex is a left handed coordinate system. This mean that the x-axis points in the same direction as your screens horizontal edges (from left to right), the y-axis points up and the z-axis point into the screen. The origin of this coordinate system is right in the center of your screen (if no transformation is added to the view matrix)
 
The texture coordinates have their origin in the top-left corner of the texture. tu points from left to right, tv from top to bottom.
 
=== The matrix transformations ===
Initially when you didnt apply any transformations the transformation matrix is the identity. This matrix leaves the vertices at their specified position.
To get some cool motion into your preset you have to apply some transformation to the matrix. If you want to apply multiple transformations, you have to mind the order in which you apply the transformations:
e.g: you want to rotate an object around itself and put further away into the screenspace. so you have to apply the rotation before the translation. in your code it looks like this:
 
<python>
gfxTranslate(0,0,5); // this is the second transformation, it pushes the object into your screen
gfxRotate(angle, 1,0,0); // this is the first transformation applied to the object, it rotates the object around the x-axis
RenderSomeCoolObjectAtOrigin(); // the initial Object is rendered around the origin
</python>
 
If you look at this code, then you notice, that the order of appliance to exactly the opposite of the appearance order in the code. So the later in the code, the earlier applied on the object.
 
To store some transformation for returning to it on a later renderingstep, you can use the gfxPushMatrix()-method. This methos pushes the matrix on a stack. I f you want to return to this matrix, then you can pop it off the stack. Remember that only the topmost matrix is popped off the stack. So if you push two matrices on the stack, and you want to return to the first pushed matrix, then you have to pop twice.
 
<python>
gfxTranslate(0,0,5); // this is the second transformation, it pushes the object into your screen
gfxPushMatrix(); // this stores the matrix on the stack
gfxRotate(angle, 1,0,0); // this is the first transformation applied to the object, it rotates the object around the x-axis
RenderSomeCoolObjectAtOrigin(); // the initial Object is rendered around the origin
gfxPopMatrix(); // this gets the topmost matrix from the stack
RenderSomeCoolObjectAtOrigin(); // the initial Object is rendered around the origin
</python>
 
the result of this snippet are two objects: the first is rotated and translated, the second is only translated.
|}
|}
== The examples ==
=== The preset ===
This is an example for a simple preset. it rotates some albumart-textured cube around itself (the rotation is defined by the music).
The code for this example is written by MrC (I only put in the comments).
<python>
// AlbumArtCube.vtx
// Author - MrC
float time = 0;
float rx,rxamt,ry,ryamt;


void Render()
After choosing a content type ([[Movies_(Video_Library)|Movies]], [[TV Shows (Video Library)|TV shows]] or [[Music Videos]]), one can decide on a scraper to use. There are currently several scrapers available of each type. For movies, the TheMovieDb.org[http://themoviedb.org] is the one recommended, as this is a free and open database of movies that anyone can contribute to. The other available scrapers are for example scrapers for different languages or for adult movies.
{
[[image:Set_content2.jpg|360px]]
  // time stores the the elapsed time since the preset started
  time += TIMEPASS;                                   


  // set the coverart of the current song as texture
[[image:Set.content.movies.jpg|360px]]
  gfxSetTexture(TEXTURE_ALBUMART); 
  // push the object into the screen. the distance is calculated from the current TREBLE-value                   
  gfxTranslate(0, 0, 2.0f - (TREBLE * 0.5));           


  // change the rotation-direction for rotations around the x axis according to the BASS-value
[[image:Set.content.tv.jpg|360px]]
  if (BASS>0.3) rxamt = 1;                             
  if (BASS<-0.3) rxamt = -1;
  // change the rotation-direction for rotations around the y axis according to the TREBLE-value
  if (TREBLE>0.3) ryamt = 1;                           
  if (TREBLE<-0.3) ryamt = -1;


  //calculate the current rotation angle from direction and elapsed time
  rx = rx + (rxamt*TIMEPASS);
  ry = ry + (ryamt*TIMEPASS);


  //add some continuous rotation to the preset
===Options After Selecting Scraper===
  gfxRotate(-70+(Sin(time)*12),1,0,0);
;Exclude folder from scans
:Excludes the selected folder from scans, even if it's a subfolder of a folder that has contents set.
;Run Automatic Scan
:Runs a scan against the selected information source (scraper) on all video files contained in the selected folder after selecting 'OK'
;Use Foldername for Lookups
:Uses foldernames as basis for the search when scraping (instead of filenames). If folder contains IFO and VOB files, this is needed for any matching to take place.
;Folder contains a single Video
:The standard assumption is that the source contains multiple video files, this option dictates that the selected source or folder only contains one video.
;Folder contains a single TV Show
:The standard assumption is that the source contains multiple TV shows, this option dictates that the selected source or folder only contains one TV show.
;Scan Recursively
:Scans subfolders two levels down or more for video files. Note that TV Show scrapers always scan recursively.


  // rotate around x-axis. Because of the previous rotation around y you have to put the z axis in here
===Scraper settings===
  gfxRotate(rx*90,0,0,1);
Some scrapers like the IMDb scraper allow the user to change options related to that scraper, see more:<br>
* [[IMDb (Video Library)#IMDb scraper settings|IMDb scraper settings]]<br>
  // this is the first transformation. it rotates around the y axis
* [[TheTVDB.com (Video Library)#TheTVDB.com Scraper Settings|TheTVDB.com scraper settings]]
  gfxRotate(ry*90,0,1,0);


  // set some color here
===Switching Scrapers / Removing Folder Contents from Library===
  gfxColour(1, 1, 1, 1);
Setting the content back to '''<None>''' after previously having selected a scraper for a source, will prompt users if they want to remove the contents from the Library.<br>
  // render a cube textured with the previously definded texture, the albumart
This is recommended if you wish to switch scrapers (first set content to '''<None>''' and then choose the new scraper).<br>
  gfxCube(-0.25f, -0.25f, -0.25f, 0.25f, 0.25f, 0.25f);
Setting content to '''<None>''' also removes the contents of the selected folder from the Library altogether. This is useful if you want to remove the contents of an entire folder from the Library as [[Video_Library#Video_Context_Menu_in_Library_Mode|The Context Menu]] will only remove single items.
}
</python>


=== The transition ===
==Additional information==
This transition slides in the new preset.
On movie naming conventions, see the [[Movies (Video Library)#Troubleshooting movie lookups|movies documentation page]].
(Code: MrC)


The only difference between presets and transitions is that you have to specify when the transition is over by using the FINISHED variable.
On TV show naming conventions for TV shows scraper, see the [[TV Shows|TV Shows documentation page]].
<python>
// Slide.tra
// Author - MrC


int direction;
float position;


// here we initialize some variables
After adding new video files, if you find that the information is incorrect then you can simply remove that lookup information from the database by switching the view to "Title" and pressing the black-button on the controller.
void Init()
{
position = 0;
// the direction is randomly chosen
direction = Rand() * 4;
}


void Render()
Another valid way of making sure your scraper finds its way to correct information for your newly added media is by the use of [[Import_-_Export_Library#Video_nfo_Files|Nfo files]]. Nfo files can be used to [[Import_-_Export_Library#Movies|provide data for a movie]] or influence the search behavior of scrapers (e.g by pointing it to a [[Import_-_Export_Library#Video_nfo_files_containing_an_URL|predefined URL]]).
{
  // calculate the new position from the elapsed time
position += TIMEPASS*0.75;
// end the transition if the position is greater or equal to 1
  if (position >= 1.0f)
  FINISHED = true;


  // set the current preset as texture
If you would like to remove the entire video database (for example after a bad scan, or you have problems with the library, or for whatever reason), then you can simply use the [[Filemanager]] or [[HOW-TO:_FTP_into_your_Xbox | FTP]], and either rename the MyVideos*.db, in directory Q:\UserData\Database, to something else (i.e. MyVideos*.db.backup) or delete it. Then restart, and the movie & TV show information gathering can be redone.
  gfxSetTexture(TEXTURE_CURRPRESET);
  gfxSetAspect(0);
  // translate the rectangle (rendered below) to the magic position of 2.414.
  // If you translate some rectangle with size -1,1,1,-1 by 2.414 into screen
  // the result is exactly as big as the screen, so you will see no difference
  // between the previously rendered preset and the transition, that renders the
  // preset on a rectangle.
  gfxTranslate(0, 0, 2.414);
  gfxColour(1, 1, 1, 1);
  gfxTexRect(-1, 1, 1, -1);
 
  // set the next preset as texture
  gfxSetTexture(TEXTURE_NEXTPRESET);


  // choose direction
'''*TIP!:''' If you like to use lookup to catalog off-line DVD-Video library (or other movies stored on DVD/CD media) see
if (direction == 0)
*[[HOW-TO: Catalog and use lookups on your offline DVD/CD movie library (via fake files)]]
{
// Top to bottom
float i = -3 + position * 2;
// draws a rectangle initially out of screen and by time it slides down.
gfxTexRect(-1, i+2, 1, i);
}
// same as above but other direction
else if (direction == 1)
{
// Bottom to top
float i = 1 - (position * 2);
gfxTexRect(-1, i+2, 1, i);
}
else if (direction == 2)
{
// Left to right
float i = -3 + position * 2;
gfxTexRect(i, 1, i+2, -1);
}
else
{
// Right to left
float i = 1 - position * 2;
gfxTexRect(i, 1, i+2, -1);
}
}
</python>


[[Category:Development]]
[[category:How To|Scraper]]
[[category:Scraper]]
[[category:Usage]]
[[category:Library]]
[[category:Video Library]]

Revision as of 00:24, 29 October 2010

Cleanup.png This page or section may require cleanup, updating, spellchecking, reformatting and/or updated images. Please improve this page if you can. The discussion page may contain suggestions.


Template:XBMC wiki toc Inline

Scrapers are used by XBMC to retrieve data from a webpage which is used in the Video Library. To be able to utilize them you first have to "Set Content" to the source you plan to add information on.

Setting Contents

In the Files View of the 'Videos' section of XBMC, bring up the Context Menu. By selecting "Set Content" one can set the type of content for the chosen directory.

The Context menu can be brought up by either the 'C' key or the 'Windows' Application key on the Keyboard or by pressing right mouse button on the appropriate item. On the Mac version of XBMC, the context menu can be displayed by holding the Menu button on the Apple Remote or by pressing C on the keyboard.

Set content0.jpg

Different types of scrapers can be assigned to different directories, but be aware that 'TV Shows' scrapers must be assigned to a folder containing multiple TV shows ( or at least be one directory above the TV show folder itself) unless you select the Folder contains a single TV Show Option, e.g.

TV Shows
     |----TV Show 1
     |       |___ TV Show 1 Media files
     |
      ----TV Show 2
             |___ TV Show 2 Media files

In the above example you would assign the chosen TV Shows scraper to the TV Shows folder. Note that each TV show needs to be in its own folder for XBMC to be able to scan it into the library.

After choosing a content type (Movies, TV shows or Music Videos), one can decide on a scraper to use. There are currently several scrapers available of each type. For movies, the TheMovieDb.org[1] is the one recommended, as this is a free and open database of movies that anyone can contribute to. The other available scrapers are for example scrapers for different languages or for adult movies. File:Set content2.jpg

Set.content.movies.jpg

File:Set.content.tv.jpg


Options After Selecting Scraper

Exclude folder from scans
Excludes the selected folder from scans, even if it's a subfolder of a folder that has contents set.
Run Automatic Scan
Runs a scan against the selected information source (scraper) on all video files contained in the selected folder after selecting 'OK'
Use Foldername for Lookups
Uses foldernames as basis for the search when scraping (instead of filenames). If folder contains IFO and VOB files, this is needed for any matching to take place.
Folder contains a single Video
The standard assumption is that the source contains multiple video files, this option dictates that the selected source or folder only contains one video.
Folder contains a single TV Show
The standard assumption is that the source contains multiple TV shows, this option dictates that the selected source or folder only contains one TV show.
Scan Recursively
Scans subfolders two levels down or more for video files. Note that TV Show scrapers always scan recursively.

Scraper settings

Some scrapers like the IMDb scraper allow the user to change options related to that scraper, see more:

Switching Scrapers / Removing Folder Contents from Library

Setting the content back to <None> after previously having selected a scraper for a source, will prompt users if they want to remove the contents from the Library.
This is recommended if you wish to switch scrapers (first set content to <None> and then choose the new scraper).
Setting content to <None> also removes the contents of the selected folder from the Library altogether. This is useful if you want to remove the contents of an entire folder from the Library as The Context Menu will only remove single items.

Additional information

On movie naming conventions, see the movies documentation page.

On TV show naming conventions for TV shows scraper, see the TV Shows documentation page.


After adding new video files, if you find that the information is incorrect then you can simply remove that lookup information from the database by switching the view to "Title" and pressing the black-button on the controller.

Another valid way of making sure your scraper finds its way to correct information for your newly added media is by the use of Nfo files. Nfo files can be used to provide data for a movie or influence the search behavior of scrapers (e.g by pointing it to a predefined URL).

If you would like to remove the entire video database (for example after a bad scan, or you have problems with the library, or for whatever reason), then you can simply use the Filemanager or FTP, and either rename the MyVideos*.db, in directory Q:\UserData\Database, to something else (i.e. MyVideos*.db.backup) or delete it. Then restart, and the movie & TV show information gathering can be redone.

*TIP!: If you like to use lookup to catalog off-line DVD-Video library (or other movies stored on DVD/CD media) see