Fractal surface
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/05/2010 at 15:16, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 11.5
Platform: Windows ;
Language(s) : C++ ;---------
I am currently trying to create a space rock object for my planet X Generator plugin. I have toyed a lot with c4djack's surfacespread plugin and I know he has experience with making fractal landscapes and objects. I was wondering if he or anyone else would mind sharing some of their expertise with me on this subject.I assume that to make such an object I will need to create a cube in GetVirtualObjects() and then turn it in to a polygon object and then iterate through all the points in th eobject and move them around based on some randomization algorithm. Does this sound about right to create a rock like object?
If i am way off, could you give me a little insight as to how I would go about creating a fractal surface..
Thanks a lot for your time.
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/05/2010 at 16:47, xxxxxxxx wrote:
You're not way off. Creating a cube, converting it to a PolygonObject, then doing some changes to the polygon mesh and returning the result is the way to go. You might also wanna check out some noise functions
Cheers,
Jack -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/05/2010 at 16:58, xxxxxxxx wrote:
Hey Jack. Thanks for the reply, for some reason whenever I try to create a cube in GetVirtualObjects, nothing gets shon in the viewport. Do you have a sample code of how to create a cube in GetVirtual Objects.
Also,
when you say noise functions do you mean RidgedMultifractal()
Thanks,
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/05/2010 at 13:45, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Do you have a sample code of how to create a cube in GetVirtual Objects.
How about this?
BaseObject *cube = BaseObject::Alloc(Ocube); return cube;
If the default settings of the cube are not suitable for what you're trying to do, just get the cube's container and change them.
Originally posted by xxxxxxxx
when you say noise functions do you mean RidgedMultifractal()
Also, but not only
Cheers,
Frank -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/05/2010 at 13:54, xxxxxxxx wrote:
Hey Thanks for the reply Jack. I did manage to figure that part out after doing some tweaking. I'm not sure why it wasn't working for me before.. LOL
What other noise functions are you refering to?
Also, I am finding out that I can't make changes to objects within GetVirtualObjects() like add a material to them or anything like that. Am I allowed to change the cubes default settings within GetVirtualObjects or will that cause a threading problem?
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 30/05/2010 at 14:00, xxxxxxxx wrote:
Also, another question is, when I get this rock object made within GetVirtualObjects, how do I then add a material to that object? I have tried adding a material to the sky object I am trying to do and I get all sorts of problems. Check https://developers.maxon.net/forum/topic/5051/4975_questionto see what I am refering to.
Is there a better safer way to do this than I am with the link I sent?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/05/2010 at 05:48, xxxxxxxx wrote:
Check your other threads regarding this topic. I have posted some examples there.
cheers,
Matthias -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/05/2010 at 05:50, xxxxxxxx wrote:
Okay Jack here's what I have...
BaseObject *SpaceRock::GetVirtualObjects(BaseObject* op, HierarchyHelp* hh) { Bool dirty = op->CheckCache(hh) || op->IsDirty(DIRTY_DATA); if (!dirty) return op->GetCache(hh); BaseObject *cube = BaseObject::Alloc(Ocube); if(!cube) goto Error; cube->SetParameter(PRIM_CUBE_SUBX, GeData(4),0); cube->SetParameter(PRIM_CUBE_SUBY, GeData(4),0); cube->SetParameter(PRIM_CUBE_SUBZ, GeData(4),0); PolygonObject *polyCube = ToPoly(cube); if(!cube) goto Error; Vector * points = polyCube->GetPointW(); LONG pointCount = polyCube->GetPointCount(); for (int i = 0; i < pointCount; i++) { Real arr[20]; InitFbm(arr,10,2.0,0.5); RidgedMultifractal(arr, points[i], 10, 3, 7); Turbulence(points[i],10, TRUE); SNoise(points[i]); Fbm(arr, points[i], 10); } cube->Message(MSG_UPDATE); return polyCube; Error: return NULL; }
Unfortunately nothing happens to the cube .. so I must be doing something wrong... I figured I'd try all the noise functions just to see what happened.... Do you see anything I should change?
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/05/2010 at 05:51, xxxxxxxx wrote:
And Thanks again Matthias...
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/05/2010 at 06:55, xxxxxxxx wrote:
Maybe the changes you're making to the point positions are just too small to see? Remember, the noise functions only return values between 0 and 1 (or -1 and 1), so you'll want to multiply them with some value control the deformation intensity.
Cheers,
Frank -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/05/2010 at 08:06, xxxxxxxx wrote:
Could you post a quick example of what you mean by that?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/05/2010 at 17:19, xxxxxxxx wrote:
Originally posted by xxxxxxxx
What other noise functions are you refering to?
All of them, just take a look into the SDK documentation.
Originally posted by xxxxxxxx
Could you post a quick example of what you mean by that?
Well, just multiply it.
Real x = Turbulence(points[i],10, TRUE) * 5.0;
You actually do know that those Noise functions return values, right? In your code it looks like you just call them without doing anything with their results.
I strongly advise you to stick your nose into the SDK documentation and read about the basics, since most of your questions here are answered there!
Also your code looks quite inefficient in several places, e.g. initializing the Fbm array in every iteration of your loop is neither necessary nor does it lead to a good performance. Last but not least, you have to convert your allocated object to a polygon object. In your code, you just cast it. Read about Current State To Object in the SDK docs. Don't forget to check for memory leaks by using the c4d_debug.txt file.
Cheers,
Jack -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/05/2010 at 17:34, xxxxxxxx wrote:
Hey Jack,
Yeah I did know that the functions returned a value. I often seem to come off a bit naive when I am charting in to new territory for myself because I am mostly learning as I go. I do appreciate you answering my questions as it helps to make it all more clear.
I will poke around in the SDK to get a better understanding of these concepts. The Current State To Object I have not used before but i will look in to that.
Thanks again.
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/05/2010 at 17:39, xxxxxxxx wrote:
Originally posted by xxxxxxxx
I often seem to come off a bit naive when I am charting in to new territory
Sometimes, maybe, a little
Originally posted by xxxxxxxx
I am mostly learning as I go.
That's how most of us learned it, I guess. Nothing wrong with that.
Originally posted by xxxxxxxx
I do appreciate you answering my questions as it helps to make it all more clear.
I don't mind answering lots of questions, but I want people to do some research on their own.
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime."Cheers,
Frank -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/05/2010 at 17:41, xxxxxxxx wrote:
I'll go fishing. Thanks!
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/05/2010 at 18:06, xxxxxxxx wrote:
I am only find this about Current State To Object:
Current State To Object (CSTO)
CSTO has to be executed on a duplicate of an object because CSTO modifies the existing caches. In some cases you have to use a temporary document as well (GetVirtualObjects()).Is there more in the SDK about it? Should I use a CallCommand() to do CSTO?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/05/2010 at 19:21, xxxxxxxx wrote:
Okay so after doing some more digging in the SDK and some searches here at the cafe, I have found two ways to do the current State To Object.
BaseObject *SpaceRock::GetVirtualObjects(BaseObject* op, HierarchyHelp* hh) { Bool dirty = op->CheckCache(hh) || op->IsDirty(DIRTY_DATA); if (!dirty) return op->GetCache(hh); ModelingCommandData mcd; BaseObject *cube = BaseObject::Alloc(Ocube); if(!cube) goto Error; cube->SetParameter(PRIM_CUBE_SUBX, GeData(4),0); cube->SetParameter(PRIM_CUBE_SUBY, GeData(4),0); cube->SetParameter(PRIM_CUBE_SUBZ, GeData(4),0); PolygonObject *polyCube = ToPoly(cube); if(!polyCube) goto Error; Vector * points = polyCube->GetPointW(); LONG pointCount = polyCube->GetPointCount(); //mcd.op = polyCube; //mcd.mode = MODIFY_ALL; //SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd); Real arr[20]; InitFbm(arr,10,2.0,0.5); for (int i = 0; i < pointCount; i++) { Real rmf = RidgedMultifractal(arr, points[i], 10, 3, 7) * 5.0; Real turb = Turbulence(points[i],10, TRUE) * 5.0; Real snoise = SNoise(points[i]) * 5.0; Real fbm = Fbm(arr, points[i], 10) * 5.0; points[i] = points[i] * turb; points[i] = points[i] * rmf; points[i] = points[i] * snoise; points[i] = points[i] * fbm; } //CallCommand(12233); //Current State To Object cube->Message(MSG_UPDATE); return polyCube; Error: return NULL; }
I have commented both ways out but you can see that I do it with the CallCommand() and I also do it with a SendModelingCommand(). Is there a particularly more effective way to do it? Also, I still must not be doing it correctly, because nothing is happening to my cube. I believe that given the changes I made to the loop that at least something should happen to the points _but nothing is which leads me to believe that it is still not correctly doing the CSTO.
Do you notice anything in particular that I am doing wrong? I will keep looking for more info here and in the SDK as well. Thanks,
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/06/2010 at 00:43, xxxxxxxx wrote:
You need to use SendModelingCommand(), then get the result.
Also remember that you sometimes have to clone your original object, and use the modeling command on the clone, as it's shown in some threads here in the forum.The ToPoly cast can be removed, since it does not change the object. Rather cast the modeling command result to a PolygonObject, that would make more sense
Also, if you would have taken a close look into the SDK, as I advised you, you would have found some nice demo code for exactly this modeling command in the documentation. It also shows you how to get the result.
Cheers,
Jack -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/06/2010 at 16:11, xxxxxxxx wrote:
Well after some blood, sweat, and SDK searching I finally figured it out. When you're right you're right Jack,,, I learned much more by combing through the SDK...
Thanks for the pep talk.. LOL
~Shawn -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 03/06/2010 at 18:26, xxxxxxxx wrote:
If I want to subdivide the rock using the SendModelingCOmmand() is this okay to do from within GetVirtualObjects or is that unsafe? I know it says you can't chan ge the scene from within GVO but if the object hasn't been added to the scene yet, is it safe to subdivide it?
Thanks,
~Shawn