private void RenderTerrain(RegionContextBase rcontext, RegionRenderInfo rri)
        {
            GL.PushMatrix();

            // if the terrain has changed,
            if (rri.refreshTerrain)
            {
                rri.refreshTerrain = false;
                UpdateRegionTerrainMesh(rcontext, rri);
            }

            // apply region offset
            GL.MultMatrix(Math3D.CreateTranslationMatrix(CalcRegionOffset(rcontext)));

            // everything built. Display the terrain
            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.TextureCoordArray);
            GL.EnableClientState(ArrayCap.NormalArray);

            GL.TexCoordPointer(2, TexCoordPointerType.Float, 0, rri.terrainTexCoord);
            GL.VertexPointer(3, VertexPointerType.Float, 0, rri.terrainVertices);
            GL.NormalPointer(NormalPointerType.Float, 0, rri.terrainNormal);
            GL.DrawElements(BeginMode.Quads, rri.terrainIndices.Length, DrawElementsType.UnsignedShort, rri.terrainIndices);

            GL.PopMatrix();
        }
        private void RenderAvatars(RegionContextBase rcontext, RegionRenderInfo rri)
        {
            OMV.Vector3 avatarColor        = ModuleParams.ParamVector3(m_renderer.m_moduleName + ".OGL.Avatar.Color");
            float       avatarTransparancy = ModuleParams.ParamFloat(m_renderer.m_moduleName + ".OGL.Avatar.Transparancy");

            float[] m_avatarMaterialColor = { avatarColor.X, avatarColor.Y, avatarColor.Z, avatarTransparancy };

            lock (rri.renderAvatarList) {
                foreach (RenderableAvatar rav in rri.renderAvatarList.Values)
                {
                    GL.PushMatrix();
                    GL.Translate(rav.avatar.RegionPosition.X,
                                 rav.avatar.RegionPosition.Y,
                                 rav.avatar.RegionPosition.Z);

                    GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Diffuse, m_avatarMaterialColor);
                    GL.Disable(EnableCap.Texture2D);
                    Glu.GLUquadric quad = Glu.gluNewQuadric();
                    Glu.gluSphere(quad, 0.5d, 10, 10);
                    Glu.gluDeleteQuadric(quad);

                    GL.PopMatrix();
                }
            }
        }
Exemplo n.º 3
0
        // something about the terrain has changed, do some updating
        public void UpdateTerrain(RegionContextBase rcontext)
        {
            RegionRenderInfo rri = GetRegionRenderInfo(rcontext);

            // making this true will case the low level renderer to rebuild the terrain
            rri.refreshTerrain = true;
            return;
        }
        private void RenderOcean(RegionContextBase rcontext, RegionRenderInfo rri)
        {
            GL.PushMatrix();

            // apply region offset
            GL.MultMatrix(Math3D.CreateTranslationMatrix(CalcRegionOffset(rcontext)));

            GL.PopMatrix();
            return;
        }
Exemplo n.º 5
0
        // rendering specific information for placing in  the view
        public void MapRegionIntoView(RegionContextBase rcontext)
        {
            if (!m_trackedRegions.Contains(rcontext))
            {
                m_trackedRegions.Add(rcontext);
            }
            // get the render info block to create it if it doesn't exist
            RegionRenderInfo rri = GetRegionRenderInfo(rcontext);

            return;
        }
        /// <summary>
        /// Create the animation. The passed animation block is expected
        /// to contain a defintion of a fixed rotation. If not, bad things will happen.
        /// </summary>
        /// <param name="anim">The IAnimation block with the info.</param>
        /// <param name="id">localID to lookup the prim in the RegionRenderInfo.renderPrimList</param>
        public AnimatPosition(OMV.Vector3 newPos, float durationSeconds, RegionRenderInfo rri, uint id)
            : base(AnimatBase.AnimatTypePosition)
        {
            m_infoID = id;
            RenderablePrim rp = rri.renderPrimList[id];

            m_origionalPosition = rp.Position;
            m_targetPosition    = newPos;
            m_durationSeconds   = durationSeconds;
            m_distanceVector    = m_targetPosition - m_origionalPosition;
            m_progress          = 0f;
        }
 private void ComputeVisibility(RegionContextBase rcontext, RegionRenderInfo rri)
 {
     m_renderer.Camera.ComputeFrustum();
     lock (rri.renderPrimList) {
         foreach (uint ind in rri.renderPrimList.Keys)
         {
             RenderablePrim rp = rri.renderPrimList[ind];
             rp.isVisible = m_renderer.Camera.isVisible(rp.Position.X, rp.Position.Y, rp.Position.Z, 10f);
         }
     }
     return;
 }
