Author Topic: Interaction with a 3D Space  (Read 7208 times)

0 Members and 1 Guest are viewing this topic.

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Interaction with a 3D Space
« Reply #15 on: December 06, 2011, 03:34:55 pm »
Shit, that was way over my head. Let me break this down to see if I understand.
Sorry, I'm not good at explaining. I'll try step-by-step:
1. The 3D engine uses 8.8 fixed point numbers. What impact does that have on my two-byte position variables?
It's best that you keep using those variables, and to use it with the 3D engine, check the distance between the position of a chip (this doesn't need to be accurate), and if it's below the maximum viewing distance (for example: 100), then substract the player's coordinates from the coordinates of the ship and store in signed 8-bit variables. Then you use that as the integer part of the xpoint, ypoint and zpoint variables. Then set the from coordinates to 0 (or edit the 3D engine so they will always be treated as 0 (faster)). Then you just call C3Dto2D, and use the onscreen x and y coordinates as the location for drawing a scaled sprite, of which you calculate the size by the 'depth' (z-coordinate) of the point. Don't forget to check if the point is valid (a=1 after calling C3Dto2D), or the camera will look forward and backward.

2. I understand about speed. How do I make Speed variable?
The move routine I gave you is the only routine that uses the speed constant, so just replace the constant with the variable. Based on how your game works, It's best to set the x, y and z used in the routine to 0, then call it and add the integer parts of the outputs to your position. Then save the decimal parts and use them again for the next time you call the move routine. Also don't forget that these numbers are signed when handling them.

3. Do I need to look for a ship, then call the 3D engine each time I find one? Or does one of those routines handle that?
you need to handle that yourself. The 3D engine is still in an early stage so it can only convert individual points.

BTW: I forgot to answer this in my previous post, but yes, the temp variables can be overwritten, but only between the routines, so make sure the interrupt routine doesn't use them.
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Interaction with a 3D Space
« Reply #16 on: December 06, 2011, 05:09:50 pm »
Ok. You should know, that the whole screen will not have a viewscreen. It will only be about 2/3 the height of the screen and 2/3 of the length of the screen. How does that affect the routine?


Oh, and how do I handle calculating distance between you and ships, taking into account sectors as well?
« Last Edit: December 06, 2011, 07:16:11 pm by ACagliano »

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Interaction with a 3D Space
« Reply #17 on: December 07, 2011, 02:36:39 pm »
The eastest way for the viewscreen is just render as fullscreen, then overlay with the HUD. It's not the most efficient way to do it, but for only a few ships, it should work.

For the distance, you can use the Pythagorean theorem. Use the sector as the upper byte and the coordinates as the lower bytes, then do this in 24-bit math: √((X2-X1)²+(Y2-Y1)²+(Z2-Z1)²).
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Interaction with a 3D Space
« Reply #18 on: December 07, 2011, 07:17:37 pm »
The eastest way for the viewscreen is just render as fullscreen, then overlay with the HUD. It's not the most efficient way to do it, but for only a few ships, it should work.

Ok, easy enough.

For the distance, you can use the Pythagorean theorem. Use the sector as the upper byte and the coordinates as the lower bytes, then do this in 24-bit math: √((X2-X1)²+(Y2-Y1)²+(Z2-Z1)²).

*Stares at computer blankly.