Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6
This is the forum to discuss the Wrox book Professional XNA Game Programming: For Xbox 360 and Windows by Benjamin Nitschke; ISBN: 9780470126776
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 16th, 2007, 09:31 PM
Registered User
Join Date: Oct 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default About Cal Normal Vec in RacingGame's Landscape

When I was reading a RacingGame's source file which named Landscape.cs, I found myself puzzled by the following codes:

it's in Landscape's Construction, which is to Calculate the Normal Vectors for each Vertexs of the Landscape.

// Step 2: Calculate all edge vectors (for normals and tangents)
// This involves quite complicated optimizations and mathematics,
// hard to explain with just a comment. Read my book :D
Vector3 edge1 = pos - CalcLandscapePos( x, y + 1, heights );
Vector3 edge2 = pos - CalcLandscapePos( x + 1, y, heights );
Vector3 edge3 = pos - CalcLandscapePos( x - 1, y + 1, heights );
Vector3 edge4 = pos - CalcLandscapePos( x + 1, y + 1, heights );
Vector3 edge5 = pos - CalcLandscapePos( x - 1, y - 1, heights );

// Step 3: Calculate normal based on the edges (interpolate
// from 3 cross products we build from our edges).
vertices[index].normal = Vector3.Normalize(
                        Vector3.Cross( edge2, edge1 ) +
                        Vector3.Cross( edge4, edge3 ) +
                        Vector3.Cross( edge3, edge5 ) );

the Comment says: "This involves quite complicated optimizations and mathematics." But I found the sampling was dissymmetric and I couldn't see the mathematics base of this method.
the Comment also says: "Read my book". But I hadn't found any explain about this in "Professional XNA Game Programing". Is there an other book which explains this method?

I am a Chinese student, and I am writing something to explain the codes of RacingGame.(I hope that won't make me a pirate.) As a collage student, my experience is limited, but I like game developing and I already have my own game project which called "SmartTank".
if you see this topic, plz tell me how to find the answer. anybody who knows the answer plz let me know too. Thanks a lot.


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
WebService(Method Cal) RAGHAVENDRAN .NET Web Services 1 January 2nd, 2008 10:17 AM
displaying variable in normal text yuvin ASP.NET 1.0 and 1.1 Basics 5 January 12th, 2007 02:03 AM
3rd normal form dBbob SQL Server DTS 0 June 8th, 2005 11:29 AM
please help me! how to diplay chinese normal? james007 Crystal Reports 5 April 26th, 2004 10:48 PM
First normal form and attachement questions?? wasaan SQL Server 2000 2 July 17th, 2003 09:43 AM

All times are GMT -4. The time now is 09:30 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.