Author Topic: Tips & Tricks with MeshView  (Read 264 times)

0 Members and 1 Guest are viewing this topic.

Not Yet Rated!

Offline nargil66

  • Forum Moderator
  • Full Member
  • *
  • Topic Author
  • Posts: 1115
  • Country: bg
  • Karma: +12/-0
  • Gender: Male
    • View Profile
    • Awards
  • Time Zone: ?
Tips & Tricks with MeshView
« on: 01 March 2019, 18:37:38 »
Original description of MeshView by Tamchi:

I'm working on a new mesh viewer for TQ and IT:



This is an early screenshot, but you can already see the default material. It's a gradient based on the texture coordinates, so the borders you see are where the texture is stitched.



The program supports loading more than one mesh at a time and the meshes' source folders are automatically scanned for textures. (The texture's extension is ignored, it starts with the shortest matching filename, in alphabetical order, then proceeds to the longer ones.)



Supported texture formats are TQ textures and XNA or WIC compatible image files:
tex, dds, dib, hdr, pfm, ppm, tga, jpeg, tiff, gif, png, bmp and HD Photo + any WIC plugins installed on the computer.



Additive shaders are rendered as emissive textures, so it is possible to preview glowing auras.



The background color can be changed the same way as the colors of the lights. Text inputs in MeshView are somewhat different from those in most other programs: Because there are no input dialogs or save buttons every input is applied directly to the rendering. If the input is invalid, the background turns red and the value is ignored until it changes to a valid one. If a valid value is entered, the text field's background turns green as soon as the changes are applied.
(In case there is an input that takes some time to process, the text field will first turn yellow and then green or red to show whether the changes have been saved.)

I finished the save module for meshes, so this is now a functional mesh editor.

The COLLADA export seems to be easier than I though: I finished a very basic export for vertex positions and normals! The code is relatively simple, so I should be able to add texture support and skeleton export in the next few days.



Imports are more complicated, but it's doable.

I finally got the texture coords working:



Softimage's crosswalk import seems to be picky about where I link the vertex parameters, so I moved it where every 3D program can understand it. I still had to manually select the textures, because the program didn't recognize the effect definitions. The next thing I want to add are bone definitions and proper rigging...

On a side note: I ran a test on some of the msh files: Most were working fine, but some of the shader definitions contained duplicate texture references. I added a workaround, but the exporter's behaviour may differ from the game's when loading these meshes.

The bone indices in the weights are a bit... strange. You can sort them manually with the panel under "Vertices".

---

I updated MeshView to version 1.2. It's now portable and you can import .obj files over existing meshes. It's similar to MeshDrawCS' import function in that you need a base mesh to load a .obj, but works properly, merges multiple normals per vertex and lets you import small meshes over larger ones to create objects with any number of vertices and triangles.
(The last one is untested, should work though...)

---

Some tricks from my poor experience with MeshView:

Trick #1 - Ruin a mesh and use it as a "dummy"
 
