Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - phlux

Pages: [1]
1
Support / Re: My lights are messed up
« on: September 08, 2015, 10:05:54 am »
Hi Egon,

thanks again. I will play with the light settings a little bit more ;)

Your screenshots look awesome btw. Is this the same game from the trailers on the homepage? You should update them. Really neat stuff you achieved there.

Cheers, Chris

2
Support / Re: My lights are messed up
« on: September 04, 2015, 03:01:09 pm »
Quote
Maybe you aren't calling build() again on the merged object or something like that?

I checked my code. I did call build() on everything. However I did change my code from creating block aside block aside block to only draw the walls and floor/ceiling parts I really needed and voila smooth lighting!  8)



So I think because of the overlapping Object3Ds everything was messed up.

But I discovered some more oddities. Maybe you can shed some light on them (no pun intended).
So when I turn away from the light source, I get some strangly lit walls (note: I have fogging enabled, changed to per_pixel as you suggested. No ambient light explicitly set). This is a 180 rotation away from the light source:


The next thing is, the light is somehow shining through my walls. Imagine following layout

Code: [Select]
#####
#..V#
#.#.#
#.#.#
#L#?#
#####

Whereas L is the light V is the player position looking south and ? is the position the light shines through.




Is this normal? (I hope not) How can I fix this?

Thanks in advance!

3
Support / Re: My lights are messed up
« on: September 01, 2015, 10:56:13 pm »
Thanks for the in-depth explanation. I think I might understand what the problem is. Because of the objects not aligning correctly with each other the vertex normals cause the light to look strange.

After testing your code and understanding the problem I tweaked my code a little bit.
The dimensions I defined for a dungeon block were, width = 1.5 and height = 1. Changed them to w = 6 and h = 4.
I noticed that you translate your primitive to the desired location whereas I create the sides of the cube at the desired position. Does this make a difference?
Changing these values didn't solve the problem.

This is my code for creating my cubes. So as you can see I already used single panes.

