mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-04 21:10:32 +00:00
Added basic Walkabout with #define renamed and no editor.
This commit is contained in:
parent
c08413ffde
commit
f4c940f4fe
22 changed files with 3725 additions and 196 deletions
|
|
@ -1293,6 +1293,56 @@ bool River::collideBox(const Point3F &start, const Point3F &end, RayInfo* info)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool River::buildPolyList( PolyListContext context, AbstractPolyList* polyList, const Box3F& box, const SphereF& sphere )
|
||||
{
|
||||
Vector<const RiverSegment*> hitSegments;
|
||||
for ( U32 i = 0; i < mSegments.size(); i++ )
|
||||
{
|
||||
const RiverSegment &segment = mSegments[i];
|
||||
if ( segment.worldbounds.isOverlapped( box ) )
|
||||
{
|
||||
hitSegments.push_back( &segment );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !hitSegments.size() )
|
||||
return false;
|
||||
|
||||
polyList->setObject( this );
|
||||
polyList->setTransform( &MatrixF::Identity, Point3F( 1.0f, 1.0f, 1.0f ) );
|
||||
|
||||
for ( U32 i = 0; i < hitSegments.size(); i++ )
|
||||
{
|
||||
const RiverSegment* segment = hitSegments[i];
|
||||
for ( U32 k = 0; k < 2; k++ )
|
||||
{
|
||||
// gIdxArray[0] gives us the top plane (see table definition).
|
||||
U32 idx0 = gIdxArray[0][k][0];
|
||||
U32 idx1 = gIdxArray[0][k][1];
|
||||
U32 idx2 = gIdxArray[0][k][2];
|
||||
|
||||
const Point3F &v0 = (*segment)[idx0];
|
||||
const Point3F &v1 = (*segment)[idx1];
|
||||
const Point3F &v2 = (*segment)[idx2];
|
||||
|
||||
// Add vertices to poly list.
|
||||
U32 i0 = polyList->addPoint(v0);
|
||||
polyList->addPoint(v1);
|
||||
polyList->addPoint(v2);
|
||||
|
||||
// Add plane between them.
|
||||
polyList->begin(0, 0);
|
||||
polyList->vertex(i0);
|
||||
polyList->vertex(i0+1);
|
||||
polyList->vertex(i0+2);
|
||||
polyList->plane(i0, i0+1, i0+2);
|
||||
polyList->end();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
F32 River::getWaterCoverage( const Box3F &worldBox ) const
|
||||
{
|
||||
PROFILE_SCOPE( River_GetWaterCoverage );
|
||||
|
|
|
|||
|
|
@ -404,6 +404,7 @@ public:
|
|||
virtual bool castRay(const Point3F &start, const Point3F &end, RayInfo* info);
|
||||
virtual bool collideBox(const Point3F &start, const Point3F &end, RayInfo* info);
|
||||
virtual bool containsPoint( const Point3F& point ) const { return containsPoint( point, NULL ); }
|
||||
virtual bool buildPolyList( PolyListContext context, AbstractPolyList* polyList, const Box3F& box, const SphereF& sphere );
|
||||
|
||||
// WaterObject
|
||||
virtual F32 getWaterCoverage( const Box3F &worldBox ) const;
|
||||
|
|
|
|||
|
|
@ -652,6 +652,52 @@ bool WaterBlock::castRay( const Point3F &start, const Point3F &end, RayInfo *inf
|
|||
return mObjBox.isContained(info->point);
|
||||
}
|
||||
|
||||
bool WaterBlock::buildPolyList( PolyListContext context, AbstractPolyList* polyList, const Box3F& box, const SphereF& )
|
||||
{
|
||||
if(context == PLC_Navigation && box.isOverlapped(mWorldBox))
|
||||
{
|
||||
polyList->setObject( this );
|
||||
MatrixF mat(true);
|
||||
Point3F pos = getPosition();
|
||||
pos.x = pos.y = 0;
|
||||
mat.setPosition(pos);
|
||||
polyList->setTransform( &mat, Point3F(1, 1, 1) );
|
||||
|
||||
Box3F ov = box.getOverlap(mWorldBox);
|
||||
Point3F
|
||||
p0(ov.minExtents.x, ov.maxExtents.y, 0),
|
||||
p1(ov.maxExtents.x, ov.maxExtents.y, 0),
|
||||
p2(ov.maxExtents.x, ov.minExtents.y, 0),
|
||||
p3(ov.minExtents.x, ov.minExtents.y, 0);
|
||||
|
||||
// Add vertices to poly list.
|
||||
U32 v0 = polyList->addPoint(p0);
|
||||
polyList->addPoint(p1);
|
||||
polyList->addPoint(p2);
|
||||
polyList->addPoint(p3);
|
||||
|
||||
// Add plane between first three vertices.
|
||||
polyList->begin(0, 0);
|
||||
polyList->vertex(v0);
|
||||
polyList->vertex(v0+1);
|
||||
polyList->vertex(v0+2);
|
||||
polyList->plane(v0, v0+1, v0+2);
|
||||
polyList->end();
|
||||
|
||||
// Add plane between last three vertices.
|
||||
polyList->begin(0, 1);
|
||||
polyList->vertex(v0+2);
|
||||
polyList->vertex(v0+3);
|
||||
polyList->vertex(v0);
|
||||
polyList->plane(v0+2, v0+3, v0);
|
||||
polyList->end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
F32 WaterBlock::getWaterCoverage( const Box3F &testBox ) const
|
||||
{
|
||||
Box3F wbox = getWorldBox();
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@ public:
|
|||
virtual void inspectPostApply();
|
||||
virtual void setTransform( const MatrixF & mat );
|
||||
virtual void setScale( const Point3F &scale );
|
||||
virtual bool buildPolyList( PolyListContext context, AbstractPolyList* polyList, const Box3F& box, const SphereF& sphere );
|
||||
|
||||
// WaterObject
|
||||
virtual F32 getWaterCoverage( const Box3F &worldBox ) const;
|
||||
|
|
|
|||
|
|
@ -816,6 +816,48 @@ F32 WaterPlane::distanceTo( const Point3F& point ) const
|
|||
return ( point.z - getPosition().z );
|
||||
}
|
||||
|
||||
bool WaterPlane::buildPolyList( PolyListContext context, AbstractPolyList* polyList, const Box3F& box, const SphereF& )
|
||||
{
|
||||
if(context == PLC_Navigation)
|
||||
{
|
||||
polyList->setObject( this );
|
||||
polyList->setTransform( &MatrixF::Identity, Point3F( 1.0f, 1.0f, 1.0f ) );
|
||||
|
||||
F32 z = getPosition().z;
|
||||
Point3F
|
||||
p0(box.minExtents.x, box.maxExtents.y, z),
|
||||
p1(box.maxExtents.x, box.maxExtents.y, z),
|
||||
p2(box.maxExtents.x, box.minExtents.y, z),
|
||||
p3(box.minExtents.x, box.minExtents.y, z);
|
||||
|
||||
// Add vertices to poly list.
|
||||
U32 v0 = polyList->addPoint(p0);
|
||||
polyList->addPoint(p1);
|
||||
polyList->addPoint(p2);
|
||||
polyList->addPoint(p3);
|
||||
|
||||
// Add plane between first three vertices.
|
||||
polyList->begin(0, 0);
|
||||
polyList->vertex(v0);
|
||||
polyList->vertex(v0+1);
|
||||
polyList->vertex(v0+2);
|
||||
polyList->plane(v0, v0+1, v0+2);
|
||||
polyList->end();
|
||||
|
||||
// Add plane between last three vertices.
|
||||
polyList->begin(0, 1);
|
||||
polyList->vertex(v0+2);
|
||||
polyList->vertex(v0+3);
|
||||
polyList->vertex(v0);
|
||||
polyList->plane(v0+2, v0+3, v0);
|
||||
polyList->end();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void WaterPlane::inspectPostApply()
|
||||
{
|
||||
Parent::inspectPostApply();
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ public:
|
|||
virtual void inspectPostApply();
|
||||
virtual void setTransform( const MatrixF & mat );
|
||||
virtual F32 distanceTo( const Point3F& point ) const;
|
||||
virtual bool buildPolyList( PolyListContext context, AbstractPolyList* polyList, const Box3F& box, const SphereF& sphere );
|
||||
|
||||
// WaterObject
|
||||
virtual F32 getWaterCoverage( const Box3F &worldBox ) const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue