• Content count

  • Joined

  • Last visited

Community Reputation

110 Neutral

About Krum110487

  • Rank
  1. the near and far (to my understanding) is how many units towards(near) and away(far) from the camera. so -1 would be (origin - 1) (towards) and 2 would be (origin + 2) (away), so anything will render in the range of -1 to 0 or 0 to 2 so anything lower than -1 or higher than 2 wouldn't show, and it may or may not include 2 and -1 as not rendering, I am unsure, I just noticed you were cutting it close, it is always a good idea to play it safe and have some padding. although I am new, so if you want a more detailed explanation, you might wait for someone else.
  2. Ortho Near/Far not working as I expected

    ok this is weird, if the matrix is "replaced" then why does commenting out ortho have a different result? I set the ortho, for the width and height, then I set the Matrix mode, if that is truly replacing the matrix then there shouldn't be any difference between [CODE] GL.Ortho(0, screen_width, screen_height, 0, -10000, 10000); GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); [/CODE] or [CODE] //GL.Ortho(0, screen_width, screen_height, 0, -10000, 10000); GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); [/CODE] but there is most definitely a difference, BUT I think I just figured out what may be wrong (as I was typing) I think matrix mode generates the projection Identity matrix using the current matrix, BUT it will remove the z index stuff because a projection matrix has a 0 for the z index. [CODE]screen_height 0 0 0 screen_width 0 0 0 0[/CODE] or something of that sort, am I close?
  3. I could be wrong, but you might have your near a bit off on the orthographicOffCenter, try: CreateOrthographicOffCenter(0.0f, 1.0f, 1.0f, 0.0f, -1.0f, 2.0f);
  4. ok I am having an issue where I have a plane which I am spinning in 3d space, and it is getting cut off then the edge is to far away, or past the near. so I figured I would set the near and far to really high numbers to see if that would fix it, but it doesn't seem to matter, does ortho not cover this? [CODE] GL.Ortho(0, screen_width, screen_height, 0, -10000, 10000); GL.Viewport(0, 0, screen_width, screen_height); [/CODE] then the render code is this: [CODE] GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); //GL.Scale(.5,.5,.5); GL.Rotate(video_rotation_x % 360, 0, 1, 0); GL.Rotate(video_rotation_y % 360, 1, 0, 0); GL.Rotate(video_rotation_z % 360, 0, 0, 1); GL.Begin(BeginMode.Quads); GL.TexCoord2(0, 0); GL.Vertex2(x, y); GL.TexCoord2(1, 0); GL.Vertex2(x + (float)video_width, y); GL.TexCoord2(1, 1); GL.Vertex2(x + (float)video_width, y + (float)video_height); GL.TexCoord2(0, 1); GL.Vertex2(x, y + (float)video_height); GL.End(); [/CODE] I assumed that the -10000 would be more than enough for the near, but the corners at certain angles is cut off (looks flat) and I am just curious as to why, the video is not wider than 800 and it is at 0, so the max it could be is -800 right? maybe a bit further, but shouldn't come near -10,000, but no matter what value I use, it doesn't seem to make a difference. also if I scale it to .5, .5, .5 it isn't clipped at all, so I am not sure how to fix it. what am I missing?
  5. OpenGL Rotate flat surface in 3D space

    That is good to know, Thanks!
  6. OpenGL Rotate flat surface in 3D space

    @dpadam450 Sorry, I am still getting used to the terminology, by flat 3d object I mean a 3d plane. since I have posted I just realized the I was using projection (not that it matters, since what I want is perspective, and even in model view it had none). @haegarr, you have pretty much told me what I needed to know, I am still getting used to this, I will dig around in Frustrum and such for a while see what I figure out. I also just got a handle on units (sort of), I think you will see less and less of me as things finally click [img][/img] thanks for the information!
  7. Ok, I am new to OpenGL and I am having a bit of trouble: currently I am rotating a texture by using glRotate on the vertex's [CODE] GL.Rotate(45, 1.0, 0.0, 0.0); GL.Begin(BeginMode.Polygon); GL.TexCoord2(0, 0); GL.Vertex2(ULx, ULy); GL.TexCoord2(1, 0); GL.Vertex2(URx, URy); GL.TexCoord2(1, 1); GL.Vertex2(BRx, BRy); GL.TexCoord2(0, 1); GL.Vertex2(BLx, BLy); GL.End(); [/CODE] This works fine, but since it is just a 2d matrix operation all of the rotations are pretty much squashing the texture (it doesn't look like the far side is far away), in the example, I would expect the top to have a smaller width than the bottom width, because it is visible but further away. this isn't the case, and I understand why (I've taken Linear Algebra :-P) I am looking to create a 3D FLAT object, would it be a cube where one side is 0 width? and I want to rotate it in 3D space where the perspective is correct. I don't really know how to accomplish this yet, most of the code I find makes 3D cubes (although I am having trouble placing my texture on it). Any help is appreciated. thanks.
  8. I am only double posting because I solved this, and I figured if anyone was curious, they would like to know. Instead of a call back, which can be called at any time (which I assume will mostly be AFTER a frame is rendered and before it is cleared, thus not rendering, I used this in my render loop. [CODE] if(player.IsPlaying) { Bitmap bitmap = memRender.CurrentFrame; BitmapData data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0); bitmap.UnlockBits(data); bitmap.Dispose(); } base.OnRenderFrame(e);[/CODE] it is playing the video just fine, although I am not sure how to handle multiple textures yet. also is there a more efficient way of doing this?
  9. (This is slightly off topic from your question, but it relates) just for some specifics on animation, I am not keen on OpenGL (getting there), but I have drawn sprites, I used this technique, I made 8 images for each direction (except only 1 for left and right since it can be flipped), each one I assumed was at a 4 pixel pace (aka 4 pixel movement between each frame) so this is how it worked in code: pseudo code: while moving right move 4 pixel go to next frame otherwise if you were to simply animate it separate of movement you will get floating foot syndrome, where they look like they are doing a moon walk forward or something. of course the more frames you have the better it will look, so once you get a sprite system, you will have a nice method of animation, that looks like the steps they are taking are moving them. As for the program to use, MSPaint is fine, albeit limited, and it depends how 8bit you want to go, if you want to look like a nintendo game, mspaint is great, you can use photoshop if you want more tools and layers, you simply have to limit the pallet to 8 bit colors.
  10. Ok, I am new to openGL. I am having a hard time figuring out what the best method is for rendering a video in 3D space. I am using C# as my development because I only really want to focus on Windows for now and it is great for quick prototyping...anyway. I am using OpenTK which is essentially the same as openGL (if you didn't already know), so information on either would be great. I am using VLC so any file type can be supported. Currently I have this code: [source lang="csharp"]IMediaPlayerFactory factory = new MediaPlayerFactory(); IVideoPlayer player = player = factory.CreatePlayer<IVideoPlayer>(); IMedia media = factory.CreateMedia<IMedia>(@"C:\test.flv"); IMemoryRenderer memRender = player.CustomRenderer; memRender.SetCallback(delegate(Bitmap frame) { //This is my callback, so every frame for VLC code call this. //This code should lock and update the texture (unsure if it is needed to lock) }); memRender.SetFormat(new BitmapFormat(300, 300, ChromaType.RV24)); player.Open(media); player.Play();[/source] would it be better to render in the Callback? or during the render loop? I have tried everything and searched the net for ideas to get the bitmap from the video to the texture, but I haven't been successful, I know the bitmap is correct, because I wrote code to output it, so it is rendering, I just can't get OpenTK to generate the texure and load it onto the screen. I want the focus to be on speed. any help is appreciated, thanks!
  11. I am only double-posting to show the solution to my problem! What I had to end up doing was reference the dll containing my parent class from the script dll. Then (and this is the part that had me confused) in the reference properties you MUST change "Copy Local" to false... and the following code works like a charm! ... assembly = Assembly.LoadFile(...); foreach (Type type in assembly.GetTypes()) { if(type.IsClass && type.Namespace == "Script") { Console.WriteLine(; Engine.Map MapTemp = (Engine.Map) Activator.CreateInstance(type); MapTemp.onLoad(); } } } I hope this helps someone developing a dll based engine!
  12. I don't use Borland, but I would assume you are not referencing them, so the compiler doesn't know to look at the DLL. Although I am not 100% sure :-\
  13. EDIT: It seems I have found my problem, although I still can't seem to fix it: -------------------------------------------------------------------- First off, hello! I am developing a simple 2D engine for PC/Xbox 360 for a game, but mostly for practice with C#, XNA, Classes, and Game making! I want my engine to use DLL's for the scripting engine I am creating, I can load the script and run the code, but since I load the DLL dynamically, I can't run the methods without using: object obj = type.InvokeMember(null, BindingFlags.Public..., null, null, null); type.InvokeMember("TestFunction", BindingFlags.InvokeMethod, null, obj, null); break; I plan on putting all of my "map" scripts into one DLL, so I don't have a thousand DLL's to take care of, which will look something like this... namespace Script { public class Map0001 : Map { public void TestFunction() { Console.WriteLine("DLL CALL WORKS!"); } } public class Map0002 : Map { public void TestFunction() { Console.WriteLine("DLL CALL WORKS!"); } } } I can successfully find the class I want, but it is within a sequential loop, which is fine for loading the game, but I would like to deep copy the class to prevent me having to search for it over and over. I am not exactly sure of how to do that with a dynamically loaded DLL, it shouldn't be too hard, I just can't seem to find the solution! I would prefer if I didn't have to put a clone function within every class. My code so far: ... assembly = Assembly.LoadFile(...); foreach (Type type in assembly.GetTypes()) { if(type.IsClass && type.Namespace == "Script") { Console.WriteLine(; MethodInfo method = type.GetMethod("TestFunction", new Type[0]); if(method != null) { object obj = type.InvokeMember(null, BindingFlags.Public..., null, null, null); type.InvokeMember("TestFunction", BindingFlags.InvokeMethod, null, obj, null); break; } } any help would be awesome! thanks! -------------------------------------------------------------------------- EDIT: I think I found what I want to do, but I keep getting a runtime error. ... assembly = Assembly.LoadFile(...); foreach (Type type in assembly.GetTypes()) { if(type.IsClass && type.Namespace == "Script") { Console.WriteLine(; Engine.Map MapTemp = (Engine.Map) Activator.CreateInstance(type); MapTemp.onLoad(); } } } DLL: namespace Script { public class Map0001 : Map { public void TestFunction() { Console.WriteLine(" - DLL CALL WORKS!"); } } public class Map0002 : Map { public void TestFunction() { Console.WriteLine(" - DLL CALL WORKS!"); } } } Map Class: namespace Script { public class Map { public virtual void onLoad() { Console.WriteLine(" - Map Class (Parent Class)"); } } } I am getting an InvalidCastException here: Engine.Map MapTemp = (Engine.Map) Activator.CreateInstance(type); My guess is that it is treating the Map class within the DLL as a separate class from the one I am using...although they are identical... I can't seem to make this work either! [Edited by - Krum110487 on October 13, 2010 3:29:06 PM]
  14. C# scripting

    Quote:Original post by dilyan_rusev Hi! I would recommend boo or iron python. If it were strict c#, I would most probably used compiler services to dynamically build an assembly and load it in memory. A search in google found a sample on building c# programs with API dynamically. EDIT: Of course, MSDN has even better example on code providers. Dido thank you for the suggestion, although my question to you is, does xbox support it, the only one I have found to work on xbox is C# itself (for obvious reasons) and only if they are built, because I know that dynamically built scripts are impossible on the xbox due to not having certain API (I think reflect?). but if I am wrong please correct me. Thank you.
  15. C# scripting

    Quote:Original post by jpetrie There's nothing special about it; the basic implementation is very straightforward and is no different from writing any other C# code: The "scripts" are just classes that extend some base "script" class (or implement some interface). You then load the assembly containing the script classes dynamically via something like Assembly.Load, find all the types that extend your base class / implement your IScript interface via GetTypes(), and then create instances via Activator.CreateInstance. Note that a language being managed does not mean it is nontechnical, and C# probably isn't terribly well-suited to being used as a scripting mechanism for entirely nontechnical users. Remember, scripting just means that you're doing something to drive changes externally -- the authors of your C# scripts will still need to be reasonably competent C# programmers. Also note that you won't be able to easily hot-reload scripts without putting them in another appdomain, since you cannot remove a loaded assembly from an appdomain, only tear the domain down. This clears a couple things up for me. I understand the concept mostly, it is just implementing it that for some reason is losing me. Lets create a more tangible example so I can fully understand how I could implement it! Lets say I have this hard-coded into my program. public interface IMap { string MapName { get; set; } ... } public class Map : IMap { private string MapNameVal; string MapName { get { Return MapNameVal; } set { MapNameVal=MapName; } } Then when a map is loaded I will instantiate the Map_1 (not 100% sure on this one need to investigate Activator.CreateInstance) which will load the main() to run on load. For other functions to be called I would hard code something like... Sudo code: if(player_leaves_map) { Map_1.LeaveMap() } Then I can interact with it with the following "script". public class Map_1 : Map { public static void main() { MapName = "test"; } public void LeaveMap() { MapName = "stupid face" } } is this the idea, of course I am simplifying it, but I am researching at the moment, and I want to be able to create my classes accordingly. if you see a fundamental problem with what I am suggesting please yell at me and tell me why. Thank you for your quick response.