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

0 Members and 1 Guest are viewing this topic.

Not Yet Rated!

Offline nargil66

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

Spoiler for Hiden:
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...)
« Last Edit: 30 July 2019, 19:05:55 by nargil66 »

Not Yet Rated!

Offline nargil66

  • Forum Moderator
  • Full Member
  • *
  • Topic Author
  • Posts: 1626
  • Country: bg
  • Karma: +34/-1
  • Gender: Male
    • View Profile
    • Awards
  • Time Zone: ?
Re: Tips & Tricks with MeshView
« Reply #1 on: 14 April 2019, 22:44:59 »
Here are a few tips and tricks from my experience with MeshView - just have in mind that what i know comes mostly by trial and error - some of the info may be incomplete or even wrong.

I. Initial Setup

First, we want to make sure every TQ mesh opens with MeshView by default.
To do it, right-click on an extracted .MSH file from the game, and in the dropdown menu pick “Open With…” and in the window that opens tick “Always open with this program”. Then browse to MeshView.exe and click on it. From now on all meshes will automatically open with MeshView.

Some of the changes made in MeshView (such as edited bones, attached effects and other) does not show directly or correctly in it. To preview them faster, you may use the Viewer tool that comes with the main game along with MeshView. Or just launch the game each time. I’ll get back on previewing later.

II. Interface & Functions
This is a list of all sections you will find in MeshView’s interface, with info of what you can do in some of them.

1. Background
Here you can change the background color and lightness.

Set a value for each color (Red, Green and Blue), from 0 to 255.
0-0-0 is pure black, 255-255-255 is white. The default is set to 128-128-128 (middle gray).
Play around with the values to set a certain color.

2. Camera
Here you can rotate, move and zoom the camera to view the mesh from different angles.

“Position” - moves the camera, “Yaw” and “Pitch” rotate it, “FOV” zooms in/out, “Reset” restores the default settings.
You can also change camera mode - the two options are Perspective and Orthographic. In difference from the Perspective view, in Orthographic view the far parts of the mesh does not become smaller. This is especially useful for previewing huge meshes, like this Ladon mesh:

Perspective


Orthographic


3. Lights
Here you control the lights - their color, strength and position.
In the main “Lights” section you can add new lights from different directions. This is very useful for previewing textures. For example, if you rotate the mesh Yaw by 180 degrees in the Camera settings, you will see its back side is dark:


Try adding a new Ambient Light:

You can add a new directional light in the same way. Directional lights can be rotated around the mesh in difference from ambient lights, which surround the mesh from all sides.

You can change the color of each existent light in the Lights subsections. For ambient lights you can change color in the same way as you do with the background:


For directional lights, you can set color (default is white), as well as position:


New added lights will multiply with the old ones. I don’t advise you to use colored lights when retexturing, use normal white light instead. When previewing changes in your texture with MeshView, you can turn off directional light by setting it to black (0-0-0) and then set the ambient light to white (255-255-255). This way the mesh will be illuminated equally from all directions.

4. Mesh
This is the main section of MeshView, where most of the manipulations are done. There are many subsections in it, I’ll stop on each one separately.

When you click on the main Mesh section, you will see two options: “New Mesh” and “Load Mesh”.
New Mesh - I assume that it allows you to change the current loaded mesh, but for me it crashes the program, so I’ll move to the next option.
Load Mesh - It allows you to load a different mesh on top of the current one. This is useful when comparing mesh sizes or to check if certain equipment will fit. Lets try to load a piece of armor over the Jackalman. Click on Load Mesh and browse to the second mesh you want to load (in this case - tigerman torso). Do they fit? Let’s find out:


Nope, they don’t :P

I haven’t tried this ever, but this may also be useful when making mounted creatures. Load both the rider and the mount, and then move rider’s MoveAxis to the needed position. Ima try this when we come to Bones subsection.

4.1 Mesh (v…)
This is where you can Save the mesh after editing. You can also export in different formats or add missing sections.

“Add MIF Section”- Adds a new empty link to a MIF file (used by Viewer to load mesh data) if the mesh doesnt have one. To edit or remove existing links you have to do it in the MIF subsection below.

