Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Krum110487

Member Since 22 Sep 2010
Offline Last Active Aug 19 2012 04:21 PM

Topics I've Started

Ortho Near/Far not working as I expected

17 August 2012 - 04:26 PM

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?

GL.Ortho(0, screen_width, screen_height, 0, -10000, 10000);
GL.Viewport(0, 0, screen_width, screen_height);

then the render code is this:
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();

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?

Rotate flat surface in 3D space

14 August 2012 - 10:02 AM

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

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();

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.

C# Rendering Video from external thread using LibVlc

13 August 2012 - 12:43 AM

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!

Invoking Methods quickly from a dynamic DLL

13 October 2010 - 03:02 AM

EDIT:
It seems I have found my problem, although I still can't seem to fix it:
http://www.yoda.arachsys.com/csharp/plugin.html
--------------------------------------------------------------------


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(type.name);

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(type.name);

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]

C# scripting

22 September 2010 - 03:22 AM

Hello, I would first like to point out, that I am new on the gaming scene, but I have been programming for quite some time.

I know that C# scripting is possible, as I have seen examples of it, although they are somewhat confusing to me and leave out key ideas.

Here is what I am in need for and why:

1) I need a scripting system for low level users to script game aspects.
2) The language needs to be completely managed so it is not too technical
3) I would like if the language was compatible with XNA and XBOX (meaning they must be compiled)

thus I have deduced that I need C# for these needs.

now, I have seen plenty of scripting systems that require you to include, create classes...etc which is a bit too hard for what I will require for my user-base to do.

I would love if it is possible to create a system to where the script can look along the lines of...


class Map_142
{
public override void OnEnter()
{
Player.ShowMessage("You entered map" + this.Map.Number + "!");
}
}


I imagine that Map_142 would have to extend another class to work correctly.

Mind you, I am just giving an example, I wouldn't mind it if there has to be a parameter passed or some inheritance as I can do this automatically, but as long as it is close to this format, that would be awesome.

I know what I want, but I don't have the first clue of how to make a scripting language in C# to work in this manner. I will in worst case scenario use a language like lua and sacrifice XBOX compatibility if need be.

I have been looking around, but I can't seem to find a clear cut example of what I am looking for. I am just sorta lost when it comes to C# and scripting.

any help is appreciated!
Thank you for your time!

PARTNERS