Code: [Select]
    private Object3D createWalkableTile(int x, int y) {
        SimpleVector upperLeftFront = new SimpleVector(x * TILE_WIDTH, 0, -y * TILE_WIDTH);
        SimpleVector upperRightFront = new SimpleVector((x * TILE_WIDTH) + TILE_WIDTH, 0, -y * TILE_WIDTH);
        SimpleVector lowerLeftFront = new SimpleVector(x * TILE_WIDTH, TILE_HEIGHT, -y * TILE_WIDTH);
        SimpleVector lowerRightFront = new SimpleVector((x * TILE_WIDTH) + TILE_WIDTH, TILE_HEIGHT, -y * TILE_WIDTH);

        SimpleVector upperLeftBack = new SimpleVector(x * TILE_WIDTH, 0, -(y * TILE_WIDTH) + TILE_WIDTH);
        SimpleVector upperRightBack = new SimpleVector((x * TILE_WIDTH) + TILE_WIDTH, 0, -(y * TILE_WIDTH) + TILE_WIDTH);
        SimpleVector lowerLeftBack = new SimpleVector(x * TILE_WIDTH, TILE_HEIGHT, -(y * TILE_WIDTH) + TILE_WIDTH);
        SimpleVector lowerRightBack = new SimpleVector((x * TILE_WIDTH) + TILE_WIDTH, TILE_HEIGHT, -(y * TILE_WIDTH) + TILE_WIDTH);

        Object3D tile = new Object3D(4);
        tile.addTriangle(lowerLeftBack, 0, 0, lowerRightBack, 1, 0, lowerLeftFront, 0, 1, textureManager.getTextureID(DUNGEON_FLOOR));
        tile.addTriangle(lowerRightBack, 1, 0, lowerRightFront, 1, 1, lowerLeftFront, 0, 1, textureManager.getTextureID(DUNGEON_FLOOR));

        tile.addTriangle(upperLeftBack, 1, 0, upperLeftFront, 1, 1, upperRightBack, 0, 0, textureManager.getTextureID(DUNGEON_CEILING));
        tile.addTriangle(upperRightBack, 0, 0, upperLeftFront, 1, 1, upperRightFront, 0, 1, textureManager.getTextureID(DUNGEON_CEILING));
        tile.invert();

//        tile.compile();
//        tile.strip();
        tile.build();


        return tile;
    }

    private Object3D createWall(int x, int y) {
        SimpleVector upperLeftFront = new SimpleVector(x * TILE_WIDTH, 0, -y * TILE_WIDTH);
        SimpleVector upperRightFront = new SimpleVector((x * TILE_WIDTH) + TILE_WIDTH, 0, -y * TILE_WIDTH);
        SimpleVector lowerLeftFront = new SimpleVector(x * TILE_WIDTH, TILE_HEIGHT, -y * TILE_WIDTH);
        SimpleVector lowerRightFront = new SimpleVector((x * TILE_WIDTH) + TILE_WIDTH, TILE_HEIGHT, -y * TILE_WIDTH);

        SimpleVector upperLeftBack = new SimpleVector(x * TILE_WIDTH, 0, -(y * TILE_WIDTH) + TILE_WIDTH);
        SimpleVector upperRightBack = new SimpleVector((x * TILE_WIDTH) + TILE_WIDTH, 0, -(y * TILE_WIDTH) + TILE_WIDTH);
        SimpleVector lowerLeftBack = new SimpleVector(x * TILE_WIDTH, TILE_HEIGHT, -(y * TILE_WIDTH) + TILE_WIDTH);
        SimpleVector lowerRightBack = new SimpleVector((x * TILE_WIDTH) + TILE_WIDTH, TILE_HEIGHT, -(y * TILE_WIDTH) + TILE_WIDTH);

        Object3D tile = new Object3D(8);

        // Left
        tile.addTriangle(upperLeftFront, 0, 0, upperLeftBack, TILE_WIDTH, 0, lowerLeftFront, 0, TILE_HEIGHT, textureManager.getTextureID(DUNGEON_WALL_1));
        tile.addTriangle(upperLeftBack, TILE_WIDTH, 0, lowerLeftBack, TILE_WIDTH, TILE_HEIGHT, lowerLeftFront, 0, TILE_HEIGHT, textureManager.getTextureID(DUNGEON_WALL_1));

        // Right
        tile.addTriangle(upperRightFront, TILE_WIDTH, 0, lowerRightFront, TILE_WIDTH, TILE_HEIGHT, upperRightBack, 0, 0, textureManager.getTextureID(DUNGEON_WALL_1));
        tile.addTriangle(upperRightBack, 0, 0, lowerRightFront, TILE_WIDTH, TILE_HEIGHT, lowerRightBack, 0, TILE_HEIGHT, textureManager.getTextureID(DUNGEON_WALL_1));

        // Front
        tile.addTriangle(upperLeftFront, TILE_WIDTH, 0, lowerLeftFront, TILE_WIDTH, TILE_HEIGHT, upperRightFront, 0, 0, textureManager.getTextureID(DUNGEON_WALL_1));
        tile.addTriangle(upperRightFront, 0, 0, lowerLeftFront, TILE_WIDTH, TILE_HEIGHT, lowerRightFront, 0, TILE_HEIGHT, textureManager.getTextureID(DUNGEON_WALL_1));

        // Back
        tile.addTriangle(upperLeftBack, 0, 0, upperRightBack, TILE_WIDTH, 0, lowerLeftBack, 0, TILE_HEIGHT, textureManager.getTextureID(DUNGEON_WALL_1));
        tile.addTriangle(upperRightBack, TILE_WIDTH, 0, lowerRightBack, TILE_WIDTH, TILE_HEIGHT, lowerLeftBack, 0, TILE_HEIGHT, textureManager.getTextureID(DUNGEON_WALL_1));

//        tile.compile();
//        tile.strip();
        tile.build();

        return tile;
    }

I debugged the code for the generation and I didn't noticed any slight offset in the vectors during generation, I only saw whole numbers.
So I would say the edges of the cube match exactly.
As I'm blindly generating cube aside cube do the overlapping sides may cause problems? I suppose then I'll have to rethink the whole wall generation process of the dungeon...

4
Support / My lights are messed up
« on: September 01, 2015, 04:45:56 pm »
Hello everyone!

Working on my little 3D demo which is basically an old school FPS dungeon crawler lookalike. I got the basic rendering stuff done and I started to add light sources (torches) but I encountered some strange behaviour:





I strongly suspect my code which builds the blocks, that messes with the lighting as I read somewhere on the board that too many Object3Ds mess with the lighting.
I'll give you a quick rundown how I build my level:

Dungeon layout is defined in a txt file
Code: [Select]
######
#....#
#....#
#....#
######

Where # is a wall block and . is a block with only a floor and a ceiling.
I iterate over the layout and create an Object3D for each block. Because I'm a lazy slob, a non wall block only has the floor and ceiling which I inverted then during creation (so you basically stand inside the cube and can see the walls from inside).

After adding wall and floor tiles to a separate array (walls and tiles) I call Object3D.mergeAll with the arrays as parameter and add the result to the world.
When I add a red light for testing it results in the images shown above.

I'm also unsure on how the compileAndStrip() function works... If I call it on the wall and tile Object3Ds lighting gets removed completely. I added some fog via setFogging() and it gets removed too when I call compileAndStrip().

So, how can I fix my lights? I can add some code if anything needs clarification.

Cheers!