Exemplo n.º 8
0
        // create and initialize the renderinfoblock
        private RegionRenderInfo GetRegionRenderInfo(RegionContextBase rcontext)
        {
            RegionRenderInfo ret = null;

            if (!rcontext.TryGet <RegionRenderInfo>(out ret))
            {
                ret = new RegionRenderInfo();
                rcontext.RegisterInterface <RegionRenderInfo>(ret);
                ret.oceanHeight = rcontext.TerrainInfo.WaterHeight;
            }
            return(ret);
        }
        /// <summary>
        /// Called for each frame. Advance the position.
        /// </summary>
        /// <param name="timeSinceLastFrame">seconds since last frame display</param>
        /// <param name="rri">RegionRenderInfo for region the animation is in</param>
        /// <returns>true to say we never exit</returns>
        public override bool Process(float timeSinceLastFrame, RegionRenderInfo rri)
        {
            bool  ret          = true;
            float thisProgress = timeSinceLastFrame / m_durationSeconds;

            m_progress += thisProgress;
            RenderablePrim rp = rri.renderPrimList[m_infoID];

            if (m_progress >= 1f)
            {
                // if progressed all the way, we're at the destination
                rp.Position = m_targetPosition;
                ret         = false; // we're done animating
            }
            else
            {
                // only part way there
                rp.Position = m_origionalPosition + m_distanceVector * m_progress;
            }
            return(ret);
        }
        /// <summary>
        /// Called for each frame. Advance the rotation.
        /// </summary>
        /// <param name="timeSinceLastFrame">seconds since last frame display</param>
        /// <param name="rri">RegionRenderInfo for region the animation is in</param>
        /// <returns>true to say we never exit</returns>
        public override bool Process(float timeSinceLastFrame, RegionRenderInfo rri)
        {
            float nextStep      = m_rotationsPerSecond * timeSinceLastFrame;
            float nextIncrement = Constants.TWOPI * nextStep;

            while (nextIncrement > Constants.TWOPI)
            {
                nextIncrement -= Constants.TWOPI;
            }
            OMV.Quaternion newRotation = OMV.Quaternion.CreateFromAxisAngle(m_rotationAxis, nextIncrement);
            lock (rri) {
                try {
                    RenderablePrim rp = rri.renderPrimList[m_infoID];
                    rp.Rotation = newRotation * rp.Rotation;
                }
                catch (Exception e) {
                    LogManager.Log.Log(LogLevel.DBADERROR, "Did not find prim for FixedRotation: {0}", e);
                }
            }
            return(true);        // we never exit
        }
Exemplo n.º 11
0
 /// <summary>
 /// Loop through the list of animations for this region and call their "Process" routines
 /// </summary>
 /// <param name="timeSinceLastFrame">seconds since list frame</param>
 /// <param name="rri">RegionRenderInfo for the region</param>
 public static void ProcessAnimations(float timeSinceLastFrame, RegionRenderInfo rri)
 {
     lock (rri) {
         List <AnimatBase> removeAnimations = new List <AnimatBase>();
         foreach (AnimatBase ab in rri.animations)
         {
             try {
                 if (!ab.Process(timeSinceLastFrame, rri))
                 {
                     removeAnimations.Add(ab);   // remember so we can remove later
                 }
             }
             catch {
             }
         }
         // since we can't remove animations while interating the list, do it now
         foreach (AnimatBase ab in removeAnimations)
         {
             rri.animations.Remove(ab);
         }
     }
 }
