R
rosegoldphoenix
Guest
Hey all,
I've been fiddling around with GMS' 3D abilities lately. I've gotten the basics down and can create some neat looking little environments and whatnot. However, all of this is for implementation into a game project which makes heavy use of surface drawing. The problem is that every time I try adding a surface to my project, the whole 3D projection screws up!
Here's a picture of my test project w/o out the surfaces:
And here's a picture when I draw the little dude as a surface:
If I attempt to draw the CAM as a surface, I get a black screen.
Here's the Draw event of my CAM object (using HeartBeast's lovely 3D tutorial as a base). Imagine the surface stuff isn't there and you'll get what we see in the first image.
And here's the code for the sprite dude:
I just have no idea what's going wrong!! Any help would be hELLA appreciated
I've been fiddling around with GMS' 3D abilities lately. I've gotten the basics down and can create some neat looking little environments and whatnot. However, all of this is for implementation into a game project which makes heavy use of surface drawing. The problem is that every time I try adding a surface to my project, the whole 3D projection screws up!
Here's a picture of my test project w/o out the surfaces:
And here's a picture when I draw the little dude as a surface:
If I attempt to draw the CAM as a surface, I get a black screen.
Here's the Draw event of my CAM object (using HeartBeast's lovely 3D tutorial as a base). Imagine the surface stuff isn't there and you'll get what we see in the first image.
Code:
///draw camera
if !surface_exists(surf) {surf = surface_create(view_wview,view_hview);};
surface_set_target(surf);
{
draw_clear_alpha(c_white,0);
//settings
d3d_set_zwriteenable(true);
d3d_set_hidden(true);
//vects
xvect = lengthdir_x(32,dir);
yvect = lengthdir_y(32,dir);
zvect = lengthdir_y(32,zdir);
d3d_set_projection(x,y,z,x+xvect,y+yvect,z+zvect,0,0,1);
if (room == rm_movingTerrain || room == rm_movingGrid)
{
d3d_set_projection_ext(x,y,z,x+xvect,y+yvect,z+zvect,0,0,1,ang,global.aspect_ratio,1,32000);
}
//lighting
d3d_set_lighting(true);
d3d_set_shading(false);
d3d_light_define_ambient(c_blue);
d3d_light_define_point(0,room_width,room_height/2,100,max(room_width,room_height),c_fuchsia);
d3d_light_enable(0,true);
//fog
d3d_set_fog(true,c_black,max(room_width,room_height)/4,max(room_width,room_height));
}
surface_reset_target();
draw_surface(surf,view_wview,view_yview);
Code:
if !surface_exists(surf) {surf = surface_create(sprite_width,sprite_height);}
surface_set_target(surf);
{
draw_clear_alpha(c_white,0);
d3d_light_define_ambient(c_white);
d3d_transform_set_identity();
d3d_transform_add_rotation_x(90);
d3d_transform_add_rotation_z(point_direction(x, y, CAM.x, CAM.y)+90);
d3d_transform_add_translation(x, y, z+sprite_get_height(sprite_index))
draw_sprite_ext(sprite_index, image_index, 0, 0, 1, 1, 0, c_white, 1);
d3d_transform_set_identity();
}
surface_reset_target();
draw_surface(surf,x,y)