SlideShare ist ein Scribd-Unternehmen logo
1 von 22
Flex:  Realidade Aumentada e Arduíno Como ligar a Realidade Aumentada ao código adobe Flex® All sections to appear here
Resumo Da Realidade Aumentada à Realidade
Flex: Realidade Aumentada e Arduíno Adobe @ theMuseum
Ligação Flex ao Arduíno
Downloads Download Software Arduíno Download AS3 Glue Download Serial Proxy
http://www.arduino.cc http://code.google.com/p/arduino/downloads/list
http://www.cote.cc/blog/serialproxy-v014-can-use-com-ports-above-9
http://code.google.com/p/as3glue/downloads/list
Instalação/Configuração Instalação Arduino Configuração SerialProxy Configuração Flex
Configuração SerialProxy newlines_to_nils=false # Comm ports used comm_ports=10,2,3,4 # Default settings comm_baud=57600 comm_databits=8 comm_stopbits=1 comm_parity=none # Idle time out in seconds timeout=300 # Port 10 settings (ttyS0) net_port10=5331 # Port 2 settings (ttyS1) net_port2=5332 # Port 3 settings (ttyS2) net_port3=5333 # Port 4 settings (ttyS3) net_port4=5334
Copie a pasta Arduíno para o seu computador Ligue o Arduíno ao seu computador Windows Vista Windows 7
Windows 7
Windows 7 (cont.)
Windows 7 (cont.)
Windows 7 (drivers)
Flex Builder ®
Flex Builder® pptPlex Section Divider The slides after this divider will be grouped into a section and given the label you type above.  Feel free to move this slide to any position in the deck.
AS3 Glue
Código AS3 apoiado pela Livraria Glue
Ligações do Arduíno +     a -   c
No Flex Builder®
packageexamples { //  importação das bibliotecas do FLARManager cujo autor é EricSocolofsky http://transmote.com/flar importcom.transmote.flar.FLARManager; importcom.transmote.flar.marker.FLARMarker; importcom.transmote.flar.marker.FLARMarkerEvent; importcom.transmote.flar.utils.geom.FLARPVGeomUtils; importcom.transmote.utils.time.FramerateDisplay; //importação das bibliotecas de Flash importflash.display.Bitmap; importflash.display.Sprite; importflash.events.Event; importflash.events.MouseEvent; importflash.events.TimerEvent; importflash.filters.DropShadowFilter; importflash.media.Sound; importflash.media.SoundChannel; importflash.net.URLRequest; importflash.utils.Timer; //  Importação das bibliotecas do Arduino AS3 Glue importnet.eriksjodin.arduino.Arduino; importnet.eriksjodin.arduino.events.ArduinoEvent; //Importação da Biblioteca de particulas que permite fazer nevar criada por SebLee-Delisle import net.pluginmedia.pv3d.SnowStorm; //Importação das bibliotecas que permitem a visualização modelo PMD 3D import org.b2ox.pv3d.MikuMikuDance; import org.b2ox.pv3d.MikuMikuDance.VMDController; //Importação das biblioteca libspark import org.libspark.flartoolkit.support.pv3d.FLARCamera3D; //Importação da biblioteca papervision 3D import org.papervision3d.cameras.*; import org.papervision3d.lights.PointLight3D; import org.papervision3d.materials.*; import org.papervision3d.materials.shadematerials.PhongMaterial; import org.papervision3d.materials.utils.MaterialsList; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.parsers.DAE; import org.papervision3d.objects.primitives.*; import org.papervision3d.render.LazyRenderEngine; import org.papervision3d.scenes.Scene3D; import org.papervision3d.view.Viewport3D; //  A classStartAdobeAndArduino irá estender a classe sprite public class StartAdobeAndArduino extends Sprite { //  criação das variáveis que iremos precisar privatevarfm:FLARManager; privatevar scene:Scene3D; privatevar view:Viewport3D; privatevar camera:FLARCamera3D; privatevarlre:LazyRenderEngine; //Declaramos as variáveis que vão conter os Planos privatevarplano:Plane; //Declaramos as variáveis que vão conter os contentores privatevar contentor:DisplayObject3D; //Declaramos a variável das sombras nos objectos        privatevardropShadowFilter:DropShadowFilter; //Declaramos a variável da neve privatevarneve:SnowStorm; // Declaramos as variáveis que vão conter os marcadores privatevar marker0:FLARMarker; privatevar marker1:FLARMarker; // variáveis para os videos privatevar v1:Vid; //Variáveis para modelo dae privatevar pointLight3D:PointLight3D; privatevarphong:PhongMaterial; privatevar modelContainer:DisplayObject3D; privatevarmodel:DAE; privatevardaeFile:String; //Variáveis de som privatevarmyURL:URLRequest = newURLRequest("../resources/assets/Adriana.mp3"); private varmySong: Sound         = new Sound(myURL); //      variáveis para os modelos mikumikudancee publicvarpmd:MikuMikuDance; privatevarcontrol:VMDController; //      Variáveis para o arduino protectedvarcircuit:Arduino; //Variáveis para controlar a musica protectedvarchannel:SoundChannel; protectedvarsongTimer:Timer; protectedvarmyDelay:Timer = newTimer(1000); protectedvarPosition:Number = 0; protectedvartocar:Boolean = false; protectedvarligado:Boolean = false; //      Declaramos a moldura que vai cobrir o écran [Embed(source = '../resources/assets/logo.png')] publicvarlogoCls:Class; //Função principal publicfunctionStartAdobeAndArduino() { //Criamos as variáveis que vão receber os videos damos o caminho para os videos e paramos os videos //se não os mesmos começavam a tocar mesmo sem os marcadores serem detectados. v1 = newVid(); v1.vid.source = "../resources/assets/t-rex.flv"; v1.vid.stop(); //Chamamos a função que Carrega os modelos PMD 3D bem com depois inicia a função iniFLAR() que //inicia o FLARManager que é a biblioteca que permite a utilização de multiplos marcadores loadingData(); // inicia o arduino no local host e porta 5331 circuit = newArduino("127.0.0.1", 5331); circuit.requestFirmwareVersion(); circuit.addEventListener(ArduinoEvent.FIRMWARE_VERSION, iniciaarduino); // chama esta função para iniciar o código Firmata } privatefunctioniniciaarduino(e:ArduinoEvent):void { circuit.enableDigitalPinReporting();  // activa o relatório dos pinos digitais do arduino circuit.setPinMode(6,Arduino.OUTPUT);  // diz ao arduino que este pino é usado como saida circuit.setPinMode(2,Arduino.OUTPUT); circuit.setPinMode(3,Arduino.OUTPUT); circuit.setPinMode(4,Arduino.OUTPUT); circuit.setPinMode(5,Arduino.OUTPUT); circuit.writeDigitalPin(2,Arduino.HIGH);  // Manda o arduino activar este pino com 5 volts

Weitere ähnliche Inhalte

Empfohlen

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Empfohlen (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Adobeatmuseum

  • 1. Flex: Realidade Aumentada e Arduíno Como ligar a Realidade Aumentada ao código adobe Flex® All sections to appear here
  • 2. Resumo Da Realidade Aumentada à Realidade
  • 3. Flex: Realidade Aumentada e Arduíno Adobe @ theMuseum
  • 4. Ligação Flex ao Arduíno
  • 5. Downloads Download Software Arduíno Download AS3 Glue Download Serial Proxy
  • 9. Instalação/Configuração Instalação Arduino Configuração SerialProxy Configuração Flex
  • 10. Configuração SerialProxy newlines_to_nils=false # Comm ports used comm_ports=10,2,3,4 # Default settings comm_baud=57600 comm_databits=8 comm_stopbits=1 comm_parity=none # Idle time out in seconds timeout=300 # Port 10 settings (ttyS0) net_port10=5331 # Port 2 settings (ttyS1) net_port2=5332 # Port 3 settings (ttyS2) net_port3=5333 # Port 4 settings (ttyS3) net_port4=5334
  • 11. Copie a pasta Arduíno para o seu computador Ligue o Arduíno ao seu computador Windows Vista Windows 7
  • 17. Flex Builder® pptPlex Section Divider The slides after this divider will be grouped into a section and given the label you type above. Feel free to move this slide to any position in the deck.
  • 19. Código AS3 apoiado pela Livraria Glue
  • 22. packageexamples { // importação das bibliotecas do FLARManager cujo autor é EricSocolofsky http://transmote.com/flar importcom.transmote.flar.FLARManager; importcom.transmote.flar.marker.FLARMarker; importcom.transmote.flar.marker.FLARMarkerEvent; importcom.transmote.flar.utils.geom.FLARPVGeomUtils; importcom.transmote.utils.time.FramerateDisplay; //importação das bibliotecas de Flash importflash.display.Bitmap; importflash.display.Sprite; importflash.events.Event; importflash.events.MouseEvent; importflash.events.TimerEvent; importflash.filters.DropShadowFilter; importflash.media.Sound; importflash.media.SoundChannel; importflash.net.URLRequest; importflash.utils.Timer; // Importação das bibliotecas do Arduino AS3 Glue importnet.eriksjodin.arduino.Arduino; importnet.eriksjodin.arduino.events.ArduinoEvent; //Importação da Biblioteca de particulas que permite fazer nevar criada por SebLee-Delisle import net.pluginmedia.pv3d.SnowStorm; //Importação das bibliotecas que permitem a visualização modelo PMD 3D import org.b2ox.pv3d.MikuMikuDance; import org.b2ox.pv3d.MikuMikuDance.VMDController; //Importação das biblioteca libspark import org.libspark.flartoolkit.support.pv3d.FLARCamera3D; //Importação da biblioteca papervision 3D import org.papervision3d.cameras.*; import org.papervision3d.lights.PointLight3D; import org.papervision3d.materials.*; import org.papervision3d.materials.shadematerials.PhongMaterial; import org.papervision3d.materials.utils.MaterialsList; import org.papervision3d.objects.DisplayObject3D; import org.papervision3d.objects.parsers.DAE; import org.papervision3d.objects.primitives.*; import org.papervision3d.render.LazyRenderEngine; import org.papervision3d.scenes.Scene3D; import org.papervision3d.view.Viewport3D; // A classStartAdobeAndArduino irá estender a classe sprite public class StartAdobeAndArduino extends Sprite { // criação das variáveis que iremos precisar privatevarfm:FLARManager; privatevar scene:Scene3D; privatevar view:Viewport3D; privatevar camera:FLARCamera3D; privatevarlre:LazyRenderEngine; //Declaramos as variáveis que vão conter os Planos privatevarplano:Plane; //Declaramos as variáveis que vão conter os contentores privatevar contentor:DisplayObject3D; //Declaramos a variável das sombras nos objectos privatevardropShadowFilter:DropShadowFilter; //Declaramos a variável da neve privatevarneve:SnowStorm; // Declaramos as variáveis que vão conter os marcadores privatevar marker0:FLARMarker; privatevar marker1:FLARMarker; // variáveis para os videos privatevar v1:Vid; //Variáveis para modelo dae privatevar pointLight3D:PointLight3D; privatevarphong:PhongMaterial; privatevar modelContainer:DisplayObject3D; privatevarmodel:DAE; privatevardaeFile:String; //Variáveis de som privatevarmyURL:URLRequest = newURLRequest("../resources/assets/Adriana.mp3"); private varmySong: Sound = new Sound(myURL); // variáveis para os modelos mikumikudancee publicvarpmd:MikuMikuDance; privatevarcontrol:VMDController; // Variáveis para o arduino protectedvarcircuit:Arduino; //Variáveis para controlar a musica protectedvarchannel:SoundChannel; protectedvarsongTimer:Timer; protectedvarmyDelay:Timer = newTimer(1000); protectedvarPosition:Number = 0; protectedvartocar:Boolean = false; protectedvarligado:Boolean = false; // Declaramos a moldura que vai cobrir o écran [Embed(source = '../resources/assets/logo.png')] publicvarlogoCls:Class; //Função principal publicfunctionStartAdobeAndArduino() { //Criamos as variáveis que vão receber os videos damos o caminho para os videos e paramos os videos //se não os mesmos começavam a tocar mesmo sem os marcadores serem detectados. v1 = newVid(); v1.vid.source = "../resources/assets/t-rex.flv"; v1.vid.stop(); //Chamamos a função que Carrega os modelos PMD 3D bem com depois inicia a função iniFLAR() que //inicia o FLARManager que é a biblioteca que permite a utilização de multiplos marcadores loadingData(); // inicia o arduino no local host e porta 5331 circuit = newArduino("127.0.0.1", 5331); circuit.requestFirmwareVersion(); circuit.addEventListener(ArduinoEvent.FIRMWARE_VERSION, iniciaarduino); // chama esta função para iniciar o código Firmata } privatefunctioniniciaarduino(e:ArduinoEvent):void { circuit.enableDigitalPinReporting(); // activa o relatório dos pinos digitais do arduino circuit.setPinMode(6,Arduino.OUTPUT); // diz ao arduino que este pino é usado como saida circuit.setPinMode(2,Arduino.OUTPUT); circuit.setPinMode(3,Arduino.OUTPUT); circuit.setPinMode(4,Arduino.OUTPUT); circuit.setPinMode(5,Arduino.OUTPUT); circuit.writeDigitalPin(2,Arduino.HIGH); // Manda o arduino activar este pino com 5 volts
  • 23. privatefunctionPiscaLEDs(event:TimerEvent):void{ if(marker0 == null) { if (ligado==true){ circuit.writeDigitalPin(2,Arduino.LOW); circuit.writeDigitalPin(3,Arduino.LOW); circuit.writeDigitalPin(4,Arduino.LOW); circuit.writeDigitalPin(5,Arduino.LOW); ligado=false; }else { ligado=true; circuit.writeDigitalPin(2,Arduino.HIGH); circuit.writeDigitalPin(3,Arduino.HIGH); circuit.writeDigitalPin(4,Arduino.HIGH); circuit.writeDigitalPin(5,Arduino.HIGH); } }elseif (ligado==true){ circuit.writeDigitalPin(6,Arduino.LOW); ligado=false; }else { ligado=true; circuit.writeDigitalPin(6,Arduino.HIGH); } } // Função que carrega o Modelo PMD 3D privatefunctionloadingData():void { pmd = newMikuMikuDance(); pmd.loadPMD("../Data/nanoha1052.zip://nanoha1052.pmd", 15, afterLoading); // carrega o Modelo 3D e chama a função afterLoading } //Carrega os Movimentos do modelo PMD 3D e depois chama a função iniFLAR privatefunctionafterLoading():void { pmd.loadVMD("../Data/motions.zip://popipo.vmd", "popipo"); pmd.loadVMD("../Data/motions.zip://WiM-DIVA.vmd", "test", function ():void { pmd.rotationX = 180; pmd.rotationZ = 90; pmd.scale = 1; pmd.looping = true; pmd.y=-50; pmd.play(); iniFLAR(); // chamamos a função que inicia biblioteca FLARManager } ); } //Função que inicia a biblioteca FLARManager que controla os marcadores privatefunctioniniFLAR():void { // Passamos o caminho onde está o ficheiro de configuração (xml) do FLARManager para o construtor do FLARManager // O FLARManager cria e usa uma FLARCameraSource por defeito. // A imagem da primeira camara detectada será usada na detecção dos Marcadores. circuit.writeDigitalPin(3,Arduino.HIGH); circuit.writeDigitalPin(4,Arduino.HIGH); circuit.writeDigitalPin(5,Arduino.HIGH); } protected function ActualizaLEDS(led1:Boolean, led2:Boolean, led3:Boolean, led4:Boolean):void { circuit.writeDigitalPin(2,int(led1)); //escreve HIGH ou LOW conforme valor da variável led1 circuit.writeDigitalPin(3,int(led2)); circuit.writeDigitalPin(4,int(led3)); circuit.writeDigitalPin(5,int(led4)); } protectedfunctionplaySong():void { if (tocar==false){ channel = mySong.play(Position); // continua a tocar apartir do ponto onde ficou songTimer = newTimer(25); // faz o update dos LEDS a cada 25ms. songTimer.addEventListener(TimerEvent.TIMER, ActualizaSom); // chama a função que vai ver intensidade do som songTimer.start(); Position = channel.position; tocar=true; } } privatefunctionstopSong():void { Position = channel.position;// guarda posição da música antes de a parar channel.stop(); // para a música tocar=false;// actualiza a variável tocar songTimer.stop(); // para o relógio da música songTimer.removeEventListener(TimerEvent.TIMER, ActualizaSom); // chama a função que vai ver intensidade do som circuit.writeDigitalPin(2,Arduino.LOW); // desliga os pinos do Arduino circuit.writeDigitalPin(3,Arduino.LOW); circuit.writeDigitalPin(4,Arduino.LOW); circuit.writeDigitalPin(5,Arduino.LOW); } protectedfunctionActualizaSom(e:TimerEvent):void { // inicializa as variaveis para falso, de modo aos LED ficarem desligados var led1:Boolean, led2:Boolean, led3:Boolean, led4:Boolean = false; varavgVol:Number = ((channel.leftPeak + channel.rightPeak) / 2); // acha a media entre canal esquerdo e direito. if (avgVol > .1) { led1 = true; } if (avgVol > .25) { led2 = true; } if (avgVol > .5) { led3 = true; } if (avgVol > .75) { led4 = true; } ActualizaLEDS(led1,led2,led3,led4); } //Função que faz piscar o LED ligado á porta 6 caso o marcador 0 esteja activo //ou pisca os leds 2,3,4,5 se o marcador 0 não estiver activo
  • 24. fm = newFLARManager("../resources/flar/flarConfig.xml"); // Esperamos que o FLARManager inicialize antes de iniciar os motores 3D. fm.addEventListener(Event.INIT, init3D); // iniciamos a procura de eventos relacionados com marcadores (FLARMarkerEvents). fm.addEventListener(FLARMarkerEvent.MARKER_ADDED, onAdded); fm.addEventListener(FLARMarkerEvent.MARKER_REMOVED, onRemoved); fm.addEventListener(FLARMarkerEvent.MARKER_UPDATED, onUpdated); // adicionamos FLARManager.flarSource á lista que vai ser apresentada por forma // a apresentar o video. addChild(Sprite(fm.flarSource)); // adicionamos a moldura ao ecrán varlogo:Bitmap = newlogoCls(); addChild(logo); myDelay.addEventListener(TimerEvent.TIMER, PiscaLEDs); } // Função quando um marcador é encontrado adicionado privatefunctiononAdded(e:FLARMarkerEvent):void { // se o marcador for igual ao padrão definido em flarConfig.xml // então iniciar o video ou animação correspondente if( e.marker.patternId==0){ marker0 = e.marker; pmd.changeMotion("popipo"); pmd.visible = true; contentor.visible = true; pmd.play(); neve.visible=true; playSong(); } if( e.marker.patternId==1){ myDelay.start(); marker1 = e.marker; model.visible=true; modelContainer.visible=true; v1.vid.play(); } } // Função quando um marcador é removido ou perdido privatefunctiononRemoved(e:FLARMarkerEvent):void { // se o marcador for igual ao padrão definido em flarConfig.xml // então parar o video ou animação correspondente if( e.marker.patternId==0){ marker0 = null; pmd.visible = false; neve.visible=false; stopSong(); } if( e.marker.patternId==1){ marker1 = null; neve.visible=false; model.visible=false; modelContainer.visible=false; myDelay.stop(); circuit.writeDigitalPin(6,Arduino.LOW); v1.vid.stop(); } } // Função quando um marcador é actualizado não usada privatefunctiononUpdated(e:FLARMarkerEvent):void { trace("Update!"); } //Função que inicia a neve privatefunctioninitSnow():void { //Define a quantidade de neve, o tamanho dos flocos de neve, e o tamanho do cubo onde os flocos vão cair neve=newSnowStorm(100, .4,2000); scene.addChild(neve); neve.y=1000; neve.visible=false; } // Função que espera que o FLARManager seja iniciado antes de começar os motores 3D (librarias) privatefunction init3D(e:Event):void { //uma vez que o FLARManager já foi iniciado retiramos a espera por esse evento fm.removeEventListener(Event.INIT, init3D); //Criamos a cena 3D isto é o mundo que desejamos ver scene = new Scene3D(); // A Camera utilizada aqui é a mesma que você já conhece do cinema, ela grava o que acontece no mundo // e projeta na tela (ViewPort). camera = new FLARCamera3D(fm.cameraParams); camera.z = -200; // O Viewport3D, fazendo uma analogia à tela de cinema é onde é projetado o filme para que seja possível assistí-lo. // Portanto, é uma região retangular onde é projetado a Cena 3D. view = new Viewport3D(stage.stageWidth, stage.stageHeight, true,true,false, false); //adicionamos ao motor 3D a cena a camara e o viewport que é a tela lre = new LazyRenderEngine(scene, camera, view); //Cria uma variável que adiciona sombra para o modelo collada //dropShadowFilter = newDropShadowFilter(distance, angle, color, alpha, x blur, y blur, strength, quality, innershadowboolean, knockoutboolean, hideobjectboolean); dropShadowFilter = newDropShadowFilter(10, 0, 0x000000, .5, 5, 5, 1, 1,true); //view.filters = [filter1 to apply, filter2 to apply]; view.filters = [dropShadowFilter]; // Cria o ponto de Luz o coloca o mesmo no espaço 3D pointLight3D = new PointLight3D(true); pointLight3D.x = 1000; pointLight3D.y = 1000; pointLight3D.z = -1000; //Chama a função que inicia a neve initSnow(); // Carrega o modelo Collada (Dae). // (Os modelos Collada devem ser dimensionados e rodados de modo a ficarem escalados com o marcador; // atenção cada modelo é diferente model = new DAE(true, "model", true); model.load("../resources/assets/t-rex.dae");// terra model.rotationX = 180; model.rotationZ = 90; model.scale = 0.70; model.x= 0; model.y= 0; model.z= 0; modelContainer = new DisplayObject3D(); //adiciona o modelo ao contentor modelContainer.addChild(model); modelContainer.visible = false; // adicionamos o modemo VMD ao contentor contentor = new DisplayObject3D(); contentor.addChild(pmd); pmd.visible = false; contentor.visible = false; //Adicionamos os contentores á cena scene.addChild(modelContainer); scene.addChild(contentor); //Adicionamos a luza á cena scene.addChild(pointLight3D) //Adicionamos tudo ao Viewport para vermos na cena addChild(view); // mostra o framerate para vermos a preformance pode ser retirado addChild(newFramerateDisplay()); //Por fim chamamos um evento de entrada em cada frame e a função loop que é onde aplicamos as matrizes de transformação //e efectuamos o rendering da cena completa. addEventListener(Event.ENTER_FRAME, loop); } // inicializamos a função que se repete para sempre privatefunctionloop(e:Event):void { neve.update(); if(marker0 != null) { contentor.transform = FLARPVGeomUtils.convertFLARMatrixToPVMatrix(marker0.transformMatrix);//aplica a matriz de transformação } if(marker1 != null) { modelContainer.transform = FLARPVGeomUtils.convertFLARMatrixToPVMatrix(marker1.transformMatrix); } // Chamamos o motor de renderização lre.render(); } } }
  • 25.
  • 26. Sites úteis Serproxy Serialproxy 0.1.4 ( renomeado para Serproxy ) http://www.cote.cc/blog/serialproxy-v014-can-use-com-ports-above-9 JeanPhilippe AS3 Glue  http://code.google.com/p/as3glue/ ErikSjodin, eriksjodin.net SnowStormparticles SebLee-Delisle http://www.sebleedelisle.com FlarManager EricSocolofsky http://transmote.com/flar FLARToolKit Saqoosha http://www.libspark.org/wiki/saqoosha/FLARToolKit/en MiKuMiKuDance b2ox http://www.libspark.org/browser/as3/FLARMMD/trunk/src/org/b2ox/pv3d Ferramentas para criar danças dos modelos 3D Miku http://www.geocities.jp/higuchuu4/index_e.htm email: spsantossilva@gmail.com Site: http://ssweb.org/video