public static ILrentObject addXMSH(string xmsh, string xcol, API_Device D, Vector3 pos, Quaternion rot, LrentFile z_File, bool a_Notify = true) { eCFile F = new eCFile(FileManager.GetFile("resources/emptyLevelEntity.bin")); eCDynamicEntity E = new eCDynamicEntity(F); E.GUID.Value = Guid.NewGuid(); EFile e0 = FileManager.GetFile(xmsh); //string x = FileManager.mapFilename(xmsh), x2 = FileManager.mapFilename(xcol); string x = "#G3:/" + xmsh, x2 = "#G3:/" + xcol; E.Name.pString = e0.Name.Replace(e0.Extension, "");//xmsh.Replace("._xmsh", "") //@"#G3:/data/raw/meshes/World//" + (E["eCMesh_PS"].Properties["MeshFileName"].Object as bCString).pString = x; E.Query<eCCollisionShape_PS>()[0].SetXColMesh(x2);//DonCamp_01_L01_COL._xcom E.Query<eCCollisionShape_PS>()[1].SetXColMesh(x2); ILrentObject O = new ILrentObject(z_File, E); O.LoadModels(D); E.ApplyBoundingVolume(GENOMEMath.toGENOME(O.Nodes[0].BoundingBox)); O.File.UpdateContextBox(); O.File.addObject(O); O.Position = pos; O.Rotation = rot; if(a_Notify) RisenWorld.OnEntityAdded(O); return O; }
/// <summary> /// /// </summary> /// <param name="json"></param> /// <returns></returns> public static String APIDevaiceDataResponse(API_Device json) { n = DateTime.Now; requestTime = n.ToString("yyyy-MM-ddTHH:mm:ss+9:00"); if (requestTime.Length < 24) { requestTime = String.Format("{0:0000}-{1:00}-{2:00}T{3:00}:{4:00}:{5:00}+9:00", n.Year, n.Month, n.Day, n.Hour, n.Minute, n.Second); } var _n = GetUnixTime(n); var nonce = GetNonce(_n); var digest = GetDigest(hex, requestTime, api_Pass, access_Key); var wsse = String.Format("UsernameToken Username={0}, PasswordDigest={1}, Nonce={2}, Created={3}", api_Id, digest, nonce, requestTime); //if (!IP.StartsWith("http")) //{ // IP = "http://" + IP; //} //var url = IP + "/WebAPI/guidance_send.php"; var url = URL; var req = System.Net.HttpWebRequest.Create(url); req.Method = "POST"; req.Headers.Add("x-wsse", wsse); req.ContentType = "application/x-www-form-urlencoded"; try { DataContractJsonSerializer jsonSer = new DataContractJsonSerializer(typeof(API_Device)); MemoryStream ms = new MemoryStream(); jsonSer.WriteObject(ms, json); ms.Position = 0; using (StreamWriter w = new StreamWriter(req.GetRequestStream())) { w.Write(new StreamReader(ms).ReadToEnd()); } string JSON = getJson(json); System.Net.HttpWebResponse res = (System.Net.HttpWebResponse)req.GetResponse(); var resStream = res.GetResponseStream(); Status = res.StatusCode.ToString(); resStream.Close(); res.Close(); } catch (System.Net.WebException e) { Status = e.Status.ToString(); } catch { } return(Status); }
private static string getJson(API_Device json) { using (var stream = new MemoryStream()) { var serializer = new DataContractJsonSerializer(json.GetType()); serializer.WriteObject(stream, json); return(Encoding.UTF8.GetString(stream.ToArray())); } }
public ImageViewer(Form1 a_Form, PostProcessingManager a_Manager) : base(a_Form.Application) { this.D = a_Form.Device; InitializeComponent(); this.Show(a_Form); renderer = new ivRenderer(this); a_Manager.AddPostProcessor(renderer); CreateBackbuffer(false, pictureBox1); this.FormClosing += new FormClosingEventHandler(ImageViewer_FormClosing); xLoader = new XIMGLoader(); }
public GraphicNode FinishObjekt(API_Device D) { List<MeshPart> GSOs = new List<MeshPart>(); for (int i = 0; i < SubObjekte.Count; i++) { SubObj s = SubObjekte[i]; MeshPart sub = s.CreateMeshPart(D); GSOs.Add(sub); } if (GSOs.Count != 0) { Mesh m = new Mesh(SubObj.CreateFrustum(SubObjekte), CullMode.Back, GSOs.ToArray()); return new GraphicNode("", m, D); } return null; }
public static void Convert(API_Device D, string a_ObjFile, Vector3 a_Size, string a_ObjColFile = null, string a_Root = null) { LevelMeshConverter.D = D; LevelMeshConverter.MainFolder = a_Root; FileInfo F = new FileInfo(a_ObjFile); string objn = F.Name.Replace(F.Extension, ""); FileInfo M = new FileInfo(F.FullName.Replace(F.Extension, "") + ".mtl"); if (M.Exists) { WavefrontMaterial[] Mats = WavefrontMaterial.LoadFromFile(M.FullName); foreach (WavefrontMaterial m in Mats) { if (m.Name == null) continue; if (m.Name.EndsWith("._xmat")) break; EFile e = FileManager.CreateNewPhysicalFile(FileManager.NewFileType.Material, RisenEditorWin32Interop.MeshConverter.MapFilename(m.Name, objn) + "._xmat", false); if (e.IsOpenable) continue; XmatWrapper m2 = null; Func<string, Vector3, eCShaderDefault.GenericSampler> G = (x, y) => { if (!string.IsNullOrEmpty(x)) { x = ConvertImage(x, F.Directory); return new eCShaderDefault.GenericSampler(x); } else return new eCShaderDefault.GenericSampler(new Color4(y)); }; eCShaderDefault.GenericSampler d = G(m.DiffuseTexture, m.Diffuse), s = G(m.SpecularTexture, m.Specular), sp = new eCShaderDefault.GenericSampler(new Color4(1, m.SpecularPower, m.SpecularPower, m.SpecularPower)), op = new eCShaderDefault.GenericSampler(new Color4(1)); m2 = new XmatWrapper(e, d, d, s, sp); m2.ToFile(); } } if (a_ObjColFile == null) a_ObjColFile = a_ObjFile; EFile t0 = FileManager.GetFile(objn + "._xmsh"), t1 = FileManager.GetFile(objn + "_COL._xcom"); if(t0.IsOpenable && t1.IsOpenable) return; EFile e0 = FileManager.CreateNewPhysicalFile(FileManager.NewFileType.StaticModel, objn + "._xmsh"), e1 = FileManager.CreateNewPhysicalFile(FileManager.NewFileType.StaticModel, objn + "_COL._xcom"); MeshConverter.Convert(a_ObjFile, e0.Path, e1.Path, a_Size.X, a_Size.Y, a_Size.Z); }
public GraphicNode FinishObjekt(API_Device D) { List<MeshPart> GSOs = new List<MeshPart>(); for (int i = 0; i < SubObjekte.Count; i++) { SubObj s = SubObjekte[i]; if (s.Vertices.Length == 0) continue; MeshPart sub = s.CreateMeshPart(D); if(sub != null && sub.Buffer.VertexCount > 0) GSOs.Add(sub); } if (GSOs.Count != 0) { Mesh m = new Mesh(SubObj.CreateFrustum(SubObjekte), CullMode.Back, GSOs.ToArray()); return new GraphicNode("", m, D); } return null; }
void DoThreading(EFile[] a_Files, List<LrentFile> a_FilesFin, API_Device D) { HWND v_MainBlock = ThreadManager.CreateSemaphore(0, 1); Queue<EFile> m_Files = new Queue<EFile>(a_Files.Length); foreach (EFile f in a_Files) m_Files.Enqueue(f); int c = Math.Max(Environment.ProcessorCount - 2, 1); c = Math.Min(c, m_Files.Count); c = 1; HWND[] m_Threads = new HWND[c]; object[] O = new object[] { m_Files, a_FilesFin, v_MainBlock, D}; for (int i = 0; i < m_Threads.Length; i++) { m_Threads[i] = ThreadManager.CreateThread(DoThreading2); ThreadManager.StartThread(m_Threads[i], O); } ThreadManager.WaitForSingleObject(v_MainBlock); ThreadManager.AbortObject(v_MainBlock); }
public Texture2D LoadTextureFromFile(EFile s, API_Device D) { Stream fStream = s.Open(FileAccess.Read); fStream.Position = 16L; int i0 = fStream.ReadInt(); int i1 = fStream.ReadInt(); fStream.Position = i0; Texture2D T = Texture2D.FromStream(D.HadrwareDevice(), fStream, i1); s.Close(); return T; /* BinaryReader bReader = new BinaryReader(fStream); char[] ResMagic = bReader.ReadChars(4); char[] ResClass = bReader.ReadChars(4); int PropOffset = bReader.ReadInt32(); int PropLength = bReader.ReadInt32(); int DataOffset = bReader.ReadInt32(); int DataLength = bReader.ReadInt32(); long RawDateTime = bReader.ReadInt64(); char[] RawFileExt = bReader.ReadChars(8); bReader.BaseStream.Position = PropOffset; byte[] Buffer = new byte[PropLength]; for (int i = 0; i < PropLength; i++) Buffer[i] = bReader.ReadByte(); bReader.BaseStream.Position = DataOffset; byte[] Surface = new byte[DataLength]; for (int i = 0; i < DataLength; i++) Surface[i] = bReader.ReadByte(); fStream.Close(); bReader.Close(); DataStream ds = new DataStream(Surface, true, true); Texture2D t11 = Texture2D.FromStream(D.HadrwareDevice(), ds, (int)ds.Length); ds.Dispose(); Surface = null; ds = null; return t11;*/ }
public static void addLrent(List<GraphicNode> gns, API_Device D) { Dictionary<string, List<VegetationMiniPart>> ps = new Dictionary<string, List<VegetationMiniPart>>(); for (int i = 0; i < gns.Count; i++) { for (int j = 0; j < gns[i].Mesh.Parts.Length; j++) { VegetationMiniPart p = new VegetationMiniPart(gns[i], j); if (ps.ContainsKey(p.sPath)) ps[p.sPath].Add(p); else { List<VegetationMiniPart> psa = new List<VegetationMiniPart>(); psa.Add(p); ps.Add(p.sPath, psa); } } } Build(D, ps); foreach (GraphicNode gn in gns) gn.Dispose(); }
public override ShaderResourceTexture CreateTexture(API_Device D) { bCImageResourceString s = base.Container.Properties["ImageFilePath"].Object as bCImageResourceString; return new ShaderResourceTexture(s.pString, D); }
public void LoadModel(EFile file, API_Device D) { //fStream = new FileStream(FileName, FileMode.Open, FileAccess.Read); fStream = file.Open(FileAccess.Read); bReader = new BinaryReader(fStream); Seek(136); UInt32 xacFileSize = bReader.ReadUInt32(); char[] cs = bReader.ReadChars(3); string s = cs[0].ToString() + cs[1].ToString() + cs[2].ToString(); if (s != "XAC") throw new Exception("This is not a valid XMAC file."); Seek(146); if (bReader.ReadByte() != 0) { long p = bReader.BaseStream.Position; bReader = new bReader2(fStream); bReader.BaseStream.Position = p; } Seek(148); while ((xacFileSize + 140) != Tell()) { UInt32 secID = bReader.ReadUInt32(); if (secID == 1) { // Mesh. readMeshSection(); } else if (secID == 2) { // Weighting. readWeightingSection(); } else if (secID == 7) { // General scene information. readInfoSection(); } else if (secID == 11) { // Nodes. readNodesSection(); } else if (secID == 13) { // Mats. readMatsSection(); } // (secID == 3) would belong to "MatSection" but all of them are read by readMatsSection(). //else throw new EngineError("Unknown Error", EngineErrorType.NoInformation); else break;//this prevents it from crashing while loading faces, some other models can't be seen when this is activated due to some problems } var tmp = SubObj.CreateData(Vertices, TVertices, Normals, Tris); for (int i = 0; i < Materials.Count; i++) { if ((Materials[i].n.Contains("EMFX")) || (Materials[i].n.Contains("collision", StringComparison.CurrentCultureIgnoreCase))) continue; string qs = Materials[i].n; SubObj so = new SubObj(qs, i); so.CreateVertexBuffer(tmp, true); so.LoadMaterial(D); SubObjekte.Add(so); //Matrix rm = Matrix.RotationAxis(Vector3.UnitY, MathHelper.PiOver2); //for (int i2 = 0; i2 < so.Vertices.Length; i2++) // so.Vertices[i2].Position = Core.TransformVec3(so.Vertices[i2].Position.ToVec3(), rm).ToVec4(1.0f); } SubObjekte.Remove(null); }
public UserConsole(Form1 F, PostProcessingManager a_Manager) { D = F.Device; drawer = new ConsolProcessor(F, this); a_Manager.AddPostProcessor(drawer); m_Strings = new List<string>(); currLine = string.Empty; }
public void Init(API_Device D) { this.OwnerDraw = true; this.LargeImageList = this.SmallImageList = new ImageList(); this.LargeImageList.ImageSize = new Size(22, 22); this.LargeImageList.Images.Add(new Bitmap(this.LargeImageList.ImageSize.Width, this.LargeImageList.ImageSize.Height)); if (main != null) return; FileManager.g_pApp.PauseRendering(); GameLibrary.ShaderResourceTexture mT = new ShaderResourceTexture("GUI_IconSets01._ximg", D); System.IO.Stream S = new System.IO.MemoryStream(); SlimDX.Direct3D11.Texture2D.ToStream(D.Context, mT.Texture, SlimDX.Direct3D11.ImageFileFormat.Jpg, S); FileManager.g_pApp.ResumeRendering(); main = new Bitmap(S); mT.Dispose(); S.Dispose(); }
public VegetationMiniPartCollection(ICollection<VegetationMiniPart> ps) { ManagedWorld.NodeLibrary.RemoveNode(this); gps = ps.ToArray<VegetationMiniPart>(); p = gps[0].sPath; D = gps[0].mBody.Device; //List<Vector3> ms = new List<Vector3>(); //List<Quaternion> qs = new List<Quaternion>(); List<byte> bs = new List<byte>(); int stride = 3 * 4 + 4 * 4;//float3 + float4 BoundingBox abs = new BoundingBox(new Vector3(1E10f), new Vector3(-1E10f)); foreach (VegetationMiniPart gp in gps) { abs = abs.Extend(gp.bb); //ms.Add(gp.vPosition); //qs.Add(gp.qOrientation); bs.AddRange(gp.vPosition.GetBytes()); bs.AddRange(gp.qOrientation.GetBytes()); } this.BoundingBox = abs; DataStream ds = new DataStream(bs.ToArray(), true, true); sBuffer = new ShaderResourceBuffer(ds, SlimDX.Direct3D11.BindFlags.VertexBuffer, SlimDX.Direct3D11.CpuAccessFlags.None, SlimDX.Direct3D11.ResourceUsage.Default, SlimDX.Direct3D11.ResourceOptionFlags.None, stride, D); ds.Dispose(); vb = new SlimDX.Direct3D11.VertexBufferBinding(sBuffer.Buffer, sBuffer.Description.StructureByteStride, 0); qTST = new GraphicNode("", null, D); qTST.BoundingBox = this.BoundingBox; qTST.ParentNode = this; }
public GrassNode(List<GraphicNode> gs, API_Device D, ILrentObject a_Obj) : base(gs, true) { this.D = D; ManagedWorld.NodeLibrary.RemoveNode(this); }
internal ivRenderer(DeviceApplication da) { DA = da; D = da.Device; }
public ShaderResourceTexture CreateTexture(API_Device D) { if(ColorModifier == eEShaderColorModifier.eEShaderColorModifier_Default) return (Operand as subClassBase).CreateTexture(D); ShaderResourceTexture src = (Operand as subClassBase).CreateTexture(D); ShaderResourceTexture R = new ShaderResourceTexture(src.Width, src.Height, 1, SlimDX.Direct3D11.ResourceUsage.Default, SlimDX.Direct3D11.BindFlags.ShaderResource, SlimDX.Direct3D11.CpuAccessFlags.None, SlimDX.DXGI.Format.B8G8R8A8_UNorm, 1, SlimDX.Direct3D11.ResourceOptionFlags.None, D); FileManager.e_MatEffect.Variables["sourceTex0"].SetVariable(src.ShaderResourceView); FileManager.e_MatEffect.Variables["dim"].SetVariable(new Vector2(R.Width, R.Height)); bool all = ColorComponent == eEShaderColorSrcComponent.eEShaderColorSrcComponent_Default; bool rgb = ColorComponent == eEShaderColorSrcComponent.eEShaderColorSrcComponent_RGB; FileManager.e_MatEffect.Variables["r"].SetVariable(ColorComponent == eEShaderColorSrcComponent.eEShaderColorSrcComponent_R || all || rgb); FileManager.e_MatEffect.Variables["g"].SetVariable(ColorComponent == eEShaderColorSrcComponent.eEShaderColorSrcComponent_G || all || rgb); FileManager.e_MatEffect.Variables["b"].SetVariable(ColorComponent == eEShaderColorSrcComponent.eEShaderColorSrcComponent_B || all || rgb); FileManager.e_MatEffect.Variables["a"].SetVariable(ColorComponent == eEShaderColorSrcComponent.eEShaderColorSrcComponent_A || all); FileManager.e_MatEffect.Variables["op"].SetVariable((int)ColorModifier - 1); FileManager.g_pApp.PauseRendering(); FileManager.r_MatTarget.SetTarget(ClearType.All); FullScreenQuad.RenderQuad(FileManager.e_MatEffect.Techniques["blend"].Passes[0]); R.CopyFrom(FileManager.r_MatTarget, 0, 0, R.Width, 0, R.Height, 0, 0); FileManager.g_pApp.ResumeRendering(); return R; }
public override ShaderResourceTexture CreateTexture(API_Device D) { if (TexturePath == "._ximg") return null; return new ShaderResourceTexture(TexturePath, D); }
public override ShaderResourceTexture CreateTexture(API_Device D) { this.GetType(); return null; }
public void LoadModel(EFile file, API_Device D) { List<List<Vector3>> verts = new List<List<Vector3>>(); List<List<Vector3>> tverts = new List<List<Vector3>>(); List<List<int>> faces = new List<List<int>>(); List<int> vcounts = new List<int>(); List<int> icounts = new List<int>(); List<string> matnames = new List<string>(); int allinds = 0; int allverts = 0; int numoldverts = 0; float x = 0, y = 0, z = 0, u = 0, v = 0, w = 0; this.SubObjekte = new List<SubObj>(); //FileStream fStream = new FileStream(file., FileMode.Open, FileAccess.Read); Stream fStream = file.Open(FileAccess.Read); bReader = new BinaryReader(fStream); Skip(70); int vd = bReader.ReadInt32(); Skip(53); numSubMehshes = bReader.ReadInt32(); for (int h = 0; h < numSubMehshes; h++) { verts.Add(new List<Vector3>()); tverts.Add(new List<Vector3>()); faces.Add(new List<int>()); Suche((int)vd, 77, 97, 116, 101, 114, 105, 97, 108); Skip(20); short len = Math.Abs(bReader.ReadInt16()); //string name = bReader.ReadString(); //matnames.Add(name.Replace("._xmat", ".dds")); byte[] namebs = bReader.ReadBytes(len); string name = new System.Text.ASCIIEncoding().GetString(namebs); matnames.Add(name); Suche((int)vd, 73, 110, 100, 101, 120, 67, 111, 117, 110, 116); Skip(12); int indcount = Math.Abs(bReader.ReadInt32()); icounts.Add(indcount); allinds += indcount; Skip(54); int vertcount = Math.Abs(bReader.ReadInt32()); vcounts.Add(vertcount); allverts += vertcount; } bReader.BaseStream.Position = (vd + 202); int vdsize = Math.Abs(bReader.ReadInt32()); Skip(12); int o = Math.Abs(bReader.ReadInt32()); o /= 4; Skip(56); int svd = (int)bReader.BaseStream.Position; for (int ii = 0; ii < numSubMehshes; ii++) { for (int i = 0; i < (o * vcounts[ii]) ; i++) { float f = bReader.ReadSingle(); int id = (i + 1) % o; if (id == 1) { y = -f; } if (id == 2) { z = f; } if (id == 3) { x = f; verts[ii].Add(new Vector3(x,y,z)); } if (o == 13) { if (id == 11) { w = f; } if (id == 12) { u = f; } if (id == 0) { v = f;//v = 1 - f; tverts[ii].Add(new Vector3(u,v,w)); } } if (o == 15) { if (id == 11) { w = f; } if (id == 12) { u = f; } if (id == 13) { v = f; tverts[ii].Add(new Vector3(u,v,w)); } } } } for (int jj = 0; jj < numSubMehshes; jj++) { for (int n = 0; n < icounts[jj]; n++) { int f = (int)bReader.ReadUInt32(); f -= numoldverts; float id = (n + 1) % 3; if (id == 1) { x = f; } if (id == 2) { y = f; } if (id == 0) { z = f; faces[jj].Add((int)x); faces[jj].Add((int)y); faces[jj].Add((int)z); } } numoldverts += vcounts[jj]; } for (int s = 0; s < numSubMehshes; s++) { SubObj so = new SubObj(matnames[s], s); List<Tri> ts = new List<Tri>(); for (int fl = 0; fl < faces[s].Count; fl += 3) ts.Add(new Tri(faces[s][fl], faces[s][fl + 1], faces[s][fl + 2], faces[s][fl], faces[s][fl + 1], faces[s][fl + 2], faces[s][fl], faces[s][fl + 1], faces[s][fl + 2], s)); int c = verts[s].Count + 1; Vector3[] vtmp = new Vector3[c]; List<Vector3> ns = new List<Vector3>(vtmp); for (int h = 0; h < verts[s].Count; h++) verts[s][h] = Vector3.Transform(verts[s][h], mRot).ToVec3(); var tmp = SubObj.CreateData(verts[s], tverts[s], ns, ts); so.CreateVertexBuffer(tmp, true); so.LoadMaterial(D); SubObjekte.Add(so); } file.Close(); }
public override ShaderResourceTexture CreateTexture(API_Device D) { throw new NotImplementedException(); }
public void Load(EFile F, API_Device D) { BinaryStream s = F.Open(FileAccess.Read).CopyToBin(); HeaderXmot a = new HeaderXmot(s); //a.data. }
public abstract ShaderResourceTexture CreateTexture(API_Device D);
private static void Build(API_Device D, Dictionary<string, List<VegetationMiniPart>> ps) { BoundingBox bb = new BoundingBox(new Vector3(1E10f), new Vector3(-1E10f)); foreach (KeyValuePair<string, List<VegetationMiniPart>> kvp in ps) { if (easy) { VegetationMiniPartCollection gp = new VegetationMiniPartCollection(kvp.Value); lrentPatches.Add(gp); bb = bb.Extend(gp.BoundingBox); } else { BoundingBox BB2 = new BoundingBox(new Vector3(1E10f), new Vector3(-1E10f)); foreach (VegetationMiniPart gp in kvp.Value) BB2 = BB2.Extend(gp.bb); bb = bb.Extend(BB2); mDepth = 3; float l = (bb.Maximum - bb.Minimum).Length(); if (l < 5000) mDepth = 0; bTree(kvp.Value, lrentPatches, 0, BB2); } } List<Node> qs = lrentPatches.Cast<Node>().ToList(); trees.Add(new OcTree.Oc(bb, qs, 0, null)); /* if (trees.Count == 0) return; bb = trees[0].ContainerBox; IList<Node> ns = new List<Node>(); foreach (OcTree.Oc on in trees) { bb = bb.Extend(on.ContainerBox); on.Find(ref ns, ref bb); } qT = new OcTree.Oc(bb, ns, 0, trees[0].Device);*/ }
public override ShaderResourceTexture CreateTexture(API_Device D) { return (ColorSrc1.Operand as subClassBase).CreateTexture(D); ShaderResourceTexture src0 = ColorSrc1.CreateTexture(D); ShaderResourceTexture src1 = ColorSrc1.CreateTexture(D); ShaderResourceTexture src2 = BlendSrc.CreateTexture(D); int w = Math.Max(Math.Max(src0.Width, src1.Width), src2.Width); int h = Math.Max(Math.Max(src0.Height, src1.Height), src2.Height); ShaderResourceTexture R = new ShaderResourceTexture(w, h, 1, SlimDX.Direct3D11.ResourceUsage.Default, SlimDX.Direct3D11.BindFlags.ShaderResource, SlimDX.Direct3D11.CpuAccessFlags.None, SlimDX.DXGI.Format.B8G8R8A8_UNorm, 1, SlimDX.Direct3D11.ResourceOptionFlags.None, D); FileManager.e_MatEffect.Variables["sourceTex0"].SetVariable(src0.ShaderResourceView); FileManager.e_MatEffect.Variables["sourceTex1"].SetVariable(src1.ShaderResourceView); FileManager.e_MatEffect.Variables["sourceTex2"].SetVariable(src2.ShaderResourceView); FileManager.e_MatEffect.Variables["dim"].SetVariable(new Vector2(w, h)); FileManager.g_pApp.PauseRendering(); FileManager.r_MatTarget.SetTarget(ClearType.All); FullScreenQuad.RenderQuad(FileManager.e_MatEffect.Techniques["Lerp"].Passes[0]); R.CopyFrom(FileManager.r_MatTarget, 0, 0, R.Width, 0, R.Height, 0, 0); FileManager.g_pApp.ResumeRendering(); return R; }
public override ShaderResourceTexture CreateTexture(API_Device D) { return (Source0 as subClassBase).CreateTexture(D); eEColorSrcCombinerType q = (eEColorSrcCombinerType)base.Container.Properties["CombinerType"].Object; ShaderResourceTexture src0 = ColorSrc1.CreateTexture(D); ShaderResourceTexture src1 = ColorSrc2.CreateTexture(D); if (src0 == null || src1 == null) return src0 != null ? src0 : src1; ShaderResourceTexture R = new ShaderResourceTexture(Math.Max(src0.Width, src1.Width), Math.Max(src0.Height, src1.Height), 1, SlimDX.Direct3D11.ResourceUsage.Default, SlimDX.Direct3D11.BindFlags.ShaderResource, SlimDX.Direct3D11.CpuAccessFlags.None, SlimDX.DXGI.Format.B8G8R8A8_UNorm, 1, SlimDX.Direct3D11.ResourceOptionFlags.None, D); FileManager.e_MatEffect.Variables["sourceTex0"].SetVariable(src0.ShaderResourceView); FileManager.e_MatEffect.Variables["sourceTex1"].SetVariable(src1.ShaderResourceView); FileManager.e_MatEffect.Variables["dim"].SetVariable(new Vector2(R.Width, R.Height)); FileManager.g_pApp.PauseRendering(); FileManager.r_MatTarget.SetTarget(ClearType.All); switch (q) { case eEColorSrcCombinerType.eEColorSrcCombinerType_Add : FullScreenQuad.RenderQuad(FileManager.e_MatEffect.Techniques["Combiner_Add"].Passes[0]); break; case eEColorSrcCombinerType.eEColorSrcCombinerType_Subtract: FullScreenQuad.RenderQuad(FileManager.e_MatEffect.Techniques["Combiner_Sub"].Passes[0]); break; case eEColorSrcCombinerType.eEColorSrcCombinerType_Multiply: FullScreenQuad.RenderQuad(FileManager.e_MatEffect.Techniques["Combiner_Mul"].Passes[0]); break; case eEColorSrcCombinerType.eEColorSrcCombinerType_Max: FullScreenQuad.RenderQuad(FileManager.e_MatEffect.Techniques["Combiner_Max"].Passes[0]); break; case eEColorSrcCombinerType.eEColorSrcCombinerType_Min: FullScreenQuad.RenderQuad(FileManager.e_MatEffect.Techniques["Combiner_Min"].Passes[0]); break; } R.CopyFrom(FileManager.r_MatTarget, 0, 0, R.Width, 0, R.Height, 0, 0); FileManager.g_pApp.ResumeRendering(); //src0.ToFile("src0.dds", SlimDX.Direct3D11.ImageFileFormat.Dds); //src1.ToFile("src1.dds", SlimDX.Direct3D11.ImageFileFormat.Dds); //R.ToFile("res.dds", SlimDX.Direct3D11.ImageFileFormat.Dds); return R; }
public override ShaderResourceTexture CreateTexture(API_Device D) { bCFloatColor q0 = (bCFloatColor)base.Container.Properties["Color"].Object; float al = (float)base.Container.Properties["Alpha"].Object; Color4 q = new Color4((Color3)q0); q.Alpha = al; ShaderResourceTexture s = new ShaderResourceTexture(q, D); return s; }
public InputLayout FetchILayout(EffectPassDescription d, API_Device D) { if (bufferedLayouts.ContainsKey(d.Name)) return bufferedLayouts[d.Name]; else { InputLayout ilayout = new InputLayout(D.HadrwareDevice(), d.Signature, ies); bufferedLayouts.Add(d.Name, ilayout); return ilayout; } }
public override ShaderResourceTexture CreateTexture(API_Device D) { bTObjArray<bCFloatAlphaColor> Colors = base.Container.Properties["Colors"].Object as bTObjArray<bCFloatAlphaColor>; if (Colors == null || Colors.Length == 0) return ShaderResourceTexture.WhiteTexture; return new ShaderResourceTexture(Colors[0], D); }
public Material LoadMaterial(EFile _File, API_Device D) { if (_File.IsOpenable) { ShaderResourceTexture T = null; if (_File.Name == "Nat_Stone_Rock_01_Diffuse_01_Specular._xmat") T = new ShaderResourceTexture("Nat_Stone_Rock_01_Diffuse_01._ximg", D); else if (_File.Name == "Special_Water_Swamp_01_Diffuse_01._xmat") T = new ShaderResourceTexture("Special_Water_Caustics_01_Diffuse_01._ximg", D); else { XmatWrapper W = new XmatWrapper(_File); bCGuid src_Diffuse = (W.Mat.dataObj.Class as eCShaderDefault).ColorSrcDiffuse.Token; bCGuid src_Normal = (W.Mat.dataObj.Class as eCShaderDefault).ColorSrcNormal.Token; bCGuid src_Specular = (W.Mat.dataObj.Class as eCShaderDefault).ColorSrcSpecular.Token; if (src_Diffuse.IsValid) { eCShaderDefault shader = (W.Mat.dataObj.Class as eCShaderDefault); eCShaderEllementBase ellement = shader.GetEllementByGuid(shader.ColorSrcDiffuse.Token); if (ellement is subClassBase) T = (ellement as subClassBase).CreateTexture(D); } if (T == null) T = ShaderResourceTexture.WhiteTexture; } return new Material(T); } else { return new Material("42", true, D); } }
LrentFile Read(EFile file, API_Device D) { SystemLog.Append(LogImportance.Information, "Lrent file imported : " + file.Name); if (file.Name.Contains("Levelmesh_Water_Rivermesh.lrent") || file.Name.Contains("OutMain_Nav.lrent") || !file.IsOpenable) return null; return new LrentFile(file, D); }