WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-10-2008, 11:53 AM
Jerry Jerry is offline
Member
 
Join Date: Jun 2004
Posts: 105
BTW, if you want to see yourself in the mirror you can do this:

Code:
import viz
viz.go()

man = viz.add('male.cfg')
man.translate(0,0,4)

link = viz.link(viz.MainView,man)
link.preTrans([0,-1.8,0])

def addMirror(mirror,mat=None):

	#If mirror matrix is not specifed, get matrix of mirror object
	if mat is None:
		mat = mirror.getMatrix()
		
	#Position of mirror
	pos = viz.Vector(mat.getPosition())
	
	#Direction mirror is pointing
	dir = viz.Vector(mat.getForward())
	dir.normalize()

	#Quaternion rotation of mirror
	quat = mat.getQuat()
	
	#Create render texture
	tex = viz.addRenderTexture()
	
	#Create render node for rendering reflection
	lens = viz.addRenderNode(size=[1024,1024])
	lens.attachTexture(tex)
	lens.setInheritView(True,viz.POST_MULT)
	lens.disable(viz.CULL_FACE,op=viz.OP_SET_OVERRIDE)

	#Setup reflection matrix
	rot = viz.Matrix.quat(quat)
	invRot = rot.inverse()
	lens.setMatrix(viz.Matrix.translate(pos*-1.0)*invRot*viz.Matrix.scale(1,1,-1)*rot*viz.Matrix.translate(pos))
	
	#Setup reflection clip plane
	plane = vizmat.Plane(pos=pos,normal=dir)
	dist = plane.distance([0,0,0])
	lens.clipPlane([-dir[0],-dir[1],-dir[2],dist+0.001])

	#Project reflection texture onto mirror
	mirror.texture(tex)
	mirror.texGen(viz.TEXGEN_PROJECT_EYE)

#Add gallery environment
gallery = viz.add('gallery.ive')

#Use existing painting as mirror and specify the matrix
mirrorsurface = viz.addTexQuad()
mirrorsurface.alpha(.2)
mirrorsurface.scale(.99,.74,1)
mirrorsurface.setPosition([-.329, 1.8, 2.9]) #Y,Z,X
mirrorsurfacerotation = [0,0,0] #rotation around the Z,Y,X axes
mirrorsurface.rotate(mirrorsurfacerotation) 
m = viz.Matrix()
m.setPosition(mirrorsurface.getPosition(viz.ABS_GLOBAL))
m.setEuler(mirrorsurfacerotation[0]-180,-mirrorsurfacerotation[1], mirrorsurfacerotation[2]) #Z,X,Y

#Apply mirror settings to mirror object
addMirror(mirrorsurface,m)

#Increase ambient lighting
viz.MainView.getHeadLight().ambient(1,1,1)
Reply With Quote
  #2  
Old 04-10-2008, 01:23 PM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
@ Jerry: I already know how to see myself in the mirror. But I want to create a glass window where you can see through, but also reflects, like a real life glass window. So what I want to make is a transparent mirror. The problem is that I don't know how to make the reflection texture transparent.
Reply With Quote
  #3  
Old 04-10-2008, 02:26 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Using the following code makes the mirror semi-transparent for me:
Code:
mirrorsurface.alpha(.2)
mirrorsurface.appearance(viz.TEXMODULATE)
Reply With Quote
  #4  
Old 04-11-2008, 03:40 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Thanks, that was exactly what I was looking for!

I started playing around with two mirrors facing each other, but then the reflection of mirror1 is not reflected in mirror 2. Instead, you'll see a black square at the position of mirror2 in the reflection of mirror1. And when you look into mirror2, you'll see a black square at the position of mirror1. Both mirror reflections work well for the rest of the environment. I was wondering if it is possible at all to fix this. I don't really need the solution, I just want to know if it is possible. But if the solution is quite simple, then I'm all ears (or eyes).
Reply With Quote
  #5  
Old 04-11-2008, 04:04 AM
Frank Verberne Frank Verberne is offline
Member
 
Join Date: Mar 2008
Location: Netherlands
Posts: 148
Thanks, that was exactly what I was looking for!

I started playing around with two mirrors facing each other, but then the reflection of mirror1 is not reflected in mirror 2. Instead, you'll see a black square at the position of mirror2 in the reflection of mirror1. And when you look into mirror2, you'll see a black square at the position of mirror1. Both mirror reflections work well for the rest of the environment. I was wondering if it is possible at all to fix this. I don't really need the solution, I just want to know if it is possible. But if the solution is quite simple, then I'm all ears (or eyes).

I also noticed a significant framerate drop when an avatar and it's reflection are in view. Is there any way the algorithm for the reflection texture can be modified so that the framerate won't drop (as much)? Now the drop is from 72 fps to 36 fps.
Reply With Quote
  #6  
Old 02-09-2011, 03:35 AM
chris_user chris_user is offline
Member
 
Join Date: Feb 2011
Posts: 20
hope anyone can help me with my problem;
when I apply the mirroring effect, the mirroring looks fine, but the reflected model is way too bright.

this line is the reason for the good looking mirror effect, but it also blows out the placed model if you take a direct look

viz.MainView.getHeadLight().ambient(1,1,1)

is there a possibility to exclude the effect for the model?
hope anybody can help

thanks in advance
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a Vizard Sensor Plugin farshizzo Plug-in development 25 08-01-2019 12:24 AM
Vizard and Augmented Reality realvision Vizard 4 04-04-2008 10:59 AM
Vizard won't run wouters Vizard 5 02-05-2008 11:12 AM
Fall 2007 release of Vizard R3 3 D Announcements 0 10-15-2007 04:50 PM
wxPython with Vizard farshizzo Vizard 18 09-29-2005 08:49 AM


All times are GMT -7. The time now is 02:25 AM.


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