Author Topic: 2D Isometric Maps With 3D Models...  (Read 15777 times)

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
2D Isometric Maps With 3D Models...
« on: December 12, 2006, 08:40:52 pm »
Hello everyone! I have managed to achieve this quite well....

My problem is, Im not sure how it would scale in terms of speed.

Please, please do me the huge favour of reading this through. My deadline is christmas, and its drawing dangerously near:O



I currently have all tiles and objects(including npcs) in zordered linked list.
I draw the full list, including the models in the right order.

Unfortunately, I cant really cache the 3d models when its their turn to be rendered. It uses way too much memory. So, I must render them each time they are needed.

I have implemented a "dirty rectangles" system, so only the objects(tiles/npcs/etc) that intersect a dirty rectangle will be redrawn.

Here are the steps in order...IGNORING DIRTY RECTS:)

-Iterate through map objects, painting each at the right location...
-If its a tile, then paint a tile...
-If its an avatar(npc/player), then render model to 200x200 framebuffer,
with a MAGENTA background. Create new image with MAGENTA set to TRANSPARENT. Paint onto main backbuffer.


Now, that works. It really does. The problem is it seems like a lot of trouble. Is there any ways I can improve this?

Is faster/possible to make the map into some kind of 3d object itself, dynamically?
Is it possible to set the framebuffer jpct renders onto transparent, to cut out an extra step?

Also, how on earth could I have several different avatars?
I would think a separate world for each model would work perfectly,
but is it too memory intensive?

Thank you in advance for this!


BTW: My FPS is ~80 when im not painting anything new, but drops to
~30 when im in fullscreenmode, and moving my character.
In window mode, im lucky if i get 18, and its only ONE character:(.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline Mizuki Takase

  • int
  • **
  • Posts: 97
    • View Profile
2D Isometric Maps With 3D Models...
« Reply #1 on: December 12, 2006, 09:03:06 pm »
Wow, your project looks really awesome! I miss the great video games like Crusader: No Remorse... Anyway!!


Quote
Is faster/possible to make the map into some kind of 3d object itself, dynamically?

Are your tiles small pieces of mesh? If so, then I would guess yes. I would assume that you can probably merge them all into one big Object3D map or so after translating the tiles before merging.

Quote
Is it possible to set the framebuffer jpct renders onto transparent, to cut out an extra step?

Why do you have to render your avatar onto a secondary framebuffer, set the alpha transparency and then placing that onto the main framebuffer? That sounds really tasking!

Quote
Also, how on earth could I have several different avatars?
I would think a separate world for each model would work perfectly,
but is it too memory intensive?

Several different avatars? I would guess to have different 3d meshes...

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
2D Isometric Maps With 3D Models...
« Reply #2 on: December 12, 2006, 09:10:06 pm »
Thank you:) Yes! I like Crusader too!:D

My tiles are 2D images. The dimensions are 48x24, and tiles with height
go up in increments of 15px.


I need to draw to another bufferedimage, because I NEED the model to have a TRANSPARENT background, so it can be drawn onto the map:)
I use MAGENTA as the background color, because its least used in my models:)
If I could get the thing to be transparent itself, OR PERHAPS get jpct
to render STRAIGHT ONTO my bufferedimage?

Is it possible to do that?:P


The models are 3D, and thats it:).
I currently set the camera and lights to a roughly isometric angle,
and make them look at the models center. This also happens to be the (0,0) of the world space, i think.

If I were to draw several different characters,  id have to keep moving the camera and lights(might be slow), or maybe you can hide all but the current model im rendering by setting them to totally transparent.

The other, probably easier way, might be to make a new world for each object, but i would imagine id be frowned on by people here;).
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline Mizuki Takase

  • int
  • **
  • Posts: 97
    • View Profile
2D Isometric Maps With 3D Models...
« Reply #3 on: December 12, 2006, 09:18:24 pm »
Hold the presses~! Have you ever considered making a lot of planes of your tiles and then use Object3D.setBillboarding(boolean mode)? Billboarding is something where the texture will always face the camera or so....

Oh, Object3D also have setVisibility(boolean). As quoted from the javadoc,
Quote
Sets the object to visible/invisible. Invisible objects won't be processed/rendered at all.
That sounds like something you wanted...

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
2D Isometric Maps With 3D Models...
« Reply #4 on: December 12, 2006, 09:23:34 pm »
No, I havent! I didnt know that feature was implemented in jpct!:D

The problem is, however:

How to make planes.
How to stack them so they look as they do now, with 2d drawing.
Is it faster than 2d, even in software render mode?
And, last, but not least....

How do I move the models now?:D I mean, I KNOW that one tile is 24x48,
and that I can move to then next, based on those dimensions.

How do I figure out the equivalent in 3d space? I  must admit, ive not wrapped my head around this:P
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline Mizuki Takase

  • int
  • **
  • Posts: 97
    • View Profile
