Jump to content
  • Advertisement
Sign in to follow this  
discodowney

Milkshape 3D model - PS2 Vector Unit Help

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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).

Other than that, we need some more information.
What doesn't work exactly?
Can you post some code of the relevant sections (please remember to use the [source] tags).

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!