You can corrupt a mesh, so no shaders to work on it (it's always invisible), while preserving its bones and attach points. I use this trick when I want dyes to have no effect on the character, or to attach one or more other creature meshes on it, so only the attachments remain visible. Given example is with femalevilagenpc01.msh, on which i'm working right now.

You will need:
1. Tamchi's MeshView.
2. Extracted femalevillagenpc01.msh.
3. Some other similar mesh, for example femaletownnpc01.msh (maybe completely different will work too, but i havent tried).

How to corrupt it:
1. Load the second mesh you have extracted (femaletownnpc01.msh) in Meshview.
2. In MeshView, go to Mesh > Mesh (v10/11) and in the right menu choose "save partial data (.obj)". Save the .obj file somewhere and close Meshview.



3. Now load the first mesh (femalevillagenpc01.msh) in MeshView. Inside, go to the same directory, but choose "replace data (.obj)". In the window, browse to your saved .obj file from the other mesh and open it.
4. Save the mesh you just corrupted as a copy of "femalevillagenpc01.msh". When you open it im MeshView it will look normal, but ingame it will be invisible. Thats it. Attach whatever you want on it.



---

Trick #2 - Making an armor piece invisible on the character

This one is very simple. There are 4 default attach points for the armors on the characters (they also work on other creatures). Their names are:
"Head" - for the helmet, hair or circlet.
"Upper Body" - for the torso armor.
"Forearm" - for the armbands or bracelets.
"Lower Body" - for the leg armor.

How to make armors invisible:

They are not really invisible, just very small. For example, the normal size attach point for ambands (in the mesh TextData section) looks like this:

Quote
AttachPoint
{
    name   = "Forearm"
    origin = (0.000000, 0.000000, 0.000000)
    xAxis  = (1.000000, 0.000000, 0.000000)
    yAxis  = (0.000000, 1.000000, 0.000000)
    zAxis  = (0.000000, 0.000000, 1.000000)
}

To make it "invisible", change it to this:
 
Quote
AttachPoint
{
    name   = "Forearm"
    origin = (0.000000, 0.000000, 0.000000)
    xAxis  = (0.000001, 0.000000, 0.000000)
    yAxis  = (0.000000, 0.000001, 0.000000)
    zAxis  = (0.000000, 0.000000, 0.000001)
}



The armor piece will still be equippable and visible in the inventory UI, but not on your character in the game world.

---

Trick #3 - Flipping attach points on XYZ axis

Here it becomes a bit more complicated. Here is how to flip (invert) the position of secondary meshes attached to your base mesh, using the TextData values of the XYZ coordinate system.

First, let me explain a little about the 3d coordinates. There are 3 base axes:
 
X - widht/horizontal axis
Y - height/vertical axis
Z - depth/perspective axis

Each axis has + and - values. The positive directions are:
 
for X - right (from our point of view)
for Y - up
for Z - front (pointing toward us)

The negative (-) directions are pointing exactly in opposite of the positive ones - left, down, back.



For this example i attached a modified Battle Standard to the invisible creature mesh from the first trick, to show the flip rotations more clearly.
Here is the default position of attachments in MeshView and how it looks ingame:

Quote
AttachPoint
{
    name   = "Standard"
    origin = (0.000000, 0.000000, 0.000000)
    xAxis  = (1.000000, 0.000000, 0.000000)
    yAxis  = (0.000000, 1.000000, 0.000000)
    zAxis  = (0.000000, 0.000000, 1.000000)
}



Ok, not let's try flipping the attached standard on the invisible creature on the horizontal (X) axis. To do it we put a "-" before the 1.000000 value on xAxis:

Quote
AttachPoint
{
    name   = "Standard"
    origin = (0.000000, 0.000000, 0.000000)
    xAxis  = (-1.000000, 0.000000, 0.000000)
    yAxis  = (0.000000, 1.000000, 0.000000)
    zAxis  = (0.000000, 0.000000, 1.000000)
}

Let's see what happens ingame:



The entire flag is flipped horizontally, but it is NOT rotated.
Ok, what if we put a "-" to the Y axis? Let's try:

Quote
AttachPoint
{
    name   = "Standard"
    origin = (0.000000, 0.000000, 0.000000)
    xAxis  = (1.000000, 0.000000, 0.000000)
    yAxis  = (0.000000, -1.000000, 0.000000)
    zAxis  = (0.000000, 0.000000, 1.000000)
}



The battle standard is flipped vertically now, and its tip is underground. If we were able to see it, it would be still pointing toward us.
Let's try the Z axis now:

Quote
AttachPoint
{
    name   = "Standard"
    origin = (0.000000, 0.000000, 0.000000)
    xAxis  = (1.000000, 0.000000, 0.000000)
    yAxis  = (0.000000, 1.000000, 0.000000)
    zAxis  = (0.000000, 0.000000, -1.000000)
}



The standard is flipped in perspective, but do you notice something not being right. Lets rotate the invisible character so the flag point toward us again:



The positions and the text are backwards again... The how to actually ROTATE it on 180 degrees, without flipping it? This is the trick:

Quote
AttachPoint
{
    name   = "Standard"
    origin = (0.000000, 0.000000, 0.000000)
    xAxis  = (-1.000000, 0.000000, 0.000000)
    yAxis  = (0.000000, 1.000000, 0.000000)
    zAxis  = (0.000000, 0.000000, -1.000000)
}

We flip BOTH the X and the Z axis, and the standard is finally looking as it should:



If we rotate it again, we will see the default position, as it is in the first picture. Only now its poiting to the opposite direction.

This is how to flip and rotate attached mesh to 180 degrees. I'll show you some more complex rotations (by angle) in the next part.

---

(To be continued)
« Last Edit: 17 April 2019, 00:29:58 by nargil66 »

Not Yet Rated!

Offline nargil66

  • Forum Moderator
  • Full Member
  • *
  • Topic Author
  • Posts: 1115
  • Country: bg
  • Karma: +12/-0
  • Gender: Male
    • View Profile
    • Awards
  • Time Zone: ?
Re: Tips & Tricks with MeshView
« Reply #1 on: 14 April 2019, 22:44:59 »
Trick #4 - Transfering bones between meshes

Do you know what mesh rigging and skinning is? I didnt knew neither of those terms untill recently.

Rigging - Rigging is the process of setting up the skeleton in a model. It includes linking the bones in a hierarchy, setting constraints on the bones' movement, and setting up controls (which are aids for the animator).

Skinning - Skinning is the process of attaching vertexes to bones. Skinning also refers to an animation technique where a model is animated using a skeleton (primarily when a vertex may be influenced by more than one bone).

What does this has to do with Mesh View, you may ask? Well, MeshView allows you to edit, replace or even rewrite the skeletal structure of a mesh, which affects 3 things: the shape of the mesh, its animation, and last but not least important - its attach points.
Transferring bones from one mesh to another is pretty simple actually. All you have to do is this:



In this example the bones of a nymph are being replaced with human female bones. The mesh appearance will not change much, but its animations/attach points... I'm pretty sure after some adjustments the nymph can wear human armors. I'll show some examples later.
« Last Edit: 14 April 2019, 23:05:36 by nargil66 »

Not Yet Rated!

Offline nargil66

  • Forum Moderator
  • Full Member
  • *
  • Topic Author
  • Posts: 1115
  • Country: bg
  • Karma: +12/-0
  • Gender: Male
    • View Profile
    • Awards
  • Time Zone: ?
Re: Tips & Tricks with MeshView
« Reply #2 on: 17 April 2019, 13:43:42 »
Proof of the bone transfer theory - the first armored nymph in TQ history (well, only partially ;)):



It was alot harder than i expected tho. Neither 3ds max or viewer could do it perfectly, so i just switched to "manual mode".

Here is the new nymph mesh, is someone wants to try it:
https://mega.nz/#!NDIgyQgb!8C35qMzjwBIubM0uYp0y64BJ0wEgEuG9qYNMU9TSOnY
I also removed some parts of the mesh with MeshDrawCS - the bow, necklace and bag, as well the annoying side hairs (always floating).



Tags: