Milkshape 3D model - PS2 Vector Unit Help

This topic is 3167 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Anyone used this much? im using a model created in Milkshape for a PS2 project. I know this isnt really the forum to use but i cant get onto the official milkshape one and dont know where else to go. Basically im making a representation of the solar system with a point light where the sun is. So the light is in the centre of the sun model. In order for the sun to be illuminated so, i need to reverese the normals of the model. But i dont know how. I have the model as a text file and i tried changing the normals signs, but thgat didnt work. So, anyone know how to do this? [Edited by - discodowney on April 15, 2010 7:34:53 AM]

Share on other sites
Well, basically inverting a vector (which the normal is) means multiplying it by -1, i.e. the inverse of vector (-2,5,3) would be (2,-5,-3).

What doesn't work exactly?
Can you post some code of the relevant sections (please remember to use the [source] tags).

Share on other sites
Okay, so ive tried changing the normals of the model to opposite signs when they are read in. So nMesh will always be 0 here.the for loop under //the normals reads in the normals. Then the next one inverts them. It is working, kinda. the normals are being inverted. I can tell cos the planets that are rotating the sun are being lit up back to front, i.e. the parts that should be light are dark and the parts that should be dark are lit.

But the sun still isnt illuminated. Any ideas?

m_pMeshes[nMesh].pNormals = new Vector3[m_pMeshes[nMesh].nNormals];	// The normals	for(int nNormal = 0; nNormal < m_pMeshes[nMesh].nNormals; nNormal++)	{		GetNextLOC(strLine);		// x, y, z		sscanf(strLine, "%f %f %f",			&m_pMeshes[nMesh].pNormals[nNormal].x,			&m_pMeshes[nMesh].pNormals[nNormal].y,			&m_pMeshes[nMesh].pNormals[nNormal].z);						}	for(int nNormal = 0; nNormal < m_pMeshes[nMesh].nNormals; nNormal++)	{		m_pMeshes[nMesh].pNormals[nNormal].x *= -1;		m_pMeshes[nMesh].pNormals[nNormal].y *= -1;		m_pMeshes[nMesh].pNormals[nNormal].z *= -1;	}

Share on other sites
Could be wrong on this, but I think most renderers will skip lighting backfacing polygons. What effect does enabling/disabling backface culling have?

Share on other sites
There is no back face culling.

Anyone know anything about vector unit coding? i think my problem might be there.

Share on other sites
If there is no backface culling and your renderer isn't lighting backfacing polygons, the unlit polygons on the near side of the sun will block the lit polygons behind them. Have you tried putting your camera inside the sun model?

Share on other sites
To render object as light, don't you have to set its emissive material property to render the object as the light?

Share on other sites
Its strange, if i translate the model by even as little as 0.01 plus or mius then half the model gets lit, Plus lights the right half and minus the left half. Ill be in college later and ill stick up the VU code because something has to be going wrong there i justs cant, for the life of me, see what it is.

Share on other sites
Heres the vector unit code. The modelthat isnt illuminating is at the origin so if anyone spots anything they think could be causing the problem thatd be great:

lq			Norm, NormStart(Counter)				; Load the normal	MatrixMultiplyVertex Norm, fLightTrans, Norm		; Transform the normal into world space (important that norm.w is 0)	MatrixMultiplyVertex Vert, fLightTrans, Vert		; Transform the vertex into world space	sub.xyz		ToLight, PtLightPos, Vert					; Get the vector from the vert to the light	VectorNormalizeXYZ ToLight, ToLight					; Normalise this vector (and it becomes the light direction, just as in directional lighting)	VectorDotProduct  fIntensity, ToLight, Norm			; Get the intensity	lq.xyz		fAmbient, LightCols+3(vi00)	;madd.xyz	fIntensity, fAmbient, vf00[w]	max.x		fIntensity, fIntensity, vf00			; Clamp to > 0	mini.x		fIntensity, fIntensity, vf00[w]			; Clamp to < 1	lq			fLightCol, PtLightCol(vi00)				; Load the light colour	mul.xyz		fLightCol, fLightCol, fIntensity[x]		; Scale the colour by the intensity	loi			128											mul			fLightCol, fLightCol, i					; Scale the values from 0-1 to the range 0-128    ftoi0   	iLightCol, fLightCol					; Convert to ints	sq   		iLightCol, NormStartOut(Counter)		; And write to the output buffer

1. 1
2. 2
Rutin
22
3. 3
4. 4
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 44
• Forum Statistics

• Total Topics
633742
• Total Posts
3013639
×