Code Monkey home page Code Monkey logo

opensage.blenderplugin's Introduction

OpenSAGE

Build Status Discord Chat codecov

OpenSAGE: a free, open source re-implementation of SAGE, the 3D real time strategy (RTS) engine used in Command & Conquer™: Generals and other RTS titles from EA Pacific.

This project is being developed with an initial focus on Command & Conquer: Generals and Command & Conquer: Generals Zero Hour. Support for other SAGE-based games may come later. The primary development target is Windows, with support planned for macOS at a later date.

Work in progress

This project is in the very early stages. There is still a long way to go before there's anything playable. The initial focus is on understanding the data formats used in Command & Conquer: Generals and Zero Hour.

Here's a rough roadmap:

Parse data files

  • .map
  • .w3d
  • .wak
  • .wnd
  • .csf
  • .ini
  • .ani
  • .dds
  • .tga
  • .const
  • .apt
  • .wav
  • .mp3

Rendering

  • Render 3D models loaded from .w3d, including animations
  • Render maps loaded from .map (in progress)
  • Render particle systems (in progress)
  • Render GUI loaded from .wnd (in progress)

Game logic

  • Scripting engine (in progress)
  • APT virtual machine (in progress)
  • AI - Path finding, base building, fighting
  • Physics engine
  • Weapons
  • Locomotors
  • Input (keyboard, mouse)
  • Network play
  • Much more...

Platforms

  • Windows
    • OpenGL 4.3
    • Direct3D 11
  • Mac
    • Metal 2 (requires macOS High Sierra)
  • Linux
    • OpenGL 4.3

Legal disclaimers

  • This project is not affiliated with or endorsed by EA in any way. Command & Conquer is a trademark of Electronic Arts.
  • This project is non-commercial. The source code is available for free and always will be.
  • OpenSAGE is nowhere near playable yet, but when it is and you want to play Generals or Zero Hour with it, you will need to have a legally acquired installation of one of those games. OpenSAGE uses data files from the original games. You can purchase Command & Conquer: The Ultimate Collection through Origin.
  • This is a blackbox re-implementation project. The code in this project was written based on reading data files, and observing the game running. In some cases (for example refpack decompression) the code was written based on specs available on the Internet. I believe this puts the project in the clear, legally speaking. If someone at EA disagrees, please talk to me.
  • If you want to contribute to this repository, your contribution must be either your own original code, or open source code with a clear acknowledgement of its origin. No code that was acquired through reverse engineering executable binaries will be accepted.
  • No assets from the original games are included in this repo.

A note on the name: while Command & Conquer is a trademark of EA, SAGE is not (as far as I can tell, based on a US trademark search). "OpenSAGE" seems like a good way to make it clear what the project is about, without infringing on trademarks.

About

OpenSAGE is being created by me, Tim Jones. I was at university in February 2003 when C&C Generals was first released. I spent far too much time playing it and the sequel, Zero Hour (and as a consequence, not enough time studying). In my opinion, as a near-real-world RTS game, it is still unmatched even 14 years later.

I later bought The First Decade on DVD, and it was this copy I wanted to install in Windows 10. I even bought an external DVD drive in order to do so. It wasn't straightforward, and it made me worry that one day I won't be able to play what is still my favourite RTS game.

One thing led to another, and I found myself opening .map files in a hex viewer. I had the idea of recreating the game, using the original assets. This appealed to me on many levels: it's a preservation of history, it satisfies my nostalgia, and it's an extreme programming challenge.

It's a vast project, and who knows how far I'll get. Hopefully we'll all have some fun along the way.

Community

We have a growing OpenSAGE Discord community. If you have questions about the project or can't get it working, there's usually someone there who can help out.

Acknowledgements

First, I would like to thank Stephan Vedder (feliwir) for his efforts, over several years, to understand several of the key SAGE data formats, including .w3d. Without his prior work, I would have had a much harder time getting started.

DeeZire's module list has been extremely helpful in understanding all the Object parameters in .ini files.

The font used in the OpenSAGE logo was created by Dexistor371 and is available from DeviantArt.

The sage / leaf icon used in the OpenSAGE logo was created by Monjin Friends and is licenced under Creative Commons CC BY 3.0 US. It is available from the Noun Project.

Finally, I want to thank the original team who built Generals and Zero Hour, because without their work, I wouldn't be doing any of this. (As I get further into the project, I'm gaining ever greater admiration for what those people were able to achieve 14 years ago, both technically and artistically.)

Similar projects

These projects have similar goals:

OpenRA already does for the Westwood RTS games what I hope to do for the EA-era RTS games with OpenSAGE.

opensage.blenderplugin's People

Contributors

feliwir avatar github-actions[bot] avatar michaelschnabel-dm avatar nkx111 avatar rizzntine avatar tarcontar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

opensage.blenderplugin's Issues

Plugin produces duplicate output

When invoking a W3D HAM export via script, then the plugin will print log output twice.

