Bool MeshEnt::SelectFace( U16 index, Bool append) // = FALSE) { if (!selData) { selData = new SelectData; } if (!append) { selData->faces.DisposeAll(); selData->verts.DisposeAll(); } List<U16>::Iterator vi( &selData->faces); U16 * ii; while ((ii = vi++) != NULL) { if (*ii == index) { break; } } if (ii) { return FALSE; } selData->faces.Append( new U16( index)); FaceObj &face = RootPriv().faces[index]; U32 j; for (j = 0; j < 3; j++) { selData->verts.Append( new U16( face.verts[j])); } return TRUE; }
void MeshEnt::UnSelectFaces( Area<S32> * rect) // = NULL { if (!selData) { return; } MeshRoot & root = RootPriv(); if (!rect) { selData->verts.DisposeAll(); selData->faces.DisposeAll(); } else { // get temp memory Vector * verts; U8 * hits; U32 heapSize = Vid::Heap::ReqVector( &verts, root.vertices.count, &hits, root.vertices.count); Utils::Memset( hits, 0, root.vertices.count); // set up transform matrices and transform verts to view space Matrix tranys[MAXMESHPERGROUP]; Bool doMultiWeight = (root.rootControlFlags & controlMULTIWEIGHT) && Vid::renderState.status.multiWeight ? TRUE : FALSE; root.SetVertsView( statesR, tranys, verts, root.vertices.count, doMultiWeight); // transform verts and clip in Z // U16 i, j; for (i = 0; i < root.faces.count; i++) { FaceObj &face = root.faces[i]; BucketLock &bucky = buckys[face.buckyIndex]; if (!(bucky.flags0 & RS_2SIDED)) { // backface cull // Plane plane; plane.Set( verts[face.verts[0]], verts[face.verts[2]], verts[face.verts[1]]); if (plane.Dot( verts[face.verts[0]]) <= 0.0f) { continue; } } for (j = 0; j < 3; j++) { Vector & vect = verts[face.verts[j]]; if (vect.z < Vid::Math::nearPlane || vect.z >= Vid::Math::farPlane) { // done or 3D clip continue; } // project // VertexTL v; Vid::ProjectFromCamera_I( v, vect); if (v.vv.x >= rect->p0.x && v.vv.x < rect->p1.x && v.vv.y >= rect->p0.y && v.vv.y < rect->p1.y) { // if a vert is inside the on screen box // UnSelectFace( i); break; } } } Vid::Heap::Restore( heapSize); } }
void MeshEnt::RenderPlaneBuildEffect() { MeshPlaneBuild * fx = (MeshPlaneBuild *)effect; MeshPlaneType * type = fx->GetType(); const Bounds & bounds = fx->bounds; Vector o; WorldMatrixRender().Transform( o, fx->origin); Vector v0, v1, v2; if (type->data.vector.y) { v0.Set( o.x - 1, o.y, o.z); v1.Set( o.x, o.y, o.z - 1); v2.Set( o.x + 1, o.y, o.z + 1); if (!fx->planeEnt && this == fx->Ent()) { if (type->data.root) { Matrix m = WorldMatrixRender(); Matrix r( Quaternion( PI * .5f, Vector( 1, 0, 0))); m = m * r; m.SetScale( Vector( bounds.Width(), bounds.Height(), bounds.Breadth())); m.posit = o; type->data.root->TexAnim(); type->data.root->RenderColor( m, fx->colorAnim.Current().color); } else if (type->data.texture) { Vid::RenderFlareSprite( TRUE, o, bounds.Radius(), type->data.texture, fx->colorAnim.Current().color, type->data.blend); } } } else if (type->data.vector.z) { v0.Set( o.x - 1, o.y, o.z); v1.Set( o.x, o.y + 1, o.z); v2.Set( o.x + 1, o.y - 1, o.z); if (!fx->planeEnt && type->data.root && this == fx->Ent()) { if (type->data.root) { Matrix m = WorldMatrixRender(); m.SetScale( Vector( bounds.Width(), bounds.Height(), bounds.Breadth())); m.posit = o; type->data.root->TexAnim( &type->data.root->groups, FALSE); type->data.root->RenderColor( m, fx->colorAnim.Current().color); } else if (type->data.texture) { Vid::RenderFlareSprite( TRUE, o, bounds.Radius(), type->data.texture, fx->colorAnim.Current().color, type->data.blend); } } } else { v0.Set( o.x - 1, o.y, o.z); v1.Set( o.x, o.y, o.z - 1); v2.Set( o.x + 1, o.y, o.z + 1); } Vid::Clip::Xtra::Set( v0, v1, v2 ); if ((clipFlagCache |= Vid::Clip::Xtra::BoundsTest( viewOrigin, bounds.Radius())) != clipOUTSIDE) { F32 t = fx->paramAnim.Current().scale; if (fmod(t, 2.0f) >= 1) { // viewOrigin is setup by Camera::BoundsTest( MeshEnt *) Vid::SetTranBucketZ( viewOrigin.z, Vid::sortEFFECT0); Vid::SetWorldTransform( statesR[0].WorldMatrix()); Vid::Clip::Xtra::clipColor = type->data.color; RootPriv().RenderWireframe( statesR, teamColor, type->data.blend, clipFlagCache); Vid::Clip::Xtra::clipColor = 0; effecting = TRUE; } else { Vid::Clip::Xtra::Invert(); Vid::Clip::Xtra::clipColor = type->data.color; Vid::SetTranBucketZ( viewOrigin.z, Vid::sortEFFECT0); Vid::SetWorldTransform( statesR[0].WorldMatrix()); Color c = teamColor; c.a = 222; RootPriv().RenderWireframe( statesR, c, type->data.blend, clipFlagCache); Vid::Clip::Xtra::clipColor = 0; Vid::Clip::Xtra::Invert(); effecting = FALSE; // call the base render // render over wireframe (this->*renderProcSave)(); } } Vid::Clip::Xtra::Clear(); Vid::Heap::Check(); }