Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Blender .x File

Author
Message
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 22nd Oct 2011 22:35
At the moment i am just tyring to throw together as many mini projects as i can to help me build up some knowledge and get me in the problem solving mindframe, hence why i am throwing up a lot of seemingly unrelated posts just lately.
Currently i am trying to make a door that opens on a hinge when the camera is near it and space bar is pressed. I think i can do this as the hands on book pretty much has it covered by using an invisible sphere and using a door as a limb and just rotating the sphere object etc etc. So i think ill be ok.

But here is where i have a problem. I will be doing all my models in blender. Im not very good at using it and have only just started really but progress is slow but steady. I have checked the .x exporter and exported my very simple poor door model with a very simple texture. It is supposed to look like this:

But it does not. It is simple to load and does seem to work but the texture is not there, just a simple light brown version of it. What am i missing to make the texture come out properly either in blender or DB?

For anyone interested the media and code is on this thread to.

Attachments

Login to view attachments
Darkzombies
13
Years of Service
User Offline
Joined: 25th Dec 2010
Location: In multiple tabs, most likely youtube.
Posted: 22nd Oct 2011 23:02
Well I think you may have to texture it yourself with commands, also the spaces in the filename may be causing it as well.

zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 22nd Oct 2011 23:19
I looked at your model in dxviewer, and it appears the same way as dbpro is showing it. So I'll have to play around with export the .blend file. Here is the info dxviewer stated

*note: I hardly use 3d inside of dbpro. I'm sure this is a quick fix on how the texture is applied in blender and exported.

' material 0 - No effect instance specified.
Reverting to the default effect.
SAS: Loading effect 'Resource:#103'

Your signature has been erased by a mod please reduce it to 600 x 120.
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 22nd Oct 2011 23:42
I dont think its anything wrong with DB pro, i think i havent textured it properly in blender, but if im honest i really dont know how, even after watching several tutorials. Some say pack the texture up so i have. The texture covers the whole object which for this instance is ok but its not something i wanted to do as i only wanted the face i selected in blender to be textured as a test, yet it did the whole lot. Yet despite doing this it only renders like this, and does not show up as being textured at all in the main view window.
I am wondering what other problems i may experience when exporting blender stuff to dbpro, such as animations or whatever new 3d things i learn in the near future (armatures etc? i havent got a clue).

What is the standard operating procedure to creating something in blender and exporting it to DBpro. If there is none then why not.
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 22nd Oct 2011 23:46
Quote: "What am i missing to make the texture come out properly either in blender or DB?"

Blender isn't exporting texture coordinates - they will all be set to (0,0), which will be one corner of the texture, which is why everything is appearing as one shade of brown.

