Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: WolvenKit/Cyberpunk-Blender-add-on
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.5.4
Choose a base ref
...
head repository: WolvenKit/Cyberpunk-Blender-add-on
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.5.5
Choose a head ref

Commits on Mar 31, 2024

  1. Update sector_import.py

    Simarilius-uk authored Mar 31, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    478b41b View commit details

Commits on Apr 4, 2024

  1. fix having removed anims from glob calls

    Simarilius-uk authored Apr 4, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    cbb5128 View commit details

Commits on Apr 11, 2024

  1. use .update for additional options required for different blender ver…

    …sions instead of duplicates
    DoctorPresto committed Apr 11, 2024
    Copy the full SHA
    4690cb5 View commit details
  2. Copy the full SHA
    eef3ab9 View commit details
  3. Copy the full SHA
    138110a View commit details
  4. move vert group check to mesh validation loop

    DoctorPresto committed Apr 11, 2024
    Copy the full SHA
    31e9969 View commit details
  5. prevent runtime error when selecting untriangulated faces

    DoctorPresto committed Apr 11, 2024
    Copy the full SHA
    9bd242b View commit details

Commits on Apr 16, 2024

  1. Copy the full SHA
    b4fc7d4 View commit details
  2. better print to console on blender startup

    better spacing and messaging when blender starts
    DoctorPresto committed Apr 16, 2024
    Copy the full SHA
    1c11ef7 View commit details
  3. include PIL

    pil allows much more in depth image processing, will give us the ability to alleviate some of the stress from cycles nodes with custom ones as well as to generate and edit mlmasks
    DoctorPresto committed Apr 16, 2024
    Copy the full SHA
    6a94851 View commit details
  4. add function for less verbose message box usage to common.py

    can now import the show_message function from common and call it with: show_message(message)
    instead of always calling the operator directly which is more verbose and a bit of a pain
    DoctorPresto committed Apr 16, 2024
    Copy the full SHA
    81bd4c4 View commit details
  5. move the depot remapping option to experimental features

    less confusing for basic users
    DoctorPresto committed Apr 16, 2024
    Copy the full SHA
    29be7d0 View commit details
  6. Copy the full SHA
    36aa914 View commit details
  7. allow exporting of custom .phys files

    no more need for a vanilla .phys.json, generated colliders now are directly exportable to a json created by blender
    DoctorPresto committed Apr 16, 2024
    Copy the full SHA
    c63748f View commit details
  8. Merge pull request #132 from WolvenKit/collision_rework

    allow exporting of custom .phys files
    DoctorPresto authored Apr 16, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    f43d801 View commit details
  9. Copy the full SHA
    7e98fd1 View commit details

Commits on Apr 17, 2024

  1. switch to getting collision collections by name

    the other way was inconsistent, this seems to be better
    DoctorPresto committed Apr 17, 2024
    Copy the full SHA
    f88d6eb View commit details
  2. Merge pull request #133 from WolvenKit/collision_rework

    switch to getting collision collections by name
    DoctorPresto authored Apr 17, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    ada8ba0 View commit details

Commits on Apr 18, 2024

  1. Fix indexs and a few tweaks to collisions

    nodeDataIndexs were wrong, made some improvements to collisions (like actually using the rotation that was calculated)
    Simarilius-uk committed Apr 18, 2024
    Copy the full SHA
    92e1f3f View commit details
  2. Copy the full SHA
    73ff831 View commit details
  3. Update sector_import.py

    Simarilius-uk committed Apr 18, 2024
    Copy the full SHA
    8e3080a View commit details
  4. Update __init__.py to 1.5.5

    Simarilius-uk authored Apr 18, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    bd5b202 View commit details
  5. Merge pull request #134 from Simarilius-uk/main

    Sector Import: Fix indexs and a few tweaks to collisions
    Simarilius-uk authored Apr 18, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    af44a74 View commit details
82 changes: 65 additions & 17 deletions i_scene_cp77_gltf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
def install_dependency(dependency_name):
print(f"required package: {dependency_name} not found")
from pip import _internal as pip
print(f"Attempting to install {dependency_name}")
try:
pip.main(['install', dependency_name])
print(f"Successfully installed {dependency_name}")
except Exception as e:
print(f"Failed to install {dependency_name}: {e}")

print('-------------------- Cyberpunk IO Suite Starting--------------------')
print()

import bpy
import bpy.utils.previews
import os
import textwrap
try:
import PIL
except (ImportError, ModuleNotFoundError):
install_dependency('pillow')


