• Advertisement
  • entries
    743
  • comments
    1924
  • views
    582235

Textures

Sign in to follow this  

109 views

[EDIT - Decided to just start this post again [smile]]



Demo.

Fair bit of progress tonight. I've gone from a diffuse coloured cube spinning around on the screen to a randomly generated maze of textured cubes, with pixel fog enabled and a camera that allows for WASD and mouse-based freelook left and right and up and down.

Collision detection is sort of working along the X/Z plane, just by tradional 2D methods. It needs a lot of development since it is quite basic and you can't slide along walls if the angle of movement is slightly towards them, but never mind for now.

The floor is two big triangles, textured with wrap mode on.

I've also added a directional light and normals to the vertices. I'm just using the face normal for each vertex normal since everything is cubic. I don't pretend to understand the maths, but I lifted a function from the book to compute these face normals, and it seems to work.

Generally, for a 24 hour period since last posting, I call that steps in the right direction [smile].

On a side note, I've also finally been convinced of the joys of GetAsyncKeyState(Key) & 0x8000f over responding to WM_KEYDOWN and WM_KEYUP messages. Yay! One less dependancy between my main.cpp and my engine.
Sign in to follow this  


5 Comments


Recommended Comments

Quote:
Original post by HopeDagger
Looking good! If this pace remains constant, you'll have a 3D MMORPG up in two weeks. [grin]


That's the plan. I'm going to call it Forgotton Legends Of The Warrior Monks Of The Dragon Island Of Xandar 2: The Realms Of Extraordinary Chaos Witches, and I'm planning to host it on my 2 meg broadband connection, so thousands of online players shouldn't be a problem.

Either that or host it on my GameDev webspace. I reckon there's plenty of spare bandwidth.

Share this comment


Link to comment
Haha, seriously, I pictured myself with some friends shooting each other for a second there :-D. You've got a single plane, but tons of cover! I reckon it'd be fun, but it could be that I'm easily amused.

EDIT: also, for wall sliding against easy geometry like the one in your current "level": given the plane normal of the face you collide with, and the movement direction of the player, this equation will yield the new movement direction:

vNewDir = vDir - ( vNormal . vDir )


where '.' signifies the dot product.

For example, a face pointing along the positive z-axis:
vNormal = { 0, 0, 1 }

and a player moving sideways:
vDir = { -0.7, 0, -0.7 }
.
The dot product yields
vNormal . vDir = { 0 * -0.7, 0 * 0, 1 * -0.7 } = { 0, 0, -0.7 }
,
and subtracting this from vDir gives the new movement dir:
vNewDir = vDir - ( vNormal . vDir ) = { -0.7 - 0, 0 - 0, -0.7 - -0.7 } = { -0.7, 0, 0 }
.
So the player will now only be moving to the left (along the face).

In words: you cancel out that part of the velocity vector (movement dir) that alignes with the normal of the face. Expressing this in English is pretty hard for me, sorry about that :-).

Share this comment


Link to comment
Quote:
Original post by Todo
Haha, seriously, I pictured myself with some friends shooting each other for a second there :-D. You've got a single plane, but tons of cover! I reckon it'd be fun, but it could be that I'm easily amused.

EDIT: also, for wall sliding against easy geometry like the one in your current "level": given the plane normal of the face you collide with, and the movement direction of the player, this equation will yield the new movement direction:

vNewDir = vDir - ( vNormal . vDir )


where '.' signifies the dot product.

For example, a face pointing along the positive z-axis:
vNormal = { 0, 0, 1 }

and a player moving sideways:
vDir = { -0.7, 0, -0.7 }
.
The dot product yields
vNormal . vDir = { 0 * -0.7, 0 * 0, 1 * -0.7 } = { 0, 0, -0.7 }
,
and subtracting this from vDir gives the new movement dir:
vNewDir = vDir - ( vNormal . vDir ) = { -0.7 - 0, 0 - 0, -0.7 - -0.7 } = { -0.7, 0, 0 }
.
So the player will now only be moving to the left (along the face).

In words: you cancel out that part of the velocity vector (movement dir) that alignes with the normal of the face. Expressing this in English is pretty hard for me, sorry about that :-).


Your English is superb. You explain that far better than the English language text books seem to explain all this vector gibberish to me. Thanks.

As I say, the collision detection is pretty basic at the moment (store old position, move, check to see if in an occupied square, move back to old position if so), so it will need a major overhaul to try to implement it properly, but I suspect your notes above will prove invaluable when I do.

Thanks.

[EDIT] Actually, I have a plan for collision response within a simple 2D tile-based map like this. I was thinking it really should be no different to the collision response I've implemented in any of my 2D tile based games, since the collision is along a single and regularly-tiled plane.

I think I need to decouple the actual movement code from the camera class, then when a move is performed, seperate out the x movement from the z movement. I can then apply each in turn and use the same approach I've used in 2D games before - move along the x, if a collision then anchor to the x coord alongside the collided cell, then repeat for the z.

I believe this will allow for sliding along walls in the way that I want. I'm toying with the idea of writing a small game using the kind of map above as a first exercise in 3D creation, so if I can find a good collision system for the map objects that works, I can just hack collisions around free objects in the same way, by defining a square around their base centred on their mid-point.

Might work. I'll hopefully be able to find out tonight, then I can start a new project based on this experimental code and see if I can put some kind of little game together with it.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement