ACagliano wrote:
Ok I need some help. I've been doing some research and have only found results relevant to Unity, or using other libraries that I can't use in ez80 C.
1. Say I have two 3D coordinates. (x1, y1, z1) and (x2, y2, z2). The latter is the coordinate group I need to track towards. The former is the coordinate group of the object doing the tracking. I also have the rotation of the first object.. its vectors on the x,y axis and the z. I want to calculate the degree of rotation that the first object needs to make in order to be facing in the direction of the second object. From there, I want to rotate the first objects direction slowly so its like its slowly turning towards its target <== I already have code set up for this part, its the first part I'm not sure how to do. Would you recommend to do full 3d trig on this, or handle the x/y axis first, and then the final axis separately?
2. My rendering routine goofs up something fierce. As described in the last set of commit notes:
Rendering Main Function: lcars/render.h References to: lcars/mapdata.h, movement/move3d.h
Issues:
Algorithm botches up something terrible. When you first boot in, assuming you have no save file, everything seems ok. The borg sphere is to scale--ish. It's a little off the left of where it should be though.
However, once you start moving, things quickly go wrong. Angling to the left or right makes it disappear completely or move the wrong way, in spite of the fact that we should still see it. And then, it will randomly just scale up to a massive size, rather than gradually scale up.
Could I possibly ask some people who know rendering better than I to have a look at my code and see where I went wrong. I put it together myself based on my very shaky understanding of 3d trig, but trig in math and rendering in code was never my strongest suite.
3. While the rendering algorithm, once debugged, should handle scaling objects and positioning them on screen properly, it does not clip those sprites to within the viewscreen (as in hide whatever is outside the boundary). That boundary is defined by xStart, yStart, xWidth, and yHeight variables within the game loop in main.c. Can someone please advise me on how to do this.
1. Say I have two 3D coordinates. (x1, y1, z1) and (x2, y2, z2). The latter is the coordinate group I need to track towards. The former is the coordinate group of the object doing the tracking. I also have the rotation of the first object.. its vectors on the x,y axis and the z. I want to calculate the degree of rotation that the first object needs to make in order to be facing in the direction of the second object. From there, I want to rotate the first objects direction slowly so its like its slowly turning towards its target <== I already have code set up for this part, its the first part I'm not sure how to do. Would you recommend to do full 3d trig on this, or handle the x/y axis first, and then the final axis separately?
2. My rendering routine goofs up something fierce. As described in the last set of commit notes:
Commit Notes, Star Trek MP wrote:
Rendering Main Function: lcars/render.h References to: lcars/mapdata.h, movement/move3d.h
Issues:
Algorithm botches up something terrible. When you first boot in, assuming you have no save file, everything seems ok. The borg sphere is to scale--ish. It's a little off the left of where it should be though.
However, once you start moving, things quickly go wrong. Angling to the left or right makes it disappear completely or move the wrong way, in spite of the fact that we should still see it. And then, it will randomly just scale up to a massive size, rather than gradually scale up.
Could I possibly ask some people who know rendering better than I to have a look at my code and see where I went wrong. I put it together myself based on my very shaky understanding of 3d trig, but trig in math and rendering in code was never my strongest suite.
3. While the rendering algorithm, once debugged, should handle scaling objects and positioning them on screen properly, it does not clip those sprites to within the viewscreen (as in hide whatever is outside the boundary). That boundary is defined by xStart, yStart, xWidth, and yHeight variables within the game loop in main.c. Can someone please advise me on how to do this.
Try this for putting the object in view of the player, Rotation is output
Code:
Vector = ObjectVector - PlayerVector;
Vector =
(tan(ObjectRotOffset[0])*Vector[0],tan(ObjectRotOffset[1])*Vector[1]),tan(ObjectRotOffset[2])*Vector[2])
//ObjectRotOffset is Object's offset degrees from global
Rotation = (tan⁻¹(Vector[2]/Vector[1]),tan⁻¹(Vector[0]/Vector[1]))
// Vector[0] is X
// Vector[1] is depth
// Vector[2] is Y
// Vectors are translated from global to local coordinates
// Rotation[0] is horizontal
// Rotation[1] is vertical
Return Rotation
Hope this helps!