You are on page 1of 5

Newspaper Headlines

Here we will make an application by using blenders game engine. It will be useful to readability for large image files on the screen. We will zoom in or out and slide around by the mouse. First of all you need to have about 10 newspapers headline images. For this example I will use www.haberler.com (Turkish). There are a lot of newspapers; I just chose 10 of them. To get the images, you need to dig some HTML. I chose a name like images for the folder name. This folder is in the blend files folder.

I tried to use Python but i didnt find good sources to download our news headline images automatically in blender 3d. And also i couldnt make it dynamically created planes too. We will use external JPG files applied to the pre-created planes. It looks like a large billboard, and gliding over the images. We can make carrousel or booklet like things too. However I will not go in deep fancy animations or lots of coding here. For the usage, there are only mouse wheel up and down for zooming and mouse move to slide around. ESC key closes the program naturally. I know it is very tedious to find and download 10 JPG images every day, so for Windows, I wrote a simple script to gather the images. Thanks to this answer here:

http://stackoverflow.com/questions/2528608/script-to-download-file-and-rename-according-todate-on-windows-vista-machine Full script code is here, i saved it updateNew.vbs: Starts here:


Dim cevap cevap = MsgBox ("Do you want to update?", vbOkCancel , "Newspaper updater script") if cevap = vbOK then 'Edit your newspaper links here CALL download("http://img.haberler.com/gazete/hurriyetgazetesi/bugun.jpg","1.jpg") CALL download("http://img.haberler.com/gazete/milliyetgazetesi/bugun.jpg","2.jpg") CALL download("http://img.haberler.com/gazete/posta-gazetesi/bugun.jpg","3.jpg") CALL download("http://img.haberler.com/gazete/sabah-gazetesi/bugun.jpg","4.jpg") CALL download("http://img.haberler.com/gazete/sozcu-gazetesi/bugun.jpg","5.jpg") CALL download("http://img.haberler.com/gazete/bugun-gazetesi/bugun.jpg","6.jpg") CALL download("http://img.haberler.com/gazete/haberturkgazetesi/bugun.jpg","7.jpg") CALL download("http://img.haberler.com/gazete/vatan-gazetesi/bugun.jpg","8.jpg") CALL download("http://img.haberler.com/gazete/taraf-gazetesi/bugun.jpg","9.jpg") CALL download("http://img.haberler.com/gazete/takvimgazetesi/bugun.jpg","10.jpg") MsgBox "Images are updated!", vbOKOnly , "Newspaper updater script" end if Sub download(URL, FileName) Dim strURL, strFile, strFolder, oFSO, dt, oHTTP, oStream strURL = URL ''# The URL to download strFile = FileName ''# The file name strFolder = "images" ''# The folder where to save the files Const adTypeBinary = 1 Const adSaveCreateOverWrite = 2 ''# If the download folder doesn't exist, create it oFSO = CreateObject("Scripting.FileSystemObject") If Not oFSO.FolderExists(strFolder) Then oFSO.CreateFolder(strFolder) End If ''# Generate the file name dt = CreateObject("WbemScripting.SWbemDateTime") dt.SetVarDate(Now) strFile = oFSO.GetBaseName(strFile) & "." & oFSO.GetExtensionName(strFile) ''# Download the URL oHTTP = CreateObject("MSXML2.XMLHTTP") oHTTP.open("GET", strURL, False) oHTTP.send() If oHTTP.Status <> 200 Then ''# Failed to download the file WScript.Echo("Error " & oHTTP.Status & ": " & oHTTP.StatusText) Else oStream = CreateObject("ADODB.Stream") oStream.Type = adTypeBinary oStream.Open()

''# Write the downloaded byte stream to the target file oStream.Write(oHTTP.ResponseBody) oStream.SaveToFile(oFSO.BuildPath(strFolder, strFile), adSaveCreateOverWrite) oStream.Close() End If End Sub

Code is ended here. If you are using Linux or Mac you need to use their console scripts. And also if you want this to work in Windows machine, you need to enable Windows Scripting Host. http://en.wikipedia.org/wiki/Windows_Script_Host Before we run our blender application, we need to double click this VB script file to download the upto-date or fresh news. For the blender new file, we need to enable Import Images as Planes from add-on tab in the user preferences.

Edit the planes like this image in 2 rows:

To see the textured planes better i enabled GLSL and Textured Solid. For aligning I changed values from Properties*Object*Transform. So their locations look perfectly aligned. For the camera slide I modified a little this code (MouseLook.py): from bge import logic, render from mathutils import Vector class MouseLook: def __init__(self,cont): self.cont=cont self.sen_mouse = self.cont.sensors["mouse"] self.act_rotx = self.cont.actuators["rotx"] self.act_rotz = self.cont.actuators["roty"]

self.cont.activate(self.act_rotx) self.cont.activate(self.act_rotz) x = render.getWindowWidth()//2 y = render.getWindowHeight()//2 self.screen_center = (x,y) render.setMousePosition(*self.screen_center) def getMouseOffset(self): vec_screencenter = Vector(self.screen_center) vec_mouseposition = Vector(self.sen_mouse.position) return vec_mouseposition-vec_screencenter def main(self): vec_offset = self.getMouseOffset() vec_offset *= -0.005 self.act_rotx.dLoc = [vec_offset.x,0,0] self.act_rotz.dLoc = [0,vec_offset.y,0] render.setMousePosition(*self.screen_center) mouse_look = MouseLook(logic.getCurrentController()) init = False def main(): global init if init: mouse_look.main() else: init = True

I used one of the Nilunders tutorials: http://www.youtube.com/watch?v=YYlOhtDwElM (Basic Mouse Look)

There we have a Camera parented with a cube. I sized the cube to zero to not to be visible. To watch the program in action, click this video: http://youtu.be/J3hEUk3FIBo As you see it is not perfectly working, there is some refresh or FPS problem that I dont know how to fix, and some mouse acting strange. I hope you will enhance it and make it more useful! Waiting your comments here: www.facebook.com/blenderWorks

You might also like