ml: Get Asset Importer loading the model.
This commit is contained in:
+29
-4
@@ -1,9 +1,9 @@
|
|||||||
[tool.pyright]
|
[tool.pyright]
|
||||||
|
|
||||||
include = [
|
include = [
|
||||||
"*.py",
|
"*.py",
|
||||||
"renpy/",
|
"renpy/",
|
||||||
"module/"
|
"src/"
|
||||||
]
|
]
|
||||||
|
|
||||||
exclude = [
|
exclude = [
|
||||||
@@ -21,3 +21,28 @@ reportOptionalIterable = false
|
|||||||
reportOptionalContextManager = false
|
reportOptionalContextManager = false
|
||||||
reportOptionalOperand = false
|
reportOptionalOperand = false
|
||||||
reportMissingModuleSource = false
|
reportMissingModuleSource = false
|
||||||
|
|
||||||
|
|
||||||
|
[tool.cyright]
|
||||||
|
include = [
|
||||||
|
"*.py",
|
||||||
|
"renpy/",
|
||||||
|
"src/"
|
||||||
|
]
|
||||||
|
|
||||||
|
exclude = [
|
||||||
|
"module/build/",
|
||||||
|
]
|
||||||
|
|
||||||
|
ignore = [
|
||||||
|
"renpycoverage.py"
|
||||||
|
]
|
||||||
|
|
||||||
|
reportGeneralTypeIssues = false
|
||||||
|
reportOptionalSubscript = false
|
||||||
|
reportOptionalMemberAccess = false
|
||||||
|
reportOptionalCall = false
|
||||||
|
reportOptionalIterable = false
|
||||||
|
reportOptionalContextManager = false
|
||||||
|
reportOptionalOperand = false
|
||||||
|
reportMissingModuleSource = false
|
||||||
|
|||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Copyright 2004-2025 Tom Rothamel <pytom@bishoujo.us>
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person
|
||||||
|
# obtaining a copy of this software and associated documentation files
|
||||||
|
# (the "Software"), to deal in the Software without restriction,
|
||||||
|
# including without limitation the rights to use, copy, modify, merge,
|
||||||
|
# publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
# and to permit persons to whom the Software is furnished to do so,
|
||||||
|
# subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be
|
||||||
|
# included in all copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
from assimp cimport (
|
||||||
|
Importer, aiProcessPreset_TargetRealtime_Quality, aiProcess_ConvertToLeftHanded, aiProcess_FlipUVs, aiScene,
|
||||||
|
aiMesh, aiMatrix4x4
|
||||||
|
)
|
||||||
|
|
||||||
|
cdef class Loader:
|
||||||
|
|
||||||
|
cdef Importer importer
|
||||||
|
cdef const aiScene *scene
|
||||||
|
|
||||||
|
def load(self, filename: str) -> None:
|
||||||
|
cdef const aiScene *scene
|
||||||
|
|
||||||
|
filename_bytes = filename.encode()
|
||||||
|
self.scene = self.importer.ReadFile(filename_bytes, aiProcessPreset_TargetRealtime_Quality | aiProcess_ConvertToLeftHanded | aiProcess_FlipUVs) # type: ignore
|
||||||
|
|
||||||
|
if not self.scene:
|
||||||
|
raise Exception("Error loading %s: %s" % (filename, self.importer.GetErrorString()))
|
||||||
@@ -80,6 +80,11 @@ def main():
|
|||||||
if cubism:
|
if cubism:
|
||||||
setuplib.include_dirs.append("{}/Core/include".format(cubism))
|
setuplib.include_dirs.append("{}/Core/include".format(cubism))
|
||||||
|
|
||||||
|
assimp = "RENPY_USE_ASSIMP" in os.environ
|
||||||
|
if assimp:
|
||||||
|
pkgconfig_packages = "assimp\n" + pkgconfig_packages
|
||||||
|
library("assimp")
|
||||||
|
|
||||||
# src/ directory.
|
# src/ directory.
|
||||||
cython("_renpy", [ "src/IMG_savepng.c", "src/core.c" ])
|
cython("_renpy", [ "src/IMG_savepng.c", "src/core.c" ])
|
||||||
cython("_renpybidi", [ "src/renpybidicore.c" ])
|
cython("_renpybidi", [ "src/renpybidicore.c" ])
|
||||||
@@ -129,6 +134,9 @@ def main():
|
|||||||
if cubism:
|
if cubism:
|
||||||
cython("renpy.gl2.live2dmodel")
|
cython("renpy.gl2.live2dmodel")
|
||||||
|
|
||||||
|
if assimp:
|
||||||
|
cython("renpy.gl2.modelloader", language="c++")
|
||||||
|
|
||||||
# renpy.text
|
# renpy.text
|
||||||
cython("renpy.text.textsupport")
|
cython("renpy.text.textsupport")
|
||||||
cython("renpy.text.texwrap")
|
cython("renpy.text.texwrap")
|
||||||
|
|||||||
+103
@@ -0,0 +1,103 @@
|
|||||||
|
cdef extern from "assimp/vector2.h":
|
||||||
|
cdef struct aiVector2D:
|
||||||
|
float x
|
||||||
|
float y
|
||||||
|
|
||||||
|
cdef extern from "assimp/vector3.h":
|
||||||
|
cdef struct aiVector3D:
|
||||||
|
float x
|
||||||
|
float y
|
||||||
|
float z
|
||||||
|
|
||||||
|
cdef extern from "assimp/matrix4x4.h":
|
||||||
|
cdef struct aiMatrix4x4:
|
||||||
|
float a1, a2, a3, a4
|
||||||
|
float b1, b2, b3, b4
|
||||||
|
float c1, c2, c3, c4
|
||||||
|
float d1, d2, d3, d4
|
||||||
|
|
||||||
|
cdef extern from "assimp/postprocess.h":
|
||||||
|
cdef enum:
|
||||||
|
aiProcess_CalcTangentSpace
|
||||||
|
aiProcess_JoinIdenticalVertices
|
||||||
|
aiProcess_MakeLeftHanded
|
||||||
|
aiProcess_Triangulate
|
||||||
|
aiProcess_RemoveComponent
|
||||||
|
aiProcess_GenNormals
|
||||||
|
aiProcess_GenSmoothNormals
|
||||||
|
aiProcess_SplitLargeMeshes
|
||||||
|
aiProcess_PreTransformVertices
|
||||||
|
aiProcess_LimitBoneWeights
|
||||||
|
aiProcess_ValidateDataStructure
|
||||||
|
aiProcess_ImproveCacheLocality
|
||||||
|
aiProcess_RemoveRedundantMaterials
|
||||||
|
aiProcess_FixInfacingNormals
|
||||||
|
aiProcess_SortByPType
|
||||||
|
aiProcess_FindDegenerates
|
||||||
|
aiProcess_FindInvalidData
|
||||||
|
aiProcess_GenUVCoords
|
||||||
|
aiProcess_TransformUVCoords
|
||||||
|
aiProcess_FindInstances
|
||||||
|
aiProcess_OptimizeMeshes
|
||||||
|
aiProcess_OptimizeGraph
|
||||||
|
aiProcess_FlipUVs
|
||||||
|
aiProcess_FlipWindingOrder
|
||||||
|
aiProcess_SplitByBoneCount
|
||||||
|
aiProcess_Debone
|
||||||
|
aiProcess_GlobalScale
|
||||||
|
aiProcess_EmbedTextures
|
||||||
|
aiProcess_ForceGenNormals
|
||||||
|
aiProcess_DropNormals
|
||||||
|
aiProcess_GenBoundingBoxes
|
||||||
|
|
||||||
|
aiProcessPreset_TargetRealtime_Fast
|
||||||
|
aiProcessPreset_TargetRealtime_Quality
|
||||||
|
aiProcessPreset_TargetRealtime_MaxQuality
|
||||||
|
|
||||||
|
aiProcess_ConvertToLeftHanded
|
||||||
|
|
||||||
|
cdef extern from "assimp/mesh.h":
|
||||||
|
cdef enum aiPrimitiveType:
|
||||||
|
aiPrimitiveType_POINT
|
||||||
|
aiPrimitiveType_LINE
|
||||||
|
aiPrimitiveType_TRIANGLE
|
||||||
|
aiPrimitiveType_POLYGON
|
||||||
|
|
||||||
|
|
||||||
|
cdef struct aiMesh:
|
||||||
|
unsigned int mNumVertices
|
||||||
|
unsigned int mNumFaces
|
||||||
|
|
||||||
|
aiVector3D *mVertices
|
||||||
|
aiVector3D *mNormals
|
||||||
|
aiVector3D *mTangents
|
||||||
|
aiVector3D *mBitangents
|
||||||
|
|
||||||
|
cdef extern from "assimp/scene.h":
|
||||||
|
|
||||||
|
cdef struct aiNode:
|
||||||
|
aiMatrix4x4 mTransformation
|
||||||
|
aiNode *mParent
|
||||||
|
unsigned int mNumChildren
|
||||||
|
aiNode **mChildren
|
||||||
|
unsigned int mNumMeshes
|
||||||
|
unsigned int *mMeshes
|
||||||
|
|
||||||
|
cdef struct aiScene:
|
||||||
|
unsigned int mNumMeshes
|
||||||
|
unsigned int mNumMaterials
|
||||||
|
unsigned int mNumAnimations
|
||||||
|
unsigned int mNumTextures
|
||||||
|
unsigned int mNumLights
|
||||||
|
unsigned int mNumCameras
|
||||||
|
|
||||||
|
aiNode *mRootNode
|
||||||
|
aiMesh **mMeshes
|
||||||
|
|
||||||
|
cdef extern from "assimp/Importer.hpp" namespace "Assimp":
|
||||||
|
|
||||||
|
cdef cppclass Importer:
|
||||||
|
Importer()
|
||||||
|
const aiScene *ReadFile(const char* pFile, unsigned int pFlags)
|
||||||
|
const aiScene *GetScene()
|
||||||
|
const char *GetErrorString()
|
||||||
Reference in New Issue
Block a user