Skip to main content
GameDev.net gamedev.net
🔒 Locked 🤖 Godot

Creating a camera class

Started by raidzero Jun 4, 2012 at 8:15 PM 3 replies 2.5k views
Original Post
raidzero
raidzero
I'm in the process of porting my C#/XNA game to Java/LWJGL, but a few things I can't figure out.
I'm using a Vector2f from LWJGL for a Vector2, but what are the equivalents of a Vector2 and the get/set accessors and the keyword value in Java with LWJGL?



#region Declarations
private static Vector2 position = Vector2.Zero;
private static Vector2 viewPortSize = Vector2.Zero;
private static Rectangle worldBoundary = new Rectangle(0, 0, 0, 0);
#endregion
#region Properties
public static Vector2 Position
{
get { return position; }
set
{
position = new Vector2(
MathHelper.Clamp(value.X, worldBoundary.X, worldBoundary.Width - ViewPortWidth),
MathHelper.Clamp(value.Y, worldBoundary.Y, worldBoundary.Height - ViewPortHeight));
}
}
dAND3h
dAND3h
Maybe it is just me, but I don't really understand your question. You are using a Vector2 class with [color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]LWJGL and asking what the equivalent is in [/background]

[/font][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]LWJGL ?[/background]

[/font]

raidzero
raidzero

Maybe it is just me, but I don't really understand your question. You are using a Vector2 class with

[background=rgb(250, 251, 252)]LWJGL and asking what the equivalent is in [/background]


[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif]

[background=rgb(250, 251, 252)]LWJGL ?[/background][/font]





I'm asking what is the Java/LWJGL equivalent of a Vector2 from C#
dAND3h
dAND3h
As far as I am aware, there is no native Vector2 class in java. I am not familiar with LWJGL, but a quick google search leads me back to the Vector2f class you defined above, which is equivalent to the Vector2 from C#(assuming you are using an outside graphics framework because C# does not natively have a any of those types of classes).
bobbias
bobbias
The best choice is to avoid the org.lwjgl.util classes and go with the vector classes from javax.vecmath which is part of the java3d package.

The lwjgl util package is slated for removal because the vector and matrix classes there are crippled compared to those defined in the javax.vecmath package.

Most of the time you'll be passing either float arrays or FloatBuffers to lwjgl functions anyway, vector2f/vector3f etc. are really just used for convenience.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.