‘’Resize” - When you click on this, a small window appears, where you can enter an new scale value for the mesh. Let’s try to fit the jackalman to the armor a little better, by making it larger by 10%. We change scaling factor from 1 to 1,1 (MeshView only accept commas, not dot symbols):


Result:

Meh. It was just an experiment.
After resizing, the mesh scale will always show as 1, no matter its larger now.

“Add TextData Section” - Adds a new empty TextData field (you will be using it most frequenty) if the mesh doesnt have one. To edit or remove the mesh TextData you have to do it in the subsection below.

“Save” - Saves the edited mesh. You can choose a new name and location.

“Close” - close a chosen mesh you have loaded. In the above case, you can close the tigerman armor, leaving only the Jackalman.

Rest of the buttons - Im not sure how they work and not gonna risk giving you false info.

4.1.1 MIF
In this section you can change or remove the mesh MIF link, as described in the previous part.

4.1.2 TextData
As far as my knowledge goes, here you can change or add attach points. You can also attach new entities - effects, items or even creatures to the main mesh.

Attach Points - They define the default position of equipment, effects, lights, cameras or custom added entities to the mesh. Here is an example of a basic attach point (in this case, Torso Armor):
Quote
AttachPoint
{
    name   = "Upper Body"
    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)
}
This type of attach point is fixed to the base coordinate system. It may follow the mesh animation, but if the mesh is moved, the attach point will stay in place.

There is another type of attach point - one that has a certain bone as parent. Its position is dependent on that bone. Weapon attach points are a good example:
Quote
AttachPoint
{
    name   = "R Hand"
    parent = "Bone_R_Weapon"
    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)
}

Modifying the attach points
Editing text data will allow you to move, resize or rotate attach points. But first, let me explain a little about the 3D coordinate system. 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:
 
+X - right (from our point of view)
+Y - up
+Z - front (pointing toward us)

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

Moving Attach Points
Knowing this, lets try to move an attach point. For this example, we'll move the hair helmet of the main female character (as its always there by default). The only thing you need is extracted femalepc01.msh (its located in Creatures.arc - “Resources/Creatures/PC/Female” directory). Extract it, and then place it in the same directory, only in Database folder (Database/Creatures/PC/Female). If the folders does not exist, just create them. After you move the mesh in that directory, open it with MeshView and locate the “Head” attach point in TextData section:


Right now its control point is the coordinate center, which is exactly between the feet of the character. To move the helmet,  you need to edit only the “origin” part:


Which stands for:
Quote
origin = (X - 0.000000, Y - 0.000000, Z - 0.000000)

The helmet attach point is 0 aside, 0 high, and 0 deep compared to the center - its exactly in it.
Lets say we want to move the helmet slightly left (for us), up, and in front of the character. Look above to the axis cross again. According to it, for left, up and front, we need -X, +Y and +Z. Lets try:

Here all values are equal, but you can change them as you wish. This will define how far up, left and in front the attach point moves. Just preserve which is "+" and which is "-" .

After editing, open “Mesh (v…)” section and save the mesh in the same Database location, overwriting the old one.


Time to check the result ingame. Launch the game, it will read your modified mesh from Database folder instead of that in the Resources ARC file. Here is the moved hair helmet, exactly as we wanted it:


Scaling Attach Points
You needed the origin for moving, for scaling you don’t. You need the XYZ axes instead.
We moved the hair helmet, what if we want to make it bigger or smaller now? Or only wider while keeping its height/depth the same?
How about making it so small, that its “invisible”? This is very useful when making “Play as Monster” mods - for example a human helmet doesn't fit a Minotaur. its better if we scale it down to get it out of the picture.

Since we already started with the hair helmet, lets just keep modifying it. For start we will make it smaller by 50%, this time only by the X axis. This is how:


Lets see ingame:

The attachment width is reduced by 50%, height and depth remain the same. To change the entire hair by 50% while preserving its shape, do this:
Quote
AttachPoint
{
    name   = "Head"
    origin = (0.000000, 0.000000, 0.000000)
    xAxis  = (0.500000, 0.000000, 0.000000)
    yAxis  = (0.000000, 0.500000, 0.000000)
    zAxis  = (0.000000, 0.000000, 0.500000)
}

