Using Transformations For Billboards, I searched, I googled, and all those other things. |
![]() ![]() |
Using Transformations For Billboards, I searched, I googled, and all those other things. |
Nov 6 2009, 11:37 PM
Post
#1
|
|
|
GMC Member Group: GMC Member Posts: 546 Joined: 8-May 07 From: Tennessee Member No.: 78341 |
I'm trying to use billboards (polygons that face the camera and appear as a flat image) for some effects in a fangame. I've got the objects to face the camera on the X and Y axis, but I'm having some trouble getting them to face the camera on the Z axis. Screens of what I'm talking about:
Smoke effect viewed from side: http://img190.imageshack.us/img190/8755/screenshot105w.pngLooks pretty good IMO Viewed from top: http://img156.imageshack.us/img156/9680/screenshot106j.pngLooks like ****. Same with ring-get effect: Viewed from side, looks good: http://img156.imageshack.us/img156/4610/screenshot111a.png Viewed from top, the sparkles don't face the camera correctly: http://img23.imageshack.us/img23/410/screenshot113y.png Here's the code I am using for the sparkle effect currently (draw event, the smoke effect is relatively the same): CODE draw_set_alpha(alpha) d3d_transform_set_identity() d3d_transform_add_rotation_z(point_direction(x,y,camera_3rdperson.xf,camera_3rdperson.yf)) //rotates it towards the camera on the X/Y axis d3d_transform_add_translation(x,y,z) d3d_draw_wall(0,-r,r,0,r,-r,tex,1,1) d3d_transform_set_identity() draw_set_alpha(1) I've tried several things to get it to rotate correctly, but nothing has worked so far. Also I can't use the billboard effect from the FPS tutorial (or any similar effect that doesn't use transformations) since I plan on using this effect with certain enemies, so they point towards your character. Any help would be greatly appreciated. |
|
|
|
Nov 6 2009, 11:43 PM
Post
#2
|
|
|
^destroyed evil chicken^ Group: GMC Member Posts: 393 Joined: 18-January 07 From: The land of AUS Member No.: 68535 |
what is -r and r?
I would reccomend(for ease) to have 2 modes for each drawing. mode 1 would draw a wall while mode 2 would draw a floor at a elevated z |
|
|
|
Nov 6 2009, 11:47 PM
Post
#3
|
|
|
GMC Member Group: GMC Member Posts: 546 Joined: 8-May 07 From: Tennessee Member No.: 78341 |
what is -r and r? I would reccomend(for ease) to have 2 modes for each drawing. mode 1 would draw a wall while mode 2 would draw a floor at a elevated z r stands for radius And I've tried that, it just made the effect look worse :\ |
|
|
|
Nov 7 2009, 03:01 AM
Post
#4
|
|
|
GMC Member Group: GMC Member Posts: 364 Joined: 2-July 07 Member No.: 82619 |
This is a script I made for drawing a billboard. It uses another script, which is included.
Billboard CODE var x1,y1,z1; x1=argument0 y1=argument1 z1=argument2 var x2,y2,z2; x2=obj_camera.x y2=obj_camera.y z2=obj_camera.z var dir1,dir2; dir1=point_direction(x1,y1,x2,y2) dir2=d3d_point_direction(x1,y1,-z1,x2,y2,-z2) d3d_transform_set_identity() d3d_transform_add_rotation_x(dir2) d3d_transform_add_rotation_z(dir1-90) d3d_transform_add_translation(x1,y1,z1) var s; s=2; d3d_draw_wall(-s,0,-s,s,0,s,tex,1,1) d3d_transform_set_identity() d3d_point_direction() CODE return (point_direction(0,argument2,point_distance(argument0,argument1,argument3,argument4),argument5)); Note: you may have to flip the z-axis in the code. This code was made for a camera where up on the z-axis is positive and down is negative. This post has been edited by jsorgeagames: Nov 7 2009, 03:01 AM |
|
|
|
Nov 7 2009, 06:04 AM
Post
#5
|
|
|
GMC Member Group: GMC Member Posts: 546 Joined: 8-May 07 From: Tennessee Member No.: 78341 |
This is a script I made for drawing a billboard. It uses another script, which is included. Billboard ... d3d_point_direction() ... Note: you may have to flip the z-axis in the code. This code was made for a camera where up on the z-axis is positive and down is negative. Thanks, works perfect ;P The smoke effect still looks kind of...bad, due to it clipping through the floor sometimes, but it's nothing I didn't expect...and it looks way better than it did If you want credit, I do need a way to fill the credits screen up XD |
|
|
|
Nov 8 2009, 09:03 PM
Post
#6
|
|
|
GMC Member Group: GMC Member Posts: 364 Joined: 2-July 07 Member No.: 82619 |
This is a script I made for drawing a billboard. It uses another script, which is included. <snip> Thanks, works perfect ;P The smoke effect still looks kind of...bad, due to it clipping through the floor sometimes, but it's nothing I didn't expect...and it looks way better than it did If you want credit, I do need a way to fill the credits screen up XD No, it's okay, I don't need credit. I didn't make the d3d_point_direction() script though, I got it here on the forums, but I don't remember who made it. EDIT: As for it clipping through the floor, I thought up a method of pushing it higher, out of the floor: CODE var floorz; //floor z
floorz=0 var myz; //smoke z myz=1.5 var s; //size s=2 if myz-s<floorz myz=floorz+s+.1 This post has been edited by jsorgeagames: Nov 8 2009, 09:07 PM |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 22nd November 2009 - 11:23 AM |