This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: The WMO MOPT Chunk  (Read 1254 times)

abdalrahman9

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 129
    • View Profile
The WMO MOPT Chunk
« on: July 25, 2015, 11:23:57 am »
Hello there, i just wanted to ask if anyone knows or has any clue what the last four bytes of the MOPT Refer to. As it seems in the wiki it doesn't explain much and also in the 010 templates, it is named "Unknown Float". Through my research of trying to figuring what it tries to refer to, i have found out that it might mean the distance from the portal to one of the axis (x,y, or z). The property that sets the distance it is far from is the direction of the normal. Now i have only proved my theory to be true only for portals that are parallel with one of the axis. Here is an example of what i mean:

In this example, the portal is parallel to the X-axis which means that its normal is perpendicular to that X-Axis. This portal is taken from the GoldShireInn.wmo and it is the third portal of the wmo. I have copied other several portals to see make sure and so far, the distance to the parallel axis is the float number of the unknown.

However, a problem comes up when the portal is slanted. This means that when the portal is not parallel to any axis the float number becomes weird. In the wmo file, almost all the portals that are not parallel to any axis have a very small number float. An example is the sixth portal of the GoldShireInn.wmo. The unknown float is "0.8327567". I tried to recreate it in 3ds max and this is how it looks like:

As you can see, the portal is not parallel to any of the axis and that is why the last float unknown is weird. I am pretty sure it happened because of the translation of the portal.

I will keep on checking and see if i could solve anything but if anyone has any ideas please do tell.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: The WMO MOPT Chunk
« Reply #1 on: July 25, 2015, 05:03:49 pm »
What unknown float? In MOPT I don't see anything unknown, only in MOPR where it probably just is padding.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

abdalrahman9

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 129
    • View Profile
Re: The WMO MOPT Chunk
« Reply #2 on: July 25, 2015, 05:55:21 pm »
Well in the wiki it doesn't show it but it is after the 3 float values (x,y,z) of the normal. Here is a picture of it that has the 010 template applied which shows the unknown 4 byte:


EDIT: Now the Wiki states the following "C4Plane  plane;". Now i am not sure if this is soppuse to include the unknown four bytes and if does, what is that last piece of information after the float normal x,y, and z?
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: The WMO MOPT Chunk
« Reply #3 on: July 25, 2015, 06:34:57 pm »
It is likely a point-normal-form.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

abdalrahman9

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 129
    • View Profile
Re: The WMO MOPT Chunk
« Reply #4 on: July 25, 2015, 06:55:46 pm »
Hum, after i searched a little the only thing i was able to get was the formula of the point-normal-form equation
n•(r - r0) = 0. I am not sure what this has to do with the last 4 byte float variable.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: The WMO MOPT Chunk
« Reply #5 on: July 25, 2015, 07:49:32 pm »
https://en.wikipedia.org/wiki/Plane_(geometry)#Point-normal_form_and_general_form_of_the_equation_of_a_plane

the values in C4Plane are abcd.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

abdalrahman9

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 129
    • View Profile
Re: The WMO MOPT Chunk
« Reply #6 on: July 26, 2015, 09:21:05 am »
Ow my you are right! Thanks for the link. I never thought that solution would be that simple. I appreciate the hand!
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Supora

  • Registred Member
  • Wiki Incarnate
  • *****
  • Posts: 143
    • View Profile
Re: The WMO MOPT Chunk
« Reply #7 on: July 26, 2015, 10:55:04 am »
Quote from: "schlumpf"
https://en.wikipedia.org/wiki/Plane_(geometry)#Point-normal_form_and_general_form_of_the_equation_of_a_plane

the values in C4Plane are abcd.
Thnx for the link because when I googled for C4Plane I only got some airplanes results.

@abdalrahman9
You can use this code in blender for getting the normal vector values of the plane. Just copy this code then create new text document in blender "addons" folder name it to whatever you like and change file extencion to py. Then paste this code to this document and save it. Load this addon, select the face and you will see the values in Object Data tab under normals
Code: [Select]
bl_info = {
    "name": "Face Normal Display",
    "author": "CoDEmanX",
    "version": (1, 0),
    "blender": (2, 68, 0),
    "location": "Properties Editor > Data > Normals",
    "description": "Show normal property for active mesh face",
    "warning": "Edited normal is discarded on mode change!",
    "wiki_url": "",
    "tracker_url": "",
    "category": "Mesh"}

import bpy
import bmesh
from mathutils import Vector


def draw_func(self, context):
    layout = self.layout

    wm = context.window_manager
    me = context.object.data

    row = layout.row()
    row.active = me.is_editmode

    col = row.column()
    col.scale_y = 3
    col.scale_x = 2
    col.prop(wm, "face_normal_lock", icon='LOCKED' if wm.face_normal_lock else 'UNLOCKED', text="")

    sub = row.row()
    sub.enabled = not wm.face_normal_lock

    col = sub.column()

    if me.is_editmode:
        bm = bmesh.from_edit_mesh(me)
        if bm.faces.active is not None:

            col.prop(wm, "face_normal_active", text="", expand=True)
            sub.prop(wm, "face_normal_active", text="")

            if wm.face_normal_normalize and wm.face_normal_active != bm.faces.active.normal:
                wm.face_normal_active = bm.faces.active.normal
        else:
            col.label("No active face!")

    else:
        p = me.polygons
        if p.active is not None:
            col.prop(p[p.active], "normal", text="", expand=True)
            row.prop(p[p.active], "normal", text="")
        else:
            col.label("No active face!")

    layout.column().prop(wm, "face_normal_normalize")


def upd_normal(self, context):
    bm = bmesh.from_edit_mesh(context.object.data)
    if context.window_manager.face_normal_normalize:
        bm.faces.active.normal = self.face_normal_active.normalized()
    else:
        bm.faces.active.normal = self.face_normal_active

def upd_normalize(self, context):
    if self.face_normal_normalize:
        upd_normal(self, context)

def register():
    bpy.types.DATA_PT_normals.prepend(draw_func)
    bpy.types.WindowManager.face_normal_active = bpy.props.FloatVectorProperty(subtype='DIRECTION', min=-1.0, max=1.0, precision=3, update=upd_normal)
    bpy.types.WindowManager.face_normal_lock = bpy.props.BoolProperty(name="Lock", description="Disable normal editing above")
    bpy.types.WindowManager.face_normal_normalize = bpy.props.BoolProperty(name="Normalize / Update on selection changes", description="Disable for manual input, then re-enable", update=upd_normalize)


def unregister():
    bpy.types.DATA_PT_normals.remove(draw_func)
    del bpy.types.WindowManager.face_normal_active
    del bpy.types.WindowManager.face_normal_lock
    del bpy.types.WindowManager.face_normal_normalize



if __name__ == "__main__":
    register()
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

abdalrahman9

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 129
    • View Profile
Re: The WMO MOPT Chunk
« Reply #8 on: July 26, 2015, 12:20:52 pm »
Thank you Supora for the code but i am not able to use it. I am doing this in maxscript and things there are a little different. Though thanks for the code, i am sure it will help me.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »