[QUOTE=Larikang;37366756]It's actually pretty easy to do that. Ruby has a bunch of metaprogramming helper methods that make that sort of code very elegant.[/QUOTE]
Is there a way to do it without using eval?
[QUOTE=sambooo;37367352]Is there a way to do it without using eval?[/QUOTE]
Module#define_method, Object#instance_variable_set
In fact, just check out all of Module's instance methods. So much metaprogramming goodness.
[QUOTE=Kopimi;37367212]phew good thing there's no demos allowed otherwise people might see your game isn't worth approving to be on steam[/QUOTE]
I don't see why you have to be so rude all the time. I said literally nothing that would evoke such a response from anybody. In fact, I even admitted myself that the game currently isn't very fun at the moment.
Why do you have to be so antagonistic?
[QUOTE=Dark7533;37363875][IMG]http://i639.photobucket.com/albums/uu118/blayze7533/noise4.png[/IMG]
Next build a poly mesh and use this algorithm for the height map.[/QUOTE]
uh, is that supposed to be fractal noise?
[editline]23rd August 2012[/editline]
[QUOTE=Kopimi;37367212]phew good thing there's no demos allowed otherwise people might see your game isn't worth approving to be on steam[/QUOTE]
can someone fill me in on this
[QUOTE=Overv;37364101]Both libraries will convert their internal representation to column major order when actually using it, but it does influence multiplication. As philly c was trying to say, GLM uses column major multiplication and OpenTK uses row major multiplication.[/QUOTE]
To be more precise: [url]http://fgiesen.wordpress.com/2012/02/12/row-major-vs-column-major-row-vectors-vs-column-vectors/[/url]
[QUOTE=sambooo;37365760]Okay I've hardly used ruby yet and I already love it, it just feels like I've finally found a language that works with me not against me[/QUOTE]
<3<3<3
Hmph, I clearly don't even understand inheritance yet. Can one of you wizards explain why gen_getter is undefined in the Thing class here?
[code]class MetaClass
def create_method name, &block
self.class.send(:define_method, name, &block)
end
def gen_getter name
getter = '@' << name.to_s
puts getter
# create_method getter {
# }
end
def gen_setter name
getter = '@' << name.to_s
puts setter
# create_method setter {
# }
end
end
class Thing < MetaClass
gen_getter :test
end[/code]
Something about that structure strikes me as being similar to Lua.
Oh oh oh I got this, I need to define methods in the Module class, yay progress
[editline]23rd August 2012[/editline]
[code]class Module
def gen_getter name
getter = '@' << name.to_s
puts getter
end
end
class Thing
gen_getter :test
end[/code]
Alright, so I'm on the last step of the transformation page of open.gl, and have hit a bump.
My major problem (read: pain the ass) is that LWJGL doesn't come with any nice methods that help with perspective projection or view matrix creation, so I did a bit of research and taught myself which values are important in each matrix. As a result, I've got a method that sets up the projection matrix for me:
[code]
private Matrix4f perspective(float fov, float aspectRatio, float zNear, float zFar) {
float zm = zFar - zNear;
float zp = zFar + zNear;
Matrix4f persp = new Matrix4f();
persp.m00 = (1 / (float)Math.tan(Math.toRadians(fov / 2))) / aspectRatio;
persp.m11 = 1 / (float)Math.tan(Math.toRadians(fov / 2));
persp.m22 = -zp / zm;
persp.m32 = -(2 * zNear * zFar) / zm;
return persp;
}
[/code]
And according to the only reliable source I've found, the view matrix can be taken as a simple identity with a slight modification to ensure that Z is "up:"
[code]
Matrix4f view = new Matrix4f();
view.m13 = 1f;
[/code]
((1, 3) is the value to be changed that I have ascertained from the LWJGL wiki pages, and produces the desired effect).
The only thing wrong with the result of all of this is that without translating the view matrix backwards on the z component, the drawn object is behind the camera, but the whole object can never be drawn. Here's the average result (fov 45, view.translate(0.0f, 0.0f, -1.2f)):
[IMG]https://dl.dropbox.com/u/38489921/halp.png[/IMG]
So close to the expected result!
The only thing I can think of is that I may accidentally be scaling something somewhere, or ~maybe~ that changing (1, 3) is incorrect in the view matrix.
All my problems would go away if LWJGL just had nice helper functions, but I guess learning the building blocks is fun :)
If any more info is needed as to what I'm doing, the entire code is here, with commented sections:
[URL="http://pastie.org/4572970"]http://pastie.org/4572970[/URL]
I did it!
[code]class Module
def gen_getter symbol
module_eval do
define_method symbol do | |
instance_variable_get "@#{symbol}"
end
end
end
def gen_setter symbol
module_eval do
temp = symbol.to_s << '='
define_method temp do | value |
instance_variable_set "@#{symbol}", value
end
end
end
end
class Thing
gen_setter :test
gen_getter :test
end
t = Thing.new
t.test = 'Hi'
puts t.test[/code]
[editline]23rd August 2012[/editline]
Also I replaced all tabs with 2 spaces because Ruby
[QUOTE=sambooo;37369248]Also I replaced all tabs with 2 spaces because Ruby[/QUOTE]
oh no he di'int
I read that it's the convention for indentation in Ruby, I'm using 4 space width tabs in my editor but they are really wide in code tags so I replaced them
Oh maybe I'm about to cause my first page long holy war, cool
Just picked up my new whiteboard. Let the project-sketching begin!
[img]http://localhostr.com/files/kW7Uj2r/capture.png[/img]
[QUOTE=Dr Magnusson;37369393]Just picked up my new whiteboard. Let the project-sketching begin!
[img]http://localhostr.com/files/kW7Uj2r/capture.png[/img][/QUOTE]
You uh... Gonna hang that up? Or just crawl on the floor when trying to figure out array indices?
Game of Life in XNA:
[t]https://dl.dropbox.com/u/15606445/GoL.png[/t]
That satisfaction when it actually works how it's meant to. Spent so long trying to figure out what I did wrong in the calculation of how many neighbours each pixel has then realizing it wasn't because of that. Damn references. Download if for some reason you may want it: [url]https://dl.dropbox.com/u/15606445/GoL.rar[/url]
I'm starting to hate modern OpenGL again...
[csharp]Shader.SetUniform("transform", Matrix4.Identity);[/csharp]
[code]#version 150
in vec2 position;
in vec4 color;
uniform mat4 transform;
out vec4 Color;
void main()
{
Color = color;
gl_Position = vec4( position, -1.0f, 1.0f ); // WORKS
gl_Position = vec4( position, -1.0f, 1.0f ) * transform; //DOES NOT
}[/code]
Any idea what's causing this? :tinfoil:
I'm honestly on the verge of reverting back to immediate mode here.. It's not optimal, but at least it works.
[QUOTE=voodooattack;37369476]I'm starting to hate modern OpenGL again...
[csharp]Shader.SetUniform("transform", Matrix4.Identity);[/csharp]
[code]#version 150
in vec2 position;
in vec4 color;
uniform mat4 transform;
out vec4 Color;
void main()
{
Color = color;
gl_Position = vec4( position, -1.0f, 1.0f ); // WORKS
gl_Position = vec4( position, -1.0f, 1.0f ) * transform; //DOES NOT
}[/code]
Any idea what's causing this? :tinfoil:
I'm honestly on the verge of reverting back to immediate mode here.. It's not optimal, but at least it works.[/QUOTE]
Shouldn't that multiplication be the other way around?
[QUOTE=danharibo;37369494]Shouldn't that multiplication be the other way around?[/QUOTE]
I tried that too.
[QUOTE=Jookia;37369436]You uh... Gonna hang that up? Or just crawl on the floor when trying to figure out array indices?[/QUOTE]
It's coming up this afternoon, I literally just got it in the door :v:
Well, I got it...sort of:
[IMG]https://dl.dropbox.com/u/38489921/halp2.png[/IMG]
The only difference in code is that I have to translate my view matrix by -1.2f on the z axis, and the only difference visually is that the angle of my image is a little higher.
I'll move onto full 3D, and come back to this particular problem if it causes bigger ones down the line. Night successful. Bed ti-oh wait, it's 9AM.
...is it weird that after seeing this thing spin for the entire night I can't look at a still image of it? In my app, the two images also blend with time...so I'm seeing that too. In this still image.
Somebody get help.
Pfffft, I figured it out, I was passing the transform before activating the shader.
[QUOTE=voodooattack;37369505]I tried that too.[/QUOTE]
Double check that the uniform is the problem, create a matrix inside the shader.
edit:
Well nevermind then
Whats a good game font that has a fantasy vibe but isn't too over the top. Probably not the best place to post, but since you guys worked on such games I think you could give me a tip.
Comic Sans MS or Papyrus
[IMG]http://imgur.com/pcD6L.png[/IMG]
Tried to made repeating textures. Terrible. I really need to implement mip-mapping.
Also, FPS goes up and down by 100 for some reason. Maybe you should not have triangles that are 2048 x 2048 in size.
[QUOTE=SupahVee;37366152]I've created a new blog post :D
This time it is about 2d procedurally generated worlds.[/QUOTE]
Mind posting the source? I would love to generate some rooms in my app.
Also today I got my GCSE results: I got a D in ICT. How. The. Fuck.
[QUOTE=Matt-;37370297]Mind posting the source? I would love to generate some rooms in my app.
Also today I got my GCSE results: I got a D in ICT. How. The. Fuck.[/QUOTE]
ICT is awful, that's how.
[QUOTE=WTF Nuke;37370122]Whats a good game font that has a fantasy vibe but isn't too over the top. Probably not the best place to post, but since you guys worked on such games I think you could give me a tip.[/QUOTE]
Here's my personal favourite, LondonTwo: [url]http://www.dafont.com/london-between.font[/url]
[QUOTE=Matt-;37370297]Mind posting the source? I would love to generate some rooms in my app.
Also today I got my GCSE results: I got a D in ICT. How. The. Fuck.[/QUOTE]
I remember my ICT GCSE exam, everyone but one person left after 20mins.
Sorry, you need to Log In to post a reply to this thread.