Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 16th, 2007, 09:31 PM
Registered User
 
Join Date: Oct 2007
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.








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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.