from bpy.props import (StringProperty, EnumProperty, BoolProperty, CollectionProperty, FloatProperty, IntProperty, PointerProperty)
from bpy.types import (Scene, Operator, PropertyGroup, Object, OperatorFileListElement, Panel, AddonPreferences, TOPBAR_MT_file_import, TOPBAR_MT_file_export)
@@ -26,7 +44,7 @@
bl_info = {
"name": "Cyberpunk 2077 IO Suite",
"author": "HitmanHimself, Turk, Jato, dragonzkiller, kwekmaster, glitchered, Simarilius, Doctor Presto, shotlastc, Rudolph2109, Holopointz",
"version": (1, 5, 4),
"version": (1, 5, 5),
"blender": (3, 6, 0),
"location": "File > Import-Export",
"description": "Import and Export WolvenKit Cyberpunk2077 gLTF models with materials, Import .streamingsector and .ent from .json",
@@ -36,14 +54,15 @@
"tracker_url": "https://github.com/WolvenKit/Cyberpunk-Blender-add-on/issues/new/choose",
}
plugin_version = ".".join(map(str, bl_info["version"]))
printstatement = f"Cyberpunk IO Suite version: {plugin_version}"

icons_dir = os.path.join(os.path.dirname(__file__), "icons")
custom_icon_col = {}
script_dir = get_script_dir()

print()
print(printstatement)
print(f"Cyberpunk IO Suite version: {plugin_version}")
print()
print('-------------------- Cyberpunk IO Suite Finished--------------------')

class CP77IOSuitePreferences(AddonPreferences):
bl_idname = __name__
@@ -105,11 +124,13 @@ def draw(self, context):
layout = self.layout
box = layout.box()

row = box.row()
row.prop(self, "depotfolder_path")
row = box.row()
row.prop(self, "show_modtools",toggle=1)
row.prop(self, "experimental_features",toggle=1)
row.prop(self, "experimental_features",toggle=1)
if self.experimental_features:
row = box.row()
row.prop(self, "depotfolder_path")
row = box.row()
if self.show_modtools:
row.alignment = 'LEFT'
box = layout.box()
@@ -461,14 +482,37 @@ class CP77CollisionExport(Operator):
bl_description = "Export project collisions to .phys.json"

filepath: StringProperty(subtype="FILE_PATH")


def draw(self, context):
layout = self.layout
layout.prop(context.scene.cp77_panel_props, "collision_type")

def execute(self, context):
cp77_collision_export(self.filepath)
collision_type = context.scene.cp77_panel_props.collision_type
cp77_collision_export(self.filepath, collision_type)
return {"FINISHED"}

def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {"RUNNING_MODAL"}


class CP7PhysImport(Operator):
bl_idname = "import_scene.phys"
bl_label = "Import .phys Collisions"
bl_options = {'REGISTER', 'UNDO'}
bl_description = "Import collisions from an exported .phys.json"

filepath: StringProperty(subtype="FILE_PATH")

def execute(self, context):
cp77_phys_import(self.filepath)
return {"FINISHED"}

def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {"RUNNING_MODAL"}


class CP7PhysImport(Operator):
bl_idname = "import_scene.phys"
@@ -1240,7 +1284,8 @@ class CP77EntityImport(Operator,ImportHelper):
description="Collector to put the imported entity in",
default='',
options={'HIDDEN'})

cp77_addon_prefs = bpy.context.preferences.addons[__name__].preferences

def draw(self, context):
layout = self.layout
row = layout.row(align=True)
@@ -1254,8 +1299,9 @@ def draw(self, context):
row.prop(self, "update_gi")
row = layout.row(align=True)
row.prop(self, "with_materials")
row = layout.row(align=True)
row.prop(self,"remap_depot")
if cp77_addon_prefs.experimental_features:
row = layout.row(align=True)
row.prop(self,"remap_depot")
row = layout.row(align=True)
if not self.include_collisions:
row.prop(self, "include_collisions")
@@ -1302,7 +1348,7 @@ class CP77StreamingSectorImport(Operator,ImportHelper):
am_modding: BoolProperty(name="Generate New Collectors",default=False,description="Generate _new collectors for sectors to allow modifications to be saved back to game")
with_materials: BoolProperty(name="With Materials",default=False,description="Import Wolvenkit-exported materials")
remap_depot: BoolProperty(name="Remap Depot",default=False,description="replace the json depot path with the one in prefs")

cp77_addon_prefs = bpy.context.preferences.addons[__name__].preferences

def draw(self, context):
layout = self.layout
@@ -1313,8 +1359,9 @@ def draw(self, context):
row.prop(self, "am_modding")
row = layout.row(align=True)
row.prop(self, "with_materials")
row = layout.row(align=True)
row.prop(self, "remap_depot")
if cp77_addon_prefs.experimental_features:
row = layout.row(align=True)
row.prop(self,"remap_depot")

