// NeL - MMORPG Framework
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see .
#ifndef NL_UV_H
#define NL_UV_H
#include "types_nl.h"
#include "stream.h"
namespace NLMISC
{
// ***************************************************************************
/**
* 2d UV.
*
*/
/* *** IMPORTANT ********************
* *** IF YOU MODIFY THE STRUCTURE OF THIS CLASS, PLEASE INCREMENT IDriver::InterfaceVersion TO INVALIDATE OLD DRIVER DLL
* **********************************
*/
class CUV
{
public:
float U,V;
public:
CUV() {}
CUV(float u, float v) : U(u), V(v) {}
// modify uv's
void set(float u, float v) { U = u; V = v; }
// bin operators.
CUV operator+(const CUV &v) const
{ return CUV(U+v.U, V+v.V);}
// binary -
CUV operator-(const CUV &v) const
{ return CUV(U-v.U, V-v.V);}
// unary -
CUV operator-() const
{ return CUV(-U, -V); }
// = operators.
CUV &operator*=(float f)
{ U*=f;V*=f; return *this;}
CUV &operator+=(const CUV &v)
{ U+=v.U;V+=v.V; return *this;}
CUV &operator-=(const CUV &v)
{ U-=v.U;V-=v.V; return *this;}
/// This operator is here just for map/set insertion (no meaning). comparison order is U,V.
bool operator<(const CUV &o) const
{
if(U!=o.U)
return U