2D Isometric Maps With 3D Models...
« Reply #5 on: December 12, 2006, 09:29:42 pm »
Ah~~ I keep on editting my own replies too slowly... Anyway!

I wanted to move Object3D stuff in 3d space and Egon told me this... http://www.jpct.net/forum/viewtopic.php?t=607&highlight=project

To make a plane, Primitives.getPlane(int quads, float scale) would help...

Shameless ad of my silly project.. Its supposed to be like Strider2 or Castlevania:Symphony of the Night... http://www.cs.uno.edu/~tvle/hotaru/New%20Text%20Document.htm

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
2D Isometric Maps With 3D Models...
« Reply #6 on: December 12, 2006, 09:43:26 pm »
Quote from: "Mizuki Takase"
Hold the presses~! Have you ever considered making a lot of planes of your tiles and then use Object3D.setBillboarding(boolean mode)? Billboarding is something where the texture will always face the camera or so....

Oh, Object3D also have setVisibility(boolean). As quoted from the javadoc,
Quote
Sets the object to visible/invisible. Invisible objects won't be processed/rendered at all.
That sounds like something you wanted...


That will be very,very helpful! Thank you for pointing that out:).
Thats one less problem.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline athanazio

  • byte
  • *
  • Posts: 49
    • View Profile
    • http://www.athanazio.pro.br
2D Isometric Maps With 3D Models...
« Reply #7 on: December 12, 2006, 09:43:38 pm »
I tried something with the planes... but got out of memory on that
http://www.jpct.net/forum/viewtopic.php?t=190&start=375

any ideas ?

Offline Mizuki Takase

  • int
  • **
  • Posts: 97
    • View Profile
2D Isometric Maps With 3D Models...
« Reply #8 on: December 12, 2006, 09:51:25 pm »
To athanazio: I saw that, but was tooo scared to touch it with a stick...

Your code seems normal to me... Instead of constantly making a new plane with Primitives.getPlane(SQUARE_SIZE, 1); why not Object3D.cloneObject()? I hope that helps...

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
2D Isometric Maps With 3D Models...
« Reply #9 on: December 12, 2006, 09:54:02 pm »
Quote from: "athanazio"
I tried something with the planes... but got out of memory on that
http://www.jpct.net/forum/viewtopic.php?t=190&start=375

any ideas ?


Hmm, no idea, but i bet I get an out of memory:D
My biggest map so far is just over 4,000 tiles:)
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
2D Isometric Maps With 3D Models...
« Reply #10 on: December 12, 2006, 10:03:20 pm »
Don't create an object per tile. That's too much...as you've already noticed. Create the landscape as one single object out of single triangles (by using addTriangle) or create a plane of that size/tiling and manipulate that using an IVertexController as rolz suggested. In your code (if i've understood that correctly at first glance), you are are creating 50*50=2500 objects with 50*50*2=5000 polygons each, i.e. 12m polygons...a bit too much, isn't it?

Offline Mizuki Takase

  • int
  • **
  • Posts: 97
    • View Profile
2D Isometric Maps With 3D Models...
« Reply #11 on: December 12, 2006, 10:08:48 pm »
Since addtriangle() sounds too complicated, I wanted to know if its okay to recursively create an instance Plane object and merge that onto the bigger shape and pray that the Java garbage collector to handle the memory stuff? athanazio posted code for that, and I was hoping that is not a bad solution...

Offline cyberkilla

  • float
  • ****
  • Posts: 413
    • View Profile
    • http://futurerp.net
2D Isometric Maps With 3D Models...
« Reply #12 on: December 12, 2006, 10:11:06 pm »
Any idea what I could do Egon? I am assuming you are speaking
to athanazio in that last post?

I am unsure it would be worth putting the tiles as billboarded planes,
as I need in excess of 8,000 in some cases.
Surely 2D is the way to go for me? Wouldnt it be faster to draw?
Especially considering I plan only to use Software Rendering:).


Is there any tricks for getting 3d models onto bufferedimages,
with the background transparent?
Everything I say sounds confusing:)

At the minute, im pretending that the render is a 2d sprite with a MAGENTA background, which i set all MAGENTA pixels to transparent.

Probably faster to do some sort of bit masking.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
2D Isometric Maps With 3D Models...
« Reply #13 on: December 12, 2006, 10:15:06 pm »
I don't see where in his code he's doing this  :?: To me, it looks like as if he's just adding 5000 polygons in form of a 50*50 plane 2500 times into that array. Creating an object out of single triangles actually isn't that hard. There should be some code for this in the terrain-example in that old 0.96zip that's still available here: http://www.jpct.net/download/jpctapi_096.zip (This is just for demonstration purpose...the rest of this stuff is outdated...don't use it).

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
2D Isometric Maps With 3D Models...
« Reply #14 on: December 12, 2006, 10:17:02 pm »
@cyberkilla: I've to think about this a little...i'm not in the position to give a good answer for this now, i'm afraid.