WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   load jpg/bmp image file into wirtual world (https://forum.worldviz.com/showthread.php?t=5251)

johnallen 12-16-2014 06:48 AM

load jpg/bmp image file into wirtual world
 
Hi,

I want to load a jpg image file into my virtual world and display it on the wall (like a picture in a gallery) of my room (which is already loaded as an osgb file)

I thought this would be simple to do but couldn't find an example. In the end I came up with this which sort of works but I was wondering whether there is a better way to do it?

In particular, a way to link the jpg to the wall rather than having to tweak the position coordinates until its close enough that it looks right (rather than using the magic numbers as I've done so that it works for my room)

Code:

    room = viz.add( 'room.osgb')
    pic1 = viz.addTexture('mona.jpg')

    quad = viz.addTexQuad(parent=room)
    quad.setPosition([ 0,1.6,2.05 ])
    quad.texture(pic1)

Thanks,

John

Jeff 12-16-2014 04:57 PM

You'll probably want to apply the texture to a sub-part of the model rather than the model as a whole. In the following code a new texture is applied to one of the gallery paintings:

Code:

import viz
viz.go()

gallery = viz.addChild('gallery.osgb')
texture = viz.addTexture('lake3.jpg')
gallery.texture(texture,node='painting_starry-night')



All times are GMT -7. The time now is 05:21 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC