WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-12-2008, 10:21 AM
Andrey Andrey is offline
Member
 
Join Date: Apr 2007
Posts: 21
Saving as a WRL

Hi,

Is there any tool to save the scene created by Vizard script as a WRL file?

If there is no such a tool, then could you recommend the solution for the following problem. I know the parameters of the cylinder in Vizard: position of the bottom, position of the top, scale. How to convert them to WRML cylinder node parameters ‘translation’, rotation’ and ‘scale’?

Thank you,
Andrey
Reply With Quote
  #2  
Old 05-12-2008, 04:42 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
WRL files are simple text files, so you can manually generate the file. Here is an example WRL file that creates a cylinder:
Code:
Transform {
	translation 0 0.25 0
	rotation 0 1 0 0
	scale 1 1 1
	children [
		Shape {
			geometry Cylinder { radius 0.05 height 0.5 }
		}
	]
}
You can use Python file routines to open a file, write the contents of the wrl, and close it.
Reply With Quote
  #3  
Old 05-13-2008, 07:29 AM
Andrey Andrey is offline
Member
 
Join Date: Apr 2007
Posts: 21
Sure, no problem to generate wrl. The problem is that the translation and rotation in WRML differ from Vizard. As to translation, WRML has opposite Z direction. More difficult situation is for rotation: since I have top (p1) and bottom (p2) cylinder positions in Vizard, to get WRML rotation parameters I tried

vizmat.LookToQuat(vizmat.VectorToPoint(p1,p2))

and

vizmat.QuatToAxisAngle(vizmat.LookToQuat(vizmat.Ve ctorToPoint(p1,p2)))

but both variants produces something mysterious. Could you help?
Reply With Quote
  #4  
Old 05-14-2008, 09:49 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The VRML rotation field is an axis-angle rotation. To convert a Vizard axis-angle rotation to a VRML axix-angle rotation, you will need to negate the x,y components of the axis vector and convert the degrees to radians. Here is a function that will return the VRML rotation of a cone given the bottom and top points of the cone:
Code:
def getVRMLConeRotation(bottom,top):
	
	v = viz.Vector(top)
	v -= bottom
	
	m = viz.Matrix()
	m.makeVecRotVec([0,1,0],v)
	
	r = m.getAxisAngle()
	
	return -r[0],-r[1],r[2],viz.radians(r[3])
Reply With Quote
  #5  
Old 05-14-2008, 12:08 PM
Andrey Andrey is offline
Member
 
Join Date: Apr 2007
Posts: 21
Thank you, now the result is not misterious. But when I add saved WRL back to Vizard I get the cylinder mirrored from X axis in respect to the original one. Is it because of the reverse convertion while adding?
Reply With Quote
  #6  
Old 05-14-2008, 05:27 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I tested it out here and it seems to work fine. Can you provide a sample script that recreates your problem?
Reply With Quote
  #7  
Old 05-15-2008, 10:03 AM
Andrey Andrey is offline
Member
 
Join Date: Apr 2007
Posts: 21
Thank you again, I already found the bug, it works normal.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
saving the scene giancamati Vizard 1 12-21-2006 09:25 AM
saving the position poolshark Vizard 3 09-26-2003 01:57 PM


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


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