Archive:NAS and Archive:Vortex Visualization Development: Difference between pages

From Official Kodi Wiki
(Difference between pages)
Jump to navigation Jump to search
>Donno
(added Western Digital MyBookWorldEdI 500GB Gigabit NAS to compatible)
 
 
Line 1: Line 1:
In short [http://en.wikipedia.org/wiki/Network_Attached_Storage NAS ('''N'''etwork '''A'''ttached '''S'''torage)] is a a stand-alone device where you can install one or more harddisk-drives (either internally or externally), and then connect that device directly to your network. The NAS device is given its own IP-address and you configure it to share the harddrives and their data contents on the network to multiple client devices such as XBMC and your computer.
Vortex Visualization Development
This way you do not have to have your computer(s) powered on all the the time and the data will still always be available on your network and accessible from multiple devices. It is also possible to 'convert' a modest computer into a dedicated NAS device, in fact that is the cheapest way to get your own NAS, (the downside with using a whole computer as a NAS device is the size of the computer-case and possibly the electricity it consums).




== Coding your own presets and transitions for Vortex ==


==NAS (Network Attached Storage) and XBMC==
=== The filetypes ===
XBMC already supports [[SMB|SMB/SAMBA/CIFS]] (and [[UPnP]]) network-protocols which many NAS (Network Attached Storage) devices support. It is also possible to stream via FTP to XBMC but that is not recommended because the FTP network-protocol was never designed for streaming so that will not be covered here, nor officialy supported.
* '''*.vtx''' - preset file, the actual visualization
To stream from a NAS device to XBMC simply setup a [[SMB|SMB/SAMBA/CIFS]] (or [[UPnP]]) share on the NAS with a username and password, (once you have configured its network settings and connected it to your network), then add a [[bookmarks|bookmark]] for that share in XBMC.
* '''*.tra''' - transition file, changes from current preset to the next preset


=== The template ===
<python>//filename - TheTransitionOrPresetFilename.Extension
//author - your name
void Init()
{
  //TODO: put your initializationcode here
}


void Render()
{
  //TODO: put your stunning graphics here
}</python>


==The definition of NAS (Network Attached Storage)==
=== The coding ===
[http://en.wikipedia.org/wiki/Network_Attached_Storage NAS ('''N'''etwork '''A'''ttached '''S'''torage)] is the name given to dedicated data storage technology that can be connected directly to a computer-network to provide centralized data-access and storage to compatible network-clients. Normally this means a harddisk-drive storage device that is attached direcly to your LAN (Local Area Network), typically a ethernet-based network, and assigned an own IP-address, rather than being attached to a computer that is serving data-files to network users. Network-Attached Storage consists of harddisk storage, (that can include support for multi-disk RAID systems), and software for configuring and mapping file locations to the Network-Attached Device. NAS software can usually handle a number of network protocols, and share formats. Configuration, including the setting of user access priorities, is usually possible using a web browser.
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


==NAS (Network Attached Storage) compatible with XBMC==
Boolean operators
This is a list of NAS (Network Attached Storage) devices and software compatible with XBMC.<br>
* '''>''' - returns true if left is greater than right
'''Please feel free to add any NAS device or software that you yourself have tested and know if it works with XBMC or not!'''
* '''<''' - 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


===NAS devices that work with XBMC===
==== The built-in VORTEX-variables ====
*[http://h10025.www1.hp.com/ewfrf/wc/product?product=3193065&lc=en&cc=uk&dlc=en&lang=en&cc=uk] HP MediaVault mv2010/2020 has either an internal 300/500gb SATA drive, and a spare bay where you can insert a second SATA drive, and 3 USB ports for external drives or a Printer. Runs a Linux 2.4 Kernel, supports UPnP and Samba, and upto 1.2 TB of data across all drives. There is also an unofficial support site/community located [http://www.k0lee.com/hpmediavault/ here]
* '''TREBLE''' - returns the treble level (float, values between -1 and 1)
*[http://www.synology.com/enu/products/DS106serise/index.php] Synology DiskStation DS-106(e) supports one internal and one external SATA drive, and 1-2 USB storage devices. UPnP and Samba is supported, among other protocols. Gigabit Ethernet.
* '''MIDDLE''' - returns the middle level (float, values between -1 and 1)
*[http://www.synology.com/enu/products/DS101serise/index.php] Synology DiskStation DS-101j supports one internal and one external IDE drive, and 1-2 USB storage devices. UPnP and Samba is supported, among other protocols.
* '''BASS''' - returns the bass level (float, values between -1 and 1)
*[http://www.linksys.com/products/product.asp?prid=640&scid=43 LinkSys NSLU2 (Network Storage Link for USB 2.0 harddisk-drives)], which is Linux and SAMBA based.
* '''TIMEPASS''' - returns the time passed since the last Render()-Call (float, value in seconds)
**As the NSLU2 is Linux-based you can 'hack' it and install all sort of software on it, for more info see [http://en.wikipedia.org/wiki/NSLU2 wikipedia]
* '''FINISHED''' - set this to true if your tranisition has finished (boolean)
*[http://www.netgear.com/products/details/wgt634u.php NetGear WTG634U Wireless Router]
**Shares from a [http://www.netgear.com/products/wgt634u_comp.php USB Mass Storage Compatible Harddrive] connected to it via USB 2.0
*[http://www.revogear.com Kuro Box (by Buffalo Technology)] for one internal harddrive. Linux-based and supports open source software.
*[http://www.buffalotech.com/products/product-detail.php?productid=97&categoryid=19 Buffalo Technology TeraStation NAS 1.0 TB (HD-H1.0TGL/R5)] supports 4-drives, RAID-0/1/5 and GigaBit ethernet.
*[http://www.buffalotech.com/products/storage.php Buffalo Technology Linkstation HD-HG300LAN and HD-HG400LAN], 300GB and 400GB respective with GigaBit ethernet.
*[http://www.maxtorsolutions.com Maxtor Shared Storage™ Networking Drives]
**Maxtor Shared Storage Plus 200GB (H01R200)
**Maxtor Shared Storage Plus 300GB (H01R300)
**Maxtor Shared Storage Plus 500GB (H01R500)
**Maxtor Shared Storage II 300GB
**Maxtor Shared Storage II 500GB
**Maxtor Shared Storage II 1TB
*[http://www.snap-server.co.uk Quantum / Snap Appliance Snap Servers (Models 2000, 2040, 2200 and 4100)] (formely: [http://www.ateonix.com Ateonix Nasas]).
*ASUS WL-500g (Deluxe) Wireless-Router with USB 2.0 harddisks support, requires [http://www.macsat.com/wlguide third-party firmware].
*[http://www.thecus.com/products_over.php?cid=1&pid=1 Thecus N2100], 2-internal 3.5" SATA bays, RAID 0/1 and 3 USB-ports for external hardrives.
*Lacie Ethernet Disk Mini 250GB.
*SimpleTech SimpleShare NAS 400GB.
*[http://www.westerndigital.com Western Digital WD NetCenter™ Network Drives]
**WD NetCenter 160GB Ethernet Network Drive
**WD NetCenter 250GB Ethernet Network Drive
**WD NetCenter 320GB Ethernet Network Drive
**WD NetCenter 500GB Ethernet Network Drive
*[http://www.wdc.com/en/products/products.asp?driveid=278&language=en Western Digital MyBookWorldEdI 500GB Gigabit NAS]
*[http://www.infrant.com Infrant ReadyNAS NV] supports up to 4 SATA drives in RAID 0-,1,5 and their own X-RAID protocol. OCE is possible under X-RAID. UPnP and Samba is supported, among other protocols.
*Vantec NexStar LX NAS (Works with latest Firmware Basic46 and XBMC 2.0.1 - tested on January 8, 2007).
*[http://www.dlink.com/products/?pid=509 D-Link DNS-323], 2-internal 3,5" SATA bays, RAID 0/1 Standalone and JBOD. CIFS/SMB and allows FXP between XBMC and NAS.
*[http://http://www.fantomdrives.com/products/harddrives/fdnd.php4 Fantom Drives Network Disk Drive FDND250] does work with the latest T3CH XMBC (Revision 7841/MC360). You will have to edit the SOURCES.XML file or add a bookmark. Under the FILES tag in Sources.xml, under SMB Network Shares (Not Workgroup SMB), add this: <path>smb://absolute IP address/</path>, without a password set.  Also, create a new folder in root instead of under public. if you want to manually 'Add Source' to My Videos or My Music, select Add Network Location, and enter the absolute IP address (ex: 192.168.1.xxx) and the remote share should reveal itself. Also, rename the device without any dashes or other non-alpha characters (ex:change "storage10b-3" to "storage1015")


===NAS software that works with XBMC===
==== The built-in VORTEX-constants ====
*[http://www.freenas.org FreeNAS] ([http://sourceforge.net/projects/freenas/ sourceforge.net project-page]), a free open source FreeBSD-based operating-system that turns any x86 computer into a SAMBA NAS device, (plus firewall and FTP-server). (Tested July 2006)
===== Blendmodes =====
*[http://www.openfiler.com Openfiler] ([http://sourceforge.net/projects/openfiler/ sourceforge.net project-page]), a free open source Linux-based operating-system that turns any x86 computer into a SAMBA NAS device.  
* '''const int BLEND_OFF = 0;''' - disables Blending
*[http://www.clarkconnect.com ClarkConnect Community Edition 4.0], a free Linux-based operating-system that turns any x86 computer into a SAMBA NAS device, (plus firewall and FTP-server). (Tested September 2006)
* '''const int BLEND_ADD = 1;''' - adds color values
*[http://www.serverelements.com/naslite.php NASLite], a non-free commercial closed source alternative to the above mentioned FreeNAS, boots from a single floppy diskette.
* '''const int BLEND_MOD = 2;''' - modulated blend
*[http://www.serverelements.com/naslite-plus.php NASLite+], the big brother of NASLite, it has more features but is a little more expensive and must boot of a CD or a USB-stick.
* '''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


===NAS devices and software that doesn't work with XBMC===
==== The built-in VORTEX-functions ====
*[http://en.wikipedia.org/wiki/LanDrive LanDrive] (also sold as "'''LanDisk'''" and "'''LanServer'''") 3.5" harddrive enclosure with USB 2.0 port and 10/100Mb RJ-45 network-port. LanDrive, LanDrive and LanServer (as [http://en.wikipedia.org/wiki/Original_equipment_manufacturer OEM] hardware) is available under many brand names like Bytecc, Bona, Conceptronic, CoolMax, Datastorage, Ducki, FAN-TEC, Hotway, Hotec, LinITX, MacPower, MaPower, Mediasonic, Midte, NEM, NHouse, Usbex, Teac and V-Gear/VGear. (File-system permissons on the LanDrive/LanDrive/LanServer are not working 100% with XBMC, and results differ between firmware versions, but all brands and models have the same problem). If you want to test your LanDrive with XBMC then suggest you try firmware version "NAS-BASIC41" which seems to be the most stable at this time.
* '''GetSpec(int a)''' - returns the spectrum value at the given position
*[http://www.byteccusa.com/product/enclosure/ME-850.htm Bytecc ME-850] Bytecc ME-850 (firmware version .24 works partially), pretty sure this is a [http://en.wikipedia.org/wiki/LanDrive LanDrive] as above sold under a different brand?
 
*[http://www.coolmaxusa.com/productdetailsnetwork.asp?item=cn-550 CoolMax NAS Model CN-550], supports SMB but doesn't seem to work with XBMC (tested November 2005), another [http://en.wikipedia.org/wiki/LanDrive LanDrive]?
==== The built-in VORTEX-functions for graphics ====
*[http://www.macpower.com.tw/products/hdd3/pleiades/pd_usblan Macpower Pleiades USB/LAN],  supports SMB but doesn't seem to work with XBMC (tested November 2005), another [http://en.wikipedia.org/wiki/LanDrive LanDrive]?
* '''gfxSetTexture(Texture texture)''' - specifies the texture to be used for the next drawing calls
*Argosy HD363N, supports SMB but doesn't seem to work with XBMC (tested March 2005)
* '''gfxSetRenderTarget(Texture texture)''' - specifies the texture as a rendertarget (output not to screen but to the texture)
*Tritton Simple NAS NSS001, supports SMB but doesn't seem to work with XBMC (tested September 2005)
** '''gfxSetRenderTarget(Map map)''' - specifies the map as a rendertarget (output not to screen but to the map)
*NetGear Storage Central SC101, does not support CIFS/SMB/SAMBA (only added to this list because so many people asked!)
** '''gfxSetRenderTarget(0)''' - specifies the screen as rendertarget (default)
*CompUSA external NAS enclosure
* '''gfxSetEnvTexture(Texture texture)''' - specifies the Texture as environment texture
*Fantom Drives Network Disk Drive FDND250 supports SMB but doesn't seem to work with XBMC (tested February 2007). Works okay via USB. Firmware Version: NAS-BASIC43, LOADER 067 Checked their website and no firmware updates are available.
* '''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))
<br><br><br>
* '''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()
{
  // time stores the the elapsed time since the preset started
  time += TIMEPASS;                                   
 
  // set the coverart of the current song as texture
  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
  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
  gfxRotate(-70+(Sin(time)*12),1,0,0);
 
  // rotate around x-axis. Because of the previous rotation around y you have to put the z axis in here
  gfxRotate(rx*90,0,0,1);
  // this is the first transformation. it rotates around the y axis
  gfxRotate(ry*90,0,1,0);
 
  // set some color here
  gfxColour(1, 1, 1, 1);
  // render a cube textured with the previously definded texture, the albumart
  gfxCube(-0.25f, -0.25f, -0.25f, 0.25f, 0.25f, 0.25f);
}
</python>
 
=== The transition ===
This transition slides in the new preset.
(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.
<python>
// Slide.tra
// Author - MrC
 
int direction;
float position;


==Converting a computer into a dedicated NAS==
// here we initialize some variables
This is a guide on how to make an 'old' computer into a cheap dedicated NAS box by using a free (and simple to use) operating-system/software like [http://www.freenas.org FreeNAS], [http://www.openfiler.com Openfiler] or [http://www.clarkconnect.com ClarkConnect Community Edition]. This guide will hopefully get a little more step-by-step oriented over time as people who test and play with these softwares adds information from their experince, but for now a short description will have to do. So for now please refer to the the respective website of the mentioned operating-system/software for more information, documentation (user-manuals), and FAQs.
void Init()
{
position = 0;
// the direction is randomly chosen
direction = Rand() * 4;
}


===Required hardware===
void Render()
*The computer itself:
{
**As people and most of all companies upgrade their to new computers they often give away or sell they old computers which usually is 4 to 6 years old hardware, most common are branded desktop or midi-tower work computers like COMPAQ, DELL, GateWay, HP, and IBM. These 'old' computer are no longer good for gaming or even office tools as they are persived as too slow performing, this however means that you can get hold of them cheap or sometimes even for free. Know though that the older the computer is, the more likely you are required to spend some extra money on it to get the performance you want/need.
  // calculate the new position from the elapsed time
**The hardware needed is [http://en.wikipedia.org/wiki/X86 Intel or AMD x86 (IBM-compatible) computer], at least 200Mhz processor and 96MB of RAM (however 500Mhz+ processor and 256MB+ RAM is recommended to be able to disable the swap/page-file), and a network-controller/adapter, (FreeNAS even supports GigaBit NIC's which is great if your other computers supports GigaBit too).
position += TIMEPASS*0.75;
**The optimal installation location of the operating-system can be debated. While some of these 'NAS operating-systems' upload everything into the RAM-memory (if you have enough RAM-memory), some of them do require to access and read/write to the location where it is installed. This means that if the installation location is the same harddrives that you share, they will not be able to spin-down as often an the computer will thus also generate more noise and heat. A great solution to this problem is to make the installation location onto a solid state memory (meaning a memory that have no moving parts), like a Compact Flash card (if you get a Compact Flash to IDE/ATA converter), or a USB-stick/key flash-memory (if your computers supports booting to USB). By getting a computer which BIOS supports booting from USB you will free up a ATA/SATA-slot and are able to connect another harddrive to the system.
*Storage (the harddisk drives):
// end the transition if the position is greater or equal to 1
**The harddrives to be shared as storage can be connected via IDE/ATA, SATA, SCSI, USB or Firewire. Most of these NAS softwares also supports hardware RAID cards and software RAID 0, 1 and 5. Best is though if you get a computer with two or more IDE/ATA channels as then you can use at least four IDE/ATA harddrives which gives good value with the most GigaBytes for your buck. SATA harddrives are as cheap as IDE/ATA (and faster), however you must then purchase a SATA PCI-adapter as none of these 'old' computers comes with SATA ports on the motherboard, but one the other hand if you plan on upgrading your NAS-compuer in a year or two then those SATA harddrives (with a SATA PCI-adapter) is the smarter choise.
  if (position >= 1.0f)
**Another nice feature is harddrive spin-down when idle (after ex. 30-minutes) which saves the life-time of the shared harddrives. All IDE/ATA harddrives connected to the internal IDE/ATA controller on the motherboard or on an internal a PCI-adapter support spin-down. Many external USB enclosures and internal IDE/ATA/SATA to USB-adapters on the other hand do not support spin down, remember that if you plan on connecting your drives via USB.<br>
  FINISHED = true;


===FreeNAS===
  // set the current preset as texture
FreeNAS is a complete operating-system and NAS software package which is free and open source, (so you do not not need any other operating-system on the target computer) and it features a nice web-interface for all configuration, (so no keyboard/video/mouse is needed after the initial installation). The FreeNAS boot-image itself takes up less than 32MB memory and can be booted from a harddrive, a USB-stick, or a Compact Flash card (if you have a Compact Flash to IDE/ATA converter).<br>
  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);


===Openfiler===
  // choose direction
If you have tested this NAS operating-system/software then please contribute some information and your experince here.<br>
if (direction == 0)
good OS because its linux...but the only problem i had with it is that you cant have local user to authenticate ftp.....users have to come from ldap or windows domain controller....and i not fluent enough with linux to make that change via the command line....freenas has no users that you can create either......so remote access is not looking so good unless you just want anonymous aceess
{
or you have to use a ftp server on a seperate computer and share your nas that way so you can have users and passwords
// 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>


===ClarkConnect Community Edition===
[[Category:Development]]
If you have tested this NAS operating-system/software then please contribute some information and your experince here.<br>
[[category:File Sharing]]

Revision as of 04:55, 28 June 2013

Vortex Visualization Development


Coding your own presets and transitions for Vortex

The filetypes

  • *.vtx - preset file, the actual visualization
  • *.tra - transition file, changes from current preset to the next preset

The template

<python>//filename - TheTransitionOrPresetFilename.Extension //author - your name void Init() {

 //TODO: put your initializationcode here

}

void Render() {

 //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 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(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(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() {

 // time stores the the elapsed time since the preset started
 time += TIMEPASS;                                     
 // set the coverart of the current song as texture
 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
 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
 gfxRotate(-70+(Sin(time)*12),1,0,0);
 // rotate around x-axis. Because of the previous rotation around y you have to put the z axis in here
 gfxRotate(rx*90,0,0,1);
 // this is the first transformation. it rotates around the y axis
 gfxRotate(ry*90,0,1,0);
 // set some color here
 gfxColour(1, 1, 1, 1);
 // render a cube textured with the previously definded texture, the albumart
 gfxCube(-0.25f, -0.25f, -0.25f, 0.25f, 0.25f, 0.25f);

} </python>

The transition

This transition slides in the new preset. (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. <python> // Slide.tra // Author - MrC

int direction; float position;

// here we initialize some variables void Init() { position = 0;

// the direction is randomly chosen direction = Rand() * 4; }

void Render() {

 // 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
 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

if (direction == 0) { // 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>