lol, just gotta say, Ive been here for 17 hours, my fingers hurt and I love it!!
Anyways, I created a quad to represent a shadow on a mesh terrain and I use linepick and aligntovector to orient the quad with the underlying terrain. The problem is the quad moves off center of the sphere, raises and lowers on the y-axis. I dont understand any of this. When I use a flattened sphere mesh to represent the shadow and the same exact linepick and aligntovector code, it works perfectly. Is it something Im doing wrong in making the quad?
heres the code...
or you can download the project here http://www.hilbily-works.com/Downloads1/Blob_Shadow_wQuad_wMeshTerrain.zip
any help would be greatly appreciated!!
[Edit] oops, you need to comment out
;TurnEntity Shdw,0,180,0
;MoveEntity Shdw,0,0,0.05
right after the linepicking, I used this to see if it would fix the problem.
Anyways, I created a quad to represent a shadow on a mesh terrain and I use linepick and aligntovector to orient the quad with the underlying terrain. The problem is the quad moves off center of the sphere, raises and lowers on the y-axis. I dont understand any of this. When I use a flattened sphere mesh to represent the shadow and the same exact linepick and aligntovector code, it works perfectly. Is it something Im doing wrong in making the quad?
heres the code...
;Blob Shadow Using Quad Mesh with Mesh Terrain Xample ;By Xyle ;9-2-06 Graphics3D 1024,768,32,1 SetBuffer BackBuffer () Sphere = CreateSphere() PositionEntity Sphere,577,3,1378 ScaleEntity Sphere,3,3,3 Shdw = CreateQuad() ShdwTex = LoadTexture("Shadow.png",2) ;Used flag 2 for alpha EntityFX Shdw,16 EntityTexture Shdw,ShdwTex PositionEntity Shdw,EntityX(Sphere,True)-8,EntityY(Sphere,True)-45,EntityZ(Sphere,True)-8 Terr = LoadMesh("Terrain.x") PositionEntity Terr, 0,0,0 ScaleEntity Terr,5,5,5 EntityPickMode Terr,2 Cam = CreateCamera() PositionEntity Cam,EntityX(Sphere,True)-40,EntityY(Sphere,True)+100,EntityZ(Sphere,True)-40 CameraRange Cam,1,2000 PointEntity Cam,Sphere Lit = CreateLight() PositionEntity Lit,EntityX(Sphere,True),EntityY(Sphere,True)+150,EntityZ(Sphere,True) PointEntity Lit,Terr CamPiv = CreatePivot() PositionEntity CamPiv,EntityX(Sphere,True),EntityY(Sphere,True),EntityZ(Sphere,True) EntityParent Cam,CamPiv EntityParent CamPiv,Sphere While Not KeyHit(1) Cls x# = 0 z# = 0 pitch# = 0 yaw# = 0 roll# = 0 If KeyDown(208) Then pitch# = -1 If KeyDown(200) Then pitch# = 1 If KeyDown(203) Then yaw# = -1 If KeyDown(205) Then yaw# = 1 If KeyDown(17) Then z# = 1 If KeyDown(31) Then z# = -1 If KeyDown(30) Then x# = -1 If KeyDown(32) Then x# = 1 MoveEntity Sphere,x#,0,z# TurnEntity CamPiv,pitch#,yaw#,roll# SphereX# = EntityX(Sphere,True) SphereY# = EntityY(Sphere,True) SphereZ# = EntityZ(Sphere,True) Temp = 0 Temp = LinePick(SphereX,SphereY,SphereZ, 0, -2000, 0 ) PositionEntity Sphere,SphereX#,PickedY()+6,SphereZ# AlignToVector( Shdw, PickedNX(), PickedNY(), PickedNZ(),2,1 ) ;TurnEntity Shdw,0,180,0 ;MoveEntity Shdw,0,0,0.05 PositionEntity Shdw,EntityX(Sphere,True)-8,EntityY(Sphere,True)-45,EntityZ(Sphere,True)-8 UpdateWorld RenderWorld Flip ;Vsync on Wend End Function CreateQuad() ;Compliments of jfk EO-11110 mesh=CreateMesh() surf=CreateSurface(mesh) ;Texture Coords ;(0,0) ... (1,0) ; . . ; . . ; . . ;(0,1) ... (1,1) v0=AddVertex(surf, 0,40,0, 0,1) v1=AddVertex(surf, 31,40,0, 1,1) v2=AddVertex(surf, 0,40,31, 0,0) v3=AddVertex(surf, 31,40,31, 1,0) AddTriangle(surf,v0,v2,v1) AddTriangle(surf,v1,v2,v3) UpdateNormals mesh Return mesh End Function
or you can download the project here http://www.hilbily-works.com/Downloads1/Blob_Shadow_wQuad_wMeshTerrain.zip
any help would be greatly appreciated!!
[Edit] oops, you need to comment out
;TurnEntity Shdw,0,180,0
;MoveEntity Shdw,0,0,0.05
right after the linepicking, I used this to see if it would fix the problem.