Skip to content

First publish #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 125 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from 124 commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
983f4f4
first commit
losanc May 3, 2021
70280f9
using fileseq to find sequences; solved blender with multiple externa…
losanc May 9, 2021
2a11210
Update README.txt
losanc May 9, 2021
ba7227e
multi fileseq supported
losanc May 23, 2021
b3f3b24
add remove sequence operator & beginging of min max velocity value
losanc May 24, 2021
f0ebc58
combine everything into 1 file, add particle radius, mesh importer
losanc May 29, 2021
50f2782
support for file saving and loading
losanc May 30, 2021
9d772e6
fix typo
losanc May 31, 2021
79ede04
try to use ui_list
losanc Jun 6, 2021
ab9b8b6
add & remove seq; show some basic info
losanc Jun 6, 2021
3ee8764
last week work, particle information panel
losanc Jun 13, 2021
688e5bd
first version of vertex color
losanc Jun 16, 2021
079c8e7
rewrite particle importer
losanc Jun 19, 2021
c6c5886
minor change
losanc Jun 27, 2021
7de8ca5
add external
losanc Jul 4, 2021
69905ef
fix hhui/blendertool#4
losanc Jul 9, 2021
9bf9c6e
Merge commit '7de8ca5d121241d778ffd8647a328b7eda3efab1' into dev
losanc Jul 9, 2021
a500baf
set dependency version
losanc Jul 9, 2021
1953bbf
fix dependecy
losanc Jul 11, 2021
acc0b09
update readme
losanc Jul 11, 2021
9e98207
fix hhui/blendertool#3, make error message more clear
losanc Jul 11, 2021
bfe66cf
code fmt
losanc Jul 11, 2021
e9c4059
keep working when restart .blende file
losanc Jul 11, 2021
0d298a8
fix for / and \ problem
losanc Jul 15, 2021
976def3
when too many particles, show as pure vertex in viewport, rather than…
losanc Jul 15, 2021
32e9a1a
Improve loading of mesh data
digitalillusions Jul 18, 2021
dc407d4
Merge branch 'sjeske/dev' into 'dev'
losanc Jul 18, 2021
d5cc6f5
small fix of numpy operator, and comment out init material
losanc Jul 18, 2021
e30c90b
enable loading mesh sequence, when save and load .blender file
losanc Jul 19, 2021
a61a454
rewrite color scaling and max value
losanc Jul 19, 2021
fe4cdb4
fix object rotation, but not color field yet(e.g. velocity)
losanc Jul 25, 2021
10f2f75
add min value attribute
losanc Jul 25, 2021
a5af4e2
add transform for 3-dim color field(e.g. velocity)
losanc Jul 26, 2021
1c24701
restructure
losanc Aug 5, 2021
80d9fa5
small fix for restructure
losanc Aug 5, 2021
dc833a5
code fmt
losanc Aug 8, 2021
59aab86
add shading node for particle importer
losanc Aug 15, 2021
79e52c6
add mesh coloring info
losanc Aug 15, 2021
f5233bc
small fix for mesh importer
losanc Aug 22, 2021
3c10642
add old particle importer
losanc Aug 22, 2021
8031c93
small fix for particle importer
losanc Sep 11, 2021
d5caa8e
add for relative path, & and fix some other small issues
losanc Sep 11, 2021
e8c85b0
add for docs
losanc Sep 12, 2021
8946cbd
small fix for particle and mesh importer
losanc Sep 19, 2021
2b61314
code fmt
losanc Sep 19, 2021
3e3c727
more comments and doc
losanc Sep 19, 2021
3c5adbf
small doc fix
losanc Sep 19, 2021
dcbaf8c
add options to use relative path or not
losanc Oct 10, 2021
04268e1
update particle importer and doc
losanc Oct 10, 2021
e53e019
small change of start & end
losanc Oct 17, 2021
2fe0bcc
update for selecting obj
losanc Oct 17, 2021
21eb7b2
small fix
losanc Oct 19, 2021
1d63f0a
some fix and auto select imported seq by selecting the obj in viewport
losanc Oct 24, 2021
c78e076
big restrucutre, using name as reference of each object,
losanc Nov 3, 2021
9e0e5f3
small bug fix
Nov 8, 2021
882c609
some support for renaming
losanc Nov 17, 2021
105a57c
fix for using same name for multiple sequence
losanc Nov 17, 2021
20f91d3
remove dependency of material
losanc Dec 6, 2021
0c40154
rewrite mesh shading, add option for use real value or clamped value
losanc Dec 7, 2021
e2a1dfa
edit panel, unfinished
losanc Dec 8, 2021
c3e76bd
possible finish of editing
losanc Dec 9, 2021
017a445
fix mesh editing
losanc Dec 9, 2021
1b5a7aa
it should fix editing now
losanc Dec 9, 2021
45d98af
add reference max& min value
losanc Dec 9, 2021
5760064
change order of ref min&max
losanc Dec 10, 2021
e5ffb26
mostly update mesh importer, and some other minor change
losanc Dec 21, 2021
21b946f
added script support; unstable version
losanc Dec 22, 2021
c8dec2f
small change of mesh importer; remove start and end
losanc Dec 27, 2021
457abcc
code fmt
losanc Dec 27, 2021
d2c47f3
some minor change
losanc Dec 30, 2021
8546081
added template
losanc Jan 6, 2022
9e03c53
format using yapf
losanc Jan 11, 2022
183464e
added unsubscribe
losanc Jan 11, 2022
254b7a2
rewrite UI
losanc Jan 11, 2022
1256749
rename to simloader; disable edit panel; temporarily solve relative p…
losanc Jan 14, 2022
fd87821
update dependencies
losanc Jan 18, 2022
97ee50e
baisc functionality has been rewritten
losanc Jan 20, 2022
5ccbdee
fix dependency
losanc Jan 20, 2022
7264842
clean up
losanc Jan 21, 2022
d11715e
edit path
losanc Jan 28, 2022
e91039f
initial implementation of reset operator
losanc Jan 31, 2022
c199947
using filter with tempaltelist; added material selection
losanc Feb 1, 2022
83f2ebb
set material; some minor fix
losanc Feb 1, 2022
767e71a
small fix
losanc Feb 2, 2022
7b05b12
build addon script
losanc Feb 2, 2022
2e8d1e9
minor fix of build addon script
losanc Feb 2, 2022
380c0ad
Update README.md
losanc Feb 2, 2022
1f3db05
initial implementation for mzd files
losanc Feb 9, 2022
3149050
remove symlinks
losanc Feb 10, 2022
ab3b837
make enable default true, false when invalid sequence given
losanc Feb 13, 2022
bc59de8
initial implementation of multi-cell structure
losanc Feb 13, 2022
e48afd4
update for the mzd and template
losanc Feb 18, 2022
3e3a921
add support for partio; some minor change
losanc Feb 24, 2022
641c79d
minor change
losanc Mar 10, 2022
a1b22c7
minor change
losanc Mar 10, 2022
9de99b2
Update importer.py
losanc Mar 13, 2022
f25f060
added support for bgeo
losanc Mar 17, 2022
363763d
several rename; add addition format module; added print information w…
losanc Mar 23, 2022
d674ce4
fix build_addon.py
losanc Mar 23, 2022
5bc6874
typo
losanc Mar 23, 2022
325d1cc
fix relative render path
losanc Mar 30, 2022
c7b5c82
initial support for 3d mesh
losanc Apr 3, 2022
3353b90
fix face orientation of 3d mesh
losanc Apr 5, 2022
546152d
minor change
losanc Apr 7, 2022
8109b98
initial fix for mzd files with duplicated faces
losanc Apr 11, 2022
e2fef18
bug fix
losanc Apr 13, 2022
7124bf6
fix for preprocess and process still exist in next for loop
losanc Apr 17, 2022
670a6b0
set attribute as split norm
losanc Apr 20, 2022
22ea9b9
make mzd by default remove duplicate face
losanc Apr 27, 2022
df91f27
add enable/disable selected; remove deselect all when chaning selected
losanc Apr 27, 2022
f1d6782
add refresh button
losanc May 4, 2022
40dcd31
fix a pattern bug; update with ui
losanc May 12, 2022
56568ec
make created object as active object
losanc Jun 18, 2022
76e69ee
update with doc
losanc Jun 18, 2022
ba64334
minor change
losanc Jun 28, 2022
f4b1c99
rename
losanc Jun 28, 2022
ce0271e
update geometry nodes for blender 3.2 & warn when remove existing nodes
losanc Jun 28, 2022
8686604
fix for confusing sequence selection
losanc Jun 28, 2022
1618e86
fix for must restart blender when installing
losanc Jun 28, 2022
470a589
rename attributes with prefix
losanc Jun 28, 2022
6aabe4c
auto select the first sequence
losanc Jul 5, 2022
dda78d3
Prepare for public release
Jul 5, 2022
4024da2
Merge branch 'sjeske/ui-improvements' into 'master'
losanc Jul 5, 2022
9addd88
Merge branch 'main' of https://github.com/losanc/blender-sequence-loa…
losanc Jul 5, 2022
bdcc826
Update __init__.py
losanc Jul 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
__pycache__/
.DS_Store
.vs_code/
*.zip

