Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Jun 2011
Offline Last Active Mar 20 2016 10:07 AM

Topics I've Started

problem rendering (properly lighting) model with WPF

24 December 2015 - 06:56 PM

I've made a model of a chess piece and exported to OBJ. I'm trying to load and render it in c# WPF and having some trouble with shading/lighting.


I have a white directional light and white ambient light. The chess piece is rendered with a black material.


The problem I am trying to solve is the lighting/shading. It does not seem to be working. Any suggestions? All I see is opaque black. However, when I open the same model in Open3dMod it looks perfect so I don't think the vertex normals are wrong.


Screen shot from my running code (shading wrong)...




Screen shot from open3dmod viewer (shaded correcty)...




I have attached my rendering code (code-behind and xml). I have also attached the model (obj format). Any suggestions to get the lighting and shading working in my code would be appreciated. I don't know what I am doing wrong here.






obj format question

18 November 2015 - 11:06 PM

Question: can I have more than one object (denoted by 'o myobject') each with more than one group in it (denoted by 'g mygroup') in one wavefront obj file? This is my goal but it is not working.


if I do that I get a mangled model. The verts are in all the right places but they are not linked into triangles correctly (model is there but looks like crap).


If I split each wavefront object ('o') into its own seperate file with its own groups the model renders correctly.

If I don't bother with groups ('g') and replace each group with an object in a single file the model renders correctly.

Is this supposed to be the case? I have tried this with two different 3d model tools (open3dmod and DeleD) and the pattern seems consistent.


That is a bit long winded so I attached some files...

'head.obj', 'upper.obj' and 'lower.obj' each have one object (one file per object). These files import right.

'player_out.obj' has 'head.obj', 'upper.obj' and 'lower.obj' in it but it does not render correctly. Same text, just all appended in one file.


What combining all three objects with groups in one file and importing renders as...




What importing all three obj files separately (each with only one object) renders as...




My goal is to make player_out.obj work but it doesn't seem to be happening. I'm trying to figure out if I have misunderstood the format or the rendering programs (DeleD and open3mod) are not working correctly (unlikely).


To be clear...the model files I have attached were extracted (converted from md3 to obj). I did not make the original md3 models.

Attached File  ayumi_objs.zip   138.71KB   42 downloads

quake md3-help with animation.cfg

22 August 2015 - 01:01 PM

I've parsed out several quake 3 md3 model files and I consistently see less frames in the individual files than what is in animation.cfg (which groups the frames together to form animations).


On parsing the model for a player model set, here is the frame count I get (NUM_FRAMES on the header)...

lower.md3 has 191 frames

upper.md3 has 153 frames

head.md3 has 1 frame


However, there are animations that exceed these numbers...like LEGS_TURN starts at frame 247 when the highest frame count is 191 in lower.md3.


The only logical reason I  can think of is maybe the frame indexes are added together (like 191+153+1) but I'm not sure of the order.


Does anyone know for sure how animation.cfg is supposed to link up with the frames in the individual files?


Here is a copy of the animation.cfg file if it helps...

// animation config file

sex	m

// first frame, num frames, looping frames, frames per second

0	30	0	20		// BOTH_DEATH1
29	1	0	20		// BOTH_DEAD1
30	30	0	20		// BOTH_DEATH2
59	1	0	20		// BOTH_DEAD2
60	30	0	20		// BOTH_DEATH3
89	1	0	20		// BOTH_DEAD3

90	40	0	18		// TORSO_GESTURE

130	6	0	15		// TORSO_ATTACK		(MUST NOT CHANGE -- hand animation is synced to this)
136	6	0	15		// TORSO_ATTACK2	(MUST NOT CHANGE -- hand animation is synced to this)

142	5	0	20		// TORSO_DROP		(MUST NOT CHANGE -- hand animation is synced to this)
147	4	0	20		// TORSO_RAISE		(MUST NOT CHANGE -- hand animation is synced to this)

151	1	0	15		// TORSO_STAND
152	1	0	15		// TORSO_STAND2

153	8	8	20		// LEGS_WALKCR
161	12	12	20		// LEGS_WALK
173	11	11	21		// LEGS_RUN
184	10	10	20		// LEGS_BACK
194	10	10	15		// LEGS_SWIM

204	10	0	18		// LEGS_JUMP
214	6	0	20		// LEGS_LAND

220	8	0	15		// LEGS_JUMPB
228	1	0	15		// LEGS_LANDB

229	10	10	15		// LEGS_IDLE
239	8	8	15		// LEGS_IDLECR

247	7	7	15		// LEGS_TURN

quake3 md3-how to tell what surface applies to what texture?

07 July 2015 - 08:47 PM

I've parsed the surface geometry and st coordinates out of the quake 3 md3 railgun file. Problem is, I have no idea what textures apply to what surfaces.


I've parsed out 5 surfaces. Is there any sure (automatic) way to figure out what texture matches to what surface?


surface names found...



texture names...







railgun1.jpg/railgun3.jpg make sense for 2 surfaces. The other 3 I have no idea. I can't attach the images (don't want to violate any laws) but I have attached my render of it. The surfaces that I haven't figured out are gray if it helps.


Attached File  md3_railgun.jpg   78.5KB   2 downloads

trouble parsing quake3 md3

03 April 2015 - 08:27 AM

My goal is to figure out how to parse MD3 quake model files so that I can write an import/export tool for DeleD. So I found a model here...




And the format definition here...




I decompressed everything and tried to parse part of the header of the 'head.MD3' file with this python 2 code...

import binascii
import struct

filename = 'head.MD3'
bytes = ''
with open(filename,'rb') as fileptr:
    bytes = fileptr.read()
bytes = binascii.hexlify(bytes)
print bytes
print 'IDENT', bytes[0:8].decode("hex"), 'VERSION', bytes[9:17]

Both IDENT and VERSION are supposed to be 32 bits (so says wikipedia). The IDENT comes in good but VERSION is junk...




f0 is 15 which is consistent with the header info but what about the trailing zeroes?


The rest of the hex dump is attached...it does not seem to be consistent with the format defenition. I don't know if I'm not parsing this correctly, if the wikipedia info is wrong or the model is junk. Full output (hex dump of the file) is attached in a txt. Can anyone offer a starting point? Any thoughts?