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 / Memblock Mesh Ocean

Author
Message
Krisper
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location:
Posted: 3rd Apr 2008 05:47 Edited at: 3rd Apr 2008 05:48
I am trying to make an ocean with moving waves on it. I have been doing a lot of searching and reading and have been told one way is with a memblock mesh. I have been looking at lots of memblock mesh examples and can make an object from a memblock mesh and can manipulate the vertex heights etc. But I am not sure of the best method to do this continually with something like an ocean swell.

So far I am creating a memblock, making a mesh from the memblock, making an object from the mesh and then deleting the mesh and the memblock. Then in my game loop I am making a mesh from the object, deleting the object, changing the vertexdata of the mesh, making an object from the mesh and then deleting the mesh. Using that method my fps drop from 3400 to 200 when I start changing the object. Is there a better way to do this?
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 3rd Apr 2008 13:03
VanB once did something like this. I'm sure it involved a boned mesh, and then he simply animated the bones at different rates to produce random surface movements.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 3rd Apr 2008 21:20 Edited at: 3rd Apr 2008 21:20
change object from mesh, I think it is called, is faster than making the object all over in every cycle.

"I kören hörs de brummande busarna Björnligan och Gondolen"
Krisper
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location:
Posted: 5th Apr 2008 07:47
I couldn't find much info on boned mesh's, I guess I would have to make that using another program.

I also couldn't find any commands like change object from mesh. All I could find was change mesh but I don't think that would help.

I ended making the mesh using a grid of limbs and the lock vertexdata for limb commands. Now the mesh updates with very little drop in fps. I have yet to work out the wave motion, but I don't think that will be too difficult.
HowDo
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: United Kingdom
Posted: 5th Apr 2008 08:20
have a look here
http://forum.thegamecreators.com/?m=forum_view&t=126981&b=6

Dark Physics makes any hot drink go cold.
Sven B
19
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 5th Apr 2008 12:12
Or try this code:



Basically, it writes a DirectX file and loads it as an object.

Memblock meshes don't use indices. DirectX files do, so this means that this way of creating a subdivided plain will have less than half the verteces than the memblock version.
It is slower to load it though. The writing of the file has some delay, but shouldn't be that significant.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
Krisper
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location:
Posted: 6th Apr 2008 07:26 Edited at: 6th Apr 2008 08:04
I am using this method to make the first object:

Would this work as well as the DirectX file?
Dabbler
17
Years of Service
User Offline
Joined: 3rd Mar 2007
Location: Minnesota
Posted: 6th Apr 2008 10:22 Edited at: 6th Apr 2008 10:28
Quote: "Then in my game loop I am making a mesh from the object, deleting the object, changing the vertexdata of the mesh, making an object from the mesh and then deleting the mesh. Using that method my fps drop from 3400 to 200 when I start changing the object. Is there a better way to do this? "


Just a thought. Try using lock vertexdata for limb and change the object directly. It might give you a couple of extra frames per second.

edit: Oops! I missed your second post. Never mind.


Whatever...
Krisper
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location:
Posted: 7th Apr 2008 05:15 Edited at: 7th Apr 2008 05:15
Well I've managed to put a wave shape in the object I have made from the mesh, next I want to make the wave travel continually from one side to the other like an ocean swell. I have no knowledge of the maths involved and it has taken me heaps of trial and error to get the code doing this much. As you can see from my code I am a total beginner. I am embarrassed to show this much as I am sure some good coders will have much better ways of doing this.

I was wondering if anyone can tell me how to make the wave travel in one direction rather than rock back and forth like it does now?

Krisper
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location:
Posted: 9th Apr 2008 02:56 Edited at: 9th Apr 2008 03:05
I have it working now. Here is some sample code if anyone is interested. You can change the wavelength, frequency and amplitude with some keys. I think they are the right terms.


I have been trying to work out how to make it roll over in the last row of limbs like a wave breaking, but it is beyond me at the moment. If anyone can improve on what I have done or can make the wave rollover like it is breaking, I'd really appreciate it. I have never learnt trigonometry or anything like that and my coding skills are pretty basic so I am sure my code is laughable and can be improved.
Simon Huggins
16
Years of Service
User Offline
Joined: 25th Mar 2008
Location:
Posted: 15th Apr 2008 18:48
I think your code is awesome. I'm pretty hands on (not that acedemic)when it comes to programming. So I'm happy when a program simply does what I want it to do. Yeah sure, I know there's a few guys out here who are just insanely clever and could optimise your code and squeeze out a few more FPS (and maybe they will). But I would be proud to have acheived what you have done. I am still learning DBPro myself and have very recently just got my head round the very basics of trigonometry. I will be studying your code and will most probably play around with it for my own benefit, as I have some ideas for future projects where this kind of routine will come in very useful indeed. Well done Krisper.
Simon Huggins
16
Years of Service
User Offline
Joined: 25th Mar 2008
Location:
Posted: 15th Apr 2008 20:40
By the way and I might be missing the point here, have you considered using the matrix commands to produce something similar. The thing is, I was trying to add a texture to your waveform generator, but it only textured the vertices/limbs(correct me if i am wrong). I noticed that you may be able to achieve quite a good result with the matrix commands and produce some very stunning effects when using textures and the ghost matrix command for example. I am still very inexperienced, so please excuse me if I am missing something here.
Simon Huggins
16
Years of Service
User Offline
Joined: 25th Mar 2008
Location:
Posted: 15th Apr 2008 21:39
I managed to texture your waveform. As I'm still a bit green, I didn't realise I had to change the set wireframe statement. I'm not sure if there's a way though to remove the tiling though and cover the entire object with just one image.

Login to post a reply

Server time is: 2024-11-25 06:54:21
Your offset time is: 2024-11-25 06:54:21