OBJS loading

png-branch
an 2019-02-20 13:45:38 -05:00
parent 848d6f4c5c
commit c6e561e406
3 changed files with 71 additions and 2 deletions

View File

@ -383,7 +383,7 @@ main menu, and physics files. Here is a listing of all chunks used within them:
| `door` | No test data (extra door data) |
| `PLAT` | No test data (platform static data) |
| `medi` | Media (liquids) |
| `ambi` | Not analyzed (ambient sounds) |
| `ambi` | Array of Ambient Sounds |
| `bonk` | Not analyzed (random sounds) |
| `term` | Array of Terminals |
| `iidx` | Not analyzed (map indices) |
@ -437,7 +437,9 @@ The type "`fixed`" refers to a 32-bit fixed point number with the format 15.16s
sign.)
The type "`angle`" refers to a 16-bit fixed point number with the format 0.9s.
This is used for all angles.
This is used for all angles. Because they're actually 16-bit, the real format
is 6.9s, but the integral part is ignored. "No angle" is represented by 65510
(-1.9) for some reason.
The type "`unit`" refers to a 16-bit fixed point number with the format 5.10s.
This is used for all world coordinates.
@ -755,6 +757,19 @@ Object is 16 bytes.
| `PosZ` | `unit` | `12` |
| `Flags` | `u16` | `14` |
- `Flags` is a Map Object Flags bit field, and the upper 4 bits are the
activation bias for monsters.
### Ambient Sound ###
Ambient Sound is 16 bytes.
| Name | Type | Offset |
| ---- | ---- | ------ |
| `Flags` | `u16` | `0` |
| `Index` | `u16` | `2` |
| `Volume` | `u16` | `4` |
### Static Map Info ###
Static Map Info is 88 bytes.

View File

@ -54,6 +54,7 @@ fn dump_chunk(opt: &Options, cid: Ident, cnk: &[u8], eid: u16) -> ResultS<()>
b"SIDS" => make_yaml(opt, &rd_array(cnk, map::read_sids)?)?,
b"POLY" => make_yaml(opt, &rd_array(cnk, map::read_poly)?)?,
b"LITE" => make_yaml(opt, &rd_array(cnk, map::read_lite)?)?,
b"OBJS" => make_yaml(opt, &rd_array(cnk, map::read_objs)?)?,
b"term" => make_yaml(opt, &rd_array(cnk, trm::read_term)?)?,
_ => (),
}

View File

@ -192,6 +192,32 @@ pub fn read_lite(b: &[u8]) -> ResultS<(Light, usize)>
ina_mid, tag}, 100))
}
pub fn read_objs(b: &[u8]) -> ResultS<(Object, usize)>
{
read_data! {
16, BE in b =>
group = u16[0];
index = u16[2];
angle = u16[4];
poly = u16[6];
pos_x = u16[8];
pos_y = u16[10];
pos_z = u16[12];
flags = u16[14];
}
let bias = flags & 0xF0_00;
let flags = flags & 0x0F_FF;
let bias = bias >> 12;
let flags = ok!(ObjectFlags::from_bits(flags), "bad ObjectFlags")?;
let angle = Angle::from_bits(angle);
let pos_x = Unit::from_bits(pos_x);
let pos_y = Unit::from_bits(pos_y);
let pos_z = Unit::from_bits(pos_z);
Ok((Object{group, index, angle, poly, pos_x, pos_y, pos_z, flags, bias}, 16))
}
#[derive(Clone, PartialEq, Serialize)]
pub struct Point
{
@ -281,6 +307,20 @@ pub struct Light
pub tag: u16,
}
#[derive(Debug, Serialize)]
pub struct Object
{
pub group: u16,
pub index: u16,
pub angle: Angle,
pub poly: u16,
pub pos_x: Unit,
pub pos_y: Unit,
pub pos_z: Unit,
pub flags: ObjectFlags,
pub bias: u16,
}
#[derive(Debug, PartialEq, Serialize)]
pub struct Minf
{
@ -386,6 +426,19 @@ bitflags! {
}
}
bitflags! {
#[derive(Serialize)]
pub struct ObjectFlags: u16
{
const Invisible = 1;
const Ceiling = 1 << 1;
const Blind = 1 << 2;
const Deaf = 1 << 3;
const Floating = 1 << 4;
const NetOnly = 1 << 5;
}
}
c_enum! {
#[derive(Debug, Serialize)]
pub enum SideType: u16