[Sidefx-houdini-list] ndc to world matrix

katrin schmid Katisss at gmx.de
Mon Aug 2 00:47:44 EDT 2010


hi,
it's running but what matrix is this?
The Projection matrix? And its quite hacky to this
for the entire time line...

Maybe iam just thinking to complicated:
http://pymel.googlecode.com/svn/tags/0.7.10/pymel/vector.py 
    def worldToCamera(self, camera=None):
        if camera is None:
            camera = core.mel.getCurrentCamera()
        return self * node.DependNode(camera).worldInverseMatrix.get()
        
    def worldToScreen(self, camera=None):
        if camera is None:
            camera = node.Camera(core.mel.getCurrentCamera())
        else:
            camera = node.Camera(camera)
            
        screen = self.worldToCamera(camera)
        
        screen.x = (screen.x/-screen.z) / tan(radians(camera.horizontalFieldOfView/2))/2.0+.5
        screen.y = (screen.y/-screen.z) / tan(radians(camera.verticalFieldOfView/2))/2.0+.5 

        xres = core.getAttr( 'defaultResolution.width' )
        yres = core.getAttr( 'defaultResolution.height' )
        filmApX = camera.horizontalFilmAperture.get()
        filmApY = camera.verticalFilmAperture.get()
    
        filmAspect = filmApX/filmApY;
        resAspect  = xres/yres;
        ratio = filmAspect/resAspect;
    
        screen.y = linmap( ((ratio-1)/-2), (1+(ratio-1)/2), screen.y )
        
        return screen   


-------- Original-Nachricht --------
> Datum: Sun, 1 Aug 2010 21:41:23 -0700
> Von: Andrew D Lyons <tstexture at gmail.com>
> An: sidefx-houdini-list at sidefx.com
> Betreff: Re: [Sidefx-houdini-list] ndc to world matrix

