Hello all,
I am currently having a little problem and I hope I can find help here.
For a little game I am currently working on I need dynamicaly generated 3D objects. The way I\'ve been going about this is by calculating the corner points and \"making\" a lot of triangles to build up the object.
I then melt them all by using Vertexdata commands to form the final object. This actually works how I need it, at least when I look at the form. Lighting however is a totally different matter.
There are two lights above and slightly to the sides of the camera. When I turn the object to look directly at it\'s front end it appears like something flat and blue (blue is the color it has). When I turn it around it appears completely unlit. A side view will have a transition between lit and unlit which doesn\'t seem to have anything to do with it\'s form. I\'ve added pictures in a zip-file so you can see what I mean. I also added a wireframe screen shot. The backdrop is just a random picture to give it a back drop for testing.
I do not move the camera nor the lights. I just turn the object.
Applying specular properties does not affect it noticably, applying a skysphere will cause the entire object to flicker in different colors of the picture used. I mean the ENTIRE object has just ONE of these colors and flickers to a completely different one when turned. (WTH?)
I also tried using the metal.fx from the pelican demo on it as an experiment. It looked like the object was cutting throught the backdrop revealing another picture (from the reflection) behind it.
Here are some code snippets to show you some of the steps the program does (can\'t post everything as the entire thing is at ~3000 lines of code, just this one gives me a headache:
Rem light and camera setup
Autocam Off : Position Camera 0,0,0,-10 : Rotate Camera 0,0,0,0
Set Point Light 0, -15,30,-10 : Set Ambient Light 10 : Make Light 1 : Set Point Light 1, 15,30,-10
Backdrop Off : Draw To Back
Rem ...
Rem This line is used repeatedly with calculated coordinates to generate the actual triangles:
Make Object Triangle ObjNr, TempCo(1).x,TempCo(1).y,TempCo(1).z,TempCo(2).x,TempCo(2).y,TempCo(2).z,TempCo(3).x,TempCo(3).y,TempCo(3).z
Rem TempCo is a user defined type suplying x,y,z-Koordinates, the object forms correctly
Rem The following function fuses them all together
Rem And removes the single triangle objects
Function Fuse(ObjNr, FirstTri, LastTri)
Make Mesh From Object 99, FirstTri
Delete Object FirstTri
Lock Vertexdata for Mesh 99
For i = FirstTri+1 To LastTri
Make Mesh From Object 98, i
Add Mesh To Vertexdata 98
Delete Object i : Delete Mesh 98
Next i
Unlock Vertexdata
Make Object ObjNr, 99, 0
Delete Mesh 99
EndFunction
Rem These are the appearence commands applied, changing them doesn\'t change the problem:
Set Object Cull ObjNr, 0
Set Object Wireframe ObjNr, 0
Set Object Specular ObjNr, 0
Position Object ObjNr, 0,-5,10
Rem Finally this is what happens to the object when turned or moved:
Rotate Object ObjNr, WrapValue(Object Angle X(ObjNr)+(y*0.1)), WrapValue(Object Angle Y(ObjNr)+(x*0.5)), 0
Position Object ObjNr, 0, -5, Object Position Z(ObjNr)-(x/200.0)
I Also tried changing the UV texture coordinates in the vertex data stuff but (maybe) since I had not idea what they should be that also didn\'t change a thing. Might also be because the object is untextured and just uses one color.
If I place a sphere right at the position of the object the sphere will be nicely lit and shaded. So I\'m guessing the problem has something to do with the way the object is generated.
Does anyone here have enough knowledge about this stuff to be able to tell me what could happen or how I could fix this?