I Need Some Help With Terrain Gen.

Immortius

Lead Software Architect
Contributor
Architecture
GUI
It's the ternary operator. Similar an if statement, "(a) ? b : c" can be read "if (a) then b else c". The difference being it is used to select a value, which is returned from the statement.
 

Doc

New Member
Is the Terasology gen code something I could use in my project? Would I still be able to market my project if I added the gen code from Terasology?
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
As per the current license setup, yes, I believe so. As long as you keep license headers, author tags, etc intact :)

Easier to just build something within our little project though, so you can still get all the updates etc without extra effort.
 
Reactions: Doc

Doc

New Member
I would make it within your project, but I have already been working on a community and a different title for my game. I have quite a few people in the community!

I will include the author comments in the code when I use it. Thanks for the help in getting me through this. After I work with the code from here I might be able to make my own custom code eventually!

Thanks all!

Edit:
Nym, you helped me a lot! I wouldn't know where to start if you didn't help!
 

Doc

New Member
I am looking at the code and typing it into my IDE, changing it slightly. Is this a proper implementation of the licence?
//this is modified code from the project terasology which is released under the following licence:
/*
* Copyright 2012 Benjamin Glatzel <benjamin.glatzel@me.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
//Benjamin's code contains this author tag:
/**
* Improved Perlin noise based on the reference implementation by Ken Perlin.
*
* @author Benjamin Glatzel <benjamin.glatzel@me.com>
*/
I have modified the code to fit some of my other code, and I have changed how some of the operations are done, for instance I have used xor shift code from Wikipedia as the number gen instead of the provided number gen.
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
I'm not an expert but I think that looks good. Maybe somebody else can chime in as well.

What's the name of your other project, if you don't mind sharing? :)
 

Doc

New Member
I don't mind sharing at all!

"The Fight For Survival" is it's name. Still working on getting it higher in Google though! :D
tffs.castraponere.com

Still very early in development...

I have a forum that has quite a few members, but I have been battling spambots like crazy. Once, a spambot generated 546 new members on my forum at one time!!! :eek:

EDIT:
Here's a screenshot I can show you of my game:

That is all done in code, so that's why I need terrain gen! :p
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
The requirements of use for Apache Licensed software are:
  1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
  2. You must cause any modified files to carry prominent notices stating that You changed the files; and
  3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
  4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
(We need to add a NOTICE file)
 

begla

Project Founder and Lead Developer
Contributor
Architecture
Logistics
To answer a question from earlier which contained a part of the FastFloor(x) function... The FastFloor(x) function abuses how Java's casting from floats to integers works to imitate the results of a default Floor(x) function (which calculates the largest integer less than or equal to x).

Simply casting the float from an integer to a float is valid, but only for positive real numbers. So we need a bit of extra code to make the negative real numbers work... And that is the snipped you've posted there! You can use that small example here to test how FastFloor works and what the difference is to simply casting from integer to float all the time.

Code:
public class TestFastFloor {
 
    public static double fastFloor(double d) {
        int i = (int) d;
        return (d < 0 && d != i) ? i - 1 : i;
    }
 
    public static void main(String[] args) {
        for (float i = -2.0f; i < 2.0f; i += 0.05) {
            System.out.println("Float: " + i);
            System.out.println("FastFloor: " + fastFloor(i));
            System.out.println("Casted: " + (int) i);
        }
    }
 
}
More on the topic can be found here... http://mathworld.wolfram.com/FloorFunction.html
 
Reactions: Doc

Doc

New Member
That explains a lot! What are the advantages of using floats though? If I just use integers and decimals, won't that work fine? Also, I still need help on the licence.

EDIT:
I'm sorry for not telling you what this was for at the beginning. (Perhaps I was embarrassed at my small project, and I didn't want to say...) I did not think that this would cause some of you to feel bad about helping me. :(
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Small projects, big projects, it doesn't matter as long as you have a healthy attitude to learn and do great things :)
 

Josh

Member
Contributor
Hunter
That explains a lot! What are the advantages of using floats though? If I just use integers and decimals, won't that work fine? Also, I still need help on the licence.

EDIT:
I'm sorry for not telling you what this was for at the beginning. (Perhaps I was embarrassed at my small project, and I didn't want to say...) I did not think that this would cause some of you to feel bad about helping me. :(
A float is bigger then any of those numbers, that's why you use floats vs Doubles,
Double: 1 .7e–308 to 1.7e+308 << Number range of how high it can go
Float: 3 .4e–038 to 3.4e+038 << Number range of how high it can go

A float pretty much doubles a double so if you want more exact things use a float vs a double or an int.
 

Immortius

Lead Software Architect
Contributor
Architecture
GUI
You seem to have that backwards. Doubles are more exact than floats, that's why they're called doubles (double precision).

We use floats because they use less space, because our rendering and physics libraries use floats (not that much point using doubles if they just have to be downcast in the end), and because we don't need the accuracy offered by doubles for the most part. The space consideration is primarily around reducing bandwidth requirements for multiplayer.

When dealing variables constrained to integer values, it is almost always better to use an integer type. floats/doubles simply can't represent some integers, and floating point error can mean things like 2f x 5f == 10f can return false.

Big Decimal doesn't suffer these issues as much, but it uses more space than even double, and is unlikely to be as fast.

On the licensing it is us (the Terasology team) that need to add a NOTICE file. You would then need to include the attribution notes from that file.
 

Josh

Member
Contributor
Hunter
You seem to have that backwards. Doubles are more exact than floats, that's why they're called doubles (double precision).

We use floats because they use less space, because our rendering and physics libraries use floats (not that much point using doubles if they just have to be downcast in the end), and because we don't need the accuracy offered by doubles for the most part. The space consideration is primarily around reducing bandwidth requirements for multiplayer.

On the licensing it is us (the Terasology team) that need to add a NOTICE file. You would then need to include the attribution notes from that file.
Yeah, I guess I was thinking of something else.
 
Top