def execute(self, context):
bob=self.filepath
@@ -1337,7 +1384,7 @@ def poll(cls, context):
def draw_header(self, context):
operator = context.space_data.active_operator
self.layout.prop(operator, "with_materials", text="")

cp77_addon_prefs = bpy.context.preferences.addons[__name__].preferences
def draw(self, context):
operator = context.space_data.active_operator
layout = self.layout
@@ -1350,8 +1397,9 @@ def draw(self, context):
row.prop(operator, 'hide_armatures')
row = layout.row(align=True)
row.prop(operator, 'use_cycles')
row = layout.row(align=True)
row.prop(operator, 'remap_depot')
if cp77_addon_prefs.experimental_features:
row = layout.row(align=True)
row.prop(self,"remap_depot")
if operator.use_cycles:
row = layout.row(align=True)
row.prop(operator, 'update_gi')
85 changes: 26 additions & 59 deletions i_scene_cp77_gltf/exporters/collision_export.py
Original file line number Diff line number Diff line change
@@ -2,62 +2,29 @@
import os
import bpy
from mathutils import Vector, Euler, Quaternion

def cp77_collision_export(filepath):
selected_collection = bpy.context.collection
with open(filepath, 'r') as phys:
data = json.load(phys)
physJsonPath = filepath

dir_name, file_name = os.path.split(filepath)
new_file_name = 'new_' + file_name
output = os.path.join(dir_name, new_file_name)

collection = selected_collection

if collection is not None:
for index, obj in enumerate(collection.objects):
colliderType = obj.name.split('_')[1]
i = data['Data']['RootChunk']['bodies'][0]['Data']['collisionShapes'][index]

i['Data']['localToBody']['position']['X'] = obj.location.x
i['Data']['localToBody']['position']['Y'] = obj.location.y
i['Data']['localToBody']['position']['Z'] = obj.location.z
i['Data']['localToBody']['orientation']['i'] = obj.rotation_quaternion.z
i['Data']['localToBody']['orientation']['j'] = obj.rotation_quaternion.x
i['Data']['localToBody']['orientation']['k'] = obj.rotation_quaternion.y
i['Data']['localToBody']['orientation']['r'] = obj.rotation_quaternion.w

if colliderType == "physicsColliderConvex" or colliderType == "physicsColliderConcave":
mesh = obj.data
if 'vertices' in i['Data']:
for j, vert in enumerate(mesh.vertices):
i['Data']['vertices'][j]['X'] = vert.co.x
i['Data']['vertices'][j]['Y'] = vert.co.y
i['Data']['vertices'][j]['Z'] = vert.co.z

elif colliderType == "physicsColliderBox":
# Calculate world-space bounding box vertices
world_bounds = [obj.matrix_world @ Vector(coord) for coord in obj.bound_box]

# Get center of the box in world space
center = sum(world_bounds, Vector()) / 8

# Update position in the json based on the center of the cube in world space
i['Data']['localToBody']['position']['X'] = center.x
i['Data']['localToBody']['position']['Y'] = center.y
i['Data']['localToBody']['position']['Z'] = center.z
# Update halfExtents
i['Data']['halfExtents']['X'] = obj.dimensions.x / 2
i['Data']['halfExtents']['Y'] = obj.dimensions.y / 2
i['Data']['halfExtents']['Z'] = obj.dimensions.z / 2

elif colliderType == "physicsColliderCapsule":
i['Data']['radius'] = obj.dimensions.x / 2 # Divided by 2 because blender dimensions are diameter
i['Data']['height'] = obj.dimensions.z

bpy.ops.cp77.message_box('INVOKE_DEFAULT', message="Succesfully Exported Collisions")
with open(output, 'w') as f:
json.dump(data, f, indent=2)

print(f'Finished exporting {new_file_name}')
from ..main.common import show_message
from .phys_export import export_colliders_to_phys

def get_collider_collections(context, collider_name):
collider_collections = []

for collection in bpy.data.collections:
if collider_name in collection.name:
collider_collections.append(collection.name)

if not collider_collections:
print(f"Error: Collider collection '{collider_name}' not found.")
return None
else:
return collider_collections

def cp77_collision_export(filepath, collision_type):
context = bpy.context
if collision_type == 'VEHICLE':
collider_name = 'collisions.phys'
collections = get_collider_collections(context, collider_name)
export_colliders_to_phys(collections, filepath)
if collision_type == 'ENTITY':
show_message('Exporting of Entity Colliders is not yet supported')
if collision_type == 'WORLD':
show_message('Exporting of collision nodes is not yet supported')
Loading