Blender 3.4.1 (hash 55485cb379f7 built 2022-12-20 01:51:19)
Read prefs: C:\Users\x\AppData\Roaming\Blender Foundation\Blender\3.4\config\userpref.blend
Read blend: D:\Projects\TheSuperHackers\GeneralsModBuilder\SampleProject\GameFilesEdited\Art\Models\AVSentry.blend
INFO: plugin version: 0.6.7
INFO: mesh 'TURRET01.002' vertices have been split because of multiple uv coordinates per vertex!
INFO: Saving file: D:\Projects\TheSuperHackers\GeneralsModBuilder\SampleProject\.Build\RawBundleItems\SampleModels\Art\W3D\AVSentry.w3d
INFO: export mode: HAM
INFO: finished
Info: plugin version: 0.6.7
Info: mesh 'TURRET01.002' vertices have been split because of multiple uv coordinates per vertex!
Info: Saving file: D:\Projects\TheSuperHackers\GeneralsModBuilder\SampleProject\.Build\RawBundleItems\SampleModels\Art\W3D\AVSentry.w3d
Info: export mode: HAM
Info: finished

Blender quit

Invoked by

blender.exe "D:\\Projects\\TheSuperHackers\\GeneralsModBuilder\\SampleProject\\GameFilesEdited\\Art\\Models\\AVSentry.blend" -b --python-expr "import bpy\nbpy.ops.export_mesh.westwood_w3d(filepath='D:\\Projects\\TheSuperHackers\\GeneralsModBuilder\\SampleProject\\.Build\\RawBundleItems\\SampleModels\\Art\\W3D\\AVSentry.w3d',check_existing=False,file_format='W3D',export_mode='HAM',use_existing_skeleton=False,animation_compression='U',force_vertex_materials=False,individual_files=False,create_texture_xmls=False)"

Perhaps Plugin outputs debug when Blender does the same?

Test: Import and export, compare binary

Right now we see discrepancies when importing and exporting W3D files with the Blender Plugin. Would it be possible to setup a test for the Blender Plugin to mass import and export w3d files and compare the new export with the original and then highlight the discrepancies? This way we could see where the Blender Plugins produces wrong results, either on import or export.

jonwil says:

I can tell you that if you export a w3d file multiple times in a row from the same it will produce the same output. At least with the max plugins (EAs or mine).

Importing textures with alpha

This is a very small issue. While Feliwir was explaining to me his attempt to add alpha it seemed like he missed the Blend Mode setting which I have circled in the screenshot.

Here is an example of the shader material nodes and settings that I use to display alpha in Blender. The default render engine in Blender 2.8 is Eeevee and this setting is only available for Eevee.

demostration of alpha setting

I recommend using either the Alpha Clip or Alpha Blend setting.

Where is the file io_mesh_w3d-X.X.zip?

This probably is a stupid question about something I'm supposed to know, but where is the file io_mesh_w3d-X.X.zip? The Installing the plugin section says "To install, open Blender's User Preferences panel, click the Add-ons tab, click the Install Add-on from File... button, select io_mesh_w3d-X.X.zip, and click Install." and I only see an io_mesh_w3d folder and an OpenSAGE.BlenderPlugin-master.zip file, not a io_mesh_w3d-X.X.zip file.

Support multiple levels of details

Right now we only support 1 level of detail (LOD) in our plugin since BFME rarely uses more LODs. However for C&C Renegade (and possible other parts of the series) this is not the case. I suggest creating a collection during import stage when a mesh has multiple LODs e.g. like this:
grafik

During export there should be an option to select the number of levels (defaulting with the levels found at import). In case a mesh has no low poly version we can easily generate one with Blender.

Part of this issue is that we must connect Hierarchy and the HLod with the BoneIndex instead of the BoneName

Visibility channel support for bones

At the moment visibility channels do not work for bones.
This seems like an issue with blender where setting PoseBone.bone.hide makes the bone unselectable in browser and also renders its bone tab blank.
I think because of this isse no keyframes for the "hide" property can be created with:

PoseBone.bone.hide = True
PoseBone.bone.insert_keyframe(data_path='hide', frame=frame)

Also the Suggestion to retrieve the bone directly from rig.data.bones and setting via:

bone.hide = True
bone.insert_keyframe(data_path='hide', frame=frame)

does not create a keyframe.

See https://developer.blender.org/T72918 for more Information.

Unable to import C&C Renegade maps with Textures into Blender

I installed the plug in correctly, and I decided to import C&C City.mix (mp_city.w3d).
While the mesh imported just fine, the only textures that were loaded were the surrounding backdrop city sky scrapers.

I checked the console, see attachment
blender w3d import issue

missing pose transform at uncompressed animation channels

At uncompressed animations from generals, it seems like the pose transform has to be applied to get the correct transform for the Animation, since the values in the channels seem to only describe Delta values from the pose transform.

wrong
fixed

For BFME/BFME2 uncompressed Animations adding that pose transform is not required, se we need a way to distinguish between those cases.

