Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

[XBOX] Tenchu: Return from Darkness - .bgm 3D Format

Featured Replies

  • Localization

The game maps use this format; each level has a map divided into sections. I'll also send the textures to help with visualization. If anyone knows a way to edit or convert them, I would be grateful.

ST01-TEXTURE.zip ST01.zip

Solved by h3x3r

  • Supporter
  • Solution

Looks simple. First you must parse vertex buffer, index buffer and then is table with info about shapes and textures.

//------------------------------------------------
//--- 010 Editor v14.0 Binary Template
//
//      File: Tenchu: Return from Darkness
//   Authors: 
//   Version: 
//   Purpose: 
//  Category: 
// File Type: *.bgm
//  ID Bytes: 
//   History: 
//------------------------------------------------
LittleEndian();OutputPaneClear();

local uint32 i,j,k,l,ElementBaseOffset,IndexBaseOffset;

FSeek(36);

uint32 TotalElementCount;
ElementBaseOffset=FTell();
byte Elements[TotalElementCount * 24];

uint32 TotalIndexCount;
IndexBaseOffset=FTell();
ushort Indices[TotalIndexCount];

struct
{
    uint32 ShapeIndex;
    
    struct
    {
        uint32 IndexOffset,IndexCount,ElementOffset,ElementCount;
        uint32 ShapeId;
        string TextureName;
        FSeek(startof(TextureName));
        FSkip(32);
        uint32 Unk4;
        float BBox[6];
    }Shape[ShapeIndex]<optimize=false>;
}Shapes;

FSeek(ElementBaseOffset);
struct
{
    for (i=0; i < Shapes.ShapeIndex; i++)
    {
        struct
        {
            FSeek(ElementBaseOffset + Shapes.Shape[i].ElementOffset * 24);
            struct
            {
                float VPosX,VPosY,VPosZ;
                ubyte R,G,B,A;
                float UVPosX,UVPosY;
            }Elements[Shapes.Shape[i].ElementCount]<optimize=false>;
            
            FSeek(IndexBaseOffset + Shapes.Shape[i].IndexOffset * 2);
            struct
            {
                uint16 Index;
            }Indices[Shapes.Shape[i].IndexCount]<optimize=false>;
        }ShapeBuffer;
    }
}ShapeBuffers;

image.thumb.png.ef4b3b13ea6ea0948d5c86214239639f.png

image.thumb.png.7d52707416538833324c06b265e8acec.png

from inc_noesis import *
import noesis
import rapi
import os

def registerNoesisTypes():
   handle = noesis.register("Tenchu: Return from Darkness - Mesh", ".bgm")
   noesis.setHandlerTypeCheck(handle, noepyCheckType)
   noesis.setHandlerLoadModel(handle, noepyLoadModel)
   noesis.logPopup()
   return 1
        
def noepyCheckType(data):
   bs = NoeBitStream(data)
   if len(data) < 20:
      return 0
   return 1
        
def noepyLoadModel(data, mdlList):
	bs = NoeBitStream(data)
	baseName = rapi.getExtensionlessName(rapi.getLocalFileName(rapi.getInputName()))
	ctx = rapi.rpgCreateContext()
	Underline = "_"

	CurPos = bs.tell()
	bs.read(20)
	Type = bs.readUInt()
	if Type == 1:
		bs.seek(CurPos, NOESEEK_ABS)
		bs.read(36)
	else:
		bs.seek(CurPos, NOESEEK_ABS)
    
	TotalElementCount = bs.readUInt()
	ElementBaseOffset = bs.tell();
	ElementBuffer = bs.read(TotalElementCount * 24)
	rapi.rpgBindPositionBufferOfs(ElementBuffer, noesis.RPGEODATA_FLOAT, 24, 0)
	rapi.rpgBindColorBufferOfs(ElementBuffer, noesis.RPGEODATA_UBYTE, 24, 12, 4)
	rapi.rpgBindUV1BufferOfs(ElementBuffer, noesis.RPGEODATA_FLOAT, 24, 16)
        
	TotalIndexCount = bs.readUInt()
	IndexBaseOffset = bs.tell();
	bs.read(TotalIndexCount * 2)
    
	ShapeIndex = bs.readUInt()
    
	for i in range(0, ShapeIndex):
	    IndexOffset = bs.readUInt() * 2
	    IndexCount = bs.readUInt()
	    ElementOffset = bs.readUInt() * 24
	    ElementCount = bs.readUInt()
	    ShapeId = bs.readUInt()
	    TNamePos = bs.tell()
	    TextureName = bs.readString()
	    bs.seek(TNamePos, NOESEEK_ABS)
	    bs.read(32)
	    Unknown = bs.readUInt()
	    BBox = bs.read(24)
	    cPos = bs.tell()
	    ShapeId = "{:04d}".format(ShapeId)
                            
	    rapi.rpgSetName(baseName + Underline + ShapeId)
	    rapi.rpgSetMaterial(TextureName)
	    if IndexCount != 0:
	        bs.seek(IndexBaseOffset + IndexOffset, NOESEEK_ABS)
	        IndexBuffer = bs.read(IndexCount * 2)
	        rapi.rpgCommitTriangles(IndexBuffer, noesis.RPGEODATA_USHORT, IndexCount, noesis.RPGEO_TRIANGLE_STRIP)
	    bs.seek(cPos, NOESEEK_ABS)
	mdl = rapi.rpgConstructModel()
	mdlList.append(mdl)
	return 1

Just drop the bgm into the texture folder named as the bgm. Noesis should open it with texture applied. Not sure when export tho. I set material name as texture name.

Vertex color works too.

Edited by h3x3r

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.