And to make it “invisible”:
Quote
AttachPoint
{
    name   = "Head"
    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)
}
This way it’s scaled down by 100000%.

Scaling up works in similar way. To increase the attachment size by 50%, we change the values to these:
Quote
AttachPoint
{
    name   = "Head"
    origin = (0.000000, 0.000000, 0.000000)
    xAxis  = (1.500000, 0.000000, 0.000000)
    yAxis  = (0.000000, 1.500000, 0.000000)
    zAxis  = (0.000000, 0.000000, 1.500000)
}

To triple its height only:
Quote
AttachPoint
{
    name   = "Head"
    origin = (0.000000, 0.000000, 0.000000)
    xAxis  = (1.000000, 0.000000, 0.000000)
    yAxis  = (0.000000, 3.000000, 0.000000)
    zAxis  = (0.000000, 0.000000, 1.000000)
}

You get the idea :)

Rotating Attach Points
Here comes the tricky part. Rotating is hardest to do - you need to use a formula to calculate rotation by a certain angle (say 18 degrees). I don’t know it, so ill just give you  the values of the more common rotations - by 45, 90, 120 and 180 degrees.
The basic rule here is - when you rotate, you change the values to all axes except the axis you are rotating around.

For this example, lets do something more complex and interesting - a triple statue of the goddess Hecate. Like this one:


Here is what you need, if you wish to follow this tutorial (if you don’t, just skip the steps and keep reading):

Setting up the statue
1. Make a new female character (pick white dye). Go to Helos bridge and equip a torch, then exit the game.
2. Extract “Creatures.arc” from Resouces folder, if you haven’t already. Inside, browse to directory:
“Creatures/NPC/NewAnm/Misc” and find “male_holdtorch.anm”.
3. Copy and paste the animation file to the main female character folder from the previous examples:
“Database/Creatures/PC/Female”. Here, create a new folder named “änm” and place the animation file inside. Your final directory should be this: “Database/Creatures/PC/Female/ANM/male_holdtorch.anm”
4. Rename the animation file from “male_hold torch.anm” to “femalepc_idle.anm”. This will replace the default character animation with a new static one, holding a torch.
5. Now lets make the character look like a statue. We need a statue texture, and fortunately, there is one ingame. Extract “SceneryGreece.arc”from Resources folder and browse to directory:
“SceneryGreece/Structure/Statue”.
6. From here, copy “nudefemaleposablestatue01.tex” and “nudefemaleposablestatue01bmp.tex”. Paste them also in “Database/Creatures/PC/Female” folder.
7. Rename the two textures to “femalepc01_white.tex” and “femalepc01_white.tex”
8. You are set up. Launch the game, and in the main menu screen your character should look like this:


Ok, the character base texture is changed, as well as the character animation. Two problems remain:
- the hair helmet is still there and we don’t need it right now.
- we need three separate bodies for a triple statue.

Let’s hit two birds with one stone. Instead of scaling the hair helmet to make it invisible, we will transform it to the other two bodies of the statue. How? Just follow the next steps.

1. In the female character folder, make copies of these 3 files:
“femalepc01.msh”, “femalepc01_white.tex” and “femalepc01_whitebmp.tex”. Now you have copies of the base female mesh and textures.
2. Rename the copied mesh to “femalepc01hairhelmet.msh”; the two copied textures to “femalepc01hairhelmet.tex” and “femalepc01hairhelmetbmp.tex”
3. In the main Database folder, create directory “Items/EquipmentHelm”. Paste the 3 files you just renamed there. You just turned the character hair to another character body. Launch the game and see what happens:


Not what we wanted. There are several new problems:
- the new body is “splashed” and moved. Remember this is the same hair helmet we used from before, and its still dependent on the “Head” attach point. Fixing this problem is easy - open the main female mesh again and reset the attach point to default position:

