Skip to content

Commit

Permalink
Merge pull request #16 from fkemmler/master
Browse files Browse the repository at this point in the history
Update PointProjector to R20, thanks @fkemmler !
  • Loading branch information
fwilleke80 committed Mar 13, 2019
2 parents 423335b + ccc3e5b commit a34544b
Show file tree
Hide file tree
Showing 27 changed files with 71 additions and 1,318 deletions.
17 changes: 17 additions & 0 deletions PointProjector/project/projectdefinition.txt
@@ -0,0 +1,17 @@
// Supported platforms
Platform=Win64;OSX

// Type of project
Type=DLL

// API dependencies
APIS=core.framework;cinema.framework

// Enable some advanced classic API support; not needed for hybrid plugins
C4D=true

// Plug-in code-style check level
stylecheck.level=3

// Custom ID
ModuleId=net.fkemmler.pointprojector
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -55,7 +55,7 @@ PolygonObject* GetRealGeometry(BaseObject* op)
return nullptr;

// Create clone of op. We only need this for the modeling command.
BaseObject *tmpOp = static_cast<BaseObject*>(op->GetClone(COPYFLAGS_0, aliasTrans));
BaseObject *tmpOp = static_cast<BaseObject*>(op->GetClone(COPYFLAGS::NONE, aliasTrans));
if (!tmpOp)
return nullptr;

Expand Down Expand Up @@ -106,11 +106,11 @@ Bool GeneratesPolygons(BaseObject* op)
Int32 opInfo = op->GetInfo();

// Get some properties
Bool isGenerator = opInfo & OBJECT_GENERATOR; // Is dropOp a generator object?
Bool isSpline = opInfo & OBJECT_ISSPLINE; // Is it a spline?
Bool isDeformer = opInfo & OBJECT_MODIFIER; // Is it a deformer?
Bool isParticleModifier = opInfo & OBJECT_PARTICLEMODIFIER;
Bool isPolygon = opInfo & OBJECT_POLYGONOBJECT;
Bool isGenerator = (opInfo&OBJECT_GENERATOR) == OBJECT_GENERATOR; // Is dropOp a generator object?
Bool isSpline = (opInfo&OBJECT_ISSPLINE) == OBJECT_ISSPLINE; // Is it a spline?
Bool isDeformer = (opInfo&OBJECT_MODIFIER) == OBJECT_MODIFIER; // Is it a deformer?
Bool isParticleModifier = (opInfo&OBJECT_PARTICLEMODIFIER) == OBJECT_PARTICLEMODIFIER;
Bool isPolygon = (opInfo&OBJECT_POLYGONOBJECT) == OBJECT_POLYGONOBJECT;

Bool isPolyInstance = op->IsInstanceOf(Opolygon); // Is it a polygon object instance?

Expand Down
File renamed without changes.
@@ -1,4 +1,4 @@
#include "c4d.h"
#include "maxon/apibase.h"
#include "wsPointProjector.h"


