Извините, ничего не найдено.

Не расстраивайся! Лучше выпей чайку!
Регистрация
Справка
Календарь

Вернуться   forum.boolean.name > Программирование игр для компьютеров > Blitz3D > 3D-программирование

3D-программирование Вопросы, касающиеся программирования 3D мира

Ответ
 
Опции темы
Старый 24.12.2006, 15:14   #1
Progger_Leo
 
Сообщений: n/a
Мультитекстуринг

Как использовать мультитекстуринг в Блице?
 
Ответить с цитированием
Старый 24.12.2006, 16:09   #2
Chuma
ПроЭктировщик
 
Регистрация: 23.11.2006
Сообщений: 130
Написано 3 полезных сообщений
(для 35 пользователей)
Re: Мультитекстуринг

Сообщение от Progger_Leo
Как использовать мультитекстуринг в Блице?
грузим текстуру tex1
грузим текстуру tex2
грузим объект

EntityTexture объект,tex1,0,0
EntityTexture объект,tex2,0,1
(Offline)
 
Ответить с цитированием
Старый 24.12.2006, 22:32   #3
Progger_Leo
 
Сообщений: n/a
Re: Мультитекстуринг

Хм. Я имел ввиду, чтобы например, можно было у куба с разных сторон приставить разную текстуру.

Или я что-то не понял?
 
Ответить с цитированием
Старый 24.12.2006, 23:29   #4
НУБ
Бывалый
 
Регистрация: 22.09.2005
Сообщений: 634
Написано 36 полезных сообщений
(для 102 пользователей)
Re: Мультитекстуринг

Сообщение от Progger_Leo
Или я что-то не понял?
- Ты что-то не правильно понял
(Offline)
 
Ответить с цитированием
Старый 24.12.2006, 23:35   #5
Progger_Leo
 
Сообщений: n/a
Re: Мультитекстуринг

Можете объяснить, чтоб сделать как я предложил выше?
 
Ответить с цитированием
Старый 24.12.2006, 23:39   #6
Тарас Шевченко
Знающий
 
Регистрация: 17.08.2006
Сообщений: 246
Написано 0 полезных сообщений
(для 0 пользователей)
Re: Мультитекстуринг

В Максе наложи, так не знаю. А зачем?
(Offline)
 
Ответить с цитированием
Старый 25.12.2006, 01:13   #7
HolyDel
 
Регистрация: 26.09.2006
Сообщений: 6,035
Написано 1,474 полезных сообщений
(для 2,707 пользователей)
Re: Мультитекстуринг

cubemap как вариант.
ставиш текстуре 128 флаг.
потом надо юзать команду setcubeface. см. ниже.
SetCubeFace texture,face
Parameters
texture - texture 
face - face of cube to select. This should be one of the following values: 
0: left (negative X) face 
1: forward (positive Z) face - this is the default. 
2: right (positive X) face 
3: backward (negative Z) face 
4: up (positive Y) face 
5: down (negative Y) face  

Description
Selects a cube face for direct rendering to a texture. 

This command should only be used when you wish to draw directly to a cube map texture in real-time. Otherwise, just loading a pre-rendered cube map with a flag of 128 will suffice. 

To understand how this command works exactly it is important to recognise that Blitz treats cubemap textures slightly differently to how it treats other textures. Here's how it works... 

A cubemap texture in Blitz actually consists of six images, each of which must be square 'power' of two size - e.g. 32, 64, 128 etc. Each corresponds to a particular cube face. These images are stored internally by Blitz, and the texture handle that is returned by LoadTexture/CreateTexture when specifying the cube map flag, only provides access to one of these six images at once (by default the first one, or '0' face). 

This is why, when loading a cubemap texture into Blitz using LoadTexture, all the six cube map images must be laid out in a specific order (0-5, as described above), in a horizontal strip. Then Blitz takes this texture and internally converts it into six separate images. 

So seeing as the texture handle returned by CreateTexture / LoadTexture only provides access to one of these images at once (no. 1 by default), how do we get access to the other five images? This is where SetCubeFace comes in. It will tell Blitz that whenever you next draw to a cubemap texture, to draw to the particular image representing the face you have specified with the face parameter. 

Now you have the ability to draw to a cube map in real-time. 

To give you some idea of how this works in code, here's a function that updates a CubeMap in real-time. It works by rendering six different views and copying them to the cube map texture buffer, using SetCube face to specify which particular cubemap image should be drawn to. 

; Start of code 
Function UpdateCubeMap( tex,camera ) 

tex_sz=TextureWidth(tex) 

;do left view 
SetCubeFace tex,0 

; copy contents of backbuffer to cube map 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

;do forward view 
SetCubeFace tex,1 
RotateEntity camera,0,0,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

;do right view 
SetCubeFace tex,2 
RotateEntity camera,0,-90,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

;do backward view 
SetCubeFace tex,3 
RotateEntity camera,0,180,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

;do up view 
SetCubeFace tex,4 
RotateEntity camera,-90,0,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

;do down view 
SetCubeFace tex,5 
RotateEntity camera,90,0,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

EndFunction 
; End of code 

All rendering to a texture buffer affects the currently selected face. Do not change the selected cube face while a buffer is locked. 

Finally, you may wish to combine the vram 256 flag with the cubic mapping flag when drawing to cube map textures for faster access.  

