/// <summary> /// Create the textures for the avatar. If this is an LLEntityAvatar, extract the /// texture info from the avatar description and blindly create textures for the /// parts of the body in the order of the faces that were generated above. /// </summary> /// <param name="ent">The entity of the avatar being decorated</param> /// <param name="forceUpdateFlag">'true' if to force a redraw. If doing the initial /// creation, a redraw update is not necessary.</param> public bool CreateAvatarTextures(IEntity ent, bool forceUpdateFlag) { IEntityAvatar ientav; LLEntityAvatar entav; if (ent.TryGet<IEntityAvatar>(out ientav)) { if (ientav is LLEntityAvatar) { entav = (LLEntityAvatar)ientav; OMV.Avatar av = entav.Avatar; if (av != null && av.Textures != null) { OMV.Primitive.TextureEntry texEnt = av.Textures; OMV.Primitive.TextureEntryFace[] texFaces = texEnt.FaceTextures; const int genCount = 7; float[] textureParams = new float[1 + ((int)Ogr.CreateMaterialParam.maxParam) * genCount]; string[] materialNames = new string[genCount]; string[] textureOgreNames = new string[genCount]; textureParams[0] = (float)Ogr.CreateMaterialParam.maxParam; int[] texIndexes = { (int)OMV.AvatarTextureIndex.HeadBaked, (int)OMV.AvatarTextureIndex.UpperBaked, (int)OMV.AvatarTextureIndex.LowerBaked, (int)OMV.AvatarTextureIndex.EyesBaked, (int)OMV.AvatarTextureIndex.HairBaked, // (int)OMV.AvatarTextureIndex.SkirtBaked }; int pBase = 1; int jj = 0; string textureOgreName; foreach (int baker in texIndexes) { CreateMaterialParameters(texFaces[baker], ent, null, pBase, ref textureParams, jj, out textureOgreName); materialNames[jj] = EntityNameOgre.ConvertToOgreMaterialNameX(ent.Name, jj); textureOgreNames[jj] = textureOgreName; // m_log.Log(LogLevel.DRENDERDETAIL, "CreateAvatarTextures: mat={0}, tex={1}", // materialNames[jj], textureOgreName); /* // The textures for the baked avatar textures are processed specially // Here we request they be loaded (if not already available) so we can specify their type EntityNameOgre textureEnt = EntityNameOgre.ConvertOgreResourceToEntityName(textureOgreName); System.Drawing.Bitmap textureBitmap = ent.AssetContext.GetTexture(textureEnt); if (textureBitmap == null) { // texture is not immediately available. Ask for it in a special way ent.AssetContext.DoTextureLoad(textureEnt, AssetContextBase.AssetType.BakedTexture, delegate(string name, bool trans) { return; }); } */ pBase += (int)textureParams[0]; jj++; } m_log.Log(LogLevel.DRENDERDETAIL, "CreateAvatarTextures: materials for {0}", ent.Name); Ogr.CreateMaterialResource7BF(0f, materialNames[0], materialNames[0], materialNames[1], materialNames[2], materialNames[3], materialNames[4], materialNames[5], materialNames[6], textureOgreNames[0], textureOgreNames[1], textureOgreNames[2], textureOgreNames[3], textureOgreNames[4], textureOgreNames[5], textureOgreNames[6], textureParams ); } else { // the avatar is not initialized yet. Try again later. return false; } } else { m_log.Log(LogLevel.DBADERROR, "CreateAvatarTexture: REQUEST BUT NOT LLAVATAR"); } } else { string modNames = ""; foreach (string mod in ent.ModuleInterfaceTypeNames()) modNames += " " + mod; m_log.Log(LogLevel.DBADERROR, "CreateAvatarTexture: REQUEST FOR TEXTURES FOR NON LL ENTITY. Mod={0}", modNames); } return true; }