IndexError: bpy_prop_collection[index]: index 191 out of range, size 191

Importing UIWRKR_SKN.W3D file from GeneralsZH-104 causes error.

plugin version: 0.6.7
Loading file: D:\Projects\TheSuperHackers\GeneralsFiles\Generals-108-GeneralsZH-104-Loose\Art\W3D\UIWRKR_SKN.W3D
Loading file: D:\Projects\TheSuperHackers\GeneralsFiles\Generals-108-GeneralsZH-104-Loose\Art\W3D\UIWRKR_SKL.W3D
creating mesh 'BOX'
loaded texture: D:\Projects\TheSuperHackers\GeneralsFiles\Generals-108-GeneralsZH-104-Loose\Art\W3D\CTCrateBoxes.dds
creating mesh 'MINED_SKIN'
creating mesh 'WORKER'
Python: Traceback (most recent call last):
  File "C:\Users\x\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_mesh_w3d\__init__.py", line 205, in execute
    load(self)
  File "C:\Users\x\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_mesh_w3d\w3d\import_w3d.py", line 137, in load
    create_data(context,
  File "C:\Users\x\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_mesh_w3d\import_utils.py", line 46, in create_data
    rig_mesh(mesh, hierarchy, rig, sub_object)
  File "C:\Users\x\AppData\Roaming\Blender Foundation\Blender\3.4\scripts\addons\io_mesh_w3d\common\utils\mesh_import.py", line 130, in rig_mesh
    mesh.vertices[i].co = matrix @ mesh_struct.verts[i]
IndexError: bpy_prop_collection[index]: index 191 out of range, size 191

Feature: Automatic export mode

Feature suggestion: Add automatic export mode.

Currently W3D export needs to be accompanied by H, A, M or a combination thereof. It would be nice if there was an "Auto" mode that determines the export mode automatically simply by the contents of the scene. Is there a hierarchy? Is there a mesh? Is there an animation? I expect this to be queryably through the Python API. It would be nice if the Blender Plugin would have this feature natively, otherwise it would have to be built externally around it.

The model shell03brddur.w3d cannot be opened.

shell03brddur is BfME 1's shell map, a giant model of Barad-dur with a lightmap material and camera animation. I have just now tested other models with the similar materials like mmdbalin.w3d, yet they seem to work.

Traceback (most recent call last):
  File "C:\Users\matt\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\io_mesh_w3d\import_w3d.py", line 226, in load
    mesh_ob.parent = bpy.data.objects[parent_pivot.name]
KeyError: 'bpy_prop_collection[key]: key "AAA_BOX01" not found'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\matt\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\io_mesh_w3d\__init__.py", line 143, in execute
    import_w3d.load(self, context, import_settings)
  File "C:\Users\matt\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\io_mesh_w3d\import_w3d.py", line 228, in load
    mesh_ob.parent = bpy.data.objects[amtName]
KeyError: 'bpy_prop_collection[key]: key "SHELL03BRDDUR" not found'

location: <unknown location>:-1

The model cbharruin04.w3d cannot be opened.

The model cbharruin04.w3d cannot be opened.

Traceback (most recent call last):
  File "C:\Users\matt\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\io_mesh_w3d\__init__.py", line 143, in execute
    import_w3d.load(self, context, import_settings)
  File "C:\Users\matt\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\io_mesh_w3d\import_w3d.py", line 188, in load
    amtName = hierarchy.header.name
AttributeError: 'NoneType' object has no attribute 'header'

location: <unknown location>:-1

Import / export of hyrachia, object and texture names

First of all, thank you for someone caring about this old game engine.

However, I have a problem.
The textures are constantly renamed when exporting.
This doesn't matter for Blender.
In games, all points “.” are new objects.
The driver entry “normalmappet.fx” may be exported as “normalmappet.fx.00X”.
Would it be possible to stop this?

W3D works with Planes.
These are simple areas that show the game where something is limited. Be it for entering, climbing over, transitioning from the landscape to the model, as an obstacle, or in special cases, what can be undercut. These areas should be invisible.

A Hyrachian model needs no bones and no amature.
However the filter returns an error?

An amature is automatically created during import.
For buildings without animation, completely pointless.
In addition, some functions do not work with buildings.

I would ask you to assign names to the objects in the W3D options and to strictly adopt them.
Blender is constantly evolving. This is brilliant for filmmakers.
For us modders, that means spending hours tricking Blender and naming objects the way we need them.
A field in the W3D Proberties where you can enter the identifier that will be published would be extremely helpful.

Should I have missed something?
Then I politely apologize.
Where do I need to check the box or change the name?

Thank you, Johannes

Support dazzle chunk type

Used for some vehicles in renegade as a mesh type. It's used e.g. for front lights and stuff like this. There are multiple dazzle types aswell which we must provide a dropdown list for in blender.

It would maybe make sense to put all the different geometry types (see image below) into one property setting.
grafik

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.