00001 #include "MercuryPoly.h" 00002 /* 00003 void MercuryPoly::AddVert(MercuryVertPacked* vert) 00004 { 00005 if (vert == NULL) 00006 return; 00007 00008 m_verts.push_back(vert); 00009 vert->AddSharingPoly(this); 00010 } 00011 00012 void MercuryPoly::CalculateNormal() 00013 { 00014 //Calculate the surface normal 00015 // This appears to be _mostly_ correct. I'm not 100% positive as normal calculations for vertex 00016 // normals sometiems comes out backwards. 00017 MercuryVertPacked* v1 = m_verts[0]->m_vertex; 00018 MercuryVertPacked* v2 = m_verts[1]->m_vertex; 00019 MercuryVertPacked* v3 = m_verts[2]->m_vertex; 00020 00021 MercuryPoint p; 00022 ((*v1 - *v2).CrossProduct(*v2 - *v3)).ConvertToVector3( p ); 00023 m_normal = p; 00024 m_normal.NormalizeSelf(); 00025 } 00026 */ 00027 /* 00028 * Copyright (c) 2006 Joshua Allen 00029 * All rights reserved. 00030 * 00031 * Redistribution and use in source and binary forms, with or 00032 * without modification, are permitted provided that the following 00033 * conditions are met: 00034 * - Redistributions of source code must retain the above 00035 * copyright notice, this list of conditions and the following disclaimer. 00036 * - Redistributions in binary form must reproduce the above copyright 00037 * notice, this list of conditions and the following disclaimer in 00038 * the documentation and/or other materials provided with the distribution. 00039 * - Neither the name of the Mercury Engine nor the names of its 00040 * contributors may be used to endorse or promote products derived from 00041 * this software without specific prior written permission. 00042 * 00043 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00044 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00045 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00046 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 00047 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00048 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00049 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00050 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00051 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00052 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00053 */ 00054