# the following ignores are used to ignore the local softlink files
# the extern folder won't be affected by this
rich
meshio
future
fileseq
13 changes: 13 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

[submodule "extern/meshio"]
path = extern/meshio
url = https://github.com/nschloe/meshio
[submodule "extern/python-future"]
path = extern/python-future
url = https://github.com/PythonCharmers/python-future
[submodule "extern/fileseq"]
path = extern/fileseq
url = https://github.com/justinfx/fileseq
[submodule "extern/rich"]
path = extern/rich
url = https://github.com/Textualize/rich
135 changes: 135 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
![](images/logo.svg)

Loading animation sequences with meshio and fileseq

- [1. Installation](#1-installation)
- [1.1 Build from source (optional)](#11-build-from-source-optional)
- [1.2 Install Addon](#12-install-addon)
- [1.3 FAQs](#13-faqs)
- [2. How to use](#2-how-to-use)
- [2. Load the animation sequence you want](#2-load-the-animation-sequence-you-want)
- [2.1 Absolute vs. Relative Paths](#21-absolute-vs-relative-paths)
- [2.2 Sequence List View](#22-sequence-list-view)
- [2.2.1 Enable/ Disable](#221-enable-disable)
- [2.2.1 Refresh Sequence](#221-refresh-sequence)
- [2.3 Settings](#23-settings)
- [2.3.1 Geometry Nodes](#231-geometry-nodes)
- [2.3.2 Path Information](#232-path-information)
- [2.3.3 Attributes Settings](#233-attributes-settings)
- [2.3.4 Split Norm per Vertex](#234-split-norm-per-vertex)

## 1. Installation

### 1.1 Build from source (optional)

1. Clone the project to download both project and dependencies

```shell
git clone https://www.graphics.rwth-aachen.de:9000/hhui/blendertool --recurse-submodules
```

2. Build the installable `.zip` file by simply running the following command. This should produce a file called `blender_sequence_loader_{date}.zip`, where `{date}` is replaced with todays date. No other dependency other than standard python3 libraries are needed to build the addon.

```shell
python3 build_addon.py
```

### 1.2 Install Addon

After obtaining an installable `.zip` file either from the releases page or from manually building the addon, this should be installed into blender. For more information on how to install addons see [here](https://docs.blender.org/manual/en/latest/editors/preferences/addons.html#installing-add-ons) for more details.

### 1.3 FAQs

1. You may need to restart blender after enabling the addon for the first time, otherwise some functionality may not work. Technically this should not be **required**, but might be necessary in some untested versions of Blender.

2. You may have to manually remove old versions of this addon (if present), before installing a new version into Blender. This should rarely be the case but might be the cause of some confusing error messages and issues.

## 2. How to use

DISCLAIMER: Some of the screenshots may not be up to date with the most recent version of the addon, especially with respect to the text and ordering of UI elements.

After installing addon, you can find it in the toolbar, which is accessible here or toggled by pressing the `n` key.

![start](images/0.png)

Then you can find it here.

![homepage](images/1.png)

### 2. Load the animation sequence you want

You can select the directory in which your data is located through the GUI by clicking the rightmost icon. It will open the default blender file explorer. Then you can go to the directory you want, for example, like image showed below. **You only need navigate to the directory and click "Accept". Files are shown but not selectable in this dialogue.**

![selecticon](images/2.png)

Then the addon will automatically try to detect the sequences in this directory, so that you simply select the sequence you want. If the desired sequence is not shown, you can switch to enter a manual pattern, where a single `@` character is used to denote a running frame index.

![after_selecting](images/3.png)

#### 2.1 Absolute vs. Relative Paths

There is a small checkbox about whether to use `relative paths` or not.

When toggled on, the blender file must be saved before loading the sequence. Then this sequence will be loaded using relative path from the location of the saved `.blend` file. As such, if you move the `.blend` file in conjunction with the data to another directory (keeping their relative locations the same) the sequence loader will still work. This is especially useful when working with cloud synchronized folders, whose absolute paths may be different on different computers.

If toggled off (default), it will use absolute path to load the sequence. For this, the `.blend` file does not have to be saved in advance.

![relative_path](images/4.png)

#### 2.2 Sequence List View

After the sequence being imported, it will be available in the `Imported Sequences` panel, with more settings being available in `Sequence Settings` panel once a sequence has been selected.

![settings](images/5.png)

By default, all supported file formats are simply imported as geometry (a collection of vertices, lines, triangles and quads). As such, you should be able to directly play/render the animation if it contains geometry.

Note: When rendering the animation, please turn on the `Lock Interface`. This will prevent artifacts from occurring, especially if the user continues to operate the Blender interface during the render process.

![lock interface](images/6.png)

##### 2.2.1 Enable/ Disable

It is possible to individually enable and disable sequences from updating when the animation frame changes. This is very useful when working with very large files or many sequences as it reduces the computational overhead of loading these sequences.
`Enabled` means, that the sequence will be updated on frame change, and `Disabled` means that the sequence won't be updated on frame change.

##### 2.2.1 Refresh Sequence

`Refresh Sequence` can be useful when the sequence is imported while the data is still being generated and not yet complete. Refreshing the sequence can detect the frames added after being imported.

#### 2.3 Settings

#### 2.3.1 Geometry Nodes

While all files are imported as plain geometry, we provide some templates that we have found to be incredibly useful for visualizing particle data.

Applying the `Point Cloud` geometry node, the vertices of the mesh are converted to a point cloud, which can be rendered only by [cycles](https://docs.blender.org/manual/en/latest/render/cycles/introduction.html) and only as spheres. The exact geometry node setup can be seen in the geometry nodes tab and may be modified as desired, e.g. to set the particle radius.

Applying `Instances` geometry nodes, the vertices of the mesh are converted to cubes, which can be rendered by both [eevee](https://docs.blender.org/manual/en/latest/render/eevee/index.html) and [cycles](https://docs.blender.org/manual/en/latest/render/cycles/introduction.html). The exact geometry node setup can be seen in the geometry nodes tab and may be modified as desired, e.g. to set the particle radius and to change the instanced geometry. **CAUTION: Because this node setup relies on the `Realize Instances` node, the memory usage increases extremely rapidly. Make sure to save the `.blend` file before attempting this, as Blender may run out of memory!!!**

Applying the `Mesh` geometry node will restore the default geometry nodes, which simply display the imported geometry as it is.

Notes:

1. `Instances` is super memory hungry compared with `Point Cloud`.
2. After applying `Point Cloud` or `Instances` geometry nodes, you need to assign the material inside the geometry nodes. So to save your work, you can simply assign the material here, then apply the `Point Cloud` or `Instances` geometry nodes.
3. To access the attributes for shading, use the `Attribute` node in the Shader Editor and simply specify the attribute string. The imported attributes can be seen in the spreadsheet browser of the Geometry Nodes tab and are also listed in the addon UI.

![material](images/7.png)

#### 2.3.2 Path Information

This shows the path of the sequence for debugging purposes, however it's not editable.

#### 2.3.3 Attributes Settings

This panel shows the available **Vertex Attributes**, it's not editable.

Note: In order to avoid conflicts with Blenders built-in attributes, all the attributes names are renamed by prefixing `bseq_`. For example, `id` -> `bseq_id`. Keep this in mind when accessing attributes in the shader editor.

#### 2.3.4 Split Norm per Vertex

We also provide the ability to use a per-vertex vector attribute as custom normals for shading.
For more details check the official documentation [here](https://docs.blender.org/manual/en/latest/modeling/meshes/structure.html#modeling-meshes-normals-custom).

Note: the addon does not check if the selected attribute is suitable for normals or not. E.g. if the data type of the attribute is int instead of float, then Blender will simply give a runtime error.
76 changes: 76 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
bl_info = {
"name": "Sequence Loader",
"description": "Loader for meshio supported mesh files/ simulation sequences",
"author": "Interactive Computer Graphics",
"version": (1, 0),
"blender": (3, 1, 0),
"warning": "",
"support": "COMMUNITY",
"category": "Import-Export",
}

import bpy
import os
import sys

current_folder = os.path.dirname(os.path.abspath(__file__))
if current_folder not in sys.path:
sys.path.append(current_folder)

if bpy.context.preferences.filepaths.use_relative_paths == True:
bpy.context.preferences.filepaths.use_relative_paths = False

from simloader import *

classes = [
SIMLOADER_obj_property,
SIMLOADER_scene_property,
SIMLOADER_mesh_property,
SIMLOADER_OT_load,
SIMLOADER_OT_edit,
SIMLOADER_OT_resetpt,
SIMLOADER_OT_resetins,
SIMLOADER_OT_resetmesh,
SIMLOADER_Import,
SIMLOADER_List_Panel,
SIMLOADER_UL_Obj_List,
SIMLOADER_Settings,
SIMLOADER_Templates,
SIMLOADER_UL_Att_List,
SIMLOADER_OT_set_as_split_norm,
SIMLOADER_OT_remove_split_norm,
SIMLOADER_OT_disable_selected,
SIMLOADER_OT_enable_selected,
SIMLOADER_OT_refresh_seq,
]


def register():
bpy.app.handlers.load_post.append(SIMLOADER_initialize)
for cls in classes:
bpy.utils.register_class(cls)
bpy.types.TEXT_MT_templates.append(draw_template)
bpy.types.Scene.SIMLOADER = bpy.props.PointerProperty(type=SIMLOADER_scene_property)
bpy.types.Object.SIMLOADER = bpy.props.PointerProperty(type=SIMLOADER_obj_property)
bpy.types.Mesh.SIMLOADER = bpy.props.PointerProperty(type=SIMLOADER_mesh_property)


# manually call this function once
# so when addon being installed, it can run correctly
# because scene is not used, so pass None into it
SIMLOADER_initilize(None)

def unregister():
for cls in classes:
bpy.utils.unregister_class(cls)
bpy.types.TEXT_MT_templates.remove(draw_template)
del bpy.types.Scene.SIMLOADER
del bpy.types.Object.SIMLOADER
bpy.app.handlers.load_post.remove(SIMLOADER_initialize)
unsubscribe_to_selected()


if __name__ == "__main__":

# unregister()
register()
8 changes: 8 additions & 0 deletions additional_file_formats/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from .mzd import readMZD_to_bpymesh, readMZD_to_meshio
from .bgeo import readbgeo_to_meshio

additional_format_loader = {'bgeo': readbgeo_to_meshio, 'mzd': readMZD_to_meshio}

__all__ = [
readMZD_to_bpymesh, readMZD_to_meshio, readbgeo_to_meshio, additional_format_loader
]
107 changes: 107 additions & 0 deletions additional_file_formats/bgeo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import gzip
import numpy as np
import meshio


def readbgeo_to_meshio(filepath):
with gzip.open(filepath, 'r') as file:
byte = file.read(5)
if byte != b"BgeoV":
raise Exception('not bgeo file format')
byte = file.read(4)
version = int.from_bytes(byte, byteorder="big")
if version != 5:
raise Exception('bgeo file not version 5')

header = {}
point_attributes = {}
point_attributes_names = []
point_attributes_sizes = []
point_attributes_types = []
position = None

byte = file.read(4)
header['nPoints'] = int.from_bytes(byte, byteorder="big")

byte = file.read(4)
header['nPrims'] = int.from_bytes(byte, byteorder="big")

byte = file.read(4)
header['nPointGroups'] = int.from_bytes(byte, byteorder="big")

byte = file.read(4)
header['nPrimGroups'] = int.from_bytes(byte, byteorder="big")

byte = file.read(4)
header['nPointAttrib'] = int.from_bytes(byte, byteorder="big")

byte = file.read(4)
header['nVertexAttrib'] = int.from_bytes(byte, byteorder="big")

byte = file.read(4)
header['nPrimAttrib'] = int.from_bytes(byte, byteorder="big")

byte = file.read(4)
header['nAttrib'] = int.from_bytes(byte, byteorder="big")

particle_size = 4

for _ in range(header['nPointAttrib']):
byte = file.read(2)
namelength = int.from_bytes(byte, byteorder="big")
name_binary = file.read(namelength)
name = name_binary.decode('utf-8')
point_attributes_names.append(name)

byte = file.read(2)
size = int.from_bytes(byte, byteorder="big")
point_attributes_sizes.append(size)
particle_size += size

byte = file.read(4)
houdni_type = int.from_bytes(byte, byteorder="big")
if houdni_type == 0:
point_attributes_types.append('FLOAT')
# read default value
# not going to do anything about it
byte = file.read(size * 4)
elif houdni_type == 1:
point_attributes_types.append('INT')
# read default value
# not going to do anything about it
byte = file.read(size * 4)
elif houdni_type == 5:
point_attributes_types.append('VECTOR')
# read default value
# not going to do anything about it
byte = file.read(size * 4)
else:
raise Exception('houdni_type unknown/ unsupported')
byte = file.read(particle_size * header['nPoints'] * 4)
# > means big endian
attribute_data = np.frombuffer(byte, dtype='>f')
attribute_data = np.reshape(attribute_data, (header['nPoints'], particle_size))
# the first 3 column is its position data
position = attribute_data[:, :3]
# the 4th column is homogeneous coordiante, which is all 1, and will be ignored

current_attribute_start_point = 4
for i in range(header['nPointAttrib']):
if point_attributes_types[i] == 'FLOAT':
point_attributes[point_attributes_names[i]] = attribute_data[:, current_attribute_start_point]
current_attribute_start_point += 1
elif point_attributes_types[i] == 'VECTOR':
point_attributes[
point_attributes_names[i]] = attribute_data[:,
current_attribute_start_point:current_attribute_start_point + 3]
current_attribute_start_point += 3
elif point_attributes_types[i] == 'INT':
data = (attribute_data[:, current_attribute_start_point]).tobytes()
# > means big endian
point_attributes[point_attributes_names[i]] = np.frombuffer(data, dtype='>i')
current_attribute_start_point += 1
remaining = file.read()
if not remaining == b'\x00\xff':
raise Exception("file didn't end")
return meshio.Mesh(position, [('vertex', [])], point_data=point_attributes)

Loading