MercuryVertex.h

Go to the documentation of this file.
00001 #ifndef MERCURYVERTEX_H
00002 #define MERCURYVERTEX_H
00003 
00004 #include "MercuryTypes.h"
00005 #include "MercuryVector.h"
00006 
00007 class MercuryPoly;
00008 
00010 typedef MercuryPoint MercuryNormal;
00011 
00012 class MercuryVertex
00013 {
00014 public:
00015     MercuryVertex();
00016     MercuryVertex( const float ix, const float iy, const float iz, const float iu, const float iv );
00017 
00018     //Act like an old vertice, which was a point
00019     inline const float GetX() const { return x; }
00020     inline const float GetY() const { return y; }
00021     inline const float GetZ() const { return z; }
00022     inline void SetX(const float ix) { x = ix; }
00023     inline void SetY(const float iy) { y = iy; }
00024     inline void SetZ(const float iz) { z = iz; }
00025     inline void ConvertToVector3( MercuryPoint & out ) const { out[0] = x; out[1] = y; out[2] = z; }
00026     inline void ConvertFromVector3( const MercuryPoint & in ) { x = in[0]; y = in[1]; z = in[2]; }
00027     inline MercuryPoint& GetPointHandle() { return *(MercuryPoint*)&x; }
00028 
00029     inline MercuryVertex& operator += ( const MercuryVertex& other ) { x+=other.x; y+=other.y; z+=other.z; return *this; }
00030     inline MercuryVertex& operator -= ( const MercuryVertex& other ) { x-=other.x; y-=other.y; z-=other.z; return *this; }
00031     inline MercuryVertex& operator *= ( float f ) { x*=f; y*=f; z*=f; return *this; }
00032     inline MercuryVertex& operator /= ( float f ) { x/=f; y/=f; z/=f; return *this; }
00033 
00034     inline MercuryVertex operator + ( const MercuryVertex& other ) const { return MercuryVertex( x+other.x, y+other.y, z+other.z, m_uv[0], m_uv[1] ); }
00035     inline MercuryVertex operator - ( const MercuryVertex& other ) const { return MercuryVertex( x-other.x, y-other.y, z-other.z, m_uv[0], m_uv[1] ); }
00036     inline MercuryVertex operator * ( float f ) const { return MercuryVertex( x*f, y*f, z*f, m_uv[0], m_uv[1] ); }
00037     inline MercuryVertex operator / ( float f ) const { return MercuryVertex( x/f, y/f, z/f, m_uv[0], m_uv[1] ); }
00038 
00039     MercuryVertex CrossProduct(const MercuryVertex& second);
00040 
00041     inline void GetUV(float* uv) const { uv[0] = m_uv[0]; uv[1] = m_uv[1]; }
00042     inline void SetUV(const float* uv) { m_uv[0] = uv[0]; m_uv[1] = uv[1]; }
00043     inline void SetU(const float u) { m_uv[0] = u; }
00044     inline void SetV(const float v) { m_uv[1] = v; }
00045     inline const MercuryNormal& GetNormal() const { return m_normal; }
00046 
00048     inline void GetNormal(MercuryNormal*& normal) { normal = &m_normal; }
00049 
00050     void SetNormal(MercuryNormal normal) { m_normal = normal; }
00051 
00052     /*  This must stay organized in this fashion so that we can quickly send
00053         data to OpenGL as a tightly packed interleaved arrays.
00054         u,v,n1,n2,n3,v1,v2,v3
00055     */
00056     float m_uv[2]; //Origional UV points.
00057     MercuryNormal m_normal;
00058 
00059     //as similar to a point as possible
00060     float x;
00061     float y;
00062     float z;
00063 } M_ALIGN(32);
00064 
00065 //This vertex wrapper will contain extra information needed for
00066 //things like normal recalculation
00067 struct MercuryVertWrapper
00068 {
00069     MDeque<MercuryPoly*> m_sharingPolys;
00070     MDequeIterator<MercuryPoly*> FindSharingPoly(MercuryPoly* p);
00071     MercuryVertex* m_vertex;
00072 };
00073 
00074 #endif
00075 
00076 /* 
00077  * Copyright (c) 2006 Joshua Allen
00078  * All rights reserved.
00079  *
00080  * Redistribution and use in source and binary forms, with or
00081  * without modification, are permitted provided that the following
00082  * conditions are met:
00083  *  -   Redistributions of source code must retain the above
00084  *      copyright notice, this list of conditions and the following disclaimer.
00085  *  -   Redistributions in binary form must reproduce the above copyright
00086  *      notice, this list of conditions and the following disclaimer in
00087  *      the documentation and/or other materials provided with the distribution.
00088  *  -   Neither the name of the Mercury Engine nor the names of its
00089  *      contributors may be used to endorse or promote products derived from
00090  *      this software without specific prior written permission.
00091  *
00092  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00093  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00094  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00095  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
00096  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00097  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00098  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00099  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00100  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00101  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00102  */
00103 

Hosted by SourceForge.net Logo