- the statue texture doesn’t show on the attached body. I’ll come back to this when we reach Shaders section.
- there is only one new body, and we need 3 total. I’ll come back to this soon, when show you how to attach entities.
- Final problem is, the attached body is facing the same direction as the main one. This is what we are going to do next - rotate it.

Rotating by 90 degrees
After we fix the splashed attach point, lets rotate it by 90 degrees around the vertical (Y) axis. Remember, we are rotating around it, so the Y value and position must remain unchanged. The X and Z axes however will have different positions:

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

Result ingame:


To rotate by 90 degrees on the opposite direction, all we have to do is switch “+” and “-” of the X and Z axes. Again, we don’t touch the Y.
Quote
AttachPoint
{
    name = "Head"
    origin = (0.000000, 0.0000000, 0.0000000)
    xAxis = (0.0000000, 0.0000000, 1.000000)
    yAxis = (0.0000000, 1.0000000, 0.0000000)
    zAxis = (-1.0000000, 0.0000000, 0.0000000)
}

Result:


The same rule applies for other axes. For example, if you want to rotate the attachment on 90 degrees around the Z axis, you do this:
Quote
AttachPoint
{
    name = "Head"
    origin = (0.000000, 0.0000000, 0.0000000)
    xAxis = (0.0000000, -1.0000000, 0.0000000)
    yAxis = (1.0000000, 0.0000000, 0.0000000)
    zAxis = (0.0000000, 0.0000000, 1.0000000)
}

Or:
Quote
AttachPoint
{
    name = "Head"
    origin = (0.000000, 0.0000000, 0.0000000)
    xAxis = (0.0000000, 1.0000000, 0.0000000)
    yAxis = (-1.0000000, 0.0000000, 0.0000000)
    zAxis = (0.0000000, 0.0000000, 1.0000000)
}

Example:


Around the X Axis:
Quote
AttachPoint
{
    name = "Head"
    origin = (0.000000, 0.0000000, 0.0000000)
    xAxis = (1.0000000, 0.0000000, 0.0000000)
    yAxis = (0.0000000, 0.0000000, -1.0000000)
    zAxis = (0.0000000, 1.0000000, 0.0000000)
}

The system is pretty simple.

Rotating by 180 degrees
This is the most simple rotation. You may have noticed we did it several times already, when we switched direction of the rotated 90 degree mesh. Here is the basic rule for 180 degrees - you switch + to - (and - to +) on all axes, except the one you are rotating around. For example, if you want to rotate by 180 degrees around the vertical Y axis, do it this way:
Quote
AttachPoint
{
    name = "Head"
    origin = (0.000000, 0.0000000, 0.0000000)
    xAxis = (-1.0000000, 0.0000000, 0.0000000)
    yAxis = (0.0000000, 1.0000000, 0.0000000)
    zAxis = (0.0000000, 0.0000000, -1.0000000)
}

Both rotated axes remain on the same position, only their values are flipped to the negative. Result ingame:


Rotating by 45 and 120 degrees
I'll just give you the values here, as I don't know how this is calculated.

120 degrees rotation around the Y axis:
Quote
AttachPoint
{
    name = "Head"
    origin = (0.0000000, 0.0000000, 0.0000000)
    xAxis = (-0.500000, 0.0000000, 0.866025)
    yAxis = (0.0000000, 1.0000000, 0.0000000)
    zAxis = (-0.866025, 0.0000000, -0.500000)
}

45 degrees around the Y axis:
Quote
AttachPoint
{
    name = "Head"
    origin = (0.0000000, 0.0000000, 0.0000000)
    xAxis = (-0.707107, 0.0000000, -0.707107)
    yAxis = (0.0000000, 1.0000000, 0.0000000)
    zAxis = (0.707107, 0.0000000, -0.707107)
}

Tired of all these numbers? Don't worry, the most boring part is over. Either way, I'll leave the rest for another time. 

---

« Last Edit: 31 July 2019, 18:14:38 by nargil66 »

Not Yet Rated!

Offline nargil66

  • Forum Moderator
  • Full Member
  • *
  • Topic Author
  • Posts: 1626
  • Country: bg
  • Karma: +34/-1
  • Gender: Male
    • View Profile
    • Awards
  • Time Zone: ?
