mirror of
https://github.com/tribes2/engine.git
synced 2026-03-25 23:29:13 +00:00
t2 engine svn checkout
This commit is contained in:
commit
ff569bd2ae
988 changed files with 394180 additions and 0 deletions
61
math/mQuadPatch.cc
Normal file
61
math/mQuadPatch.cc
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// V12 Engine
|
||||
//
|
||||
// Copyright (c) 2001 GarageGames.Com
|
||||
// Portions Copyright (c) 2001 by Sierra Online, Inc.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "Math/mQuadPatch.h"
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
// Quadratic spline patch
|
||||
//******************************************************************************
|
||||
QuadPatch::QuadPatch()
|
||||
{
|
||||
setNumReqControlPoints(3);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
void QuadPatch::calcABC( const Point3F *points )
|
||||
{
|
||||
a = points[2] - points[1];
|
||||
b = points[1] - points[0];
|
||||
c = points[0];
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
void QuadPatch::submitControlPoints( SplCtrlPts &points )
|
||||
{
|
||||
Parent::submitControlPoints( points );
|
||||
calcABC( points.getPoint(0) );
|
||||
};
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
void QuadPatch::setControlPoint( Point3F &point, int index )
|
||||
{
|
||||
( (SplCtrlPts*) getControlPoints() )->setPoint( point, index );
|
||||
calcABC( getControlPoint(0) );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
void QuadPatch::calc( F32 t, Point3F &result )
|
||||
{
|
||||
F32 t2 = t*t;
|
||||
result = a*t2 + b*t + c;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//------------------------------------------------------------------------------
|
||||
void QuadPatch::calc( Point3F *points, F32 t, Point3F &result )
|
||||
{
|
||||
calcABC( points );
|
||||
calc( t, result );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue