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.


Topics - majestik_m00se

Pages: [1]
1
Support / avoiding depth sort /transparency issues on a merged object
« on: March 09, 2012, 08:50:21 pm »
Hi,

First of all, thanks for your help previously with my earlier navigating-a-sphere questions.  I got it to work, the help I got from Egon and others on this board was very useful!

So, now I am playing around with .3ds models, and I loaded some low-poly trees into my world. they consist of a half-dozen or so quads, with an alpha 'leaf' texture applied to them (so only the leafy part shows), and a trunk, which is another low-poly mesh but with a standard, non-alpha texture applied to it.

To this point I have been using a variant of the model loader code from the JPCT wiki, that loads the sub-objects of the .3ds file and merges them into one Object3D.    The problem I've been having is that the leaves on the tree have z-ordering issues, where they pop in front of and in back of the tree trunks as you change camera perspective etc.  I have tried various values for sort depth and transparency, but since both the leaves and trunk are merged into a single object, I don't think it really solves the problem.

I suspect I might need to keep the leaves and trunk as separate objects, and apply different sort depths and transparency settings to each, but I wanted to see what people thought.  If I do that, it will double the number of tree-related objects, I don't know if that has a perf impact if there are a large number of trees.   I assume if I did that, I'd make one the child of the other or something so rotations/translations will move everything together ? (sorry,  im a bit of a newbie to 3D engine mechanics)

  I'm also assuming that I can't get away with setting sort order and transparency on the sub-objects before I merge them (ie, an Object3D can only have one value for each of these attributes.)  Along those lines, if there is some other kind of thing I should experiment with on the merged object to get my leaves to settle down, I'm interested! :-)

Thanks!


2
Support / controlling camera orientation on a sphere surface?
« on: January 25, 2012, 11:43:12 pm »
Hi,
I'm trying to get the camera orientation correct such that the player can walk on (or fly over) the surface of a sphere (for simplicity, assume the sphere is centered at JPCT world center 0,0,0). 

For the x and y camera axes, I'd like to just use "mouse look" values to set camera X and Y rotation to change the camera orientation, so that the player can move left/right on the surface of the sphere and look up or down. I'd also like to use a normal vector to the sphere surface to move the camera down until it collides with the sphere for simulating gravity. I've adapted code I've used on flat worlds and tested it out on the sphere, and it seems like it should be fine.

The problem I've been having is adjusting the camera Z-axis orientation so the camera view is always parallel to the surface.  At the moment i don't adjust the Z axis, so it's only correct if you are traveling along a major axis of the sphere, other locations/orientations on the sphere and the camera's Z rotation is wrong and the camera view looks tilted.

I've tried various things, such as taking the current camera position, converting it to polar (alt,az,radius) coordinates, then like adding 1 to the radius (to get a polar coordinate above the camera), and converting it back to cartesian x,y,z.

I've tried using that vector and also the normalized version of that vector as the "up" vector for the camera setOrientation, (something like camera.setOrientation(currentCamDirection,newUp).   But I get bizarre / incorrect results, camera does not point anywhere useful and mouse control of the camera x and y rotation becomes messed up.

I'm a bit of a 3D vector geometry dummy so I'm sure there's a simpler approach or something, suggestions/ideas welcome.

Thanks!
Ed




Pages: [1]