Rmxp 3d script

    Compartilhe
    avatar
    jiraya
    Administrador
    Administrador

    Mensagens : 1299
    Credibilidade : 54

    Rmxp 3d script

    Mensagem por jiraya em Qui Maio 17, 2012 8:46 pm

    [Autor: 'Chad mostr']
    Script RMXP 3D

    Tudo bem caras, grandes acontecimentos. Agora posso fazer com sucesso os mapas em 3D usando o editor de mapas em 2D! Agora, desta vez em torno dele é muito simples - todas as peças são simplesmente cubos eo id da telha determina que a textura do cubo fica. Isso, no entanto, comprova a validade do uso de RMXP para fazer jogos em 3D.

    Agora, não é só desenhar esses mapas 2D em 3D com a ferramenta possível, também é, até agora, muito mais rápida do que desenhar os mapas em 2D usando RGSS Módulo Graphics. Na verdade, durante o meu teste eu tenho + de 250 quadros por segundo.

    Tudo bem, então chega de conversa. Vamos chegar ao impressionante: * Aviso BIG Imagem
    Camada 1, em RMXP
    Spoiler:
    camada 2 in RMXP
    Spoiler:
    [
    camada 3 3 in RMXP
    Spoiler:
    Mapa pronto
    Spoiler:

    Agora, o código RGSS executar o demo: (Sem comentários explicativos desta vez, caras
    script
    Spoiler:
    DF_GameWindow.set_dimensions(0,0,0,0) device = DF3DDevice.new(Video::EDT_DIRECT3D9, [800,600], 32, false) smgr = device.scene_manager driver = device.video_driver camera = smgr.add_camera_scene_node_FPS camera.set_position(-100,300,-100) camera.set_target(0,0,0) $data_tilesets = load_data("Data/Tilesets.rxdata") $data_common_events = load_data("Data/CommonEvents.rxdata") $game_map = Game_Map.new $game_map.setup(1) for i in 0...20 for j in 0...15 for k in 0...3 if $game_map.data[i,j,k] != 0 node = smgr.add_cube_scene_node(64) node.set_position(i * 64, k * 64, j * 64) node.set_material_flag(Video::EMF_LIGHTING, false) texture_name = ($game_map.data[i,j,k] - 383).to_s + ".png" node.set_material_texture(0, driver.get_texture(texture_name)) end end end end lasttime = Time.now while device.run DF_Input.update if DF_Input.trigger?(DF_Input::KEY_F) p driver.get_fps end time = Time.now if time - lasttime > 5 Graphics.update lasttime = Time.now end driver.begin_scene(true, true, [255, 160, 160, 255]) smgr.draw_all driver.end_scene end device.drop

    E, claro, há uma demo tinha de ser!
    teclas:
    As setas para mover (por agora. Vou alterá-lo posteriormente para que você possa usar WASD)
    F para mostrar FPS
    CTRL + F4 para sair

    Demo
    Clique aqui

    E aqui está o código RGSS mágica que faz isso. (Normalmente, você deve colocar isso em uma cena, mas vocês sabem como fazer cenas assim eu não me incomodei)

    Spoiler:
    #First, let's move the 2D window out of the way: DF_GameWindow.set_dimensions(0,0,0,0) #next, let's create out device. The parameters are: #Driver type, screen size (in an array), bits per pixel, and fullscreen #This device is the central point of the 3D engine. Absolutely everything #can be accessed through this device. device = DF3DDevice.new(Video::EDT_DIRECT3D9, [800,600], 32, false) #Now, let's get our scene manager. The scene manager does stuff like adding nodes #and cameras smgr = device.scene_manager #Now, let's get our driver. The driver handles actually rendering. driver = device.video_driver #Let's get our mesh! (Note that you should probably add error handling here. #smgr.get_mesh will return nil if it can't find the file so make sure you #always check that the mesh was actually created. I didn't do any error handling #but a simple check for nil would suffice) mesh = smgr.get_mesh("sydney.md2") #Let's create an animated scene node from the mesh. Again, normally you #want to check for errors. node = smgr.add_animated_mesh_scene_node(mesh) #now, let's add a camera to the scene node! Camera are how you view everything #in the scene. Note that it is possible to have more than one camera and #you can switch between them, or even have them render to different parts #of the screen. camera = smgr.add_camera_scene_node #move our camera, since both the camera and scene node are at the same, default #position right now. (Which is (0,0,0)) Note that the parameters here are x, y, z. #when your camera is at (0,0,0) and has no rotation, x is sideways, y is up, #and z is forwards/backwards camera.set_position(100,100,100) #Rememeber how I said that the default position is 0,0,0? Well, since we never moved #our node, it is at 0,0,0 right now. So, Let's tell the camera to look there: camera.set_target(0,0,0) lasttime = Time.now while device.run #check if our device is still running #begin rendering the scene. I will not explain what these parameters are yet #it's not important right now, and it's kind of complicated XD driver.begin_scene(true, true, [255, 160, 160, 255]) smgr.draw_all #draw all of the scene nodes driver.end_scene #finish rendering the scene #this junk is just so Graphics doesn't whine. time = Time.now if time - lasttime > 5 Graphics.update end end #Now, alway always always remember to drop your device when you are done. #The device is something you should only drop at the end of your game, after #the device no longer runs. device.drop

    Videos

    usem a vontade valeu.

    avatar
    jiraya
    Administrador
    Administrador

    Mensagens : 1299
    Credibilidade : 54

    Re: Rmxp 3d script

    Mensagem por jiraya em Qui Maio 17, 2012 10:16 pm

    Novo link :Clique aqui!

      Data/hora atual: Seg Jan 21, 2019 6:14 pm