Re: [info-performer] pfvmLoader/ trackball and model scaling

New Message Reply Date view Thread view Subject view Author view

From: Paolo Farinelli (paolo++at++sgi.com)
Date: 02/14/2003 17:29:01


Hi Rémy,

As you suspected, your problem is that your far plane is too close and
the whole earth is clipped.

Currently, there is no official way to set channels' near and far
distances in pfvViewer based apps.
Near and Far distances are initially set to 0.01 and 100.0 respectively,
for all channels.
We will be looking at implementing near-far control into a future
release (SRC#880716).

For the moment, my advice is to use a custom module to set near and far.
I have quickly hacked myModule.C and .h (which you can find in
%PFROOT%\Src\pguide\libpfv\viewer\modules\myModule) and I am attaching
the modified source to this email.
You will need to produce a Makefile (copy one of the existing module
Makefiles), and recompile it.
Then, add this to your config file:

<Module>
  <class>myNearFar</class>
  <data>
    <Near>10.0</Near>
    <Far>10000.0</Far>
  </data>
</Module>

Note that you will also have to make sure that your newly compiled
library is found by the pfvViewer.
You have 3 options:

1. Move your NearFar library to where all the other libpfvm* modules'
libraries are.
   This is in %PFROOT%\Lib\libpfv\3.0\ on WIN32, or /usr/lib/libpfv/3.0/
on IRIX or Linux.
   Also, name your library 'libmyNearFar.lib' on WIN32 or
'libmyNearFar.so' on IRIX/Linux.

2. Add an entry to your configuration file, specifying the path to your
library, before declaring your custom module:
<modulepath>/usr/remy/pfvmodules/dsos</modulepath>

3. Add the name of your library inside your module declaration:
<Module>
  <class>myNearFar</class>
  <dso>../../pfvmodules/dsos/libmyNearFar.lib</dso>
  <data>
    <Near>10.0</Near>
    <Far>10000.0</Far>
  </data>
</Module>

Unfortunately, setting absolute paths on WIN32 is currently broken (as
you have noticed yourself), so you will either have to use option 1, or
make use of relative paths (as in option 3).

Absolute filepath setting in pfvViewer apps will be fixed in a future
release. (SRC#881845)

Some additional considerations regarding scoping of the 'myNearFar' module:

If you scope it globally (the default), it will set near and far for all
channels in all views, on frame 0.

If you scope it to a view, it will set near and far for all channels in
that view only, on frame 0. This means you can have multiple views, and
set different near and far distances by instantiating multiple myNearFar
modules and scoping one to each view.

If scoped to a world, myNearFar will set near and far for all channels
of each view that starts viewing such world. This is done in the
'enterView' callback. This would allow you to have (for example) one
view and multiple worlds, and to configure different values of near and
far for each world.

Please let me know if any of the above doesn't work. I didn't find the
time to test this module at all (yet).

Hope this helps.

Best Regards,
Paolo

Rémy Deslignes wrote:

> Hello,
>
> I have a problem with a model within a loader module and/or a
> trackball. This model is a simple sphere ( the earth in fact ).
>
> With
>
> <model>
> <filename>data/models/earth.pfb</filename>
> <scale>6,6,6</scale>
> </model>
>
> I can see the earth
>
> With
> <scale>60,60,60</scale>
> I still can see the earth which has the same aspect as previously ,
> thanks to the trackball
> But with
> <scale>600,600,600</scale>
>
> nothing appears ...
>
> Does anyone has an idea ? Is this a near / far clipping problem ?
>
> Thanks for any help .
>
> Remy
>
>
> -----------------------------------------------------------------------
> List Archives, Info, FAQ: http://www.sgi.com/software/performer/
> Open Development Project: http://oss.sgi.com/projects/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com
> -----------------------------------------------------------------------
>
>

-- 
Paolo Farinelli                                           paolo++at++sgi.com
Member of Technical Staff, OpenGL Performer              1-650-933-1808
Silicon Graphics        1600 Amphitheatre Pkwy, Mountain View, CA 94043

/* * Copyright 2002, Silicon Graphics, Inc. * ALL RIGHTS RESERVED * * This source code ("Source Code") was originally derived from a * code base owned by Silicon Graphics, Inc. ("SGI") * * LICENSE: SGI grants the user ("Licensee") permission to reproduce, * distribute, and create derivative works from this Source Code, * provided that: (1) the user reproduces this entire notice within * both source and binary format redistributions and any accompanying * materials such as documentation in printed or electronic format; * (2) the Source Code is not to be used, or ported or modified for * use, except in conjunction with OpenGL Performer; and (3) the * names of Silicon Graphics, Inc. and SGI may not be used in any * advertising or publicity relating to the Source Code without the * prior written permission of SGI. No further license or permission * may be inferred or deemed or construed to exist with regard to the * Source Code or the code base of which it forms a part. All rights * not expressly granted are reserved. * * This Source Code is provided to Licensee AS IS, without any * warranty of any kind, either express, implied, or statutory, * including, but not limited to, any warranty that the Source Code * will conform to specifications, any implied warranties of * merchantability, fitness for a particular purpose, and freedom * from infringement, and any warranty that the documentation will * conform to the program, or any warranty that the Source Code will * be error free. * * IN NO EVENT WILL SGI BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT * LIMITED TO DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, * ARISING OUT OF, RESULTING FROM, OR IN ANY WAY CONNECTED WITH THE * SOURCE CODE, WHETHER OR NOT BASED UPON WARRANTY, CONTRACT, TORT OR * OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, * OR AROSE OUT OF USE OR RESULTS FROM USE OF, OR LACK OF ABILITY TO * USE, THE SOURCE CODE. * * Contact information: Silicon Graphics, Inc., * 1600 Amphitheatre Pkwy, Mountain View, CA 94043, * or: http://www.sgi.com */

#ifndef __MY_NEAR_FAR_H__ #define __MY_NEAR_FAR_H__

///////////////////////////////////////////////////////////////////////////////

#include <Performer/pfv/pfvViewer.h>

///////////////////////////////////////////////////////////////////////////////

//class pfvXmlNode;

///////////////////////////////////////////////////////////////////////////////

class myNearFar : public pfvModule { public: myNearFar( pfvXmlNode* xml=NULL); ~myNearFar() {}

static void init(); static pfType* getClassType(){ return classType; } virtual const char* getTypeName() const {return "myNearFar";}

int setXmlField(pfvXmlNode*xml); void postConfig(); void enterWorld(); void enterView( pfvView* v);

protected: static pfType* classType;

private: void construct(); float NearValue, FarValue; };

///////////////////////////////////////////////////////////////////////////////

#endif // end of __MY_NEAR_FAR_H__

/* * Copyright 2002, Silicon Graphics, Inc. * ALL RIGHTS RESERVED * * This source code ("Source Code") was originally derived from a * code base owned by Silicon Graphics, Inc. ("SGI") * * LICENSE: SGI grants the user ("Licensee") permission to reproduce, * distribute, and create derivative works from this Source Code, * provided that: (1) the user reproduces this entire notice within * both source and binary format redistributions and any accompanying * materials such as documentation in printed or electronic format; * (2) the Source Code is not to be used, or ported or modified for * use, except in conjunction with OpenGL Performer; and (3) the * names of Silicon Graphics, Inc. and SGI may not be used in any * advertising or publicity relating to the Source Code without the * prior written permission of SGI. No further license or permission * may be inferred or deemed or construed to exist with regard to the * Source Code or the code base of which it forms a part. All rights * not expressly granted are reserved. * * This Source Code is provided to Licensee AS IS, without any * warranty of any kind, either express, implied, or statutory, * including, but not limited to, any warranty that the Source Code * will conform to specifications, any implied warranties of * merchantability, fitness for a particular purpose, and freedom * from infringement, and any warranty that the documentation will * conform to the program, or any warranty that the Source Code will * be error free. * * IN NO EVENT WILL SGI BE LIABLE FOR ANY DAMAGES, INCLUDING, BUT NOT * LIMITED TO DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES, * ARISING OUT OF, RESULTING FROM, OR IN ANY WAY CONNECTED WITH THE * SOURCE CODE, WHETHER OR NOT BASED UPON WARRANTY, CONTRACT, TORT OR * OTHERWISE, WHETHER OR NOT INJURY WAS SUSTAINED BY PERSONS OR * PROPERTY OR OTHERWISE, AND WHETHER OR NOT LOSS WAS SUSTAINED FROM, * OR AROSE OUT OF USE OR RESULTS FROM USE OF, OR LACK OF ABILITY TO * USE, THE SOURCE CODE. * * Contact information: Silicon Graphics, Inc., * 1600 Amphitheatre Pkwy, Mountain View, CA 94043, * or: http://www.sgi.com */

#include <stdio.h> #include <Performer/pf.h> #include <Performer/pf/pfChannel.h> #include <Performer/pr.h> #include <Performer/pfv/pfvXml.h> #include <Performer/pfv/pfvViewer.h>

#include "myNearFar.h"

///////////////////////////////////////////////////////////////////////////////

pfType* myNearFar::classType = NULL;

///////////////////////////////////////////////////////////////////////////////

void myNearFar::init() { if(classType==NULL) { pfvModule::init(); classType= new pfType(pfvModule::getClassType(), "myNearFar" ); } }

///////////////////////////////////////////////////////////////////////////////

void myNearFar::construct() { if(classType==NULL) init(); setType(classType); NearValue = 0.01f; FarValue = 100.0f; bindCallback(PFV_CB_POSTCONFIG); //bindCallback(PFV_CB_ENTER_WORLD); bindCallback(PFV_CB_ENTER_VIEW); }

///////////////////////////////////////////////////////////////////////////////

void myNearFar::postConfig() { int i; if( getScope()==PFV_SCOPE_GLOBAL ) { int numChans = viewer->getNumChans(); for(i=0;i<numChans;i++) { pfvDispChan* c = viewer->getChan(i); pfChannel* pfchan = c->getHandle(); if(pfchan) pfchan->setNearFar(NearValue,FarValue); } } else if( getScope()==PFV_SCOPE_VIEW ) { pfvView* view = (pfvView*)getScopeTarget(); int numChans = view->getNumChans(); for(i=0;i<numChans;i++) { pfvDispChan* c = view->getChan(i); pfChannel* pfchan = c->getHandle(); if(pfchan) pfchan->setNearFar(NearValue,FarValue); } } }

///////////////////////////////////////////////////////////////////////////////

void myNearFar::enterView(pfvView*view) { int i; int numChans = view->getNumChans(); for(i=0;i<numChans;i++) { pfvDispChan* c = view->getChan(i); pfChannel* pfchan = c->getHandle(); if(pfchan) pfchan->setNearFar(NearValue,FarValue); } }

///////////////////////////////////////////////////////////////////////////////

int myNearFar::setXmlField(pfvXmlNode* xml) { if(xml==NULL) return 0; if(!xml->nameCmp("Near")){ xml->getFloat(&NearValue); pfNotify(PFNFY_INFO,PFNFY_PRINT, "myNearFar::setXmlField - Near = %f", NearValue ); return TRUE; }

if(!xml->nameCmp("Far")){ xml->getFloat(&FarValue); pfNotify(PFNFY_INFO,PFNFY_PRINT, "myNearFar::setXmlField - Far = %f", FarValue ); return TRUE; }

return pfvModule::setXmlField(xml); }

///////////////////////////////////////////////////////////////////////////////

myNearFar::myNearFar(pfvXmlNode*xml) { construct(); if(xml) parseXml(xml); } ///////////////////////////////////////////////////////////////////////////////

extern "C" PFVM_DLLEXPORT pfvModule* pfvLoadModule_myNearFar(pfvXmlNode*xml) { pfNotify(PFNFY_INFO,PFNFY_PRINT, "pfvLoadModule_myNearFar from %s called!\n",__FILE__); myNearFar*m= new myNearFar(xml); return (pfvModule*)m; }

///////////////////////////////////////////////////////////////////////////////


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Fri Feb 14 2003 - 17:29:06 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.