Re: Tips & Tricks with MeshView
« Reply #2 on: 31 July 2019, 18:19:19 »
Post #2 is updated and gives more info. This post is reserved for the second part.
« Last Edit: 31 July 2019, 19:19:31 by nargil66 »

Not Yet Rated!

Offline monkas

  • Beginner
  • *
  • Posts: 8
  • Country: vn
  • Karma: +0/-0
  • Gender: Male
    • View Profile
    • Awards
  • Time Zone: -7
Re: Tips & Tricks with MeshView
« Reply #3 on: 02 August 2019, 09:09:14 »
Thanks for you for your tutorial.  :-* :-* :-*
« Last Edit: 02 August 2019, 10:42:29 by monkas »

Not Yet Rated!

Offline nargil66

  • Forum Moderator
  • Full Member
  • *
  • Topic Author
  • Posts: 1626
  • Country: bg
  • Karma: +34/-1
  • Gender: Male
    • View Profile
    • Awards
  • Time Zone: ?
Re: Tips & Tricks with MeshView
« Reply #4 on: 02 August 2019, 13:25:05 »
On your last question - you can convert PSD to TEX via ArtManager. Or you can export the texture as DDS and then convert it to TEX with TQ Texture Tools. I often use the second method when making addon mods or testing (except for the bumps, the program doesnt convert them right for some reason).

Not Yet Rated!

Offline soa

  • Modder
  • Full Member
  • *
  • Posts: 397
  • Country: fr
  • Karma: +15/-0
    • View Profile
    • Awards
  • Time Zone: +1
Re: Tips & Tricks with MeshView
« Reply #5 on: 12 March 2020, 00:46:42 »
Here's the basic formula for the rotation matrixes around the reference axis :



Angle is positive when your turn :
+y axis towards +z axis
+x axis towards +y axis
+z axis towards +x axis

In Viewer or PSE Editor axis are this way, x is red, y is green, z is blue


For instance, 45° around y (positive angle, +z goes towards +x) gives
cos 45°  0     sin 45°
     0      1       0
sin 45°   0    cos 45°

Hence
Quote
AttachPoint
{
    name   = "Head"
    origin = (0.000000, 0.000000, 0.000000)
    xAxis  = (0.707107, 0.000000, 0.707107)
    yAxis  = (0.000000, 0.000000, 0.000000)
    zAxis  = (-0.707107, 0.000000, 0.707107)
}

The result you gave for a 45° turn is actually a -135° turn.

Now I'm trying to adjust a shield on a Valkyrie model, I've successfully made it close to okayish using this method but is there a easier way to change the angles of the attach points in Viewer, or elsewhere ? It keeps giving me an alert of "Attachments points not editable ! Set active in Art Manager" when I try to touch them. Set As active in AM does nothing.
« Last Edit: 12 March 2020, 00:49:54 by soa »
Soulvizier for AE, Ragnarok and Atlantis [released] :
https://titanquestfans.net/index.php?topic=1201.0  / Discord : https://discord.gg/qs9t6AA
Overhaul mod with many new monsters, skills, items, features, balance and bugfixes. Increased difficulty.

Not Yet Rated!

Offline nargil66

  • Forum Moderator
  • Full Member
  • *
  • Topic Author
  • Posts: 1626
  • Country: bg
  • Karma: +34/-1
  • Gender: Male
    • View Profile
    • Awards
  • Time Zone: ?
Re: Tips & Tricks with MeshView
« Reply #6 on: 12 March 2020, 01:36:29 »
The easier method is if you just use 3d editing program like Max. You import the valkyrie model with attach points, then import the shield, then Align and Link the shield with the attach point dummy (L Hand in this case). Next you start rotating the dummy (+the shield) to the position you need it. Finally, you export the character mesh + the attach point and you copy TextData from the exported mesh to your actual mesh.
Aside from Viewer, thats the only other method i know of.

Tags:
 


SimplePortal 2.3.7 © 2008-2020, SimplePortal