5
Support / Re: Help with frustum culling and perspective
« on: August 22, 2013, 09:03:20 pm »
Okay, i tweaked the nearPlane value a bit and added 10 degree tilt to bottom. Works veeery well:



Step closer.



Thanks Egon!

6
Support / Re: Help with frustum culling and perspective
« on: August 21, 2013, 01:49:56 pm »
Haha ;D I never noticed that. Thanks for pointing that out. I will try and lower the cam a bit. When I look at the lines it also looks like the camera is tilted a bit downward.

7
Support / Re: Help with frustum culling and perspective
« on: August 21, 2013, 09:20:32 am »
Yes I did, also forgot to mention this uses the hardware renderer.

8
Support / Help with frustum culling and perspective
« on: August 20, 2013, 08:44:21 pm »
Hi,

I'm quite helpless in figuring out how to choose the correct FOV and also adjusting the nearPlane so my objects are not cut off. As mentioned in previous threads I'm working on some kind of dungeon crawler (eg Grimrock or Dungeon Master, Realms of Arkania). In the old games it is possible to stand directly in front of a wall and see the complete facing wall and some portions of the floor and ceiling. This is exactly the perspective I'm aiming for. Here is an example:



one step closer (standing direct in front of the wall)



Okay you can see here that at least a small area of floor is visible.

My implementation
Each tile (wall, floor, ceiling) is a 2x2 units small Object3D. So if a floor tile is created with the coords (0,0) (2,0) (0,2) (2,2) I position the camera at point (1,1) for example.
When I rotate the camera 90 degrees, walls will be cut off during rotation and you can see what's behind that block. From my limited 3D graphics knowledge I knew that I need to fiddle with the clipping planes in order to reduce this effect. I reduced the nearPlane to a size of 0.78f which suited my needs at first.

Same scene as the first screenshot.



Now going one step forward...



*donk* looks like I'm hugging the wall.

I tweaked the nearPlane and also the world cams FOV, nearPlane size of 0.4f and FOV of 1.2f



step closer



Looks better but editing the two values anymore makes it looks like an alien view, especially when rotating the camera. Anyone got an idea how to accomplish the desired perspective?

Here's also a movie, showing off what I got till now. It was taken with just the adjusted nearPlane: https://www.youtube.com/watch?v=7HDvKI6M5y0

9
Support / Re: Animated rotation of the camera 90 degree wise
« on: August 11, 2013, 09:33:07 am »
Okay, I take that as both work  ;D

10
Support / Re: Animated rotation of the camera 90 degree wise
« on: August 10, 2013, 10:58:53 am »
you should use grid based movement instead of checking for collisions with the camera, i think its better for this kind of games.
I second this. It's much easier and more feasible for this kind of game.

Okay so i'm on the correct way for the rotation. What method should I use for directional movement? When I move from tile to tile I need to move two units (as plates have a width of two and you stand in the middle). Shall I use moveCamera with a vector and a speed which equals the current tick count or shall I use setPosition with a vector with a small increased amount in a direction (the same tick/unit ratio like for the rotation)?

11
Support / Animated rotation of the camera 90 degree wise
« on: August 09, 2013, 04:31:50 pm »
Hi again.

I'm still on my prototype of my dungeon crawler thing demo. However I'm not quite sure how to implement 90 degree wise camera rotation.
I'm using the advanced example from the wiki as a source base. The example uses ticks for animation. My idea was that the camera needs some defined amount of ticks to finish a 90 rotation. So if a keypress to rotate the camera is detected I would use the animate() function from the example to rotate the camera until an amound of ticks is reached. Say a rotation would take 100 ticks for 90 degrees, so I would rotate the camera 0.9 degree each tick.

Is this the correct approach or is there a better way to accomplish this kind of camera movement?

I've seen that there is already some functions like checkCameraCollision() in the World class for basic cam movement (forward/backward). How are these implemented? Also are these suited for non rotational movement in a dungeon crawler?

Thanks again,
Chris

12
Support / Re: Combining MD2 models?
« on: August 01, 2013, 03:36:05 pm »
Thanks for the reply. So when I create models and weapons I need to align them so it looks like the model holds the weapon and make them share the animations.

13
Support / Combining MD2 models?
« on: July 30, 2013, 04:55:10 pm »
Hello!

I've already tried the search but to no avail. Right now I'm just playing around with the engine and have a look at whats possible and what not. I've seen that the engine supports loading MD2 models and also playing animations. However the models don't hold any weapons in their hands and my question now is, if there is a way to load two models combine them and play a skeletal animation?

For example let's say you have a MD2 model of a knight and also a model of a sword, can you add it programatically to the hand of the knight and the character model uses it correct in its animations?

Thanks in advance
Chris

Pages: [1]