Exemplo n.º 12
0
 public virtual bool Process(float timeSinceLastFrame, RegionRenderInfo rri)
 {
     return(false);   // false saying to delete
 }
        //int[] CubeMapDefines = new int[]
        //{
        //    Gl.GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
        //    Gl.GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB,
        //    Gl.GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB,
        //    Gl.GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB,
        //    Gl.GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB,
        //    Gl.GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB
        //};

        private void RenderPrims(RegionContextBase rcontext, RegionRenderInfo rri)
        {
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.Texture2D);

            lock (rri.renderPrimList) {
                bool firstPass = true;
                // GL.Disable(EnableCap.Blend);
                GL.Enable(EnableCap.Blend);
                GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
                GL.Enable(EnableCap.DepthTest);

                GL.Enable(EnableCap.Normalize);

                GL.EnableClientState(ArrayCap.TextureCoordArray);
                GL.EnableClientState(ArrayCap.VertexArray);
                GL.EnableClientState(ArrayCap.NormalArray);


StartRender:

                List <RenderablePrim> rpList = new List <RenderablePrim>(rri.renderPrimList.Values);
                // sort back to front
                rpList.Sort(delegate(RenderablePrim rp1, RenderablePrim rp2) {
                    return((int)(((OMV.Vector3.Distance(m_renderer.Camera.Position, rp1.Prim.Position)) -
                                  (OMV.Vector3.Distance(m_renderer.Camera.Position, rp2.Prim.Position))) * 100f));
                });
                foreach (RenderablePrim rp in rpList)
                {
                    // if this prim is not visible, just loop
                    if (!rp.isVisible)
                    {
                        continue;
                    }

                    RenderablePrim prp  = RenderablePrim.Empty;
                    OMV.Primitive  prim = rp.Prim;

                    if (prim.ParentID != 0)
                    {
                        // Get the parent reference
                        if (!rri.renderPrimList.TryGetValue(prim.ParentID, out prp))
                        {
                            // Can't render a child with no parent prim, skip it
                            continue;
                        }
                    }

                    GL.PushName(prim.LocalID);
                    GL.PushMatrix();

                    if (prim.ParentID != 0)
                    {
                        // Apply parent translation and rotation
                        GL.MultMatrix(Math3D.CreateTranslationMatrix(prp.Position));
                        GL.MultMatrix(Math3D.CreateRotationMatrix(prp.Rotation));
                    }

                    // Apply prim translation and rotation
                    GL.MultMatrix(Math3D.CreateTranslationMatrix(rp.Position));
                    // apply region offset for multiple regions
                    GL.MultMatrix(Math3D.CreateTranslationMatrix(CalcRegionOffset(rp.rcontext)));
                    GL.MultMatrix(Math3D.CreateRotationMatrix(rp.Rotation));

                    // Scale the prim
                    GL.Scale(prim.Scale.X, prim.Scale.Y, prim.Scale.Z);

                    // Draw the prim faces
                    for (int j = 0; j < rp.Mesh.Faces.Count; j++)
                    {
                        OMVR.Face  face      = rp.Mesh.Faces[j];
                        FaceData   data      = (FaceData)face.UserData;
                        OMV.Color4 color     = face.TextureFace.RGBA;
                        bool       alpha     = false;
                        int        textureID = 0;

                        if (color.A < 1.0f)
                        {
                            alpha = true;
                        }

                        TextureInfo info;
                        if (face.TextureFace.TextureID != OMV.UUID.Zero &&
                            face.TextureFace.TextureID != OMV.Primitive.TextureEntry.WHITE_TEXTURE &&
                            m_renderer.Textures.TryGetValue(face.TextureFace.TextureID, out info))
                        {
                            if (info.Alpha)
                            {
                                alpha = true;
                            }

                            textureID = info.ID;
                            // if textureID has not been set, need to generate the mipmaps
                            if (textureID == 0)
                            {
                                GenerateMipMaps(rp.acontext, face.TextureFace.TextureID, out textureID);
                                info.ID = textureID;
                            }

                            // Enable texturing for this face
                            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
                        }
                        else
                        {
                            if (face.TextureFace.TextureID == OMV.Primitive.TextureEntry.WHITE_TEXTURE ||
                                face.TextureFace.TextureID == OMV.UUID.Zero)
                            {
                                GL.PolygonMode(MaterialFace.Front, PolygonMode.Fill);
                            }
                            else
                            {
                                GL.PolygonMode(MaterialFace.Front, PolygonMode.Line);
                            }
                        }

                        // if (firstPass && !alpha || !firstPass && alpha) {
                        // GL.Color4(color.R, color.G, color.B, color.A);
                        float[] matDiffuse = { color.R, color.G, color.B, color.A };
                        GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Diffuse, matDiffuse);

                        // Bind the texture
                        if (textureID != 0)
                        {
                            GL.Enable(EnableCap.Texture2D);
                            GL.BindTexture(TextureTarget.Texture2D, textureID);
                        }
                        else
                        {
                            GL.Disable(EnableCap.Texture2D);
                        }

                        GL.TexCoordPointer(2, TexCoordPointerType.Float, 0, data.TexCoords);
                        GL.VertexPointer(3, VertexPointerType.Float, 0, data.Vertices);
                        GL.NormalPointer(NormalPointerType.Float, 0, data.Normals);
                        GL.DrawElements(BeginMode.Triangles, data.Indices.Length, DrawElementsType.UnsignedShort, data.Indices);
                        // }
                    }

                    GL.PopMatrix();
                    GL.PopName();
                }

                /*
                 * if (firstPass) {
                 *  firstPass = false;
                 *  GL.Enable(EnableCap.Blend);
                 *  GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
                 *  // GL.Disable(EnableCap.DepthTest);
                 *
                 *  goto StartRender;
                 * }
                 */
            }

            GL.Enable(EnableCap.DepthTest);
            GL.Disable(EnableCap.Texture2D);
        }
        private void UpdateRegionTerrainMesh(RegionContextBase rcontext, RegionRenderInfo rri)
        {
            TerrainInfoBase ti = rcontext.TerrainInfo;

            rri.terrainVertices = new float[3 * ti.HeightMapLength * ti.HeightMapWidth];
            rri.terrainTexCoord = new float[2 * ti.HeightMapLength * ti.HeightMapWidth];
            rri.terrainNormal   = new float[3 * ti.HeightMapLength * ti.HeightMapWidth];
            int nextVert = 0;
            int nextTex  = 0;
            int nextNorm = 0;

            for (int xx = 0; xx < ti.HeightMapLength; xx++)
            {
                for (int yy = 0; yy < ti.HeightMapWidth; yy++)
                {
                    rri.terrainVertices[nextVert + 0] = (float)xx / ti.HeightMapLength * rcontext.Size.X;
                    rri.terrainVertices[nextVert + 1] = (float)yy / ti.HeightMapWidth * rcontext.Size.Y;
                    rri.terrainVertices[nextVert + 2] = ti.HeightMap[xx, yy];
                    nextVert += 3;
                    rri.terrainTexCoord[nextTex + 0] = xx / ti.HeightMapLength;
                    rri.terrainTexCoord[nextTex + 1] = yy / ti.HeightMapWidth;
                    nextTex += 2;
                    rri.terrainNormal[nextNorm + 0] = 0f; // simple normal pointing up
                    rri.terrainNormal[nextNorm + 1] = 1f;
                    rri.terrainNormal[nextNorm + 2] = 0f;
                    nextNorm += 3;
                }
            }
            // Create the quads which make up the terrain
            rri.terrainIndices = new UInt16[4 * ti.HeightMapLength * ti.HeightMapWidth];
            int nextInd = 0;

            for (int xx = 0; xx < ti.HeightMapLength - 1; xx++)
            {
                for (int yy = 0; yy < ti.HeightMapWidth - 1; yy++)
                {
                    rri.terrainIndices[nextInd + 0] = (UInt16)((yy + 0) + (xx + 0) * ti.HeightMapLength);
                    rri.terrainIndices[nextInd + 1] = (UInt16)((yy + 1) + (xx + 0) * ti.HeightMapLength);
                    rri.terrainIndices[nextInd + 2] = (UInt16)((yy + 1) + (xx + 1) * ti.HeightMapLength);
                    rri.terrainIndices[nextInd + 3] = (UInt16)((yy + 0) + (xx + 1) * ti.HeightMapLength);
                    nextInd += 4;
                }
            }
            rri.terrainWidth  = ti.HeightMapWidth;
            rri.terrainLength = ti.HeightMapLength;

            // Calculate normals
            // Take three corners of each quad and calculate the normal for the vector
            //   a--b--e--...
            //   |  |  |
            //   d--c--h--...
            // The triangle a-b-d calculates the normal for a, etc
            int nextQuad = 0;
            int nextNrm  = 0;

            for (int xx = 0; xx < ti.HeightMapLength - 1; xx++)
            {
                for (int yy = 0; yy < ti.HeightMapWidth - 1; yy++)
                {
                    OMV.Vector3 aa, bb, cc;
                    int         offset = rri.terrainIndices[nextQuad + 0] * 3;
                    aa.X   = rri.terrainVertices[offset + 0];
                    aa.Y   = rri.terrainVertices[offset + 1];
                    aa.Z   = rri.terrainVertices[offset + 2];
                    offset = rri.terrainIndices[nextQuad + 1] * 3;
                    bb.X   = rri.terrainVertices[offset + 0];
                    bb.Y   = rri.terrainVertices[offset + 1];
                    bb.Z   = rri.terrainVertices[offset + 2];
                    offset = rri.terrainIndices[nextQuad + 3] * 3;
                    cc.X   = rri.terrainVertices[offset + 0];
                    cc.Y   = rri.terrainVertices[offset + 1];
                    cc.Z   = rri.terrainVertices[offset + 2];
                    OMV.Vector3 mm        = aa - bb;
                    OMV.Vector3 nn        = aa - cc;
                    OMV.Vector3 theNormal = -OMV.Vector3.Cross(mm, nn);
                    theNormal.Normalize();
                    rri.terrainNormal[nextNrm + 0] = theNormal.X; // simple normal pointing up
                    rri.terrainNormal[nextNrm + 1] = theNormal.Y;
                    rri.terrainNormal[nextNrm + 2] = theNormal.Z;
                    nextNrm  += 3;
                    nextQuad += 4;
                }
                rri.terrainNormal[nextNrm + 0] = 1.0f;
                rri.terrainNormal[nextNrm + 1] = 0.0f;
                rri.terrainNormal[nextNrm + 2] = 0.0f;
                nextNrm += 3;
            }
        }
 private void RenderAnimations(float timeSinceLastFrame, RegionContextBase rcontext, RegionRenderInfo rri)
 {
     AnimatBase.ProcessAnimations(timeSinceLastFrame, rri);
 }
