News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How do you tranlate this?

Started by Farabi, February 09, 2012, 12:01:53 PM

Previous topic - Next topic

Farabi



aiNode struct
mName aiString <?>
mTransformation aiMatrix4x4 <?>
mParent DWORD ?
mNumChildren DWORD ?
mChildren DWORD ?
mNumMeshes DWORD ?
mMeshes DWORD ?
aiNode ends

aiMesh struct
mPrimitiveTypes DWORD ?
mNumVertices DWORD ?
mNumFaces DWORD ?
mVertices DWORD ?
mNormals DWORD ?
mTangents DWORD ?
mBitangents DWORD ?
mColors DWORD AI_MAX_NUMBER_OF_COLOR_SETS dup (?)
mTextureCoords DWORD AI_MAX_NUMBER_OF_TEXTURECOORDS dup (?)
mNumUVComponents DWORD AI_MAX_NUMBER_OF_TEXTURECOORDS dup (?)
mFaces DWORD ?
mNumBones DWORD ?
mBones DWORD ?
mMaterialIndex DWORD ?
mName aiString <?>
mNumAnimMeshes DWORD ?
mAnimMeshes DWORD ?
aiMesh ends
void recursive_render (const struct aiScene *sc, const struct aiNode* nd)
175 {
176         int i;
177         unsigned int n = 0, t;
178         struct aiMatrix4x4 m = nd->mTransformation;
179
180         // update transform
181         aiTransposeMatrix4(&m);
182         glPushMatrix();
183         glMultMatrixf((float*)&m);
184
185         // draw all meshes assigned to this node
186         for (; n < nd->mNumMeshes; ++n) {
187                 const struct aiMesh*[b] mesh = scene->mMeshes[nd->mMeshes[n]];[/b]
188
189                 apply_material(sc->mMaterials[mesh->mMaterialIndex]);
190
191                 if(mesh->mNormals == NULL) {
192                         glDisable(GL_LIGHTING);
193                 } else {
194                         glEnable(GL_LIGHTING);
195                 }
196
197                 for (t = 0; t < mesh->mNumFaces; ++t) {
198                         const struct aiFace* face = &mesh->mFaces[t];
199                         GLenum face_mode;
200
201                         switch(face->mNumIndices) {
202                                 case 1: face_mode = GL_POINTS; break;
203                                 case 2: face_mode = GL_LINES; break;
204                                 case 3: face_mode = GL_TRIANGLES; break;
205                                 default: face_mode = GL_POLYGON; break;
206                         }
207
208                         glBegin(face_mode);
209
210                         for(i = 0; i < face->mNumIndices; i++) {
211                                 int index = face->mIndices[i];
212                                 if(mesh->mColors[0] != NULL)
213                                         glColor4fv((GLfloat*)&mesh->mColors[0][index]);
214                                 if(mesh->mNormals != NULL)
215                                         glNormal3fv(&mesh->mNormals[index].x);
216                                 glVertex3fv(&mesh->mVertices[index].x);
217                         }
218
219                         glEnd();
220                 }
221
222         }
223
224         // draw all children
225         for (n = 0; n < nd->mNumChildren; ++n) {
226                 recursive_render(sc, nd->mChildren[n]);
227         }
228
229         glPopMatrix();
230 }


only this part

mesh = scene->mMeshes[nd->mMeshes



This part is alomost right, but giving me a wrong results

                       mov edx,lpaiScene
mov edx,[edx].aiScene.mMeshes
mov edx,[edx+ecx*4]
mov mesh,edx
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

qWord

#1
- why is indexing used here: nd->mMeshes[n]  - that doesn't match the structure definition.
- what is scene: a pointer to a pointer array?


maybe:
mov eax,nd
mov ecx,[eax].aiNode.mMeshes
mov eax,scene
lea edx,[eax+ecx*4]
mov edx,[edx]
; edx = ptr aiMesh
FPU in a trice: SmplMath
It's that simple!

Farabi

Quote from: qWord on February 09, 2012, 12:42:11 PM
- why is indexing used here: nd->mMeshes[n]  - that doesn't match the structure definition.
- what is scene: a pointer to a pointer array?


maybe:
mov eax,nd
mov ecx,[eax].aiNode.mMeshes
mov eax,scene
lea edx,[eax+ecx*4]
mov edx,[edx]
; edx = ptr aiMesh


Hi, sorry wasting your time, yeah it was a pointer inside a pointer, a bvh structure, I tried many thing and it worked this way


xor ecx,ecx
loop_node:
push ecx
mov eax,lpaiScene
mov edx,[eax].aiScene.mMeshes
mov mesh,edx

mov eax,lpaiNode
mov edx,[eax].aiNode.mMeshes
mov edx,[edx+ecx*4]
mov node,edx

mov edx,mesh
mov ecx,node
mov eax,[edx+ecx*4]

pop ecx
inc ecx
cmp ecx,[edi].aiNode.mNumMeshes
jl loop_node


Thanks for trying to help me, I'll show the full code if you want, I'll let you know the detail someday, Im still working on it.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"