RE:light positioning

New Message Reply Date view Thread view Subject view Author view

Inge E.Henriksen (inge++at++autosim.no)
Wed, 5 Nov 1997 11:57:18 +0100


>***************************************************************************
***
>
> From: katz++at++ips.jsc.nasa.gov (Katz)
> Date: Tue, 4 Nov 1997 13:32:11 -0600 (CST)
> Subject: light positioning
>
>Hi all,
>
>I've asked some help about dynamic light node positioning a week ago but
got no answer.
>Maybe my question wasn't specific enough. I need to set up light source on
a moving object,
>such that the light moves and rotates along as the object does. Here is the
code that
>shows how I am trying to accomplish that. Unfortunately, the light does not
move when the
>object does...
>
>void main(int argc, char *argv[])
>{
> pfCoord *c;
> pfGroup *group;
> pfGeode *obj[2];
> pfLight *plight;
> vgLight *vlight;
> pfDCS *orbdcs;
> vgPosition *pos;
> vgEnv *env;
> pfMatrix orbMat;
> int indx, i, objnum;
>
> vgInitSys();
> vgDefineSys(argv[1]);
> vgConfigSys();
>
> pos = vgNewPos();
> vlight = vgNewLight();
> orbdcs = pfNewDCS();
> pfMakeEulerMat(orbMat, 0.0f, 0.0f, 0.0f);
> pfPostTransMat(orbMat, orbMat, 0.0f, 0.0f, 0.0f);
> pfDCSMat(orbdcs, orbMat);
> pfNodeName(orbdcs, "ORBDCS");
> c = (pfCoord *)pfMalloc(sizeof(pfCoord), NULL);
>
> c->xyz[0] = 14.6f;
> c->xyz[1] = 0.0f;
> c->xyz[2] = 12.6f;
> c->hpr[0] = c->hpr[1] = c->hpr[2] = 0.0f;
> vgPosVec(pos, c->xyz[0], c->xyz[1], c->xyz[2], c->hpr[0], c->hpr[1],
c->hpr[2]);
> c->xyz[0] = c->xyz[1] = c->xyz[2] = 0.0f;
>
> env = vgGetEnv(0);
>
> vgProp(vlight, VGLGHT_TYPE, VGLGHT_SPOT);
> vgProp(vlight, VGLGHT_SPOTINT, 0.5f);
> vgProp(vlight, VGLGHT_SPOTWIDTH, 30.0f);
> vgLightColor(vlight, VGLGHT_DIFFUSE, 1.0f, 0.0f, 0.0f);
> vgLightColor(vlight, VGLGHT_AMBIENT, 1.0f, 0.0f, 0.0f);
> vgSpotLightDirVec(vlight, 1.0f, 0.0f, 0.0f);
> vgPos(vlight, pos);
> vgProp(vlight, VGCOMMON_ENABLED, VG_ON);
> vgAddEnvLight(env, vlight);
>
> plight = vgGetPfLight(vlight);
> group = (pfGroup *)vgGetScenePfScene(vgGetScene(0));
> objnum = pfGetNumChildren(group);
> for(i = 0; i < objnum; i++)
> obj[i] = (pfGeode *)pfGetChild(group, i);
> for(i = 0; i < objnum; i++)
> pfRemoveChild(group, pfGetChild(group, 0));
>
> pfAddChild(group, orbdcs);
> pfAddChild(orbdcs, plight);
> pfAddChild(orbdcs, obj[0]);
>
> while (1) {
>
> vgSyncFrame();
> vgFrame();
>
> c->xyz[0] += 0.1f;
>
> pfMakeCoordMat(orbMat, c);
> pfDCSMat(orbdcs, orbMat);
> }
>}
>
>
>
>I would greatly appreciate if someone could comment about the code or
recommend a better
>way to achieve my goal.

Hello Mr.Vadim Katz
-----------------------------
An alternetive approach:
Include a lightsource in your model with a modeling-tool from MultiGen Inc.
(www.multigen.com ) or any other modelling tool that allows you to do this.
When you then move your object the lightsource should follow. Although I
have not done this myself it seems likely that it should work properly ! The
good thing with this is that you don't need to think about moving both the
object AND the lightsource.

Greetings !

>
>
>Thanks,

Youre welcome !!

>
>Vadim Katz
>United Space Alliance
>
>
>***************************************************************************
***
>
________________________________________
Inge E.Henriksen, Database designer, Autosim A/S
P.B.2303, N-9002 Tromsoe, Norway
Tlf.:+47 77675075 Fax:+47 77676701
Mailto:inge++at++autosim.no
________________________________________
--->---->---->---->---->Words for thought: John.3:16-21
________________________________________

=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
            Submissions: info-performer++at++sgi.com
        Admin. requests: info-performer-request++at++sgi.com


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:56:12 PDT

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