Procházet zdrojové kódy

ADDED: GenMeshDefault() #1556

pull/1697/head
raysan5 před 4 roky
rodič
revize
c21baf0d92
3 změnil soubory, kde provedl 23 přidání a 16 odebrání
  1. +21
    -2
      src/models.c
  2. +1
    -12
      src/raylib.h
  3. +1
    -2
      src/rlgl.h

+ 21
- 2
src/models.c Zobrazit soubor

@ -1501,6 +1501,25 @@ bool IsModelAnimationValid(Model model, ModelAnimation anim)
}
#if defined(SUPPORT_MESH_GENERATION)
Mesh GenMeshDefault(int vertexCount)
{
Mesh mesh = { 0 };
mesh.vertexCount = vertexCount;
mesh.triangleCount = vertexCount/3;
mesh.vertices = (float *)RL_CALLOC(mesh.vertexCount*3, sizeof(float));
mesh.texcoords = (float *)RL_CALLOC(mesh.vertexCount*2, sizeof(float));
mesh.normals = (float *)RL_CALLOC(mesh.vertexCount*3, sizeof(float));
mesh.colors = (unsigned char *)RL_CALLOC(mesh.vertexCount*4, sizeof(unsigned char));
// Upload vertex data to GPU (static mesh)
// NOTE: mesh.vboId array is allocated inside UploadMesh()
UploadMesh(&mesh, false);
return mesh;
}
// Generate polygonal mesh
Mesh GenMeshPoly(int sides, float radius)
{
@ -1869,7 +1888,7 @@ par_shapes_mesh* par_shapes_create_icosahedron(); // 20 sides polyhedron
}
// Generate sphere mesh (standard sphere)
RLAPI Mesh GenMeshSphere(float radius, int rings, int slices)
Mesh GenMeshSphere(float radius, int rings, int slices)
{
Mesh mesh = { 0 };
@ -1911,7 +1930,7 @@ RLAPI Mesh GenMeshSphere(float radius, int rings, int slices)
}
// Generate hemi-sphere mesh (half sphere, no bottom cap)
RLAPI Mesh GenMeshHemiSphere(float radius, int rings, int slices)
Mesh GenMeshHemiSphere(float radius, int rings, int slices)
{
Mesh mesh = { 0 };

+ 1
- 12
src/raylib.h Zobrazit soubor

@ -701,17 +701,6 @@ typedef enum {
GAMEPAD_AXIS_RIGHT_TRIGGER = 5 // [1..-1] (pressure-level)
} GamepadAxis;
// Mesh vertex attributes
typedef enum {
MESH_VERTEX_POSITION = 1,
MESH_VERTEX_TEXCOORD1 = 2,
MESH_VERTEX_TEXCOORD2 = 4,
MESH_VERTEX_NORMAL = 8,
MESH_VERTEX_TANGENT = 16,
MESH_VERTEX_COLOR = 32,
MESH_VERTEX_INDEX = 64
} MeshVertexAttributes;
// Material map index
typedef enum {
MATERIAL_MAP_ALBEDO = 0, // MATERIAL_MAP_DIFFUSE
@ -1398,7 +1387,7 @@ RLAPI void UnloadModelAnimations(ModelAnimation* animations, unsigned int count)
RLAPI bool IsModelAnimationValid(Model model, ModelAnimation anim); // Check model animation skeleton match
// Mesh generation functions
RLAPI Mesh GenMeshCustom(int vertexCount, int flags); // Generate custom empty mesh (data initialized to 0)
RLAPI Mesh GenMeshDefault(int vertexCount); // Generate an empty mesh with vertex: position, texcoords, normals, colors
RLAPI Mesh GenMeshPoly(int sides, float radius); // Generate polygonal mesh
RLAPI Mesh GenMeshPlane(float width, float length, int resX, int resZ); // Generate plane mesh (with subdivisions)
RLAPI Mesh GenMeshCube(float width, float height, float length); // Generate cuboid mesh

+ 1
- 2
src/rlgl.h Zobrazit soubor

@ -92,7 +92,7 @@
#define RL_FREE(p) free(p)
#endif
#else
#include "raylib.h" // Required for: Model, Mesh, Material, Shader, Texture2D
#include "raylib.h" // Required for: Shader, Texture2D
#endif
#include "raymath.h" // Required for: Vector3, Matrix
@ -2772,7 +2772,6 @@ void rlUnloadTexture(unsigned int id)
glDeleteTextures(1, &id);
}
// Generate mipmap data for selected texture
void rlGenerateMipmaps(Texture2D *texture)
{

Načítá se…
Zrušit
Uložit