Expand Down Expand Up @@ -38,7 +38,7 @@ Bool wsPointProjector::ProjectPosition(Vector &position, const Vector &rayDirect
Vector workPosition = collisionObjectMgI * position; // Transform position to m_collop's local space
GeRayColResult collisionResult;
Vector rPos(workPosition);
Vector rDir(collisionObjectMgI.TransformVector(rayDirection)); // Transform direction to m_collop's local space
Vector rDir(collisionObjectMgI.sqmat * rayDirection); // Transform direction to m_collop's local space

if (_collider->Intersect(rPos, rDir, rayLength, false))
{
Expand Down Expand Up @@ -95,10 +95,10 @@ Bool wsPointProjector::Project(PointObject *op, const wsPointProjectorParams &pa
Vector rayDirection(DC);

// If using parallel projection, calculate rayDirection now, as it's the same for all points
if (params._mode == PROJECTORMODE_PARALLEL)
if (params._mode == PROJECTORMODE::PARALLEL)
{
// Direction points along the modifier's Z axis
rayDirection = params._modifierMg.v3;
rayDirection = params._modifierMg.sqmat.v3;
}

// Calculate a ray length.
Expand All @@ -118,7 +118,7 @@ Bool wsPointProjector::Project(PointObject *op, const wsPointProjectorParams &pa

// Calculate ray direction for spherical projection
// This needs to be done inside the loop, as the direction is different for each point
if (params._mode == PROJECTORMODE_SPHERICAL)
if (params._mode == PROJECTORMODE::SPHERICAL)
{
// Direction points from the modifier to the position of the point
rayDirection = rayPosition - params._modifierMg.off;
Expand Down
Expand Up @@ -8,28 +8,29 @@


/// Modes of projection
enum PROJECTORMODE
enum class PROJECTORMODE
{
PROJECTORMODE_PARALLEL = 1,
PROJECTORMODE_SPHERICAL = 2
} ENUM_END_LIST(PROJECTORMODE);
NONE = 0,
PARALLEL = 1,
SPHERICAL = 2
} MAXON_ENUM_LIST(PROJECTORMODE);


/// Parameters for projection
struct wsPointProjectorParams
{
Matrix _modifierMg; ///< Global matrix of modifier
PROJECTORMODE _mode; ///< Projector mode (parallel or spherical)
Float _offset; ///< Offset attribute
Float _blend; ///< Blend attribute
Bool _geometryFalloffEnabled; ///< Geometry falloff enabled attribute
Float _geometryFalloffDist; ///< Geometry falloff distance attribute
Float32 *_weightMap; ///< Ptr to weight map
C4D_Falloff *_falloff; ///< Ptr to falloff
Matrix _modifierMg; ///< Global matrix of modifier
PROJECTORMODE _mode = PROJECTORMODE::NONE; ///< Projector mode (parallel or spherical)
Float _offset = 0.0_f; ///< Offset attribute
Float _blend = 0.0_f; ///< Blend attribute
Bool _geometryFalloffEnabled = true; ///< Geometry falloff enabled attribute
Float _geometryFalloffDist = 0.0_f; ///< Geometry falloff distance attribute
Float32* _weightMap = nullptr; ///< Ptr to weight map
C4D_Falloff *_falloff = nullptr; ///< Ptr to falloff

/// Default constructor
wsPointProjectorParams() :
_mode(PROJECTORMODE_PARALLEL),
_mode(PROJECTORMODE::PARALLEL),
_offset(0.0),
_blend(0.0),
_geometryFalloffEnabled(false),
Expand Down
7 changes: 4 additions & 3 deletions source/main.cpp → PointProjector/source/main.cpp
@@ -1,4 +1,4 @@
#include "c4d.h"
#include "maxon/apibase.h"
#include "c4d_symbols.h"
#include "wsPointProjector.h"
#include "main.h"
Expand All @@ -9,7 +9,8 @@

Bool PluginStart()
{
GePrint(PLUGIN_NAME);
String pluginName = "PointProjector 1.4.4"_s;
GePrint(pluginName);

if (!RegisterProjectorObject())
return false;
Expand All @@ -27,7 +28,7 @@ Bool PluginMessage(Int32 id, void *data)
switch (id)
{
case C4DPL_INIT_SYS:
return resource.Init(); // don't start plugin without resource
return g_resource.Init(); // don't start plugin without resource
}

return false;
Expand Down
File renamed without changes.
Expand Up @@ -84,22 +84,23 @@ Bool oProjector::Message(GeListNode *node, Int32 type, void *data)
return false;

// Get message data
DescriptionCheckDragAndDrop *msgData = (DescriptionCheckDragAndDrop*)data;
DescriptionCheckDragAndDrop* msgData = (DescriptionCheckDragAndDrop*)data;

// Check if something should be dropped into PROJECTOR_LINK
if (msgData->id == PROJECTOR_LINK)
if (msgData->_descId == PROJECTOR_LINK)
{
// Get object that the user wants to drop
BaseObject *dropOp = static_cast<BaseObject*>(msgData->element);
BaseObject* dropOp = static_cast<BaseObject*>(msgData->_element);
if (!dropOp)
return true;

// Allow drop if dropOp is something with geometry we can project on
msgData->result = GeneratesPolygons(dropOp);
msgData->_result = GeneratesPolygons(dropOp);

// Return true, as we handled the message
return true;
}
break;
}
}

Expand All @@ -115,19 +116,19 @@ DRAWRESULT oProjector::Draw(BaseObject *op, DRAWPASS drawpass, BaseDraw *bd, Bas
{
// Good practice: Always check if all required pointers are set
if (!op || !bd || !bh)
return DRAWRESULT_ERROR;
return DRAWRESULT::FAILURE;

if (drawpass == DRAWPASS_OBJECT)
if (drawpass == DRAWPASS::OBJECT)
{
// Get container, skip if that doesn't work (actually, if this doesn'T work, something is really wrong!)
BaseContainer *bc = op->GetDataInstance();
if (!bc)
return DRAWRESULT_ERROR;
return DRAWRESULT::FAILURE;

// Get document, skip if no document set
BaseDocument *doc = op->GetDocument();
if (!doc)
return DRAWRESULT_ERROR;
return DRAWRESULT::SKIP;

// Set draw matrix
bd->SetMatrix_Matrix(op, bh->GetMg());
Expand All @@ -139,7 +140,7 @@ DRAWRESULT oProjector::Draw(BaseObject *op, DRAWPASS drawpass, BaseDraw *bd, Bas
PROJECTORMODE mode = (PROJECTORMODE)bc->GetInt32(PROJECTOR_MODE, PROJECTOR_MODE_PARALLEL);

// Draw arrows in parallel mode, or star in spherical mode
if (mode == PROJECTORMODE_PARALLEL)
if (mode == PROJECTORMODE::PARALLEL)
{
DrawArrow(bd, Vector(50.0, 0.0, 0.0), 100.0, true);
DrawArrow(bd, Vector(-50.0, 0.0, 0.0), 100.0, true);
Expand Down Expand Up @@ -257,7 +258,7 @@ void oProjector::CheckDirty(BaseObject *op, BaseDocument *doc)
UInt32 dirtyness = 0;

// Flags for upcoming dirty checks
DIRTYFLAGS dirtyFlags = DIRTYFLAGS_DATA|DIRTYFLAGS_MATRIX;
DIRTYFLAGS dirtyFlags = DIRTYFLAGS::DATA|DIRTYFLAGS::MATRIX;

// Iterate collision object and its parents, and add their dirty checksums
dirtyness += AddDirtySums(collisionObject, false, dirtyFlags);
Expand All @@ -275,7 +276,7 @@ void oProjector::CheckDirty(BaseObject *op, BaseDocument *doc)
_lastDirtyness = dirtyness;

// Set modifier dirty. It will be recalculated.
op->SetDirty(DIRTYFLAGS_DATA);
op->SetDirty(DIRTYFLAGS::DATA);
}
}

Expand Down Expand Up @@ -317,10 +318,10 @@ Bool oProjector::GetDDescription(GeListNode *node, Description *description, DES
return false;

// Signalize the description has been loaded successfully
flags |= DESCFLAGS_DESC_LOADED;
flags |= DESCFLAGS_DESC::LOADED;

// Add falloff description
if (!_falloff->AddFalloffToDescription(description, bc))
if (!_falloff->AddFalloffToDescription(description, bc, flags))
return false;

return SUPER::GetDDescription(node, description, flags);
Expand Down Expand Up @@ -359,5 +360,5 @@ NodeData* oProjector::Alloc()
// Register plugin
Bool RegisterProjectorObject()
{
return RegisterObjectPlugin(ID_PROJECTOROBJECT, GeLoadString(IDS_PROJECTOROBJECT), OBJECT_MODIFIER, oProjector::Alloc, "oProjector", AutoBitmap("oProjector.tif"), 0);
return RegisterObjectPlugin(ID_PROJECTOROBJECT, GeLoadString(IDS_PROJECTOROBJECT), OBJECT_MODIFIER, oProjector::Alloc, "oProjector"_s, AutoBitmap("oProjector.tif"_s), 0);
}
76 changes: 0 additions & 76 deletions PointProjector_R16.sln

This file was deleted.

0 comments on commit a34544b

Please sign in to comment.