Isometric camera angle, and single sided polygon help:)

Started by cyberkilla, November 21, 2006, 12:41:19 PM

Previous topic - Next topic

cyberkilla

Hello! This is the first post ive made here:)

I have a project, in which I have a 2d isometric map,
and 3d models walking around.

I have managed to get it working!

My issue is that I cant find a decent isometric camera angle.

Another problem im having is: I am drawing in blender, and exporting
to 3DS format. If I open the 3DS file in blender, or openfx, etc,
it works properly. However, when I render it with jpct, I get a strange effect.

I looks as if the polygons are single sided. They have a colour from one angle, and not from the other.
This is fair enough, but my 3d model  has invisible pieces!
Then when you rotate it, the back of the model has the same problem,
except the faces that are invisible are the ones that were visible on the other angle!

I hope that makes sense:)


Can anyone give me a decent isometric angle, and an answer to my
single sided polygon issue?:)

Thanks again.

PS. This 3D engine is fantastic. I am going to plug it extensively on my websites if i get this sorted. It is nice that most people appear to be doing this anyway.


EDIT: Ive discovered a flag in blender to export doublesided:
http://wiki.flightgear.org/flightgear_wiki/index.php?title=Normals_and_Transparency_Tutorial
Just incase another has this issue.
Also http://www.christiancoders.com/cgi-bin/ubb-cgi/postdisplay.cgi?forum=Forum3&topic=000362
Details the use of CTRL+N in blender to make all faces "face" properly!

I hope that helps
[/i]
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

EgonOlsen

You may still use the singlesided model and use Object3D.setCulling(<boolean>) to disable backface culling. About the camera angle...i'm not really sure what you mean. A real isometric isn't possible, it's always perspective projection in jPCT. To come close to a real isometric view, you can move the camera farer away and decrease the camera's FOV. But you may run into zbuffer accuracy problems with this when moving too far.

cyberkilla

Hey:) I appreciate your fast response:)

I understand there will be perspective, but, its just rough.
So you suggest simply moving the camera...

Perhaps if I moved it by (-30,-30,-30)... I will post some screenshots
when I finish:)

EDIT:
This is the angle that seems to work, although, i do not know why it would:P

world.getCamera().setPosition(new SimpleVector(-4,50,30));
world.getCamera().lookAt(obj.getCenter());
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

cyberkilla

It didnt work:(

I have another problem also....

I render the model onto a buffered image of a set size,
and superimpose that onto my isometric map.

Is there a way that I can always know the offset in pixels of the base
of the model ive rendered?
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

EgonOlsen

It didn't work...because of...what?

What exactly wasn't working as expected?

About the base: Do you know the coordinates of the base line in world space (or better: of a point on that line)? You may then use Interact2D.project3D2D() to get the framebuffer coordinates. If you don't know the coordinates, use a dummy object, translate it to the base line and append it to the model as a child. Use the getTransformedCenter() on this dummy to get a point on the base line in world space and feed that into that method mentioned above.

cyberkilla

Aha! Could I work this out from the bounding box of the model?(im assuming this is a box that encapsulates the entire model).

Finding this base line coord, I can work out easily where to put it on my isometric map.

Thank you for your help. I know I am asking strange questions:).

I have solved what i said "wont work".
It is because Blender uses Z-up, and jpct seems to use Y-up.

It is a lot of trouble to rotate objects inside blender, and harder to edit
at the wrong angle.

Instead, I would like to rotate the camera so that Z is up.
Is that ok? I know you can rotate the camera, but will it cause me any real trouble?

I intend only to use the api to render models and cache as bufferedimages at this point - although, more will be used in future, because this api is so functional:).

Will I still be able to use the Interact2D.project3D2D() if i rotate the camera?

Thanks again:)

EDIT:

The solution....
float radians = -90f/(180f/(float)Math.PI);
     obj.rotateX(radians)


Im just rotating the model themselves.
So camera isnt affected:D
[/i]
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

cyberkilla

I cant seem to find anything like getBoundingBox, although, I do see a setBoundingBox.

Maybe I could get the bounding box, max y,  and use that?
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

EgonOlsen

Object3D.getMesh().getBoundingBox() is your friend. But keep in mind that this is the BB in object space, not in world space.
About the different coordinate system...yes, some editors have Z pointing up, some Y. jPCT is even more strange as it has Y pointing down. But that doesn't really matter at all. It's all about the way you think in the 3D world. Once you get used to it, the coordinate system doesn't really matter. I suggest to rotate the mesh after loading to convert it from blender's system into jPCT's. You can make this rotation permanent by using rotateMesh(); The car example is doing this too for the landscape. After that, you don't have to care about the differences any longer.

cyberkilla

Aha, thanks egon:)

So, object space coords are relative to object, so I need to figure out
how to get the world space coords.
Ill have a go:)
Thanks again.
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

cyberkilla

Solved it!!!!

This code seems to get the bottom line of a 3d object, and get its Y coord
on the backbuffer:D


         SimpleVector vec,objcenter;
         float[] boundingvec;
         boundingvec = obj.getMesh().getBoundingBox();
         objcenter   = obj.getTransformedCenter();
         
         vec = new SimpleVector(
         0, boundingvec[3], boundingvec[4]);
       
         vec.matMul(obj.getWorldTransformation());
         
         theY = Interact2D.project3D2D(world.getCamera(),buffer,vec).y;



Egon, is there any ways to increase the quality of my rendered images?
Is there any antialiasing, or, well, anything that can improve the accuracy
of my models at such a close up view?

Perhaps I should render large, and use the highly powerful java2d functions to resize the buffered image.

EDIT: Yup! Resizing with java2d is DEFINATELY the way to go!:)
Any other tips are welcomed!
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG

EgonOlsen

You may use an antialiased framebuffer as well. It exists in two flavours, i.e. 1.5*1.5 or 2*2 times oversampling. Just keep in mind that the result from Interact2D-methods don't care for the framebuffer's final size but work on the larger one (as documented).

halcor

Hi, all, first post here :)

Another non-JPCT way to improve quite a bit visual quality is to bake ambient occlusion maps into model textures. Blender CVS version has this feature (check blender.org for info and graphicall.org for CVS builds), and it's also possible with the release versions so far by using the script BRayBaker.

cyberkilla

Thanks Egon:) Ill let you know how it goes.

Welcome to the forum halcor! Im pretty new also;).

Ill look into what you say. I must admit, ive never heard of it before.


EDIT: Egon, im afraid its not possible for me to use your oversampling:)
You see, I set the background to magenta, and set that to the transparent colour.
With aliasing, i get a pink border:P
Im thinking, this will not happen if i rescale with the java2d, because ive already made the bg pixels have 0 alpha:)
http://futurerp.net - Text Based MMORPG
http://beta.rpwar.com - 3D Isometric MMORPG