Re: Light Direction relative to World Matrix
From: Kevin Spencer (kspencer_at_takempis.com)
Date: 09/16/04
- Next message: garrittg: "RE: GUID to controller ID"
- Previous message: garrittg: "RE: GUID to controller ID"
- In reply to: Mark Davis [MSFT]: "RE: Light Direction relative to World Matrix"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 16 Sep 2004 10:04:21 -0400
Thanks Mark! I kind of suspected that might be the track to move forward on.
Your explanation is exactly what I needed!
-- Thanks again, Kevin Spencer .Net Developer Microsoft MVP I get paid good money to solve puzzles for a living "Mark Davis [MSFT]" <markda@online.microsoft.com> wrote in message news:u#CAFf4mEHA.740@cpmsftngxa06.phx.gbl... > Hi Kevin... > > If you rotate the world and keep the light in a fixed position, the shadow > movement would be expected. > > I believe that your world matrix would need to be an identity matrix. > > It's usual practice to move the camera and derive the view matrix transform > from the camera position, orientation and lookat vectors. The world stays > fixed and the camera (and view) move around in the world space. > > You can then move the light in an arc (always looking at 0,0,0) and get the > effect you are looking for. On each frame, calculate the new position of > the light (x=x*cos(angle)-y*sin(angle),y=y*cos(angle)-x*sin(angle)) and the > new direction vector (lookat-pos). Don't trust my math, though:O) Of > course, you probably also want to vary the intensity/color of the light to > achieve a more realistic sunset/sunrise. > > Mark Davis (MSFT) > -- > This posting is provided "AS IS" with no warranties, and confers no rights. > Use of included information and code is subject to the terms specified at > http://www.microsoft.com/info/cpyright.htm. > -------------------- > >Reply-To: "Kevin Spencer" <kspencer@takempis.com> > >From: "Kevin Spencer" <kspencer@takempis.com> > >Subject: Light Direction relative to World Matrix > >Date: Wed, 15 Sep 2004 09:24:34 -0400 > >Lines: 37 > >X-Priority: 3 > >X-MSMail-Priority: Normal > >X-Newsreader: Microsoft Outlook Express 6.00.3790.181 > >X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 > >Message-ID: <#r84JgymEHA.3564@tk2msftngp13.phx.gbl> > >Newsgroups: microsoft.public.win32.programmer.directx.managed > >NNTP-Posting-Host: dynamicsystems.com 216.54.1.213 > >Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl > >Xref: cpmsftngxa06.phx.gbl > microsoft.public.win32.programmer.directx.managed:7135 > >X-Tomcat-NG: microsoft.public.win32.programmer.directx.managed > > > >Still working on my terrain-modelling app, and am now working on > positioning > >and moving the camera, world matix, and lights. The problem I'm having: > > > >I position the camera directly above the 0,0,0 location in the center of my > >triangle strip, and point it down, making my "up" direction in the Z > >direction. I can then rotate the world matrix to rotate my camera. I use an > >Altitude field to set the vertical (Y) position (LookFrom) of the camera, > >and a CameraRotation field to rotate the world matrix, thus rotating my > >camera. I use a Tilt field to change the Z-component of my LookAt vector, > >and thus enable the camera to both rotate and tilt up and down. However, I > >find that when I change the X or Z component of the LookAt vector, it > >changes the direction of the light (directional) relative to the world > >matrix. This means that when I rotate the camera, the shadows on the > terrain > >change, which they shouldn't. The light direction should remain constant > >relative to the world matrix. I can set X and Z to (0,0) to position the > >camera exactly in the center of the triangle strip (it's a spiralling > >square), and of course, the shadows don't change. However, I want to be > able > >to simulate different times of day by setting the angle of the light. I > >spent a long time last night trying to find the solution. > > > >I believe my math skills are not well-developed enough. I know that the > >directional light direction is a vector, but I dont' know how to rotate it > >relative to the world matrix. I can rotate a matrix, but how do you rotate > a > >vector? Or am I barking up the wrong tree here? Should I be rotating my > >camera instead of the world matrix? > > > >Any help? > > > >-- > >TIA, > >Kevin Spencer > >.Net Developer > >Microsoft MVP > >I get paid good money to > >solve puzzles for a living > > > > > > >
- Next message: garrittg: "RE: GUID to controller ID"
- Previous message: garrittg: "RE: GUID to controller ID"
- In reply to: Mark Davis [MSFT]: "RE: Light Direction relative to World Matrix"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|