123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338 |
- package model
- import (
- "time"
- "go.mongodb.org/mongo-driver/bson/primitive"
- )
- const (
- LibState_Created = 1
- LibState_Complated = 2
- LibState_Publish2Qiye = 3
- )
- type Texture struct {
- Id primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
- Image OssType `bson:"image,omitempty" json:"image"`
- CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
- }
- type ObsItem struct {
- Name string `json:"name"`
- LastModified time.Time `json:"lastModified"`
- Size uint64 `json:"size"`
- IsImage bool `json:"isImage"`
- Url string `json:"url"`
- IsDir bool `json:"isDir"`
- }
- type MaterailUv struct {
- Scale float64 `bson:"scale" json:"scale"`
- Rotate float64 `bson:"rotate" json:"rotate"`
- OffsetX float64 `bson:"offsetX" json:"offsetX"`
- OffsetY float64 `bson:"offsetY" json:"offsetY"`
- }
- type MatAlbedo struct {
- Color *Vect3 `bson:"color" json:"color"`
- Texture *OssType `bson:"texture" json:"texture"`
- UseTexture *bool `bson:"useTexture" json:"useTexture"`
- }
- type MatRoughness struct {
- UseTexture *bool `bson:"useTexture" json:"useTexture"`
- Texture *OssType `bson:"texture" json:"texture"`
- Factor *float32 `bson:"factor" json:"factor"`
- }
- type MatMetalness struct {
- UseTexture *bool `bson:"useTexture" json:"useTexture"`
- Texture *OssType `bson:"texture" json:"texture"`
- Factor *float32 `bson:"factor" json:"factor"`
- }
- type MatNormal struct {
- UseTexture *bool `bson:"useTexture" json:"useTexture"`
- Texture *OssType `bson:"texture" json:"texture"`
- Factor *float32 `bson:"factor" json:"factor"`
- FlipY *bool `bson:"flipY" json:"flipY"`
- }
- type MatDisplace struct {
- UseTexture *bool `bson:"useTexture" json:"useTexture"`
- Texture *OssType `bson:"texture" json:"texture"`
- Factor *float32 `bson:"factor" json:"factor"`
- }
- type MatDiffuse struct {
- UseTexture *bool `bson:"useTexture" json:"useTexture"`
- Texture *OssType `bson:"texture" json:"texture"`
- Factor *float32 `bson:"factor" json:"factor"`
- }
- type MatTextureFactorWithEnable struct {
- UseTexture *bool `bson:"useTexture" json:"useTexture"`
- Texture *OssType `bson:"texture" json:"texture"`
- Factor *float32 `bson:"factor" json:"factor"`
- Enable bool `bson:"enable" json:"enable"`
- }
- type MatTextureFactor struct {
- UseTexture *bool `bson:"useTexture" json:"useTexture"`
- Texture *OssType `bson:"texture" json:"texture"`
- Factor *float32 `bson:"factor" json:"factor"`
- }
- type MatTextureColor struct {
- UseTexture *bool `bson:"useTexture" json:"useTexture"`
- Texture *OssType `bson:"texture" json:"texture"`
- Color *Vect3 `bson:"color" json:"color"`
- }
- type MatOpacity struct {
- Enable bool `bson:"enable" json:"enable"`
- Factor *float32 `bson:"factor" json:"factor"`
- Texture *OssType `bson:"texture" json:"texture"`
- UseTexture *bool `bson:"useTexture" json:"useTexture"`
- }
- type MatConfig struct {
- Version int `bson:"version,omitempty" json:"version"`
- Type string `bson:"type,omitempty" json:"type"` //高光流 金属流(默认) meta spec
- Uvtransform *MaterailUv `bson:"uv,omitempty" json:"uv"`
- CullFace string `bson:"cullFace" json:"cullFace"`
- Albedo *MatTextureColor `bson:"albedo" json:"albedo"`
- Roughness *MatTextureFactor `bson:"roughness" json:"roughness"`
- Metalness *MatTextureFactor `bson:"metalness" json:"metalness"`
- Normal *MatNormal `bson:"normal" json:"normal"`
- Opacity *MatTextureFactorWithEnable `bson:"opacity" json:"opacity"`
- Displace *MatTextureFactorWithEnable `bson:"displace,omitempty" json:"displace"` //置换
- Diffuse *MatTextureColor `bson:"diffuse,omitempty" json:"diffuse"`
- Specular *MatTextureColor `bson:"specular" json:"specular"`
- Gloss *MatTextureFactor `bson:"gloss,omitempty" json:"gloss"` //光泽贴图
- UvMap string `bson:"uvMap,omitempty" json:"uvMap"` //uv包裹 box、uv
- }
- type TechMatConfig struct {
- Version int `bson:"version,omitempty" json:"version"`
- Type string `bson:"type,omitempty" json:"type"`
- Uvtransform *MaterailUv `bson:"uvtransform,omitempty" json:"uvtransform"`
- CullFace string `bson:"cullFace" json:"cullFace"`
- Albedo *MatAlbedo `bson:"albedo" json:"albedo"`
- Roughness *MatRoughness `bson:"roughness" json:"roughness"`
- Metalness *MatMetalness `bson:"metalness" json:"metalness"`
- Specular *MatAlbedo `bson:"specular" json:"specular"`
- Normal *MatNormal `bson:"normal" json:"normal"`
- Opacity *MatOpacity `bson:"opacity" json:"opacity"`
- }
- type MaterialChannels struct {
- Albedo *MaterailFeature `bson:"Albedo" json:"Albedo"`
- Roughness *MaterailFeature `bson:"Roughness" json:"Roughness"`
- NormalMap *MaterailFeature `bson:"NormalMap" json:"NormalMap"`
- BumpMap *MaterailFeature `bson:"BumpMap" json:"BumpMap"`
- Opacity *OpacityFeature `bson:"Opacity" json:"Opacity"`
- AO *AOFeature `bson:"AO" json:"AO"`
- MetalnessPBR *MaterailFeature `bson:"MetalnessPBR" json:"MetalnessPBR"`
- SpecularF0 float32 `bson:"SpecularF0" json:"SpecularF0"`
- ClearCoat *ClearCoatFeature `bson:"ClearCoat" json:"ClearCoat"`
- Displacement *MaterailFeature `bson:"Displacement" json:"Displacement"`
- CavityMap *MaterailFeature `bson:"CavityMap" json:"CavityMap"`
- Emissive *Emissive `bson:"Emissive" json:"Emissive"`
- }
- type Emissive struct {
- Color Vect3 `bson:"color" json:"color"`
- Enable bool `bson:"enable" json:"enable"`
- Factor float32 `bson:"factor" json:"factor"`
- }
- type MaterailFeature struct {
- Color *Vect3 `bson:"color" json:"color"`
- Texture *OssType `bson:"texture" json:"texture"`
- Factor *float32 `bson:"factor" json:"factor"`
- Invert *bool `bson:"invert" json:"invert"`
- Enable *bool `bson:"enable" json:"enable"`
- FlipY *bool `bson:"flipY" json:"flipY"`
- }
- type OpacityFeature struct {
- Enable bool `bson:"enable" json:"enable"`
- Type string `bson:"type" json:"type"`
- Factor float32 `bson:"factor" json:"factor"`
- Invert bool `bson:"invert" json:"invert"`
- SampleChannel string `bson:"sampleChannel" json:"sampleChannel"`
- RefractionTint Vect3 `bson:"refractionTint" json:"refractionTint"`
- RefractUseDiffuse bool `bson:"refractUseDiffuse" json:"refractUseDiffuse"`
- RefractUseShininessMap bool `bson:"refractUseShininessMap" json:"refractUseShininessMap"`
- IOR float32 `bson:"IOR" json:"IOR"`
- RoughnessFactor float32 `bson:"roughnessFactor" json:"roughnessFactor"`
- Texture OssType `bson:"texture" json:"texture"`
- }
- type AOFeature struct {
- Enable bool `bson:"enable" json:"enable"`
- OccludeSpecular bool `bson:"occludeSpecular" json:"occludeSpecular"`
- Factor float32 `bson:"factor" json:"factor"`
- Texture OssType `bson:"texture" json:"texture"`
- }
- type ClearCoatFeature struct {
- Enable bool `bson:"enable" json:"enable"`
- Thickness float32 `bson:"thickness" json:"thickness"`
- Intensity float32 `bson:"intensity" json:"intensity"`
- Color Vect3 `bson:"color" json:"color"`
- Reflectivity float32 `bson:"reflectivity" json:"reflectivity"`
- Roughness struct {
- Factor float32 `bson:"factor" json:"factor"`
- } `bson:"roughness" json:"roughness"`
- Normalmap struct {
- Factor float32 `bson:"factor" json:"factor"`
- FlipY bool `bson:"flipY" json:"flipY"`
- } `bson:"normalmap" json:"normalmap"`
- }
- //材质球
- type Material struct {
- Id primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
- UserId primitive.ObjectID `bson:"userId,omitempty" json:"userId"` //用户ID
- Name string `bson:"name,omitempty" json:"name"`
- Data *MatConfig `bson:"data,omitempty" json:"data"`
- Thumbnail *OssType `bson:"thumbnail,omitempty" json:"thumbnail"`
- CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
- Category string `bson:"category,omitempty" json:"category"`
- IsPublic *bool `bson:"isPublic,omitempty" json:"isPublic"` //是否公开
- IsEffect *bool `bson:"effect,omitempty" json:"effect"` //是否属于效果材质球
- IsPlatform *bool `bson:"platform,omitempty" json:"platform"` //是否属于平台
- }
- type Env3dOption struct {
- Rotation float64 `bson:"rotation" json:"rotation"`
- Exposure float64 `bson:"exposure" json:"exposure"`
- }
- func NewEnv3dOptionWithMap(options map[string]interface{}) *Env3dOption {
- Rotation := float64(0.0)
- if v, ok := options["rotation"].(float64); ok {
- Rotation = v
- } else if v, ok := options["rotation"].(float64); ok {
- Rotation = float64(v)
- }
- Exposure := float64(1.0)
- if v, ok := options["exposure"].(float64); ok {
- Exposure = v
- } else if v, ok := options["exposure"].(float64); ok {
- Exposure = float64(v)
- }
- return &Env3dOption{Rotation: Rotation, Exposure: Exposure}
- }
- func NewEnv3dToneMapWithMap(tone map[string]interface{}) *ToneMap {
- method := int32(0)
- Exposure := float64(1)
- Saturation := float64(1)
- Brightness := float64(0)
- Contrast := float64(0)
- if tone == nil {
- return &ToneMap{
- Method: &method,
- Exposure: &Exposure,
- Saturation: &Saturation,
- Brightness: &Brightness,
- Contrast: &Contrast,
- }
- }
- if v, ok := tone["method"].(int32); ok {
- method = v
- }
- if v, ok := tone["exposure"].(float64); ok {
- Exposure = v
- }
- if v, ok := tone["saturation"].(float64); ok {
- Saturation = v
- }
- if v, ok := tone["brightness"].(float64); ok {
- Brightness = v
- }
- if v, ok := tone["contrast"].(float64); ok {
- Contrast = v
- }
- return &ToneMap{Method: &method, Exposure: &Exposure, Saturation: &Saturation, Brightness: &Brightness, Contrast: &Contrast}
- }
- func NewEnv3dBackgroundWithMap(options map[string]interface{}) *Evn3dBackground {
- Color := options["color"].(primitive.A)
- Image := &OssType{}
- if options["image"] != nil {
- Image = NewOssTypeWithMap(options["image"].(map[string]interface{}))
- }
- Type := options["type"].(int32)
- return &Evn3dBackground{Color: &Vect3{Color[0].(float64), Color[1].(float64), Color[2].(float64)}, Image: Image, Type: Type}
- }
- type ToneMap struct {
- Method *int32 `bson:"method,omitempty" json:"method"` //0 "linear" 值0 "reinhard" 值 1 "filmic”:值2
- Exposure *float64 `bson:"exposure,omitempty" json:"exposure"` //默认值1 范围0到2
- Brightness *float64 `bson:"brightness,omitempty" json:"brightness"` //默认值0 范围-1到 1
- Contrast *float64 `bson:"contrast,omitempty" json:"contrast"` //默认值0 范围-1到1
- Saturation *float64 `bson:"saturation,omitempty" json:"saturation"` //默认值1 范围0-2
- }
- type Evn3dTextureImage struct {
- File string `bson:"file,omitempty" json:"file"`
- SizeUncompressed int32 `bson:"sizeUncompressed,omitempty" json:"sizeUncompressed"`
- Samples uint32 `bson:"samples,omitempty" json:"samples"`
- Height float32 `bson:"height,omitempty" json:"height"`
- Width float32 `bson:"width,omitempty" json:"width"`
- SizeCompressed int32 `bson:"sizeCompressed,omitempty" json:"sizeCompressed"`
- Blur float32 `bson:"blur,omitempty,truncate" json:"blur"`
- }
- type Evn3dTexture struct {
- Images []*Evn3dTextureImage `bson:"images,omitempty" json:"images"`
- LimitSize int32 `bson:"limitSize,omitempty" json:"limitSize"`
- Encoding string `bson:"encoding,omitempty" json:"encoding"`
- Type string `bson:"type,omitempty" json:"type"`
- Format string `bson:"format,omitempty" json:"format"`
- }
- type Evn3dLight struct {
- Direction Vect3 `bson:"direction,omitempty" json:"direction"`
- Lum_ratio float64 `bson:"lum_ratio,omitempty" json:"lum_ratio"`
- Color Vect3 `bson:"color,omitempty" json:"color"`
- Luminosity float64 `bson:"luminosity,omitempty" json:"luminosity"`
- Sum float64 `bson:"sum,omitempty" json:"sum"`
- Area VectXYWH `bson:"area,omitempty" json:"area"`
- Error int32 `bson:"error,omitempty" json:"error"`
- Variance float64 `bson:"variance,omitempty" json:"variance"`
- }
- type Evn3dHdrConf struct {
- Textures []*Evn3dTexture `bson:"textures,omitempty" json:"textures"`
- WriteByChannel bool `bson:"writeByChannel,omitempty" json:"writeByChannel"`
- Lights []*Evn3dLight `bson:"lights,omitempty" json:"lights"`
- DiffuseSPH []float64 `bson:"diffuseSPH,omitempty" json:"diffuseSPH"`
- }
- type CanvasBackground struct {
- Id primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
- Color *Vect3 `bson:"color,omitempty" json:"color"`
- Image *OssType `bson:"image,omitempty" json:"image"`
- Type int32 `bson:"type,omitempty" json:"type"`
- Order int32 `bson:"order,omitempty" json:"order"`
- CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
- }
|