> Oh sorry - didn't see the whole thread. Grahams example looks good except
> for one small thing ("camera" should be "cam"):
> 
> viewer = toolutils.sceneViewer()
> viewport = viewer.curViewport()
> cam = hou.node("/obj").createNode("cam")
> viewport.saveViewToCamera(cam)
> xform = cam.worldTransform()
> cam.destroy()
> 
> This is the only way of accessing the matrix for an arbitrary user
> generated
> viewport matrix afaik.
> 
> Cheers
> 
> 
> On 1 August 2010 21:23, katrin schmid <Katisss at gmx.de> wrote:
> 
> > hi,
> > viewer = toolutils.sceneViewer()
> > viewport = viewer.curViewport()
> > as mentioned in Grahams example below.
> >
> > I am trying to get the actual matrix
> > for writing to exr whatever compositors need it for.
> > I am on p. 374 of the book linked.
> > Thanks,
> > katrin
> >
> >
> > -------- Original-Nachricht --------
> > > Datum: Sun, 1 Aug 2010 21:16:48 -0700
> > > Von: Andrew D Lyons <tstexture at gmail.com>
> > > An: sidefx-houdini-list at sidefx.com
> > > Betreff: Re: [Sidefx-houdini-list] ndc to world matrix
> >
> > > Some questions below:
> > >
> > > On 1 August 2010 21:02, katrin schmid <Katisss at gmx.de> wrote:
> > >
> > > > so i try compositng WorldToCamera from this book for a start
> > > >
> > > >
> > > >
> > >
> >
> http://books.google.com.au/books?id=jXmJqzQgdY8C&pg=PA375&lpg=PA375&dq=worldToCamera&source=bl&ots=xn94-vpnh3&sig=LboAGGX2oRAbsbf0eIRdDkUOTiQ&hl=en&ei=hApWTISjIIzqvQPyjJUZ&sa=X&oi=book_result&ct=result&resnum=7&ved=0CEsQ6AEwBg#v=onepage&q=worldToCamera&f=false
> > > >
> > > > Anyone knows if its a good plan?
> > > >
> > >
> > > Not sure what you are trying to achieve. If it's just feature
> extraction,
> > > then there are edge detect COPs in the Houdini compositor. Are you
> trying
> > > to
> > > write a new COP? (The link above pulled up a blank page - they must
> > > shuffle
> > > the stuff you can't read.)
> > >
> > >
> > >
> > > > Im also not quite sure what the matrix values
> > > > viewport.saveViewToCamera(cam)
> > > >
> > >
> > >
> > > What is the viewport object? Is that the object returned by a
> > > toolutils.activePane() calll?
> > >
> > >
> > > > xform = cam.worldTransform()
> > > >
> > >
> > > This one just returns a standard Houdini matrix4 object (row major)
> > > representing the world position of the "cam" object...
> > >
> > > Cheers
> > >
> > >
> > >
> > > > represent really...
> > > > thanks for helping,
> > > > katrin
> > > >
> > > > -------- Original-Nachricht --------
> > > > > Datum: Thu, 29 Jul 2010 08:46:49 -0700
> > > > > Von: Graham Thompson <captainhammy at gmail.com>
> > > > > An: sidefx-houdini-list at sidefx.com
> > > > > Betreff: Re: [Sidefx-houdini-list] ndc to world matrix
> > > >
> > > > > There is not.  I posted some workarounds on your thread on the
> forum
> > > > > however.
> > > > >
> > > > > On Thu, Jul 29, 2010 at 8:42 AM, katrin schmid <Katisss at gmx.de>
> > wrote:
> > > > > > hi,
> > > > > > thanks for that, its surprisingly
> > > > > > hard to find. I was wondering if there a way of querying
> > > > > > worldTransform() in time for an animated camera?
> > > > > > Regards,
> > > > > > katrin
> > > > > >
> > > > > > -------- Original-Nachricht --------
> > > > > >> Datum: Thu, 29 Jul 2010 08:06:59 -0700
> > > > > >> Von: Graham Thompson <captainhammy at gmail.com>
> > > > > >> An: sidefx-houdini-list at sidefx.com
> > > > > >> Betreff: Re: [Sidefx-houdini-list] ndc to world matrix
> > > > > >
> > > > > >> The functions dealing with view transforms were added for
> Houdini
> > > 11
> > > > > >> so they aren't available in previous versions.
> > > > > >>
> > > > > >> You can kind of hack it by creating a dummy camera node,
> calling
> > > > > >> hou.GeometryViewport.saveViewToCamera on that camera, extract
> the
> > > > > >> transform from the camera then delete it.
> > > > > >>
> > > > > >> viewer = toolutils.sceneViewer()
> > > > > >> viewport = viewer.curViewport()
> > > > > >> cam = hou.node("/obj").createNode("camera")
> > > > > >> viewport.saveViewToCamera(cam)
> > > > > >> xform = cam.worldTransform()
> > > > > >> cam.destroy()
> > > > > >>
> > > > > >> On Thu, Jul 29, 2010 at 7:40 AM, katrin schmid <Katisss at gmx.de>
> > > > wrote:
> > > > > >> > hi,
> > > > > >> > so i found this here:
> > > > > >> >>>>>>>>>
> > > > > >> > Get the viewport's settings object
> > > > > >> > settings = viewport.settings()
> > > > > >> >
> > > > > >> > Among the most useful methods on the settings object are
> > > > > viewTransform()
> > > > > >> and setViewTransform(), which get and set the viewport’s
> > > > > transformation
> > > > > >> matrix respectively.
> > > > > >> > http://www.sidefx.com/docs/houdini9.5/ref/windows/edittool
> > > > > >> >>>>>>>>>
> > > > > >> >
> > > > > >> > Unfortunately i cant find viewTransform() in houdini 10
> python
> > > > > >> > or figure out how to get it. Anybody knows?
> > > > > >> > Thank you,
> > > > > >> > karin
> > > > > >> >
> > > > > >> >
> > > > > >> > -------- Original-Nachricht --------
> > > > > >> >> Datum: Wed, 28 Jul 2010 10:00:12 +0200
> > > > > >> >> Von: "katrin schmid" <Katisss at gmx.de>
> > > > > >> >> An: sidefx-houdini-list at sidefx.com
> > > > > >> >> Betreff: Re: [Sidefx-houdini-list] ndc to world matrix
> > > > > >> >
> > > > > >> >> hi,
> > > > > >> >> a python module inside a render node,
> > > > > >> >> i will use whatever works :)
> > > > > >> >> Regards,
> > > > > >> >> katrin
> > > > > >> >>
> > > > > >> >> -------- Original-Nachricht --------
> > > > > >> >> > Datum: Wed, 28 Jul 2010 00:57:09 -0700
> > > > > >> >> > Von: Alex Lim <list at poh-yee.com>
> > > > > >> >> > An: sidefx-houdini-list at sidefx.com
> > > > > >> >> > Betreff: Re: [Sidefx-houdini-list] ndc to world matrix
> > > > > >> >>
> > > > > >> >> > Hi Katrin, is this in VOP net or VEX code? There is a
> > > Transform
> > > > > VOP
> > > > > >> that
> > > > > >> >> > should let you convert from world to NDC. Will this work
> for
> > > you?
> > > > > >> >> >
> > > > > >> >> >
> > > > > >> >> > Cheers,
> > > > > >> >> > Alex
> > > > > >> >> >
> > > > > >> >> >
> > > > > >> >> >
> > > > > >> >> > On 7/28/2010 12:37 AM, katrin schmid wrote:
> > > > > >> >> > > hi,
> > > > > >> >> > > i am trying to write information into an exr's metadata
> > > > > >> >> > > and be interested in the worldToNDC matrix.
> > > > > >> >> > > Do i need to calculate it all myself?
> > > > > >> >> > > Best Regards,
> > > > > >> >> > > katrin
> > > > > >> >> >
> > > > > >> >> > _______________________________________________
> > > > > >> >> > Sidefx-houdini-list mailing list
> > > > > >> >> > Sidefx-houdini-list at sidefx.com
> > > > > >> >> >
> > > > https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
> > > > > >> >>
> > > > > >> >> --
> > > > > >> >> GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99
> EUR/mtl.
> > > > > >> >> Bis zu 150 EUR Startguthaben inklusive!
> > > > > http://portal.gmx.net/de/go/dsl
> > > > > >> >> _______________________________________________
> > > > > >> >> Sidefx-houdini-list mailing list
> > > > > >> >> Sidefx-houdini-list at sidefx.com
> > > > > >> >>
> > > https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
> > > > > >> >
> > > > > >> > --
> > > > > >> > GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> > > > > >> > Jetzt freischalten unter
> http://portal.gmx.net/de/go/maxdome01
> > > > > >> > _______________________________________________
> > > > > >> > Sidefx-houdini-list mailing list
> > > > > >> > Sidefx-houdini-list at sidefx.com
> > > > > >> >
> > https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
> > > > > >> >
> > > > > >> _______________________________________________
> > > > > >> Sidefx-houdini-list mailing list
> > > > > >> Sidefx-houdini-list at sidefx.com
> > > > > >>
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
> > > > > >
> > > > > > --
> > > > > > GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.
> > > > > > Bis zu 150 EUR Startguthaben inklusive!
> > > > http://portal.gmx.net/de/go/dsl
> > > > > > _______________________________________________
> > > > > > Sidefx-houdini-list mailing list
> > > > > > Sidefx-houdini-list at sidefx.com
> > > > > >
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
> > > > > >
> > > > > _______________________________________________
> > > > > Sidefx-houdini-list mailing list
> > > > > Sidefx-houdini-list at sidefx.com
> > > > > https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
> > > >
> > > > --
> > > > GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.
> > > > Bis zu 150 EUR Startguthaben inklusive!
> > http://portal.gmx.net/de/go/dsl
> > > > _______________________________________________
> > > > Sidefx-houdini-list mailing list
> > > > Sidefx-houdini-list at sidefx.com
> > > > https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
> > > >
> > >
> > >
> > >
> > > --
> > > =======================================
> > > Andrew D Lyons | Digital Artist | http://www.tstex.com
> > > =======================================
> > > _______________________________________________
> > > Sidefx-houdini-list mailing list
> > > Sidefx-houdini-list at sidefx.com
> > > https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
> >
> > --
> > GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl.
> > Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl
> > _______________________________________________
> > Sidefx-houdini-list mailing list
> > Sidefx-houdini-list at sidefx.com
> > https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list
> >
> 
> 
> 
> -- 
> =======================================
> Andrew D Lyons | Digital Artist | http://www.tstex.com
> =======================================
> _______________________________________________
> Sidefx-houdini-list mailing list
> Sidefx-houdini-list at sidefx.com
> https://lists.sidefx.com:443/mailman/listinfo/sidefx-houdini-list

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01



More information about the Sidefx-houdini-list mailing list