Example
; SetCubeFace Example 
; ------------------- 

width=640 
height=480 
depth=0 
mode=0 

Graphics3D width,height,depth,mode 
SetBuffer BackBuffer() 

; If user's graphics card does not support cubic mapping then quit example 
If GfxDriverCaps3D()<110 Then RuntimeError "Sorry, your graphics card does not support cubic environemnt maps." 

cam=CreateCamera() 
PositionEntity cam,0,10,-10 

; Create separate camera for updating cube map - this allows us to manipulate main camera and cube camera which avoids any confusion 
cube_cam=CreateCamera() 

light=CreateLight() 
RotateEntity light,90,0,0 

; Load object we will apply cubemap to - the classic teapot 
teapot=LoadMesh("media/teapot.x") 
ScaleEntity teapot,3,3,3 
PositionEntity teapot,0,10,0 

; Create some scenery 

; ground 
ground=CreatePlane() 
EntityColor ground,168,133,55 
ground_tex=LoadTexture("media/sand.bmp") 
ScaleTexture ground_tex,10,10 
EntityTexture ground,ground_tex 

; sky 
sky=CreateSphere(24) 
ScaleEntity sky,500,500,500 
FlipMesh sky 
EntityFX sky,1 
sky_tex=LoadTexture("media/sky.bmp") 
EntityTexture sky,sky_tex 

; cactus 
cactus=LoadMesh("media/cactus2.x") 
FitMesh cactus,-5,0,-5,2,6,.5 

; camel 
camel=LoadMesh("media/camel.x") 
FitMesh camel,5,0,-5,6,5,4 

; Load ufo to give us a dynamic moving object that the cubemap will be able to reflect 
ufo_piv=CreatePivot() 
PositionEntity ufo_piv,0,15,0 
ufo=LoadMesh("media/green_ufo.x",ufo_piv) 
PositionEntity ufo,0,0,10 

; Create texture with color + cubic environment map + store in vram flags 
tex=CreateTexture(256,256,1+128+256) 

; Apply cubic environment map to teapot 
EntityTexture teapot,tex 

While Not KeyDown(1) 

; Control camera 

; mouse look 

mxs#=mxs#+(MouseXSpeed()/5.0) 
mys#=mys#+(MouseYSpeed()/5.0) 

RotateEntity cam,mys#,-mxs#,0 

MoveMouse width/2,height/2 

; move camera forwards/backwards/left/right with cursor keys 

If KeyDown(200)=True Then MoveEntity cam,0,0,.2 ; move camera forward 
If KeyDown(208)=True Then MoveEntity cam,0,0,-.2 ; move camera back 

If KeyDown(205)=True Then MoveEntity cam,.2,0,0 ; move camera left 
If KeyDown(203)=True Then MoveEntity cam,-.2,0,0 ; move camera right 

; Turn ufo pivot, causing child ufo mesh to spin around it (and teapot) 
TurnEntity ufo_piv,0,2,0 

; Update cubemap 
UpdateCubemap(tex,cube_cam,teapot) 

RenderWorld 

Text 0,0,"Use mouse to look around" 
Text 0,20,"Use cursor keys to change camera position" 

Flip 

Wend 


Function UpdateCubemap(tex,camera,entity) 

tex_sz=TextureWidth(tex) 

; Show the camera we have specifically created for updating the cubemap 
ShowEntity camera 

; Hide entity that will have cubemap applied to it. This is so we can get cubemap from its position, without it blocking the view 
HideEntity entity 

; Position camera where the entity is - this is where we will be rendering views from for cubemap 
PositionEntity camera,EntityX#(entity),EntityY#(entity),EntityZ#(entity) 

CameraClsMode camera,False,True 

; Set the camera's viewport so it is the same size as our texture - so we can fit entire screen contents into texture 
CameraViewport camera,0,0,tex_sz,tex_sz 

; Update cubemap 

; do left view 
SetCubeFace tex,0 
RotateEntity camera,0,90,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

; do forward view 
SetCubeFace tex,1 
RotateEntity camera,0,0,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

; do right view 
SetCubeFace tex,2 
RotateEntity camera,0,-90,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

; do backward view 
SetCubeFace tex,3 
RotateEntity camera,0,180,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

; do up view 
SetCubeFace tex,4 
RotateEntity camera,-90,0,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

; do down view 
SetCubeFace tex,5 
RotateEntity camera,90,0,0 
RenderWorld 
CopyRect 0,0,tex_sz,tex_sz,0,0,BackBuffer(),TextureBuffer(tex) 

; Show entity again 
ShowEntity entity 

; Hide the cubemap camera 
HideEntity camera 

End Function
(Offline)
 
Ответить с цитированием
Старый 25.12.2006, 18:07   #8
Progger_Leo
 
Сообщений: n/a
Re: Мультитекстуринг

Спасибо!
 
Ответить с цитированием
Ответ


Опции темы

Ваши права в разделе
Вы не можете создавать темы
Вы не можете отвечать на сообщения
Вы не можете прикреплять файлы
Вы не можете редактировать сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.

Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Мультитекстуринг Hellfalcon 3D-программирование 30 18.07.2008 21:05


Часовой пояс GMT +4, время: 10:12.


vBulletin® Version 3.6.5.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot
Style crйe par Allan - vBulletin-Ressources.com