Re: Sun

New Message Reply Date view Thread view Subject view Author view

Allan Schaffer (aschaffe)
Tue, 4 Apr 1995 17:41:15 -0700


On Mar 29, 2:11pm, abrend++at++idt.unit.no wrote:
>
> I'm trying to set a sun into my model by using this code in my
> 'InitScene' function :
>
> /* Initialize sun */
> sun = pfNewLSource();
> pfLightColor(sun, 1.0f, 0.0f, 0.0f);
> pfLightAmbient(sun, 0.4f, 0.4f, 0.3f);
> pfLightPos(sun, 0.0f, 1.0f, 0.0f, 0.0f);
> viewState->sun = sun;
> pfAddChild(viewState->scene, viewState->sun);
>
> As you see my light source uses only red light which should be easy to
> detect. What more (and where) do I need to get a sun in my model ?
> Do I have to turn of the ambient light in the materials in my model ?
> How do I do this ? How can I override the default lighting in my
> model ?

For lighting to work:

1. Lighting must be enabled: pfEnable(PFEN_LIGHTING)
2. A pfLightModel must be applied: pfApplyLModel
3. A pfMaterial must be applied: pfApplyMtl
4. One or more pfLights must be on: pfLightOn
5. Illuminated geometry must have normals: pfGSetAttr, PFGS_NORMAL3

As a quick hack test, add these calls to your pipeline initialization
callback:

    pfEnable (PFEN_LIGHTING);
    pfApplyMtl(pfNewMtl(pfGetSharedArena()));
    pfApplyLModel(pfNewLModel(pfGetSharedArena()));

Also, take a look at fog.c, earthsky.c, simple.c, text.c, etc. in
/usr/src/Performer/src/pguide/libpf/progs; each uses a LightSource.

Allan

-- 
Allan Schaffer                                                aschaffe++at++sgi.com
Silicon Graphics                     http://reality.sgi.com/employees/aschaffe

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:51:10 PDT

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