From a6238d7cd61a366d63c8294933ca273f16bd6f45 Mon Sep 17 00:00:00 2001 From: JupiterRider <60042618+JupiterRider@users.noreply.github.com> Date: Tue, 17 Oct 2023 20:16:43 +0200 Subject: [PATCH 1/3] Getters for Model type added --- raylib/raylib.go | 52 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/raylib/raylib.go b/raylib/raylib.go index 4eb5529..e2aed9d 100644 --- a/raylib/raylib.go +++ b/raylib/raylib.go @@ -854,15 +854,51 @@ type MaterialMap struct { // Model is struct of model, meshes, materials and animation data type Model struct { // Local transform matrix - Transform Matrix - MeshCount int32 + Transform Matrix + // Number of meshes + MeshCount int32 + // Number of materials MaterialCount int32 - Meshes *Mesh - Materials *Material - MeshMaterial *int32 - BoneCount int32 - Bones *BoneInfo - BindPose *Transform + // Meshes array (c array) + // + // Use Model.GetMeshes instead (go slice) + Meshes *Mesh + // Materials array (c array) + // + // Use Model.GetMaterials instead (go slice) + Materials *Material + // Mesh material number + MeshMaterial *int32 + // Number of bones + BoneCount int32 + // Bones information (skeleton) (c array) + // + // Use Model.GetBones instead (go slice) + Bones *BoneInfo + // Bones base transformation (pose) (c array) + // + // Use Model.GetBindPose instead (go slice) + BindPose *Transform +} + +// GetMeshes returns the meshes of a model as go slice +func (m Model) GetMeshes() []Mesh { + return unsafe.Slice(m.Meshes, m.MeshCount) +} + +// GetMaterials returns the materials of a model as go slice +func (m Model) GetMaterials() []Material { + return unsafe.Slice(m.Materials, m.MaterialCount) +} + +// GetBones returns the bones information (skeleton) of a model as go slice +func (m Model) GetBones() []BoneInfo { + return unsafe.Slice(m.Bones, m.BoneCount) +} + +// GetBindPose returns the bones base transformation of a model as go slice +func (m Model) GetBindPose() []Transform { + return unsafe.Slice(m.BindPose, m.BoneCount) } // newModelFromPointer - Returns new Model from pointer From a272669c5318acae9c606367ac99eac69272e71e Mon Sep 17 00:00:00 2001 From: nellfs Date: Fri, 20 Oct 2023 22:31:51 -0300 Subject: [PATCH 2/3] Fixing snake example fruit spawn --- examples/games/snake/main.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/games/snake/main.go b/examples/games/snake/main.go index 9353ca9..7cb3f88 100644 --- a/examples/games/snake/main.go +++ b/examples/games/snake/main.go @@ -160,15 +160,15 @@ func (g *Game) Update() { if !g.Fruit.Active { g.Fruit.Active = true g.Fruit.Position = rl.NewVector2( - float32(rl.GetRandomValue(0, (g.ScreenWidth/squareSize)-1)*squareSize+int32(g.Offset.X)/2), - float32(rl.GetRandomValue(0, (g.ScreenHeight/squareSize)-1)*squareSize+int32(g.Offset.Y)/2), + float32(rl.GetRandomValue(0, (g.ScreenWidth/squareSize)-1)*squareSize)+(g.Offset.X)/2, + float32(rl.GetRandomValue(0, (g.ScreenHeight/squareSize)-1)*squareSize)+(g.Offset.Y)/2, ) for i := 0; i < g.CounterTail; i++ { for (g.Fruit.Position.X == g.Snake[i].Position.X) && (g.Fruit.Position.Y == g.Snake[i].Position.Y) { g.Fruit.Position = rl.NewVector2( - float32(rl.GetRandomValue(0, (g.ScreenWidth/squareSize)-1)*squareSize), - float32(rl.GetRandomValue(0, (g.ScreenHeight/squareSize)-1)*squareSize), + float32(rl.GetRandomValue(0, (g.ScreenWidth/squareSize)-1)*squareSize)+g.Offset.X/2, + float32(rl.GetRandomValue(0, (g.ScreenHeight/squareSize)-1)*squareSize)+g.Offset.Y/2, ) i = 0 } From fac9477f84f0f26e9423692839bba0c7723350c0 Mon Sep 17 00:00:00 2001 From: Allen Ray Date: Sat, 21 Oct 2023 12:15:35 -0400 Subject: [PATCH 3/3] Add UnloadImageColors --- raylib/rtextures.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/raylib/rtextures.go b/raylib/rtextures.go index 0a502c2..4300461 100644 --- a/raylib/rtextures.go +++ b/raylib/rtextures.go @@ -166,6 +166,11 @@ func LoadImageColors(img *Image) []color.RGBA { return (*[1 << 24]color.RGBA)(unsafe.Pointer(ret))[0 : img.Width*img.Height] } +// UnloadImageColors - Unload color data loaded with LoadImageColors() +func UnloadImageColors(cols []color.RGBA) { + C.UnloadImageColors((*C.Color)(unsafe.Pointer(&cols[0]))) +} + // LoadImageFromTexture - Get pixel data from GPU texture and return an Image func LoadImageFromTexture(texture Texture2D) *Image { ctexture := texture.cptr()