I've never used Blender, so I can't tell you how to fix that. You'll be on the right tract once your .x file has a section named 'MeshTextureCoords' - it's a text file so you can open the file in notepad/wordpad/your preferred text editor.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 23rd Oct 2011 00:01
Thank you for the suggestion Ian.
I had a look inside the .x file but could find no MeshTextureCoords unfortunately.
I did find Mesh { //Mesh Mesh
MeshNormals { //Mesh Normals
MeshMaterialList { //Mesh Material List
and
Material Wood_Door {
0.640000; 0.640000; 0.640000; 1.000000;;
96.078431;
0.050000; 0.050000; 0.050000;;
0.000000; 0.000000; 0.000000;;
TextureFilename {"Wood Door Tex.jpg";}
But it is all a bit jibberish to me as i dont know whats going on. There is an option to include textures but that is checked automatically so i presume that is working fine seen as the x file appears to contain it.

I can only think that i havent textured it correctly in Blender. Not as in not textured it correctly as it is textured, as far as blender is concerned the job is done but i mean not done it correctly for the export of the model into an .x file. Perhaps i should try some other way but i would rather not experiment as it was difficult enough just getting the door to change colour. Until i am proficient enough in blender i would just prefer it if someone has a special way of creating, texturing and importing an object, but i am in no real rush - as i said before i am just hammering together as many code snippets as i can to best learn the way to do things.
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 23rd Oct 2011 00:06 Edited at: 23rd Oct 2011 00:12
I think if inside blender you set the texture MAPPING to UV. But my version of .x exporter is not working properly.

Your signature has been erased by a mod please reduce it to 600 x 120.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 23rd Oct 2011 00:10
Go into Blender, open the file and select the object, select edit mode, press A, then press U, then presto, it will generate UV coordinates; and your model will render correctly.


In line with Ian's point, Blender does not render UV coordinates automatically.

If the image is saved in the same location as the model file, there will be no need to use code to texture it.

There some more information about this in my Blender .X export article.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 23rd Oct 2011 00:22
That guide seems great Chris, thank you. However i do not know where anything in the textures bit is. For example:

"Select UV as the coordiante method in the texture's property panel."
I dont even know what the property panel is. I think its the thing where you see what youve applied but i dont know, and if it is i dont know where the option UV coordinates is (unless it is that one under the mapping tab). Some pictures with this tutorial would be fantastic, especially for someone who is just starting out with blender.

I pressed A (presumably to select the whole object in edit mode) then pressed U but the only thing that happened was it brought up the UV menu and didnt actually do anything. I am using 2.6 if that is any help?
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 23rd Oct 2011 01:31
For some reason I am unable to get the .x exporter under blender 2.5 to work properly. I'll have to play around with it. I didn't have this problem in older versions.

I was able to export to .3ds and then use Microsofts conv3ds.exe to convert it to .x . But for some reason I lose the texture, and I had to load and texture the object inside dbpro. Grrrr. I might need to update my blender/reinstall and see what happens.

Also in my example I think the texture is applied in the wrong direction. I'll work on that as well



Your signature has been erased by a mod please reduce it to 600 x 120.

Attachments

Login to view attachments
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 23rd Oct 2011 01:49
included the wrong adoor.x file,, the one attached here is in text .x format. Still doesn't work right as stated above.

Your signature has been erased by a mod please reduce it to 600 x 120.

Attachments

Login to view attachments
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 23rd Oct 2011 01:52
Somarl

Quote: "I pressed A (presumably to select the whole object in edit mode) then pressed U but the only thing that happened was it brought up the UV menu and didnt actually do anything. I am using 2.6 if that is any help? "


Ok I'm using 2.59.

Select the unwrapping option you desire in that menu that pops up. There is also an Unwrap button on the tool panel to the left which brings up the same menu.

It is best to review this guide on UV mapping. I haven't seen any decent UV video tutorials for Blender; but these video tutorials are recommended for all purpose modelling.

Quote: "I might need to update my blender/reinstall and see what happens."


The latest .X exporter works very well for me.

zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 23rd Oct 2011 02:08
Quote: "Ok I'm using 2.59."
Quote: "The latest .X exporter works very well for me"


Yeah I was using Vers. 2.58.1 r38019,, and something is broken with my exporter.

Your signature has been erased by a mod please reduce it to 600 x 120.
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 23rd Oct 2011 03:08 Edited at: 23rd Oct 2011 04:18
I got it to work.

I guess conv3ds.exe didn't like the long texture name. So change your texture name to "Wood.jpg" and use the attached adoor.x file.
I'll upload a new .x when I get the texture to apply the way you had it.

I used your snippet with my attached adoor.x, Wood.jpg in the project folder


Upgraded to blender 2.6 and the .x exporter is now woking. I can't get the image to look exaclty like you first described,, because you were using blender render engine,, which applies a lot of fx to the material/texture. Your raw object and texture (the one you would see in object mode or edit mode) is the result I get. Which is exactly what I would expect.

Not sure what version of Blender you are using but I would update to the latest. Don't have spaces in your filenames it just leads to trouble. Set the mapping to UV as described earlier,, or use the properties on the right -> texture. Then scroll down and expand [mapping] and select UV for coordinates.

Your signature has been erased by a mod please reduce it to 600 x 120.

Attachments

Login to view attachments
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 23rd Oct 2011 20:28
I got it working in the end (didnt take long just not been on here because i had to do a full reformat earlier this morning due to updating firmware on my ssd).

I managed to get it showing the texture just fine by selecting the uv mapping co ords just as chris suggested. I didnt have to change the name or anything, now unless thats something you have to do for older versions but with 2.6 it works fine just going onto the mapping options and instead of selecting global selecting UV as i was advised.

Thanks folks.
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 23rd Oct 2011 20:46
Quote: "I managed to get it showing the texture just fine by selecting the uv mapping co ords just as chris suggested"


Acutally I suggested it first, but Meh!!!

The naming only comes into to play if you use the conversion tools supplied with the directx SDK and some other programs. That's the reason I suggested the naming convention. I too got it working with 2.6.

glad you got it working

Your signature has been erased by a mod please reduce it to 600 x 120.
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 23rd Oct 2011 20:56
Lol so you did. Thats just a classic case of skipping through too quick and not reading all the posts properly ha ha Thanks. In all fairness everyone does that i guess, for example i mentioned i was using 2.6 a few posts before you said im not sure what version your using so we all do it

I think next i will try and see if i can do multiple textures on an object, of course im going to have to learn that in blender first, then ill see if that exports correctly. Should it?
zenassem
21
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 23rd Oct 2011 21:13
Quote: " for example i mentioned i was using 2.6 a few posts before you said im not sure what version your using so we all do it"


Touché!

Your signature has been erased by a mod please reduce it to 600 x 120.
Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 23rd Oct 2011 21:33
While im here i dont suppose anyone has any good blender links. Particularly regarding texturing.
I usually use cgcookie's because i absolutely love Johnathan Williamsons way of doing stuff, its makes for easy watching and i find i can learn pretty much anything from his tutorials. But i am stuck on finding a decent texturing one. I cant believe how many different ways there are to texture so at the moment i am lost as to what to do. Now i only really want to learn in a way that can be imported into DBpro so there isnt much point learning to texture in a way that cant be, but i have no idea where to look. All the texturing tutorial vids are very hard to follow because people are mumbling through them clicking loads of things at once and saying, ill just press this and this while you cant see what they are doing etc.

Any decent links anyone? If i get no joy here ill just repost this thread in 3d as thats really where it probably belongs anyway. just thought id ask while ive made this one
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 23rd Oct 2011 22:26
Yo!

You will have a hard time finding any decent tutorials on that particular subject; most Blender users use Blender as the game engine... So they wouldn't care about us. While it can pretty much produce any texture you desire using Nodes and the material panel explained in the video tutorials I posted above, the .X export script does not record the extra details.

Multi-texture export also does not work; at least on my version of Blender. I cannot be asked to install 2.6 yet, I'm busy on the coding aspects of my project. Basically, the export script ignores the extra materials; it just exports the first.

It will also ignore additional FaceTextures... FaceTextures are textures applied to seperate faces; eg Ceiling, floor and wall textures for a single object room. This is accomplished by selecting a face in edit mode, and then selecting an image in the UVEditor. It will display with multitextures in Blender, but not in DirectX or DBPRO.

The workarounds for this is to use seperate limbs for seperate parts of objects that require seperate textures; or to UV map different parts of the mesh to different parts of a single texture. Hard work, but by using object-orientation, in the long run you wouldn't need to keep on UV mapping all the time.

No multi-texture export does not bother me because I do not texture my map objects in Blender because I deal with .FX shaders which are way more sophisticated and speedy than using .X texture properties. Shaders can be applied to multiple objects, cameras, UV coordinates, limbs etc etc with little CPU workload. If you do not understand shaders, then trust it is far better for DBPRO games development to learn your shaders than to learn how to get Blender to export multitextures. Although I do texture my characters in Blender, but only to take advantage of 3d brushes and to preview how they look and to export a default texture.

Ofcourse if I was interested in multi-texturing the map objects in Blender, I'd learn Python Scripting so that I could add the extra textures to the .X file; I bet it is a 30 minute job for someone who knows the Blender API; but for someone who doesn't it is a project in its own right to get it to work.

If you are desperate, consider posting on an official Blender forum; maybe someone there will know.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 24th Oct 2011 10:17 Edited at: 24th Oct 2011 10:19
Thanks for the input Chris. Im still new to programming and blender so i was not aware of any of this. I thought it was as simple as just saving your model and loading it up in DB but i was wrong.

What do people usually use then in DB? There is surely a way to create beautiful detailed models and import then nice and easy from one program to DB?
I dont think i will be able to make anything worth while in blender, just enough to conceptualise my ideas will be good enough, but once things are finished i would like to enlist in help to replace the current objects with better detailed ones, so do you think this is achieveable in blender, is it worth asking on the forums if some more support could be lent to the x exporter. Doesnt DB pro support other formats and if it does, does blender output those formats? Also will i have problems when it comes to animations, basically is blender even worth carrying on with?

Apologies for all the questions but i like to learn and i do not understand everything i am currently finding out for myself.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Oct 2011 01:59
On this forum there is also a guy who built a .X exporter, try to consult him. Not sure what his name is; but a search should bring him up. Again, it is easy for someone to improve the exporter once they understand the API, just gotta encourage someone to do it.

As for your questions about Blender.

It all takes time, it took me months to learn Blender. I've read the Wiki about 3 times; reading once takes about 7 or 8 hours. Even then I was still a rookie (still am). In my opinion, it takes at least 2-4 weeks to get good enough in Blender to use it as your primary modelling tool, its interface has a long learning curve.

In combination with decent video tutorials, the ones where you can actually hear what the person is talking about, it is a good way to learn.

Its ability to duplicate meshes at every vertex and its ability to shape, bend and deform characters, vehicles, sky scrapers or anything you put under a modifier makes it very powerful; and 90% of the modifiers work with the exporter. Mesh modifiers are a valueable asset to have; no need to manually duplicate building floors or bend road meshes.

I'm using Blender for what it is good for; animation, vertex manipulation, UV editing and things like that. Everything else I do in the engine; and DarkShader. The same way you would use Matrices for one thing, and 3D objects for another; it is down to what is good for what. I build my own level tools specific for my game mechanics; but there are editors that can be used in conjunction with Blender, such as 3D World Studio; but with these 'smaller' editors, the support is limited due to their unpopularity. I try to stick with the tools that have busy forums and plenty of people around to support your learning.


I've used Cinema4D, Max, 3D World Studio, AutoCad, Sketch Up; they all have their advantages, but Blender is free and powerful at the sametime. SketchUp is good for level develoment, but getting its files into .X is something I do not know how to do, I have not used it for a while.


If I was you I'd practice with Blender, and look into Shaders; I say this because with little money, the combination of Blender modelling and FX shader skills will allow you to make anything you want. You only need to learn once, and after that you feel stupid not bothering to learn this stuff earlier.

The key is to use Object Orientation; never do the same thing twice, just save what you did, and reuse it to derive a new model from an old one. Blender calls this linking and appending from previous objects; once you grasp that aspect of the tool then it makes things so much easier. Another object orientated Blender concept is grouping, groups work like instancing in DBPRO; you make something, then you can just plot it around using instancing. You use Ctrl G to group a series of limbs in Blender, then your group is automatically added to the 'Add Object' menu, so you can plot them around nice and easily; you can even change the source object later to different original objects; EG, changing the leaves on a tree.

Finally, script plugins. These can be added to enhance Blender. There are scripts that can generate trees with one click of a button (I think that generator is for 2.4); because it has a large community, there are lots of plugins out there.

But, no general modellig tool or level editor can do better for a game than its own custom made in game level editor; you get to place objects there and then and you see how textures really look like, plus you can set your flags and game properties on the fly. Combine this with a model editor for creating 'base' models, then you are well set for productivity.

Primarily, you can model something in Blender, texture it, export it, load it in DBPRO and have the texture displayed on it; and any bone structure attached with one line of code; providing the material is in the same directory as the model. Anything beyond this requires some programmatic elbow grease; multitexturing, bump mapping, lighting effects, halo effects etc.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 26th Oct 2011 01:33
Thanks Chris. I looked into the x exxporter and found

http://forum.thegamecreators.com/?m=forum_view&b=3&t=166987&p=0
Which i think is the one, but this is the one that is already with blender as standard now and it doesnt seem to be being updated which is a shame.
Another guy did say it was easy like you said but looks like he lost his work and never got any feedback so i think its a dead end or he did get it working and it does actually work, im not sure as i cant make anything with multiple textures yet in blender to test it.

http://forum.thegamecreators.com/?m=forum_view&t=186686&b=3

I have been reading like a madman through all the blender manual and am picking up bits here and there. I learn most of it through Johnathan Williamsons amazing tutorials.

Thats some good advice on re-using models in blender and im going to keep at blender till im happy with what i can do. I only really want to make placeholders for any project i do. Im sure if what i make is good enough someone will in time want to join in and help spruce up the graphics a little by adding better models, if not i will just steadily buy custom models and slowly improve the lot if i felt my project was worth it.

Shaders scare me as to be honest ive searched them a million times and never found a human explanation for them. ALL the definitions i have come across make no sense. Is it an effect that is applied to a model? I dont know.

Quote: "Wiki for example
In the field of computer graphics, a shader is a set of software instructions that is used primarily to calculate rendering effects on graphics hardware with a high degree of flexibility. Shaders are used to program the graphics processing unit (GPU) programmable rendering pipeline, which has mostly superseded the fixed-function pipeline that allowed only common geometry transformation and pixel-shading functions; with shaders, customized effects can be used.
"


Rendering pipeline? Fixed function pipeline? Common geometry transformation? Pixel Shading Functions?
I never understood the whole pipeline thing either, like graphics pipeline and openGL and what the hell directx even is, is it a programming language that you add onto c++ or whatever your making a game with, Why cant you just do whatever it is in c++, why would you use openGL over DirectX as some folk do, what is an openGL etc etc i could go on forever.

All these things i must learn in time but baffle my head clean off at this current moment in time.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 26th Oct 2011 03:45 Edited at: 26th Oct 2011 03:52
Quote: "I have been reading like a madman through all the blender manual and am picking up bits here and there. I learn most of it through Johnathan Williamsons amazing tutorials."


Yeah, video tutorials are best, but the manual is essential for finding out fine details and specifications.

About the door, and multi-texturing; what parts of it are you intending to texture differenty? What will the multi-texturing be used for?

Quote: "Shaders scare me as to be honest ive searched them a million times and never found a human explanation for them."


Same here, before I started to play around with them. When you start producing textures like these, you start to realize that shaders are the way forwards; it is a complex script language in its own right; but you do not have to learn the actual language.






By minimum to get working with shaders with no knowledge about them, you can get hold of ready made work. You need to apply multiple textures using what's called texture stages. This is the second parameter in the three parameter [texture object] command, and the third in the 4 parameter [texture limb] command. You texture the base image at 0, then the next is 1 and so on. There are example DBPRO files and programs in the shader pack I linked to at the start of the paragraph.

If you want to go deeper and make your own shaders, consider getting DarkShader or download FX Composer from NVidia. These are WYSIWYG editors with no programming required. I prefer DarkShader because it is less CPU intensive and not all NVidia shaders work in DBPRO.

There is no need to understand everything about shaders to use them; but if you are curious, and want to understand how they work. Simply speaking, creating effects such as the images above in CPU code is a no no. It takes ages for the CPU to read and write pixels and vertices on every loop for the graphics card; just try to create the above effects with [dot] and [point] commands, erm... no.

This is because the time it takes for the CPU to obtain such information from the Graphical Processing Unit (GPU) is much longer than the GPU obtaining the information which is pretty much there already. So, shaders are scripts compiled into the GPU so that it can be programmed directly on a per vertex, and if desired, a per pixel basis.

The shader language features IF blocks, FOR loops, Sin, Cos math commands, variables, arrays, constants, vectors, matrices, strings, timers and alot of the features regular programming languages have. Its syntax is similar to C; but a typical shader file is only 100 to 200 lines long; very short. What does most of the work is the internal function libraries and schemantics already engineered by the GPU developers; all this stuff is accessed through statements and global variables; such as the global variable TEXCORD, which is a 2 float array containing the U and V, texture coordinate of the current vertex that is being rendered. You can do anything you like with that vertex. Pixel Shaders, work with pixel colours accessible through a variable consisting of 4 floats called COLOR. So far, not so complex sounding aye.

What is complex, is all the official terminology and the mathematical calculations often scattered around in the .FX files, but the place to learn how to write shaders is here, the official Direct X HLSL reference library. It is best to look at the shader files, and when there is a part of it you do not understand, investigate via the reference library.

EDIT

Not sure why the link doesn't work: http://www.microsoft.com/en-us/library/bb509561%28v=VS.85%29.aspx

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 26th Oct 2011 09:48
Some beautiful pictures up there. I have always understood shaders are very important for much improved graphics looks and speed wise, just not really sure why but thats cleared a few things up. Not sure i will end up writing my own (as i cant even program in basic yet, let alone c ) but im sure there are plenty of shaders out there for free use that do the job i would want anyway, as really it is only just an effect file applied to a texture if im not mistaken.

As for the door, i wont really do anything with that it was just for a snippet i was trying to do to get me used to objects and limbs. Of course in the future though i can see multitexturing being invaluable on other objects when i get round to them. I really hope someone finds a way to do this in blender as i believe even someone like me will be able to produce half decent models in such a good program but it will be no good if i cant export them out properly as i see them.

Just one more sort of related question then: How do lights work. I know that you can light your scene in DBpro and im sure it takes things like bump maps into consideration on your models or terrain, but can you also light it in a program like blender and export that too? Or are there other ways of ilghting a scene. I presume it would be best to light in db as you can produce realtime effects like blinking lights or a day/night system whereas just importing everything you used to light a scene from a modelling program i suppose would just come as is. I never messed around with lighting so i have no idea what exactly you use something like blender to do then whatever the rest is in dbpro. In other words i dont know where the split should be when you stop doing stuff to a model because there is no point adding any more things to it and do the rest in dbpro.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 26th Oct 2011 14:47 Edited at: 26th Oct 2011 15:13
Unfortunately, no script has been written to export the lights, so you have to manually create them. This is the same in all map editors because the .X format and .DBO format does not have light properties. Even in 3D World studio when you load the map into DBP no lights are created automatically.

With lights you have four tecniques, dynamic, static, fake lights or a combination.

The normal dynamic way is to position lights in Blender and parent them under seperate empties. Empties get exported to .X; so give the empties useful names such as PointLight1, DirectionLight1, 2 etc.

When you load your .X file, loop through every limb and run an InString search on their names to see if a light needs to be created. Then do so using the limb rotation and angle. You could use the limb scale as the light range value; or reference the name of the limb to a configuration UDT or XML file or something where you can write all of your parameters for your light types.

It gets a little more complicated with shaders, since you also need to tell the shaders where the lights are; through the [SET EFFECT CONSTANT] command.

As for the static way, it is based on lightmapping. I've never done lightmapping with blender but it is apparently possible using the following guide. It should work because it uses UV mapping, something the DirectX exporter will handle, the question is how many layers of textures the lightmap creates. Hopefully it can just add the lighting effect to the base material.

DBPRO has a lightmapping function with DarkLights. GDK users get this function as standard. This will add lighting to your textures using stage 0 for the main texture, and stage 1 for the lighting.

There is a manual way of doing it using the [SET LIGHT MAPPING ON] function. It is somewhat an internal shader, you supply it with a base texture on stage 0, and a black and white; or coloured light image for it to do a lighting blend on the object.

This is old school stuff and it does not hurt the frame rate as much as dynamic lights; exept if you are generating them on the fly.

[Edit] I did state that a cheesey way of doing lightmapping if all else fails is to use the vertex brush; and paint the lighting effect in Blender onto the material directly in the 3d viewport.

But the exporter isn't exporting vertex colours, even though DirectX supports it. So you'd have to paint using the texture brush.

It will draw onto your object, in your viewpoint and add the paintwork on the texture for you. This is quite fast for wall and floor lighting, since lightmap generators tend to take ages to generate.

Moving on, Fake lights are sometimes use to compensate for the limited light count (usually 8) in one scene. You have to secretly move lights around with the player to make it seem like there are lots of lights everywhere; but fake lights can be a substitute and an enhancement, but not the best replacement.

The fake lights are just 3d objects, sprites or particle effects with a translucent texture; and sometimes a glowy shader. You see them alot where there are lamps on the street, light shining through distant windows and with special effects.

Lights are not the easiest part of game development, but they are rewarding. Shadow mapping is another topic that falls under this category and with shadow shaders. Shadows can be used to enhance the lighting effects, there are a number of commands for shadows in the 3D section. Dark Lights is good package for lights and shadows; it comes with decent examples, a multithreaded lightmapping command, ambient occlusion (adjusting the ambience of objects based on how much of the ambient light they can see) and some other cool stuff. It is good for people building there own level editor or for generated game levels.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 26th Oct 2011 22:02
I really did not think lights were that complex. I was wrong. What i will have to do is tackle that when i come to it as the above post is a little too much to take in at the moment. But this is a decent page and is getting bookmarked. Thanks.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 26th Oct 2011 22:28
Yep, handling lights for large maps is not easy.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 27th Oct 2011 00:27
I imagine you would need many lights, even false ones for indoor ambience and such.

If you were doing a huge outdoor map (HUGE), with a few objects such as houses and other buildings etc, and you also wanted a day night system i presume you could light the inside of buildings individually or in blender perhaps (just have 2 settings, day time and night where its darker but more light comes from the fire and torch models etc), but for outside wouldnt you just do 1 (i.e the sun). I cant imagine its that easy but really thats all it is. Sun goes up, sun goes down.
Reason i ask is one of the main reasons i am trying to learn programming is for such a scenario. Huge maps pasted together (dont know how to do this yet either, possibly blender?) with a proper day/night cycle.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 27th Oct 2011 17:30
Day and night sequencing is quite simple actually.

Extends plugin has a day night Sky Box. It is lazy mans solution but it works by adjusting the tone and feel of the background on a day and night basis.

Ambience setting and the global light can be set to change brightness over time. This is easy, just use the Timer() function to change the range of light. You can orbit the sub, perhaps represented by a billboard plane with sun animation, and place the global light on it.

The background lighting will depend on your methods, whether you use 2d images or 3d viewports.

With huge maps, they are really a load of small maps fitted side by side to appear big. No standard PC is going to render huge maps just like that.

Using City of Heroes as an example, it appears that an entire city with buildings that you can enter is loaded onto the player's screen; but really it is just nearby nearby buildings that are actually vertex dense. Stuff in the distance is 'SkyBox' work, or low resolution placeholders that temporarily fill the empty space until the player gets near to them, or walks in side the building. A bit like what you can do with placeholder lights.

If it looks good, it is good.

Quote: "I imagine you would need many lights, even false ones for indoor ambience and such. "


As I was saying you just need to position and update dynamic lights at the positions of nearby placeholders. Or use heavy lightmapping where there is unlikely to be any major change in brightness; like inside a room where the player cannot switch the light off.

Now with Blender, you will have a horrible time creating large maps without careful throught, the navigation is tedious when working on large maps. There is a fly-mode, but I find it to be a bit silly. Using the mouse to pan and move the view around a 10 mile map is just not good. Blender is more model orientated than architectural.

I gave up on it and instead worked on small maps in Blender and pieced them together in my engine. As you can see, I am working on buildings seperately:





You can piece things together in Blender using DupliGroups; and parse the model export. Make duplicates real if you just want it all to load up automatically, otherwise only empties are exported, which is what I use to load the models manually in my ingame level builder.

The array modifier is cool for duplicating meshes as I have done for walls and floors. But this is being scrapped because I now want to load my maps object by object during multiplayer playback, so large .x or .dbo file loading isn't going to work for me; although I have not tried multithreading cpu tricks yet.

But use it alot for parts of your world that needs repetition.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 27th Oct 2011 20:33
Nice screens.
Talking about navigating around blender, i saw a tutorial on John Williamson plugging one of those 3d mice and it made it look very easy to use fly mode accurately and quickly with one of them, so might be an option just yet. They are a bit pricey but not too bad and in my opinion worth it if your going to do it a lot.
I never had intention of creating 1 big map on from the start, i knew somehow i would have to do by peicing together smaller ones to make an island then fill a whole lot of water in between another load of maps peiced together etc, but i am glad to hear that this is not all that difficult, i would probably just do smaller models and use an editor to peice them together rather than the dupligroups thing, as i would essentially like to create a globe out of it (like a small planet or at least the effect of one, not actually a mapped sphere, keep going north and you eventually end up back where you started), i know this is possible i just hope i find it easy though i havent even decided what to make the map in as of yet.

Is it worth doing it in blender and exporting it as an .x or will that format not creating enough info for a terrain? If it does whats the best way to go about it, do you use heightmaps? or sculpt? I really want to ask this in a seperate thread when i am closer to the time of wanting to make a terrain, but i thought i may as well ask here to get a head start while i am on the topic of exporting the .x file.
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 27th Oct 2011 23:13 Edited at: 27th Oct 2011 23:16
Quote: "i saw a tutorial on John Williamson plugging one of those 3d mice and it made it look very easy to use fly mode accurately and quickly with one of them, so might be an option just yet"


I might try one of these out, they seem pretty good.

Quote: "keep going north and you eventually end up back where you started"


Fortunately for me my game is based on a large chunk of land; the players can't leave the land, although it is a huge span of terrain; it would probably take an hour to walk from one side to the next.

For your scenario, warping from one end to another is something I haven't thought much about. Perhaps someone else will know better, but if you wanted to do it flawlessly, I imagine you would need two cameras; one at the player, and one at the opposite side; both sharing the same angle. As you get to the edge, one camera renders the view of the northern objects, and the other renders the view of the southern.

With a spherical world; I am not sure how it would work. Perhaps all objects would need to move using cos, sine maths; about the central pivot point of the globe; or act as limbs in a global rotating object. Or perhaps the user rotates a hiden parent object the size of the global, and the character is orbitted rather than moved. The EZRotate guy probably knows what to do.

Quote: "Is it worth doing it in blender and exporting it as an .x or will that format not creating enough info for a terrain?"


I am using a combination of Blender terrains and height map terrains. Usually a heightmap is enough; even with caves, you can also use a heightmap for the roof of the cave, and walls; all by use of rotation. But for complex caves and defined mountain peaks; I will use Blender objects placed on top of a ground terrain. The sculpt tool is good for this, it makes it look realistic. And also with the proportional editing modes (O key), random proportion is pretty cool. I use the F6 to apply proportional effects after moving or scaling a vertex or set of objects.

Blender can generate heightmaps too, using the Noise deform button in the tool panel in conjunction with a selected texture in the material panel; and also with the displacement modifier.

Another aspect of general Blender modelling that I tend to use is that Ctrl L command in edit mode, and vertex groups. Ctrl L will select or deselect linked vertices, or add to the selection with shift key. In otherwords, grouping goes beyond objects; meshes inside of meshes can be grouped and duplicated (Shift D); this mesh work can be object orientated aswell. This is good for reusing bits of caves and mountains instead of pushing vertices around all of the time.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 28th Oct 2011 01:34 Edited at: 28th Oct 2011 01:36
Quote: "I might try one of these out, they seem pretty good."

Yeah they do look good, you should watch that demo john gives, it will probably swing your vote

As for my map, i was thinking something like this wouldnt be too hard to impliment.



(It was drawn in word and paint, i havent downloaded gimp yet but i will soon)

Imagine every tile on that image is a reasonable sized map made in blender and exported out.
The engine always loads about 6 of these maps at once. Which ones is decinded on the players position.
The black dot off north east of one of the tiles is the player. When he crosses the red line (which he has done) it loads 3 north plus the 2 either side. So its always showing the green bits. If he goes south of that line it loads the three south of that position.

To make the map seemless (ish) when he gets to tile 1's red line (not drawn but would be on the half way mark) for example, it would start drawing 2, 3 & 4. Same principle goes for the very ends east and west.
Im sure/hope this would work.

About the heightmaps, i really dont know how they work, do you draw them in a paint program of some kind and if so how. Then how do you get blender to recognise them as what they are. After that how would you paint you textures accuratley and neatly (like if part of the map were sand, how to blend it into a grassy area etc). For more accurate mountains etc did you just use sculpt on what the heightmap through out or did you actually make a mountain from nothing and sculpt that, then place it as an entire object on top of the heightmap?
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 28th Oct 2011 03:23 Edited at: 28th Oct 2011 03:26
Yeah, this segment system seems like it would work. I have been planning an adjacent system where all 9 surrounding squares are loaded; slightly more simple but slower than yours in terms of loading time; depending on the size of the segments.

The only issue is loading the maps without disrupting the gameplay too much.

Heightmaps derive from bitmaps; they work similar to bumpmaps, but actually raise the height of the vertices based on how bright a pixel is.

The commandset to look into is AdvancedTerrain. Search up on it on the forums. The functions for these terrains can be installed in DBPRO, and they will produce your hills out of pixel heights.

The reason why I don't use heightmaps for mountains is that you are limited to 256 levels; due to the colour tone limit. (Unless you created your own terrain generator) That amount of levels is not good for extreme heights in-terms of quality.

The good thing about Advanced terrain is that it also splits the mesh up into segments, for speed optimization.

There is also the BlitzTerrain plugin that you have to purchase, but looks really good. As for the standard terrain functions in DBPRO, they are not very good; as there isn't much you can do with the terrain. At least with Advanced terrain you can treat it as a regular object; but with the standard one you are limited to its own set of functions; no object manipulation.

Terrain generation in Blender is done with textures. You load an image texture; or generate one with one of the image generators in the material panel; then perform the actions I mentioned on the object; such as using the Noise button on the tool panel when a set of vertices are selected in edit mode.

As for terrain blending; you can just paint on the mesh in Blender; or if you are using the AdvancedTerrain; it has a Detail Shader type setup that allows you to pick a base texture and a detail texture. You paint your terrain blends on this detail texture. Play around with it to see if you like it.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 28th Oct 2011 09:59
Quote: " I have been planning an adjacent system where all 9 surrounding squares are loaded"

Yeah, my first idea was to have a 9 square but i thought about 2 things. 1 I would like some really big maps if i can load them so i might need the optimization. And 2, as long as each map was bigger than the distance "eye" could see at the half way point then it would be more than enough because if the player turned around after he got past that red line he wouldnt be able to see that in the distance something was missing. Now if its not possible to do it with maps that big then fair play it would be back to 9 squares. Im not too fussed about optimisation for anothing commercial like in a game just yet. All i want to do is make what i want and ill run it on the best machine i can do at that time. If i think its good enuogh to release on the public i will then see about not denying access to it by it being too much for most machines to run, ill tinker as much as i can to get it to run on as many mahnies as i dare, but for now it will be running on a fair specced machine, loading models from ssd's into large amounts of fast memory on a massive graphics card etc. Just to get the job done. This is why i hopefully wont have a problem with
Quote: "disrupting the gameplay too much."
or at least i hope it wont. Again ill make optimisations if i must and possibly put a flag system or soemthing that loads it when the player it least busy (like not fighting, or sleeping) or something.

I see what you mean about the heightmaps, as i didnt know what they were really before i didnt think of the 256 issue. I would like to create my own terrain generator so i could past in things like lots and lots of random generated trees for easy forest building and such but i wouldnt know where to start just yet.
I have spent a lot of time searching blitzterrain just before i posted this thread in the first place. It does look great but i have no idea what its interface is like and how to use it and how easy it is to generate nice terrain that doesnt look like it has lots of seemed textures on it (hence why i would love something with a sort of procedual "paint feature" for certain landscape types). I would love it if something like grome could be used as it looks like some really beautiful stuff can be created in that but i am not sure there is support for it, also would anything you created contain collision data anyway, such as trees, if not i imagine it would be a nightmare. Grome is a bit pricey butr affordable and in my opinion worth it but as i said, just doesnt look like you could use anything you made, but what would i know.
Ill have to look at that AdvancedTerrain, its just from what i gathered through searching, there is no point with blitzterrain being out as blitz is faster and better in all respects, or was this just marketing and is advancedterrain still a reasonable peice of software, even for an advanced ambitious project?
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 28th Oct 2011 14:37
Quote: "blitz is faster and better in all respects, or was this just marketing and is advancedterrain still a reasonable peice of software, even for an advanced ambitious project?"

I've not used Blitz, so I could not provide a proper review of it, but I feel that Blitz terrain will get more of what you need as standard since it has more features. It seems to have alot of people using it aswell. I like plugins that have lots of users with experiences to share.

I see Advanced Terrain as the minimum requirement, not the best; but not the worst either.

If you have the money, it may be worth playing around with different solutions to see what turns out to work the best. It is difficult to predict what issues may arise so early in development. If you do not wish to spend, then Advanced Terrain is the best option if you do not want to do a DIY job with code. Again, it is a reliable solution because you are creating standard objects that can make use of all the object commands, plus it is the fastest way to make a basic terrain.

If you run into issues, you have Blender for backup; using your segment system to create one terrain per segment in Blender; or perhaps two or four for levels-of-detail (LOD).

Quote: "
Im not too fussed about optimisation for anothing commercial like in a game just yet. All i want to do is make what i want and ill run it on the best machine i can do at that time."

Sounds cool if you feel it is unlikely that you will want lots of people to play your game. If you do feel confident that it will be released (for free or commercially) then I'd run regular tests on a cheap PC. If it is going to be multiplayer then even more so, optimize, do not under-estimate how much network and CPU lag with the host affects the frame rate of other connected players in Server-Client; or how each affects each other in peer-to-peer setup. And then there are graphics card glitches, it's about finding the common graphics card issues so that most people end up having something good to say about your game; they tend to prefer to talk about the negatives.

I use the worst PC possible to test my game, to see where performance hits creep up. Thanks to this setup, even this week I discovered that sprite based GUI was not going to work for my game with its busy interface; after just a few menus, my frame rate dropped from 60 to 40; too much of a frame drop for absolutely nothing, even with sprite backsave off. I have a feeling that the sprite performance is better in DBPRO than in DGDK VB, which is what I am using.

Again, my old PC saved me a months of work if I even had to re-do the interface if a substantial series of performance complaints came after release. Like commercial games, I will supply higher quality game modes for high end PCs.

Quote: "Now if its not possible to do it with maps that big then fair play it would be back to 9 squares."

6 times out of 10 the first idea I come out with turns out to be the worst idea; in terms of things I've not tried before. Sometimes you find out that there is a glitch with someone elses DLL or the internal system that screws up your plans or you missed something out in the planning phase. Using object orientation, forming your systems out of subsystems allows you to replace faulty parts, rather than building the whole thing all over again.

Fortunately for my GUI problem, I just need to replace half of the functions, the other half was made compatible with any alternative solution. As an example, I have a function called UIMenu.Create(); before it created sprites, now it creates windows; same function, different solution.

So watch out for the unexpected by using functions to call internal functions and UDTs that can have parts altered or replaced easily, rather than using direct calls to plugins in your main loops. It is easier to replace one problematic line of code in one function, than 100s of calls to a problematic DLL or internal function scattered in 100s of files.

There will be problems. Hopefully you will encounter problems nice and early; it gets more difficult to change things the larger the game gets; which is why thorough testing and using easy to replace parts is essential if you want to avoid the head and heart ache of redoing a weeks work or a months work.

Somarl
13
Years of Service
User Offline
Joined: 11th Feb 2011
Location: UK
Posted: 28th Oct 2011 19:41
Quote: " they tend to prefer to talk about the negatives."

Yeah ive followed a few games on forums in the past (some mmos too) and i know what people are like, they do tend to focus on negative stuff. I will have a few machines i can test things on including even laptops with no graphics cards just onboard stuff but my main focus at least at first will just be making something that works.

Some nice hints and tips there though Chris thank you. Its all being taken on board. Just need to start throwing some snippets together now and making things work
Chris Tate
DBPro Master
16
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 28th Oct 2011 20:52
Cool, keep me updated

Login to post a reply

Server time is: 2024-11-24 00:32:52
Your offset time is: 2024-11-24 00:32:52