Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Galaco/studiomodel

Repository files navigation

GoDoc Go report card GolangCI
codecov CircleCI

studiomodel

Golang library for loading Valve studiomodel formats (.mdl, .vtx, .vvd)

Some parts of a prop are mandatory (mdl,vvd,vtx), others are not (phy). It's up to the implementor to construct a studiomodel the way they want to.

This is a collection of parsers for different formats, it has no concept of the filesystem structure (theoretically different StudioModel components could be located in different folders).

Tested against Counter Strike Source and Counter Strike Global Offensive

Features

  • VVD reader is stable
  • VTX reader is usable, only for single LOD models
  • MDL reader is usable, currently incomplete (some properties not populated)
  • PHY reader is usable, string data table is not supported yet

Usage

package main
import (
	"github.com/galaco/studiomodel"
	"github.com/galaco/studiomodel/mdl"
	"github.com/galaco/studiomodel/phy"
	"github.com/galaco/studiomodel/vtx"
	"github.com/galaco/studiomodel/vvd"
	"log"
	"os"
)
func main() {
	filePath := "foo/prop" //
	
	// create model
	prop := studiomodel.NewStudioModel("models/error")
 // MDL
	f,err := os.Open(filePath + ".mdl") // file.Load just returns (io.Reader,error)
	if err != nil {
		log.Println(err)
		return
	}
	mdlFile,err := mdl.ReadFromStream(f)
	if err != nil {
		log.Println(err)
		return
	}
	prop.AddMdl(mdlFile)
	// VVD
	f,err = os.Open(filePath + ".vvd") // file.Load just returns (io.Reader,error)
	if err != nil {
		log.Println(err)
		return
	}
	vvdFile,err := vvd.ReadFromStream(f)
	if err != nil {
		log.Println(err)
		return
	}
	prop.AddVvd(vvdFile)
	// VTX
	f,err = os.Open(filePath + ".vtx") // file.Load just returns (io.Reader,error)
	if err != nil {
		log.Println(err)
		return
	}
	vtxFile,err := vtx.ReadFromStream(f)
	if err != nil {
		log.Println(err)
		return
	}
	prop.AddVtx(vtxFile)
	// PHY
	f,err = os.Open(filePath + ".phy") // file.Load just returns (io.Reader,error)
	if err != nil {
		log.Println(err)
		return
	}
	phyFile,err := phy.ReadFromStream(f)
	if err != nil {
		log.Println(err)
		return
	}
	prop.AddPhy(phyFile)
	
	log.Println(prop)
}

About

Go package for parsing Source Engine StudioModel formats (.mdl, .vtx, .vvd, .phy)

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

Languages

AltStyle によって変換されたページ (->オリジナル) /