Exemplo n.º 16
0
        private void CreateNewPrim(LLEntityBase ent)
        {
            m_log.Log(LogLevel.DRENDERDETAIL, "Create new prim {0}", ent.Name.Name);
            // entity render info is kept per region. Get the region prim structure
            RegionRenderInfo rri = GetRegionRenderInfo(ent.RegionContext);
            IEntityAvatar    av;

            if (ent.TryGet <IEntityAvatar>(out av))
            {
                // if this entity is an avatar, just put it on the display list
                lock (rri.renderAvatarList) {
                    if (!rri.renderAvatarList.ContainsKey(av.LGID))
                    {
                        RenderableAvatar ravv = new RenderableAvatar();
                        ravv.avatar = av;
                        rri.renderAvatarList.Add(av.LGID, ravv);
                    }
                }
                return;
            }
            OMV.Primitive prim = ent.Prim;

            /* don't do foliage yet
             * if (prim.PrimData.PCode == OMV.PCode.Grass
             || prim.PrimData.PCode == OMV.PCode.Tree
             || prim.PrimData.PCode == OMV.PCode.NewTree) {
             || lock (renderFoliageList)
             ||     renderFoliageList[prim.LocalID] = prim;
             || return;
             ||}
             */

            RenderablePrim render = new RenderablePrim();

            render.Prim      = prim;
            render.acontext  = ent.AssetContext;
            render.rcontext  = ent.RegionContext;
            render.Position  = prim.Position;
            render.Rotation  = prim.Rotation;
            render.isVisible = true; // initially assume visible

            if (m_meshMaker == null)
            {
                m_meshMaker = new Renderer.Mesher.MeshmerizerR();
                m_meshMaker.ShouldScaleMesh = false;
            }

            if (prim.Sculpt != null)
            {
                EntityNameLL          textureEnt    = EntityNameLL.ConvertTextureWorldIDToEntityName(ent.AssetContext, prim.Sculpt.SculptTexture);
                System.Drawing.Bitmap textureBitmap = ent.AssetContext.GetTexture(textureEnt);
                if (textureBitmap == null)
                {
                    // the texture is not available. Request it.
                    // Note that we just call this routine again when it is available. Hope it's not recursive
                    ent.AssetContext.DoTextureLoad(textureEnt, AssetContextBase.AssetType.SculptieTexture,
                                                   delegate(string name, bool trans) {
                        CreateNewPrim(ent);
                        return;
                    }
                                                   );
                    return;
                }
                render.Mesh = m_meshMaker.GenerateSculptMesh(textureBitmap, prim, OMVR.DetailLevel.Medium);
                textureBitmap.Dispose();
            }
            else
            {
                render.Mesh = m_meshMaker.GenerateFacetedMesh(prim, OMVR.DetailLevel.High);
            }

            if (render.Mesh == null)
            {
                // mesh generation failed
                m_log.Log(LogLevel.DBADERROR, "FAILED MESH GENERATION: not generating new prim {0}", ent.Name.Name);
                return;
            }

            // Create a FaceData struct for each face that stores the 3D data
            // in an OpenGL friendly format
            for (int j = 0; j < render.Mesh.Faces.Count; j++)
            {
                OMVR.Face face = render.Mesh.Faces[j];
                FaceData  data = new FaceData();

                // Vertices for this face
                data.Vertices = new float[face.Vertices.Count * 3];
                for (int k = 0; k < face.Vertices.Count; k++)
                {
                    data.Vertices[k * 3 + 0] = face.Vertices[k].Position.X;
                    data.Vertices[k * 3 + 1] = face.Vertices[k].Position.Y;
                    data.Vertices[k * 3 + 2] = face.Vertices[k].Position.Z;
                }

                // Indices for this face
                data.Indices = face.Indices.ToArray();

                // Texture transform for this face
                OMV.Primitive.TextureEntryFace teFace = prim.Textures.GetFace((uint)j);
                m_meshMaker.TransformTexCoords(face.Vertices, face.Center, teFace);

                // Texcoords for this face
                data.TexCoords = new float[face.Vertices.Count * 2];
                for (int k = 0; k < face.Vertices.Count; k++)
                {
                    data.TexCoords[k * 2 + 0] = face.Vertices[k].TexCoord.X;
                    data.TexCoords[k * 2 + 1] = face.Vertices[k].TexCoord.Y;
                }

                data.Normals = new float[face.Vertices.Count * 3];
                for (int k = 0; k < face.Vertices.Count; k++)
                {
                    data.Normals[k * 3 + 0] = face.Vertices[k].Normal.X;
                    data.Normals[k * 3 + 1] = face.Vertices[k].Normal.Y;
                    data.Normals[k * 3 + 2] = face.Vertices[k].Normal.Z;
                }


                // m_log.Log(LogLevel.DRENDERDETAIL, "CreateNewPrim: v={0}, i={1}, t={2}",
                //     data.Vertices.GetLength(0), data.Indices.GetLength(0), data.TexCoords.GetLength(0));

                // Texture for this face
                if (teFace.TextureID != OMV.UUID.Zero &&
                    teFace.TextureID != OMV.Primitive.TextureEntry.WHITE_TEXTURE)
                {
                    lock (Textures) {
                        if (!Textures.ContainsKey(teFace.TextureID))
                        {
                            // temporarily add the entry to the table so we don't request it multiple times
                            Textures.Add(teFace.TextureID, new TextureInfo(0, true));
                            // We haven't constructed this image in OpenGL yet, get ahold of it
                            AssetContextBase.RequestTextureLoad(
                                EntityNameLL.ConvertTextureWorldIDToEntityName(ent.AssetContext, teFace.TextureID),
                                AssetContextBase.AssetType.Texture,
                                OnTextureDownloadFinished);
                        }
                    }
                }

                // Set the UserData for this face to our FaceData struct
                face.UserData        = data;
                render.Mesh.Faces[j] = face;
            }

            lock (rri.renderPrimList) {
                rri.renderPrimList[prim.LocalID] = render;
            }
        }